[PATCH] D61506: [OpenCL] Switch to C++17

2019-05-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 198627.
Anastasia added a comment.

Added `HexFloat`!


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

https://reviews.llvm.org/D61506

Files:
  include/clang/Frontend/LangStandards.def
  test/CodeGenOpenCLCXX/addrspace-of-this.cl


Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -109,15 +109,9 @@
 // IMPL: call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* 
{{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]]
 
 // Test the address space of 'this' when invoking the operator+
-// COMMON: [[C3GEN:%[0-9]+]] = addrspacecast %class.C* %c3 to %class.C 
addrspace(4)*
 // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C 
addrspace(4)*
 // COMMON: [[C2GEN:%[0-9]+]] = addrspacecast %class.C* %c2 to %class.C 
addrspace(4)*
-// COMMON: call void @_ZNU3AS41CplERU3AS4KS_(%class.C* sret %ref.tmp, %class.C 
addrspace(4)* [[C1GEN]], %class.C addrspace(4)* dereferenceable(4) [[C2GEN]])
-// COMMON: [[REFGEN:%[0-9]+]] = addrspacecast %class.C* %ref.tmp to %class.C 
addrspace(4)*
-// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C3GEN]], 
%class.C addrspace(4)* dereferenceable(4) [[REFGEN]])
-// IMPL: [[C3VOID:%[0-9]+]] = bitcast %class.C* %c3 to i8*
-// IMPL: [[REFGENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[REFGEN]] to 
i8 addrspace(4)*
-// IMPL: call void @llvm.memcpy.p0i8.p4i8.i32(i8* {{.*}}[[C3VOID]], i8 
addrspace(4)* {{.*}}[[REFGENVOID]]
+// COMMON: call void @_ZNU3AS41CplERU3AS4KS_(%class.C* sret %c3, %class.C 
addrspace(4)* [[C1GEN]], %class.C addrspace(4)* dereferenceable(4) [[C2GEN]])
 
 // Test the address space of 'this' when invoking the move constructor
 // COMMON: [[C4GEN:%[0-9]+]] = addrspacecast %class.C* %c4 to %class.C 
addrspace(4)*
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -159,7 +159,8 @@
  LineComment | C99 | Digraphs | HexFloat | OpenCL)
 LANGSTANDARD(openclcpp, "c++",
  OpenCL, "OpenCL C++ 1.0",
- LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs | 
OpenCL)
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 
|
+ Digraphs | HexFloat | OpenCL)
 
 LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
 LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")


Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -109,15 +109,9 @@
 // IMPL: call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* {{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]]
 
 // Test the address space of 'this' when invoking the operator+
-// COMMON: [[C3GEN:%[0-9]+]] = addrspacecast %class.C* %c3 to %class.C addrspace(4)*
 // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)*
 // COMMON: [[C2GEN:%[0-9]+]] = addrspacecast %class.C* %c2 to %class.C addrspace(4)*
-// COMMON: call void @_ZNU3AS41CplERU3AS4KS_(%class.C* sret %ref.tmp, %class.C addrspace(4)* [[C1GEN]], %class.C addrspace(4)* dereferenceable(4) [[C2GEN]])
-// COMMON: [[REFGEN:%[0-9]+]] = addrspacecast %class.C* %ref.tmp to %class.C addrspace(4)*
-// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C3GEN]], %class.C addrspace(4)* dereferenceable(4) [[REFGEN]])
-// IMPL: [[C3VOID:%[0-9]+]] = bitcast %class.C* %c3 to i8*
-// IMPL: [[REFGENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[REFGEN]] to i8 addrspace(4)*
-// IMPL: call void @llvm.memcpy.p0i8.p4i8.i32(i8* {{.*}}[[C3VOID]], i8 addrspace(4)* {{.*}}[[REFGENVOID]]
+// COMMON: call void @_ZNU3AS41CplERU3AS4KS_(%class.C* sret %c3, %class.C addrspace(4)* [[C1GEN]], %class.C addrspace(4)* dereferenceable(4) [[C2GEN]])
 
 // Test the address space of 'this' when invoking the move constructor
 // COMMON: [[C4GEN:%[0-9]+]] = addrspacecast %class.C* %c4 to %class.C addrspace(4)*
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -159,7 +159,8 @@
  LineComment | C99 | Digraphs | HexFloat | OpenCL)
 LANGSTANDARD(openclcpp, "c++",
  OpenCL, "OpenCL C++ 1.0",
- LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs | OpenCL)
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 |
+ Digraphs | HexFloat | OpenCL)
 
 LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
 LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
___
cfe-commits mailing list

[clang-tools-extra] r360247 - Documentation for bugprone-inaccurate-erase: added an example of a bug that this checker catches

2019-05-08 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Wed May  8 05:02:31 2019
New Revision: 360247

URL: http://llvm.org/viewvc/llvm-project?rev=360247=rev
Log:
Documentation for bugprone-inaccurate-erase: added an example of a bug that 
this checker catches

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-inaccurate-erase.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-inaccurate-erase.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-inaccurate-erase.rst?rev=360247=360246=360247=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-inaccurate-erase.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-inaccurate-erase.rst 
Wed May  8 05:02:31 2019
@@ -11,3 +11,19 @@ container but return an iterator to the
 of the container. These redundant elements must be removed using the
 ``erase()`` method. This check warns when not all of the elements will be
 removed due to using an inappropriate overload.
+
+For example, the following code erases only one element:
+
+.. code-block:: c++
+
+  std::vector xs;
+  ...
+  xs.erase(std::remove(xs.begin(), xs.end(), 10));
+
+Call the two-argument overload of ``erase()`` to remove the subrange:
+
+.. code-block:: c++
+
+  std::vector xs;
+  ...
+  xs.erase(std::remove(xs.begin(), xs.end(), 10), xs.end());


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


[PATCH] D61424: [ASTImporter] Fix inequivalence of unresolved exception spec

2019-05-08 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 198626.
martong marked 2 inline comments as done.
martong added a comment.

- Improve and fix typo in comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61424

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp


Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -322,6 +322,36 @@
   return true;
 }
 
+/// Check the equivalence of exception specifications.
+static bool IsEquivalentExceptionSpec(StructuralEquivalenceContext ,
+  const FunctionProtoType *Proto1,
+  const FunctionProtoType *Proto2) {
+
+  auto Spec1 = Proto1->getExceptionSpecType();
+  auto Spec2 = Proto2->getExceptionSpecType();
+
+  if (isUnresolvedExceptionSpec(Spec1) || isUnresolvedExceptionSpec(Spec2))
+return true;
+
+  if (Spec1 != Spec2)
+return false;
+  if (Spec1 == EST_Dynamic) {
+if (Proto1->getNumExceptions() != Proto2->getNumExceptions())
+  return false;
+for (unsigned I = 0, N = Proto1->getNumExceptions(); I != N; ++I) {
+  if (!IsStructurallyEquivalent(Context, Proto1->getExceptionType(I),
+Proto2->getExceptionType(I)))
+return false;
+}
+  } else if (isComputedNoexcept(Spec1)) {
+if (!IsStructurallyEquivalent(Context, Proto1->getNoexceptExpr(),
+  Proto2->getNoexceptExpr()))
+  return false;
+  }
+
+  return true;
+}
+
 /// Determine structural equivalence of two types.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext ,
  QualType T1, QualType T2) {
@@ -536,24 +566,8 @@
 cast(OrigT1.getDesugaredType(Context.FromCtx));
 const auto *OrigProto2 =
 cast(OrigT2.getDesugaredType(Context.ToCtx));
-auto Spec1 = OrigProto1->getExceptionSpecType();
-auto Spec2 = OrigProto2->getExceptionSpecType();
-
-if (Spec1 != Spec2)
+if (!IsEquivalentExceptionSpec(Context, OrigProto1, OrigProto2))
   return false;
-if (Spec1 == EST_Dynamic) {
-  if (OrigProto1->getNumExceptions() != OrigProto2->getNumExceptions())
-return false;
-  for (unsigned I = 0, N = OrigProto1->getNumExceptions(); I != N; ++I) {
-if (!IsStructurallyEquivalent(Context, OrigProto1->getExceptionType(I),
-  OrigProto2->getExceptionType(I)))
-  return false;
-  }
-} else if (isComputedNoexcept(Spec1)) {
-  if (!IsStructurallyEquivalent(Context, OrigProto1->getNoexceptExpr(),
-OrigProto2->getNoexceptExpr()))
-return false;
-}
 
 // Fall through to check the bits common with FunctionNoProtoType.
 LLVM_FALLTHROUGH;
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3101,6 +3101,11 @@
 auto *Recent = const_cast(
   FoundByLookup->getMostRecentDecl());
 ToFunction->setPreviousDecl(Recent);
+// FIXME Probably we should merge exception specifications.  E.g. In the
+// "To" context the existing function may have exception specification with
+// noexcept-unevaluated, while the newly imported function may have an
+// evaluated noexcept.  A call to adjustExceptionSpec() on the imported
+// decl and its redeclarations may be required.
   }
 
   // Import Ctor initializers.


Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -322,6 +322,36 @@
   return true;
 }
 
+/// Check the equivalence of exception specifications.
+static bool IsEquivalentExceptionSpec(StructuralEquivalenceContext ,
+  const FunctionProtoType *Proto1,
+  const FunctionProtoType *Proto2) {
+
+  auto Spec1 = Proto1->getExceptionSpecType();
+  auto Spec2 = Proto2->getExceptionSpecType();
+
+  if (isUnresolvedExceptionSpec(Spec1) || isUnresolvedExceptionSpec(Spec2))
+return true;
+
+  if (Spec1 != Spec2)
+return false;
+  if (Spec1 == EST_Dynamic) {
+if (Proto1->getNumExceptions() != Proto2->getNumExceptions())
+  return false;
+for (unsigned I = 0, N = Proto1->getNumExceptions(); I != N; ++I) {
+  if (!IsStructurallyEquivalent(Context, Proto1->getExceptionType(I),
+Proto2->getExceptionType(I)))
+return false;
+}
+  } else if (isComputedNoexcept(Spec1)) {
+if (!IsStructurallyEquivalent(Context, Proto1->getNoexceptExpr(),
+   

[PATCH] D61644: Documentation for bugprone-inaccurate-erase: added an example of a bug that this checker catches

2019-05-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61644



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


[PATCH] D61438: [ASTImporter] Use llvm::Expected and Error in the importer API

2019-05-08 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 198623.
martong added a comment.

- Use LLDB_LOG_ERROR in ImportDefinitionTo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61438

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExternalASTMerger.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/ASTMerge.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/source/Symbol/ClangASTImporter.cpp
  lldb/source/Symbol/CxxModuleHandler.cpp

Index: lldb/source/Symbol/CxxModuleHandler.cpp
===
--- lldb/source/Symbol/CxxModuleHandler.cpp
+++ lldb/source/Symbol/CxxModuleHandler.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Symbol/CxxModuleHandler.h"
 
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Utility/Log.h"
 #include "clang/Sema/Lookup.h"
 #include "llvm/Support/Error.h"
 
@@ -214,13 +215,15 @@
   // Import the foreign template arguments.
   llvm::SmallVector imported_args;
 
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
   // If this logic is changed, also update templateArgsAreSupported.
   for (const TemplateArgument  : foreign_args.asArray()) {
 switch (arg.getKind()) {
 case TemplateArgument::Type: {
-  llvm::Expected type = m_importer->Import_New(arg.getAsType());
+  llvm::Expected type = m_importer->Import(arg.getAsType());
   if (!type) {
-llvm::consumeError(type.takeError());
+LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return {};
   }
   imported_args.push_back(TemplateArgument(*type));
@@ -229,9 +232,9 @@
 case TemplateArgument::Integral: {
   llvm::APSInt integral = arg.getAsIntegral();
   llvm::Expected type =
-  m_importer->Import_New(arg.getIntegralType());
+  m_importer->Import(arg.getIntegralType());
   if (!type) {
-llvm::consumeError(type.takeError());
+LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return {};
   }
   imported_args.push_back(
Index: lldb/source/Symbol/ClangASTImporter.cpp
===
--- lldb/source/Symbol/ClangASTImporter.cpp
+++ lldb/source/Symbol/ClangASTImporter.cpp
@@ -62,8 +62,16 @@
 
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
 
-  if (delegate_sp)
-return delegate_sp->Import(type);
+  if (delegate_sp) {
+if (llvm::Expected ret_or_error = delegate_sp->Import(type)) {
+  return *ret_or_error;
+} else {
+  Log *log =
+  lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+  LLDB_LOG_ERROR(log, ret_or_error.takeError(),
+ "Couldn't import type: {0}");
+}
+  }
 
   return QualType();
 }
@@ -106,7 +114,7 @@
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
 
   if (delegate_sp) {
-clang::Decl *result = delegate_sp->Import(decl);
+llvm::Expected result = delegate_sp->Import(decl);
 
 if (!result) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -127,9 +135,13 @@
   "metadata 0x%" PRIx64,
   decl->getDeclKindName(), user_id);
   }
+
+  llvm::consumeError(result.takeError());
+
+  return nullptr;
 }
 
-return result;
+return *result;
   }
 
   return nullptr;
@@ -624,6 +636,8 @@
   if (!RequireCompleteType(type))
 return false;
 
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
   if (const TagType *tag_type = type->getAs()) {
 TagDecl *tag_decl = tag_type->getDecl();
 
@@ -641,7 +655,12 @@
 TagDecl *origin_tag_decl = llvm::dyn_cast(decl_origin.decl);
 
 for (Decl *origin_child_decl : origin_tag_decl->decls()) {
-  delegate_sp->Import(origin_child_decl);
+  llvm::Expected imported_or_err =
+  delegate_sp->Import(origin_child_decl);
+  if (!imported_or_err)
+// FIXME return with false?
+LLDB_LOG_ERROR(log, imported_or_err.takeError(),
+   "Couldn't import decl: {0}");
 }
 
 if (RecordDecl *record_decl = dyn_cast(origin_tag_decl)) {
@@ -666,7 +685,12 @@
   llvm::dyn_cast(decl_origin.decl);
 
   for (Decl *origin_child_decl : origin_interface_decl->decls()) {
-delegate_sp->Import(origin_child_decl);
+llvm::Expected imported_or_err =
+delegate_sp->Import(origin_child_decl);
+if (!imported_or_err)
+  // FIXME return with false?
+  LLDB_LOG_ERROR(log, imported_or_err.takeError(),
+ "Couldn't import decl: {0}");
   }
 
   

[PATCH] D58236: Make address space conversions a bit stricter.

2019-05-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D58236#1494722 , @ebevhan wrote:

> This was accepted a while ago, but never landed. I don't have commit access; 
> could someone commit it?


Sure!


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

https://reviews.llvm.org/D58236



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


[PATCH] D61438: [ASTImporter] Use llvm::Expected and Error in the importer API

2019-05-08 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 198618.
martong added a comment.

- Add braces to 'true' cases when 'false' case has braces
- Simplify logging and error handling with LLDB_LOG_ERROR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61438

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExternalASTMerger.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/ASTMerge.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/source/Symbol/ClangASTImporter.cpp
  lldb/source/Symbol/CxxModuleHandler.cpp

Index: lldb/source/Symbol/CxxModuleHandler.cpp
===
--- lldb/source/Symbol/CxxModuleHandler.cpp
+++ lldb/source/Symbol/CxxModuleHandler.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Symbol/CxxModuleHandler.h"
 
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Utility/Log.h"
 #include "clang/Sema/Lookup.h"
 #include "llvm/Support/Error.h"
 
@@ -214,13 +215,15 @@
   // Import the foreign template arguments.
   llvm::SmallVector imported_args;
 
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
   // If this logic is changed, also update templateArgsAreSupported.
   for (const TemplateArgument  : foreign_args.asArray()) {
 switch (arg.getKind()) {
 case TemplateArgument::Type: {
-  llvm::Expected type = m_importer->Import_New(arg.getAsType());
+  llvm::Expected type = m_importer->Import(arg.getAsType());
   if (!type) {
-llvm::consumeError(type.takeError());
+LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return {};
   }
   imported_args.push_back(TemplateArgument(*type));
@@ -229,9 +232,9 @@
 case TemplateArgument::Integral: {
   llvm::APSInt integral = arg.getAsIntegral();
   llvm::Expected type =
-  m_importer->Import_New(arg.getIntegralType());
+  m_importer->Import(arg.getIntegralType());
   if (!type) {
-llvm::consumeError(type.takeError());
+LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return {};
   }
   imported_args.push_back(
Index: lldb/source/Symbol/ClangASTImporter.cpp
===
--- lldb/source/Symbol/ClangASTImporter.cpp
+++ lldb/source/Symbol/ClangASTImporter.cpp
@@ -62,8 +62,16 @@
 
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
 
-  if (delegate_sp)
-return delegate_sp->Import(type);
+  if (delegate_sp) {
+if (llvm::Expected ret_or_error = delegate_sp->Import(type)) {
+  return *ret_or_error;
+} else {
+  Log *log =
+  lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+  LLDB_LOG_ERROR(log, ret_or_error.takeError(),
+ "Couldn't import type: {0}");
+}
+  }
 
   return QualType();
 }
@@ -106,7 +114,7 @@
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
 
   if (delegate_sp) {
-clang::Decl *result = delegate_sp->Import(decl);
+llvm::Expected result = delegate_sp->Import(decl);
 
 if (!result) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -127,9 +135,13 @@
   "metadata 0x%" PRIx64,
   decl->getDeclKindName(), user_id);
   }
+
+  llvm::consumeError(result.takeError());
+
+  return nullptr;
 }
 
-return result;
+return *result;
   }
 
   return nullptr;
@@ -624,6 +636,8 @@
   if (!RequireCompleteType(type))
 return false;
 
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
   if (const TagType *tag_type = type->getAs()) {
 TagDecl *tag_decl = tag_type->getDecl();
 
@@ -641,7 +655,12 @@
 TagDecl *origin_tag_decl = llvm::dyn_cast(decl_origin.decl);
 
 for (Decl *origin_child_decl : origin_tag_decl->decls()) {
-  delegate_sp->Import(origin_child_decl);
+  llvm::Expected imported_or_err =
+  delegate_sp->Import(origin_child_decl);
+  if (!imported_or_err)
+// FIXME return with false?
+LLDB_LOG_ERROR(log, imported_or_err.takeError(),
+   "Couldn't import decl: {0}");
 }
 
 if (RecordDecl *record_decl = dyn_cast(origin_tag_decl)) {
@@ -666,7 +685,12 @@
   llvm::dyn_cast(decl_origin.decl);
 
   for (Decl *origin_child_decl : origin_interface_decl->decls()) {
-delegate_sp->Import(origin_child_decl);
+llvm::Expected imported_or_err =
+delegate_sp->Import(origin_child_decl);
+if (!imported_or_err)
+  // FIXME return with false?
+  LLDB_LOG_ERROR(log, imported_or_err.takeError(),
+ 

[PATCH] D58236: Make address space conversions a bit stricter.

2019-05-08 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

This was accepted a while ago, but never landed. I don't have commit access; 
could someone commit it?


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

https://reviews.llvm.org/D58236



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


[PATCH] D61506: [OpenCL] Switch to C++17

2019-05-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D61506#1493953 , @keryell wrote:

> In D61506#1490555 , @rsmith wrote:
>
> > Per the OpenCL C++ 1.0 specification, section 2:
> >
> > > The OpenCL C++ programming language is based on the ISO/IEC JTC1 SC22 
> > > WG21 N 3690 language specification (a.k.a. C++14 specification).
> >
> > I think it would be reasonable to permit changing the base C++ standard in 
> > OpenCL C++ mode
>
>
> Indeed! There should be an option to pick the version of C++ the user wants 
> for OpenCL.


Unfortunately, this is not easy to do. We document changes on top of other spec 
and we need to provide references. It would be a lot more work to refer to all 
different spec versions of C++. Also the development becomes more complicated 
as it needs testing and fixing against all different C++ versions. It makes 
sense to focus on one version and potentially provide an upgrade in the future. 
Also C++17 is a reasonable target most of developers should be happy with at 
this point.


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

https://reviews.llvm.org/D61506



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


[PATCH] D61670: [RFC] [MinGW] Allow opting out from .refptr stubs

2019-05-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added a reviewer: rnk.
Herald added a project: clang.

In GCC, the .refptr stubs are only generated for x86_64, and only for code 
models medium and larger (and medium is the default for x86_64 since this was 
introduced). They can be omitted (for projects that are conscious about 
performance and size, and don't need automatically importing dll data members), 
by passing -mcmodel=small.

Within LLVM, the default code model is small, but within clang we can 
distinguish between nothing being specified at all (where CodeModel is equal to 
"default") and when the small (and tiny) models have been explicitly requested.

I'm not very pleased with the form of it (in splitting hairs between default 
which implies small, and explicit small), but it has the upside of achieving 
the same effect when the same option is passed as to GCC. Is there some other 
option that would be more suitable for controlling it (with the downside of 
needing different options wrt to GCC)? Or perhaps it's not worth the mess at 
all? The actual savings from omitting it are miniscule.

For reference, the whole refptr business was introduced in GCC in this commit, 
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5496fac88af2009a2c4d5cfec0e722d5f962d80e,
 to fix this issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52790


Repository:
  rC Clang

https://reviews.llvm.org/D61670

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/dso-local-executable.c


Index: test/CodeGen/dso-local-executable.c
===
--- test/CodeGen/dso-local-executable.c
+++ test/CodeGen/dso-local-executable.c
@@ -9,8 +9,10 @@
 // COFF-DAG: @import_var = external dllimport global i32
 // COFF-DAG: declare dllimport void @import_func()
 
-// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck 
-allow-deprecated-dag-overlap --check-prefix=MINGW %s
-// MINGW-DAG: @bar = external global i32
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck 
-allow-deprecated-dag-overlap --check-prefixes=MINGW,MINGW-DEFAULT %s
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -mcode-model small -emit-llvm %s 
-o - | FileCheck -allow-deprecated-dag-overlap 
--check-prefixes=MINGW,MINGW-SMALL %s
+// MINGW-DEFAULT-DAG: @bar = external global i32
+// MINGW-SMALL-DAG: @bar = external dso_local global i32
 // MINGW-DAG: @weak_bar = extern_weak global i32
 // MINGW-DAG: declare dso_local void @foo()
 // MINGW-DAG: @baz = dso_local global i32 42
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -755,12 +755,16 @@
 return false;
 
   const llvm::Triple  = CGM.getTriple();
+  const auto  = CGM.getCodeGenOpts();
   if (TT.isWindowsGNUEnvironment()) {
 // In MinGW, variables without DLLImport can still be automatically
 // imported from a DLL by the linker; don't mark variables that
 // potentially could come from another DLL as DSO local.
+// If the small or tiny code model has been explicitly requested,
+// mark everything as DSO local.
 if (GV->isDeclarationForLinker() && isa(GV) &&
-!GV->isThreadLocal())
+!GV->isThreadLocal() && CGOpts.CodeModel != "small" &&
+CGOpts.CodeModel != "tiny")
   return false;
   }
 
@@ -783,7 +787,6 @@
 return false;
 
   // If this is not an executable, don't assume anything is local.
-  const auto  = CGM.getCodeGenOpts();
   llvm::Reloc::Model RM = CGOpts.RelocationModel;
   const auto  = CGM.getLangOpts();
   if (RM != llvm::Reloc::Static && !LOpts.PIE)


Index: test/CodeGen/dso-local-executable.c
===
--- test/CodeGen/dso-local-executable.c
+++ test/CodeGen/dso-local-executable.c
@@ -9,8 +9,10 @@
 // COFF-DAG: @import_var = external dllimport global i32
 // COFF-DAG: declare dllimport void @import_func()
 
-// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix=MINGW %s
-// MINGW-DAG: @bar = external global i32
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefixes=MINGW,MINGW-DEFAULT %s
+// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -mcode-model small -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefixes=MINGW,MINGW-SMALL %s
+// MINGW-DEFAULT-DAG: @bar = external global i32
+// MINGW-SMALL-DAG: @bar = external dso_local global i32
 // MINGW-DAG: @weak_bar = extern_weak global i32
 // MINGW-DAG: declare dso_local void @foo()
 // MINGW-DAG: @baz = dso_local global i32 42
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -755,12 +755,16 @@
 return false;
 
   const llvm::Triple  = 

[PATCH] D61664: [NewPM] Setup Passes for KASan and KMSan

2019-05-08 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added a comment.

Rubberstamp LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61664



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


[PATCH] D61668: [ARM] Fix the extensions implied by a cpu name

2019-05-08 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

LGTM but the use of "intrinsic" in the commit message is confusing. Do you mean 
feature/implied feature, as in "the implied features defined by"?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61668



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


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-05-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198606.
ilya-biryukov marked 5 inline comments as done.
ilya-biryukov added a comment.

- Make traverse() internal to its only use-site.
- s/Corpus/Arena.
- Address some other comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637

Files:
  clang/include/clang/Tooling/Syntax/Arena.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/include/clang/Tooling/Syntax/Tree/Cascade.h
  clang/include/clang/Tooling/Syntax/Tree/NodeKind.h
  clang/include/clang/Tooling/Syntax/Tree/NodeList.h
  clang/include/clang/Tooling/Syntax/Tree/Nodes.h
  clang/lib/Tooling/Syntax/Arena.cpp
  clang/lib/Tooling/Syntax/BuildFromAST.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Cascade.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/tools/CMakeLists.txt
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -0,0 +1,155 @@
+//===- TreeTest.cpp ---===//
+//
+// 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/Tooling/Syntax/Tree.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Syntax/Arena.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree/Nodes.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace clang;
+
+namespace {
+class SyntaxTreeTest : public ::testing::Test {
+protected:
+  // Build a syntax tree for the code.
+  syntax::TranslationUnit *buildTree(llvm::StringRef Code) {
+// FIXME: this code is almost the identical to the one in TokensTest. Share
+//it.
+class BuildSyntaxTree : public ASTConsumer {
+public:
+  BuildSyntaxTree(syntax::TranslationUnit *,
+  std::unique_ptr ,
+  std::unique_ptr Tokens)
+  : Root(Root), Arena(Arena), Tokens(std::move(Tokens)) {
+assert(this->Tokens);
+  }
+
+  void HandleTranslationUnit(ASTContext ) override {
+Arena = llvm::make_unique(Ctx.getSourceManager(),
+ Ctx.getLangOpts(),
+ std::move(*Tokens).consume());
+Tokens = nullptr; // make sure we fail if this gets called twice.
+Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
+  }
+
+private:
+  syntax::TranslationUnit *
+  std::unique_ptr 
+  std::unique_ptr Tokens;
+};
+
+class BuildSyntaxTreeAction : public ASTFrontendAction {
+public:
+  BuildSyntaxTreeAction(syntax::TranslationUnit *,
+std::unique_ptr )
+  : Root(Root), Arena(Arena) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance , StringRef InFile) override {
+// We start recording the tokens, ast consumer will take on the result.
+auto Tokens =
+llvm::make_unique(CI.getPreprocessor());
+return llvm::make_unique(Root, Arena,
+  std::move(Tokens));
+  }
+
+private:
+  syntax::TranslationUnit *
+  std::unique_ptr 
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
+  FileName};
+auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+assert(CI);
+CI->getFrontendOpts().DisableFree = false;
+CI->getPreprocessorOpts().addRemappedFile(
+FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
+CompilerInstance Compiler;
+Compiler.setInvocation(std::move(CI));
+if (!Diags->getClient())
+  Diags->setClient(new IgnoringDiagConsumer);
+Compiler.setDiagnostics(Diags.get());
+Compiler.setFileManager(FileMgr.get());
+Compiler.setSourceManager(SourceMgr.get());
+
+syntax::TranslationUnit *Root = nullptr;
+BuildSyntaxTreeAction Recorder(Root, this->Arena);
+if (!Compiler.ExecuteAction(Recorder)) {
+  ADD_FAILURE() << "failed to run the frontend";
+  

[PATCH] D61637: [Syntax] Introduce syntax trees

2019-05-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198609.
ilya-biryukov added a comment.

- s/corpus/arena
- Remove an accidental cmake change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637

Files:
  clang/include/clang/Tooling/Syntax/Arena.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/include/clang/Tooling/Syntax/Tree/Cascade.h
  clang/include/clang/Tooling/Syntax/Tree/NodeKind.h
  clang/include/clang/Tooling/Syntax/Tree/NodeList.h
  clang/include/clang/Tooling/Syntax/Tree/Nodes.h
  clang/lib/Tooling/Syntax/Arena.cpp
  clang/lib/Tooling/Syntax/BuildFromAST.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Cascade.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -0,0 +1,155 @@
+//===- TreeTest.cpp ---===//
+//
+// 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/Tooling/Syntax/Tree.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Syntax/Arena.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree/Nodes.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace clang;
+
+namespace {
+class SyntaxTreeTest : public ::testing::Test {
+protected:
+  // Build a syntax tree for the code.
+  syntax::TranslationUnit *buildTree(llvm::StringRef Code) {
+// FIXME: this code is almost the identical to the one in TokensTest. Share
+//it.
+class BuildSyntaxTree : public ASTConsumer {
+public:
+  BuildSyntaxTree(syntax::TranslationUnit *,
+  std::unique_ptr ,
+  std::unique_ptr Tokens)
+  : Root(Root), Arena(Arena), Tokens(std::move(Tokens)) {
+assert(this->Tokens);
+  }
+
+  void HandleTranslationUnit(ASTContext ) override {
+Arena = llvm::make_unique(Ctx.getSourceManager(),
+ Ctx.getLangOpts(),
+ std::move(*Tokens).consume());
+Tokens = nullptr; // make sure we fail if this gets called twice.
+Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
+  }
+
+private:
+  syntax::TranslationUnit *
+  std::unique_ptr 
+  std::unique_ptr Tokens;
+};
+
+class BuildSyntaxTreeAction : public ASTFrontendAction {
+public:
+  BuildSyntaxTreeAction(syntax::TranslationUnit *,
+std::unique_ptr )
+  : Root(Root), Arena(Arena) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance , StringRef InFile) override {
+// We start recording the tokens, ast consumer will take on the result.
+auto Tokens =
+llvm::make_unique(CI.getPreprocessor());
+return llvm::make_unique(Root, Arena,
+  std::move(Tokens));
+  }
+
+private:
+  syntax::TranslationUnit *
+  std::unique_ptr 
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
+  FileName};
+auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+assert(CI);
+CI->getFrontendOpts().DisableFree = false;
+CI->getPreprocessorOpts().addRemappedFile(
+FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
+CompilerInstance Compiler;
+Compiler.setInvocation(std::move(CI));
+if (!Diags->getClient())
+  Diags->setClient(new IgnoringDiagConsumer);
+Compiler.setDiagnostics(Diags.get());
+Compiler.setFileManager(FileMgr.get());
+Compiler.setSourceManager(SourceMgr.get());
+
+syntax::TranslationUnit *Root = nullptr;
+BuildSyntaxTreeAction Recorder(Root, this->Arena);
+if (!Compiler.ExecuteAction(Recorder)) {
+  ADD_FAILURE() << "failed to run the frontend";
+  std::abort();
+}
+return Root;
+  }
+
+  // Adds a file to the test VFS.
+  void addFile(llvm::StringRef Path, 

[PATCH] D61637: [Syntax] Introduce syntax trees

2019-05-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Corpus.h:23
+/// token buffers, source manager, etc.
+class Corpus {
+public:

sammccall wrote:
> I think plain SyntaxArena might be a better name here :-/
> Corpus refers to texts (the use in dex is by analogy, as we call symbols 
> "documents" from search).
> 
Went with Arena



Comment at: clang/include/clang/Tooling/Syntax/Corpus.h:26
+  Corpus(SourceManager , const LangOptions ,
+ TokenBuffer MainFile);
+

sammccall wrote:
> MainFile is presumably the whole TU, name might need a tweak.
> Can it be empty?
> The relationship between Corpus and TokenBuffer seems a little weird. Why is 
> it needed?
Operations on the trees sometimes need to know anything about underlying tokens 
- they have access to `TokenBuffer` that produced them.

More specifically, this can be used to map between spelled and expanded tokens 
and check the mappings are possible.



Comment at: clang/include/clang/Tooling/Syntax/Corpus.h:38
+  std::pair>
+  tokenizeBuffer(std::unique_ptr Buffer);
+

sammccall wrote:
> Are you planning to have a way to add tokens directly? Having to turn them 
> into text and re-lex them seems like it might be inconvenient.
The tokens have source locations and refer to a text in some buffer. 
`tokenizeBuffer` makes is easier, not harder, to mock tokens.



Comment at: clang/include/clang/Tooling/Syntax/Corpus.h:40
+
+  /// Construct a new syntax node of a specified kind. The memory for a node is
+  /// owned by the corpus and will be freed when the corpus is destroyed.

sammccall wrote:
> Now there's two ways to do this: `new (C.allocator()) T(...)` or 
> `C.construct(...)`. Do we need both?
> 
> (If we do, is the syntax `new (C) T(...)` more natural?)
I think `C.construct()` read better than `new (C) T(...)`. Not a big fan of 
placement new exprs.



Comment at: clang/include/clang/Tooling/Syntax/Tree.h:34
+
+/// Build a syntax tree for the main file.
+TranslationUnit *buildSyntaxTree(Corpus ,

sammccall wrote:
> for a translation unit? or for only decls within the main file?
For a translation unit. We will add versions that built for a subtree of the 
AST later.



Comment at: clang/include/clang/Tooling/Syntax/Tree.h:40
+/// node.
+void traverse(Node *N, llvm::function_ref Visit);
+void traverse(const Node *N, llvm::function_ref Visit);

ilya-biryukov wrote:
> sammccall wrote:
> > I've been burned with adding these APIs without use cases.
> > 
> > It seems likely you want a way to:
> >  - skip traversal of children
> >  - abort the traversal entirely
> Not having an option to abort traversal protects us against timing attacks...
> 
> Agree with both, will address in this patch.
> 
Removed from the public API, we seem to have different ideas on how it should 
look like and I'd prefer to focus on storage model in this patch.



Comment at: clang/include/clang/Tooling/Syntax/Tree/Cascade.h:1
+//===- Tree.h - cascade of the syntax tree *- C++ 
-*-=//
+//

sammccall wrote:
> sammccall wrote:
> > sammccall wrote:
> > > this is Cascade.h, not tree.h
> > why "cascade"?
> The Tree/ subdirectory seems superfluous - why are these separate from 
> Syntax/?
Cascade defines a few base nodes: a composite node (`TreeNode`) and a leaf node 
that holds tokens.
I'd really like to isolate them from language-specific nodes, so 
language-specific nodes live in a separate file (`Nodes.h`).
However, they need to see the definition of a composite node, hence the split.

Users are advised to use an umbrella header, `Tree.h`. The extra directory is 
to minimize the number of headers in the top-level directory, having too many 
is confusing.



Comment at: clang/include/clang/Tooling/Syntax/Tree/Cascade.h:74
+/// A composite tree node that has children.
+class TreeNode : public Node {
+public:

sammccall wrote:
> This use of "tree node" to mean specifically internal node seems confusing - 
> is it common?
I don't think it's common, can use `CompositeNode` - seems like a better 
alternative


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637



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


[PATCH] D61668: [ARM] Fix the extensions implied by a cpu name

2019-05-08 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio created this revision.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.
dnsampaio added reviewers: keith.walker.arm, DavidSpickett, carwil.

When using `clang -mcpu=CPUNAME+FEATURELIST`,
the intrinsic features defined by CPUNAME are
not obtained, as the entire string is passed.
This fixes that by spiting the cpuname
string in the first `+`, if any.

For example, when using

  clang -### --target=arm-arm-none-eabi -march=armv7-a -mcpu=cortex-a8+nocrc

the intrinsic

  "target-feature" "+dsp"

implied by `cortex-a8` is missing.


Repository:
  rC Clang

https://reviews.llvm.org/D61668

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-cortex-cpus.c

Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -340,30 +340,31 @@
 // RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
 // RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
 // CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "+fullfp16"
-// CHECK-CORTEX-A53-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
-// CHECK-CORTEX-A53-NOFP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "-fullfp16" "-target-feature" "-fp16fml"
+// CHECK-CORTEX-A53-FP16-NOT: "-target-feature" "+fp16fml"
+// CHECK-CORTEX-A53-NOFP16-NOT: "+fullfp16"
+// CHECK-CORTEX-A53-NOFP16-NOT: "+fp16fml"
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-NOFP16FML %s
-// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
-// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"
+// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "+fp16fml"
+// CHECK-V8A-NOFP16FML-NOT: "-target-feature" "+fullfp16"
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-FP16 %s
-// CHECK-V8A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
+// CHECK-V8A-FP16-NOT: "-target-feature" "+fp16fml"
 // CHECK-V8A-FP16: "-target-feature" "+fullfp16"
-// CHECK-V8A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
+// CHECK-V8A-FP16-NOT: "-target-feature" "+fp16fml"
 // CHECK-V8A-FP16-SAME: {{$}}
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-FP16FML %s
 // CHECK-V8A-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-NOFP16FML %s
-// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
-// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"
+// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "+fp16fml"
+// CHECK-V82A-NOFP16FML-NOT: "-target-feature" "+fullfp16"
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-FP16 %s
-// CHECK-V82A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
+// CHECK-V82A-FP16-NOT: "-target-feature" "+fp16fml"
 // CHECK-V82A-FP16: "-target-feature" "+fullfp16"
-// CHECK-V82A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
+// CHECK-V82A-FP16-NOT: "-target-feature" "+fp16fml"
 // CHECK-V82A-FP16-SAME: {{$}}
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-FP16FML %s
@@ -382,13 +383,13 @@
 // CHECK-V82A-NOFP16-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-NOFP16FML %s
-// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
-// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fullfp16"
+// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "+fp16fml"
+// CHECK-V83A-NOFP16FML-NOT: "-target-feature" "+fullfp16"
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a+fp16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-FP16 %s
-// CHECK-V83A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
+// CHECK-V83A-FP16-NOT: "-target-feature" "+fp16fml"
 // CHECK-V83A-FP16: "-target-feature" "+fullfp16"
-// CHECK-V83A-FP16-NOT: "-target-feature" "{{[+-]}}fp16fml"
+// CHECK-V83A-FP16-NOT: "-target-feature" "+fp16fml"
 // CHECK-V83A-FP16-SAME: {{$}}
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a+fp16fml -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A-FP16FML %s
@@ -407,8 +408,8 @@
 // CHECK-V83A-NOFP16-FP16FML: "-target-feature" "+fp16fml" "-target-feature" "+fullfp16"
 
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.4-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A-NOFP16FML %s
-// CHECK-V84A-NOFP16FML-NOT: "-target-feature" "{{[+-]}}fp16fml"
-// 

[PATCH] D61485: Added an assert in `isConstantInitializer`: initializer lists must be in semantic form

2019-05-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

@rsmith Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61485



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


[PATCH] D61522: Added an assertion to constant evaluation enty points that prohibits dependent expressions

2019-05-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr marked an inline comment as done.
gribozavr added a comment.

In D61522#1494155 , @rsmith wrote:

> The right thing to check in all of these cases should be only 
> `isValueDependent()`. Every type-dependent expression should generally also 
> be value-dependent (because the type is part of the value), but 
> value-dependent exactly means "dependent in a way that prevents constant 
> evaluation", so that's all that we should be checking.


Done.  PTAL.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:5784
 Expr::EvalResult Result;
-if (CollapseLoopCountExpr->EvaluateAsInt(Result, SemaRef.getASTContext()))
+if (!CollapseLoopCountExpr->isValueDependent() &&
+!CollapseLoopCountExpr->isTypeDependent() &&

ABataev wrote:
> gribozavr wrote:
> > ABataev wrote:
> > > I would suggest to modify the code of this function if we cannot get the 
> > > value of the loops.
> > > ```
> > > if (CollapseLoopCountExpr->isValueDependent() || 
> > > CollapseLoopCountExpr->isTypeDependent() || 
> > > OrderedLoopCountExpr->isValueDependent() || 
> > > OrderedLoopCountExpr->isTypeDependent()) {
> > >   Built.clear(/* size */0);
> > >   return 1;
> > > }
> > > ```
> > > at the beginning of the function.
> > I tried doing that, and a lot of tests started crashing with:
> > 
> > llvm-project/clang/lib/Sema/SemaOpenMP.cpp:9024: clang::StmtResult 
> > clang::Sema::ActOnOpenMPTargetTeamsDistributeSimdDirective(ArrayRef >  *>, clang::Stmt *, clang::SourceLoc
> > ation, clang::SourceLocation, clang::Sema::VarsWithInheritedDSAType &): 
> > Assertion `(CurContext->isDependentContext() || B.builtAll()) && "omp 
> > target teams distribute simd loop exprs were not built"' failed.
> > 
> > Also, I wanted to note that if I were to make this change, then if 
> > `EvaluateAsInt` fails, we should apply the same recovery (`Built.clear(); 
> > return`).
> The just try to use `Built.clear(/* size */1);`, I assume it must fix the 
> problems. 
Yes, this works!  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61522



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


[PATCH] D61522: Added an assertion to constant evaluation enty points that prohibits dependent expressions

2019-05-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 198603.
gribozavr added a comment.

Addressed review comments:

- Simplified error handling in SemaOpenMP,

- Only check isValueDependent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61522

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp

Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -6366,7 +6366,8 @@
 APValue Result;
 // FIXME: This doesn't consider value-dependent cases, because doing so is
 // very difficult. Ideally, we should handle them more gracefully.
-if (!EIA->getCond()->EvaluateWithSubstitution(
+if (EIA->getCond()->isValueDependent() ||
+!EIA->getCond()->EvaluateWithSubstitution(
 Result, Context, Function, llvm::makeArrayRef(ConvertedArgs)))
   return EIA;
 
@@ -9547,7 +9548,8 @@
 const FunctionDecl *FD) {
   for (auto *EnableIf : FD->specific_attrs()) {
 bool AlwaysTrue;
-if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
+if (EnableIf->getCond()->isValueDependent() ||
+!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
   return false;
 if (!AlwaysTrue)
   return false;
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -5880,14 +5880,21 @@
   if (CollapseLoopCountExpr) {
 // Found 'collapse' clause - calculate collapse number.
 Expr::EvalResult Result;
-if (CollapseLoopCountExpr->EvaluateAsInt(Result, SemaRef.getASTContext()))
+if (!CollapseLoopCountExpr->isValueDependent() &&
+CollapseLoopCountExpr->EvaluateAsInt(Result, SemaRef.getASTContext())) {
   NestedLoopCount = Result.Val.getInt().getLimitedValue();
+} else {
+  Built.clear(/*size=*/1);
+  return 1;
+}
   }
   unsigned OrderedLoopCount = 1;
   if (OrderedLoopCountExpr) {
 // Found 'ordered' clause - calculate collapse number.
 Expr::EvalResult EVResult;
-if (OrderedLoopCountExpr->EvaluateAsInt(EVResult, SemaRef.getASTContext())) {
+if (!OrderedLoopCountExpr->isValueDependent() &&
+OrderedLoopCountExpr->EvaluateAsInt(EVResult,
+SemaRef.getASTContext())) {
   llvm::APSInt Result = EVResult.Val.getInt();
   if (Result.getLimitedValue() < NestedLoopCount) {
 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
@@ -5898,6 +5905,9 @@
 << CollapseLoopCountExpr->getSourceRange();
   }
   OrderedLoopCount = Result.getLimitedValue();
+} else {
+  Built.clear(/*size=*/1);
+  return 1;
 }
   }
   // This is helper routine for loop directives (e.g., 'for', 'simd',
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11100,6 +11100,8 @@
 /// will be applied to the result.
 bool Expr::EvaluateAsRValue(EvalResult , const ASTContext ,
 bool InConstantContext) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   Info.InConstantContext = InConstantContext;
   return ::EvaluateAsRValue(this, Result, Ctx, Info);
@@ -11107,6 +11109,8 @@
 
 bool Expr::EvaluateAsBooleanCondition(bool ,
   const ASTContext ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalResult Scratch;
   return EvaluateAsRValue(Scratch, Ctx) &&
  HandleConversionToBool(Scratch.Val, Result);
@@ -4,18 +8,25 @@
 
 bool Expr::EvaluateAsInt(EvalResult , const ASTContext ,
  SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   return ::EvaluateAsInt(this, Result, Ctx, AllowSideEffects, Info);
 }
 
 bool Expr::EvaluateAsFixedPoint(EvalResult , const ASTContext ,
 SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   return ::EvaluateAsFixedPoint(this, Result, Ctx, AllowSideEffects, Info);
 }
 
 bool Expr::EvaluateAsFloat(APFloat , const ASTContext ,
SideEffectsKind AllowSideEffects) const {
+  

[PATCH] D61667: Assume `__cxa_allocate_exception` returns an under-aligned memory on Darwin if the version of libc++abi isn't new enough to include the fix in r319123

2019-05-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, ldionne.
ahatanak added a project: clang.
Herald added a reviewer: EricWF.
Herald added subscribers: dexonsmith, jkorous.

This patch resurrects r264998, which was committed to work around a bug in 
libc++abi that was causing `_cxa_allocate_exception` to return a memory that 
wasn't double-word aligned.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160328/154332.html

I reverted r264998 after fixing the bug in libc++abi in r319123 (see the link 
below), but didn't really realize that doing so could break projects using 
older versions of libc++abi that don't have the fix committed in r319123.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20171127/210878.html

In addition, this patch makes clang issue a warning if the type of the thrown 
object requires an alignment that is larger than the minimum alignment the 
libc++abi runtime guarantees.


Repository:
  rC Clang

https://reviews.llvm.org/D61667

Files:
  include/clang/Basic/AlignedExceptionObject.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/OSTargets.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CodeGenCXX/eh.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp

Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.99 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -Wno-underaligned-exception-object -DNODIAG %s
+
+struct S0 {
+  S0();
+  int m;
+};
+
+struct Overaligned1 {
+  Overaligned1();
+  int __attribute__((aligned(16))) m;
+};
+
+struct __attribute__((aligned(16))) Overaligned2 {
+  Overaligned2();
+  int m;
+};
+
+struct Overaligned3 {
+  Overaligned3();
+  int __attribute__((aligned(64))) m;
+};
+
+void test0() {
+  throw S0();
+}
+
+void test1() {
+  throw Overaligned1();
+}
+
+void test2() {
+  throw Overaligned2();
+}
+
+void test3() {
+  throw Overaligned3();
+}
+
+#if defined(NODIAG)
+// expected-no-diagnostics
+#elif defined(UNDERALIGNED)
+// expected-warning@-14 {{underaligned exception object thrown}}
+// expected-note@-15 {{(16-bytes) is larger than the guaranteed alignment of the memory Itanium C++ runtime returns (8-bytes)}}
+// expected-warning@-12 {{underaligned exception object thrown}}
+// expected-note@-13 {{(16-bytes) is larger than the guaranteed alignment of the memory Itanium C++ runtime returns (8-bytes)}}
+// expected-warning@-10 {{underaligned exception object thrown}}
+// expected-note@-11 {{(64-bytes) is larger than the guaranteed alignment of the memory Itanium C++ runtime returns (8-bytes)}}
+#else
+// expected-warning@-13 {{underaligned exception object thrown}}
+// expected-note@-14 {{(64-bytes) is larger than the guaranteed alignment of the memory Itanium C++ runtime returns (16-bytes)}}
+#endif
Index: test/CodeGenCXX/eh.cpp
===
--- test/CodeGenCXX/eh.cpp
+++ test/CodeGenCXX/eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - \
-// RUN:   | FileCheck %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-macosx10.13.99 -std=c++11 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=UNALIGNED %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-macosx10.14 -std=c++11 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ALIGNED %s
 
 struct test1_D {
   double d;
@@ -13,7 +13,8 @@
 // CHECK:   [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8)
 // CHECK-NEXT:  [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]]
 // CHECK-NEXT:  [[EXN2:%.*]] = bitcast [[DSTAR]] [[EXN]] to i8*
-// CHECK-NEXT:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 [[EXN2]], i8* align 8 bitcast ([[DSTAR]] @d1 to i8*), i64 8, i1 false)
+// UNALIGNED-NEXT:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[EXN2]], i8* align 8 bitcast ([[DSTAR]] @d1 to i8*), i64 8, i1 false)
+// ALIGNED-NEXT:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 [[EXN2]], i8* align 8 bitcast ([[DSTAR]] @d1 to i8*), i64 8, i1 false)
 // CHECK-NEXT:  call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast ({ i8*, i8* }* @_ZTI7test1_D to i8*), i8* null) [[NR:#[0-9]+]]
 // CHECK-NEXT:  unreachable
 
@@ -466,7 +467,8 @@
   // CHECK: [[T0:%.*]] = call i8* @__cxa_allocate_exception(i64 16)
   // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to %"class.test17::DerivedException"*
   

[clang-tools-extra] r360231 - [clang-tidy] Do not show incorrect fix in modernize-make-unique

2019-05-08 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May  8 01:52:18 2019
New Revision: 360231

URL: http://llvm.org/viewvc/llvm-project?rev=360231=rev
Log:
[clang-tidy] Do not show incorrect fix in modernize-make-unique

Summary:
The case when initialize_list hides behind an implicit case was not
handled before.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=360231=360230=360231=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Wed May  
8 01:52:18 2019
@@ -292,12 +292,13 @@ bool MakeSmartPtrCheck::replaceNew(Diagn
   //   Foo{1} => false
   auto HasListIntializedArgument = [](const CXXConstructExpr *CE) {
 for (const auto *Arg : CE->arguments()) {
+  Arg = Arg->IgnoreImplicit();
+
   if (isa(Arg) || isa(Arg))
 return true;
   // Check whether we implicitly construct a class from a
   // std::initializer_list.
-  if (const auto *ImplicitCE =
-  dyn_cast(Arg->IgnoreImplicit())) {
+  if (const auto *ImplicitCE = dyn_cast(Arg)) {
 if (ImplicitCE->isStdInitListInitialization())
   return true;
   }

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=360231=360230=360231=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Wed May  
8 01:52:18 2019
@@ -273,6 +273,14 @@ void initialization(int T, Base b) {
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
   // CHECK-FIXES: std::make_unique(APair{T, 1});
 
+  // Check aggregate init with intermediate temporaries.
+  std::unique_ptr PAggrTemp = std::unique_ptr(new APair({T, 1}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr PAggrTemp = 
std::unique_ptr(new APair({T, 1}));
+  PAggrTemp.reset(new APair({T, 1}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+  // CHECK-FIXES: PAggrTemp.reset(new APair({T, 1}));
+
   // Test different kinds of initialization of the pointee, when the unique_ptr
   // is initialized with braces.
 


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


[PATCH] D61642: [clang-tidy] Do not show incorrect fix in modernize-make-unique

2019-05-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360231: [clang-tidy] Do not show incorrect fix in 
modernize-make-unique (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61642?vs=198497=198594#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61642

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -273,6 +273,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
   // CHECK-FIXES: std::make_unique(APair{T, 1});
 
+  // Check aggregate init with intermediate temporaries.
+  std::unique_ptr PAggrTemp = std::unique_ptr(new APair({T, 1}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr PAggrTemp = 
std::unique_ptr(new APair({T, 1}));
+  PAggrTemp.reset(new APair({T, 1}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+  // CHECK-FIXES: PAggrTemp.reset(new APair({T, 1}));
+
   // Test different kinds of initialization of the pointee, when the unique_ptr
   // is initialized with braces.
 
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -292,12 +292,13 @@
   //   Foo{1} => false
   auto HasListIntializedArgument = [](const CXXConstructExpr *CE) {
 for (const auto *Arg : CE->arguments()) {
+  Arg = Arg->IgnoreImplicit();
+
   if (isa(Arg) || isa(Arg))
 return true;
   // Check whether we implicitly construct a class from a
   // std::initializer_list.
-  if (const auto *ImplicitCE =
-  dyn_cast(Arg->IgnoreImplicit())) {
+  if (const auto *ImplicitCE = dyn_cast(Arg)) {
 if (ImplicitCE->isStdInitListInitialization())
   return true;
   }


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -273,6 +273,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
   // CHECK-FIXES: std::make_unique(APair{T, 1});
 
+  // Check aggregate init with intermediate temporaries.
+  std::unique_ptr PAggrTemp = std::unique_ptr(new APair({T, 1}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr PAggrTemp = std::unique_ptr(new APair({T, 1}));
+  PAggrTemp.reset(new APair({T, 1}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+  // CHECK-FIXES: PAggrTemp.reset(new APair({T, 1}));
+
   // Test different kinds of initialization of the pointee, when the unique_ptr
   // is initialized with braces.
 
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -292,12 +292,13 @@
   //   Foo{1} => false
   auto HasListIntializedArgument = [](const CXXConstructExpr *CE) {
 for (const auto *Arg : CE->arguments()) {
+  Arg = Arg->IgnoreImplicit();
+
   if (isa(Arg) || isa(Arg))
 return true;
   // Check whether we implicitly construct a class from a
   // std::initializer_list.
-  if (const auto *ImplicitCE =
-  dyn_cast(Arg->IgnoreImplicit())) {
+  if (const auto *ImplicitCE = dyn_cast(Arg)) {
 if (ImplicitCE->isStdInitListInitialization())
   return true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-08 Thread Leonard Chan via cfe-commits
Just wanted to update. My latest revision (r360225) seems to have fixed the
bots. 

On Tue, May 7, 2019 at 3:50 PM Jonas Devlieghere 
wrote:

> Hi Leonard,
>
> My personal rule of thumb is that if I can fix it in something like 30
> minutes or less, I'll leave the bot red and commit a fix. Otherwise I'll
> revert my change. The problem with leaving the bot red is that if something
> else breaks, that person doesn't get a signal, and issue start to pile up.
>
> When I see a bot is red and it's blocking me, I will usually send an
> e-mail and wait about the same time for a reply, before reverting the
> change myself.
>
> Cheers,
> Jonas
>
> On Tue, May 7, 2019 at 11:20 AM Leonard Chan 
> wrote:
>
>> Thanks! It turns out that we weren't running debuginfo-tests. Trying to
>> find a mac I can ssh into to reproduce this.
>>
>> Another side question: is there usually an etiquette for how long a
>> greendragon bot is allowed to stay broken? I don't want to leave it that
>> way for too long while working on my fix if it bothers others too much.
>>
>> Thanks,
>> Leonard
>>
>> On Tue, May 7, 2019 at 10:13 AM Jonas Devlieghere 
>> wrote:
>>
>>> Hi Leonard,
>>>
>>> The test that is asserting is part of the debuginfo test. (
>>> https://github.com/llvm-project/debuginfo-tests)
>>> The reason that it's only failing on the non-incremental bot is because
>>> the incremental one isn't running those, I believe.
>>>
>>> RA stands for Release/Asserts.
>>>
>>> Hope that helps!
>>>
>>> Cheers,
>>> Jonas
>>>
>>> On Tue, May 7, 2019 at 9:44 AM Leonard Chan 
>>> wrote:
>>>
 Yup, sorry for the delay. I submitted it overnight thinking it would be
 fixed this time. I have one more way that I think should fix it, but before
 trying it out, do you know any tips on how I can try to reproduce this
 locally? I see that you're running these on an x64 mac, but I can't seem to
 trigger this on our own mac builders. Also as a side question, do you what
 RA stands for in "Clang Stage 1: cmake, incremental RA, using system
 compiler
 "?
 It seems that I'm only breaking the non-incremental RA jobs, bit the
 incremental one still works fine with my change.

 Thanks,
 Leonard

 On Tue, May 7, 2019, 09:26 Jonas Devlieghere 
 wrote:

> Hi Leonard,
>
> It appears that your patch is still triggering an assertion on
> GreenDragon:
> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c
>
> Can you please have a look?
>
> Thanks,
> Jonas
>
>
> On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: leonardchan
>> Date: Mon May  6 20:20:17 2019
>> New Revision: 360109
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=360109=rev
>> Log:
>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition
>> is an attribute declaration"
>>
>> Updated with fix for read of uninitialized memory.
>>
>> Added:
>> cfe/trunk/test/Frontend/macro_defined_type.cpp
>> cfe/trunk/test/Sema/address_space_print_macro.c
>> Modified:
>> cfe/trunk/include/clang/AST/ASTContext.h
>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/include/clang/AST/TypeLoc.h
>> cfe/trunk/include/clang/AST/TypeNodes.def
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/ParsedAttr.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
>> cfe/trunk/lib/AST/ASTContext.cpp
>> cfe/trunk/lib/AST/ASTDiagnostic.cpp
>> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
>> cfe/trunk/lib/AST/ItaniumMangle.cpp
>> cfe/trunk/lib/AST/Type.cpp
>> cfe/trunk/lib/AST/TypePrinter.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> cfe/trunk/lib/Parse/ParseDecl.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/lib/Sema/SemaType.cpp
>> cfe/trunk/lib/Sema/TreeTransform.h
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/test/Sema/address_spaces.c
>> cfe/trunk/test/SemaObjC/externally-retained.m
>> cfe/trunk/test/SemaObjC/gc-attributes.m
>> cfe/trunk/test/SemaObjC/mrc-weak.m
>> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
>> cfe/trunk/tools/libclang/CIndex.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> URL:
>> 

[PATCH] D61664: [NewPM] Setup Passes for KASan and KMSan

2019-05-08 Thread Philip Pfaffe via Phabricator via cfe-commits
philip.pfaffe accepted this revision.
philip.pfaffe added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61664



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


[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-08 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 198587.
asbirlea added a comment.

Updated test.
Improvement suggestions are always *very* much welcome!


Repository:
  rC Clang

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

https://reviews.llvm.org/D61617

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/loop-vectorize.c


Index: test/CodeGen/loop-vectorize.c
===
--- /dev/null
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,25 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 
-fno-vectorize -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+// CHECK-DISABLE-VECT-NOT: fmul <{{[0-9]+}} x double>
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for 
loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto  : CodeGenOpts.PassPlugins) {


Index: test/CodeGen/loop-vectorize.c
===
--- /dev/null
+++ test/CodeGen/loop-vectorize.c
@@ -0,0 +1,25 @@
+// RUN: %clang -target x86_64 -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fvectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-VECT
+// RUN: %clang -target x86_64 -fexperimental-new-pass-manager -S -c -O1 -fno-vectorize -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-VECT
+
+// CHECK-ENABLE-VECT-LABEL: @for_test()
+// CHECK-ENABLE-VECT: fmul <{{[0-9]+}} x double>
+
+// CHECK-DISABLE-VECT-LABEL: @for_test()
+// CHECK-DISABLE-VECT: fmul double
+// CHECK-DISABLE-VECT-NOT: fmul <{{[0-9]+}} x double>
+
+#include 
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1025,7 +1025,14 @@
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
+  PipelineTuningOptions PTO;
+  // For historical reasons, loop interleaving is set to mirror setting for loop
+  // unrolling.
+  PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
+  PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
+  PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+
+  PassBuilder PB(TM.get(), PTO, PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto  : CodeGenOpts.PassPlugins) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-08 Thread Alexandre Isoard via Phabricator via cfe-commits
alexandre.isoard added a comment.

I'm not convinced by the approach.

Can it still recognize the loop idiom into memcpy implementation but use 
`memmove` (as only `memcpy` has been blacklisted)?
Can it do the same for `memmove` (for the case without overlap), and end-up 
with infinite recursion?

I have a feeling we should pick a stance:

- either not allow the compiler to lower a builtin to a call to the library; 
(my preferred choice, but I'm biased)
- or not allow the library to use compiler builtins (but LTO flow with the 
runtime library *already* linked smells like trouble if we go this way).

The reason for my bias is that I have a multi-memcpy codegen in the compiler to 
generate those two calls:

  memcpy(left,  in, n);
  memcpy(right, in, n);

with a single loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


<    1   2