[PATCH] D34233: [CFI] Add ability to explicitly link classes

2017-06-14 Thread Enes Goktas via Phabricator via cfe-commits
egoktas updated this revision to Diff 102641.
egoktas added a comment.

Remove the edits to CGExpr.cpp which accidentally got included in the diff.


https://reviews.llvm.org/D34233

Files:
  include/clang/Basic/SanitizerBlacklist.h
  lib/Basic/SanitizerBlacklist.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h

Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -33,6 +33,7 @@
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
@@ -1204,6 +1205,8 @@
   /// Create and attach type metadata for the given vtable.
   void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
  const CXXRecordDecl *RD);
+  void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
+ llvm::Metadata *MD);
 
   /// \brief Get the declaration of std::terminate for the platform.
   llvm::Constant *getTerminateFn();
@@ -1213,6 +1216,9 @@
   llvm::Value *
   createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction );
 
+  void GetSupplementalClasslinks(const CXXRecordDecl *BaseClass,
+ llvm::StringSet<> );
+
   /// Get target specific null pointer.
   /// \param T is the LLVM type of the null pointer.
   /// \param QT is the clang QualType of the null pointer.
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4417,6 +4417,12 @@
   const CXXRecordDecl *RD) {
   llvm::Metadata *MD =
   CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
+  AddVTableTypeMetadata(VTable, Offset, MD);
+}
+
+void CodeGenModule::AddVTableTypeMetadata(llvm::GlobalVariable *VTable,
+  CharUnits Offset,
+  llvm::Metadata *MD) {
   VTable->addTypeMetadata(Offset.getQuantity(), MD);
 
   if (CodeGenOpts.SanitizeCfiCrossDso)
@@ -4475,3 +4481,16 @@
 "__translate_sampler_initializer"),
 {C});
 }
+
+void
+CodeGenModule::GetSupplementalClasslinks(const CXXRecordDecl *BaseClass,
+llvm::StringSet<> ){
+  std::string mangledClassName;
+  llvm::raw_string_ostream Out(mangledClassName);
+  getCXXABI().getMangleContext().mangleTypeName(
+  QualType(BaseClass->getTypeForDecl(), 0), Out);
+  Out.flush();
+
+  getContext().getSanitizerBlacklist().getSupplementalClasslinks(
+ mangledClassName, SupplementalClasslinks);
+}
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -986,7 +986,20 @@
 return E1.second < E2.second;
   });
 
-  for (auto BitsetEntry : BitsetEntries)
+  for (auto BitsetEntry : BitsetEntries){
+const CXXRecordDecl *BaseClassOfVTable = BitsetEntry.first;
 AddVTableTypeMetadata(VTable, PointerWidth * BitsetEntry.second,
-  BitsetEntry.first);
+  BaseClassOfVTable);
+
+// Check if user has defined supplemental class links for BaseClass.
+llvm::StringSet<> SupplementalClasslinks;
+GetSupplementalClasslinks(BaseClassOfVTable, SupplementalClasslinks);
+for (auto I = SupplementalClasslinks.begin(),
+  E = SupplementalClasslinks.end(); I != E; I++){
+  llvm::Metadata* LinkedClassMD = llvm::MDString::get(getLLVMContext(),
+  I->getKey());
+  AddVTableTypeMetadata(VTable, PointerWidth * BitsetEntry.second,
+LinkedClassMD);
+}
+  }
 }
Index: lib/Basic/SanitizerBlacklist.cpp
===
--- lib/Basic/SanitizerBlacklist.cpp
+++ lib/Basic/SanitizerBlacklist.cpp
@@ -44,3 +44,9 @@
  isBlacklistedFile(SM.getFilename(SM.getFileLoc(Loc)), Category);
 }
 
+void SanitizerBlacklist::getSupplementalClasslinks(StringRef mangledClassName,
+ llvm::StringSet<> ) const {
+  SCL->getEntriesInSection("classlink", SupplementalClasslinks,
+   mangledClassName);
+}
+
Index: include/clang/Basic/SanitizerBlacklist.h
===
--- include/clang/Basic/SanitizerBlacklist.h
+++ include/clang/Basic/SanitizerBlacklist.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringRef.h"

[PATCH] D34233: [CFI] Add ability to explicitly link classes

2017-06-14 Thread Enes Goktas via Phabricator via cfe-commits
egoktas created this revision.
egoktas created this object with visibility "All Users".

User can explicitly specify classlinks in a sanitizer blacklist file. During 
compilation with Control-Flow Integrity (CFI), the specified classes will be 
linked so that (vtables of) the class type Y can be used at virtual callsites 
that have the class type X. An example of a classlink in the sanitizer 
blacklist file would be:
 classlink:_ZTS1X=_ZTS1Y
Note that this is a one-way link. For example, if (vtables of) the class type X 
can be used at a virtual callsite with the class type Y, then the following 
line specifying the classlink should be added to the sanitizer blacklist file:
 classlink:_ZTS1Y=_ZTS1X

This is a solution for the CFI errors that can occur when there is no 
inheritance link between two classes but one class is used as the other at 
runtime.

This patch requires the new function "getEntriesInSection" in SpecialCaseList 
which is submitted for revision under Differential 
https://reviews.llvm.org/D34231.


https://reviews.llvm.org/D34233

Files:
  include/clang/Basic/SanitizerBlacklist.h
  lib/Basic/SanitizerBlacklist.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h

Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -33,6 +33,7 @@
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
@@ -1204,6 +1205,8 @@
   /// Create and attach type metadata for the given vtable.
   void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
  const CXXRecordDecl *RD);
+  void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
+ llvm::Metadata *MD);
 
   /// \brief Get the declaration of std::terminate for the platform.
   llvm::Constant *getTerminateFn();
@@ -1213,6 +1216,9 @@
   llvm::Value *
   createOpenCLIntToSamplerConversion(const Expr *E, CodeGenFunction );
 
+  void GetSupplementalClasslinks(const CXXRecordDecl *BaseClass,
+ llvm::StringSet<> );
+
   /// Get target specific null pointer.
   /// \param T is the LLVM type of the null pointer.
   /// \param QT is the clang QualType of the null pointer.
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4417,6 +4417,12 @@
   const CXXRecordDecl *RD) {
   llvm::Metadata *MD =
   CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
+  AddVTableTypeMetadata(VTable, Offset, MD);
+}
+
+void CodeGenModule::AddVTableTypeMetadata(llvm::GlobalVariable *VTable,
+  CharUnits Offset,
+  llvm::Metadata *MD) {
   VTable->addTypeMetadata(Offset.getQuantity(), MD);
 
   if (CodeGenOpts.SanitizeCfiCrossDso)
@@ -4475,3 +4481,16 @@
 "__translate_sampler_initializer"),
 {C});
 }
+
+void
+CodeGenModule::GetSupplementalClasslinks(const CXXRecordDecl *BaseClass,
+llvm::StringSet<> ){
+  std::string mangledClassName;
+  llvm::raw_string_ostream Out(mangledClassName);
+  getCXXABI().getMangleContext().mangleTypeName(
+  QualType(BaseClass->getTypeForDecl(), 0), Out);
+  Out.flush();
+
+  getContext().getSanitizerBlacklist().getSupplementalClasslinks(
+ mangledClassName, SupplementalClasslinks);
+}
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -986,7 +986,20 @@
 return E1.second < E2.second;
   });
 
-  for (auto BitsetEntry : BitsetEntries)
+  for (auto BitsetEntry : BitsetEntries){
+const CXXRecordDecl *BaseClassOfVTable = BitsetEntry.first;
 AddVTableTypeMetadata(VTable, PointerWidth * BitsetEntry.second,
-  BitsetEntry.first);
+  BaseClassOfVTable);
+
+// Check if user has defined supplemental class links for BaseClass.
+llvm::StringSet<> SupplementalClasslinks;
+GetSupplementalClasslinks(BaseClassOfVTable, SupplementalClasslinks);
+for (auto I = SupplementalClasslinks.begin(),
+  E = SupplementalClasslinks.end(); I != E; I++){
+  llvm::Metadata* LinkedClassMD = llvm::MDString::get(getLLVMContext(),
+  I->getKey());
+  AddVTableTypeMetadata(VTable, PointerWidth * BitsetEntry.second,
+

[libcxx] r305453 - Renamed some of the newly added tests. No functional change

2017-06-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Jun 15 00:44:49 2017
New Revision: 305453

URL: http://llvm.org/viewvc/llvm-project?rev=305453=rev
Log:
Renamed some of the newly added tests. No functional change

Added:

libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp
  - copied unchanged from r305452, 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp
  - copied unchanged from r305452, 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce.pass.cpp
  - copied unchanged from r305452, 
libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_iter_iter.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_init.pass.cpp
  - copied unchanged from r305452, 
libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_iter_iter_T.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp
  - copied unchanged from r305452, 
libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_iter_iter_T_op.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
  - copied unchanged from r305452, 
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
Removed:

libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_iter_iter.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_iter_iter_T.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/reduce/reduce_iter_iter_T_op.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp

Removed: 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp?rev=305452=auto
==
--- 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
 (removed)
@@ -1,97 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// 
-// UNSUPPORTED: c++98, c++03, c++11, c++14
-
-// template
-// OutputIterator exclusive_scan(InputIterator first, InputIterator last,
-//   OutputIterator result, T init);
-// 
-
-#include 
-#include 
-#include 
-
-#include "test_iterators.h"
-
-template 
-void
-test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast)
-{
-std::vector::value_type> v;
-
-//  Not in place
-std::exclusive_scan(first, last, std::back_inserter(v), init);
-assert(std::equal(v.begin(), v.end(), rFirst, rLast));
-
-//  In place
-v.clear();
-v.assign(first, last);
-std::exclusive_scan(v.begin(), v.end(), v.begin(), init);
-assert(std::equal(v.begin(), v.end(), rFirst, rLast));  
-}
-
-
-template 
-void
-test()
-{
-  int ia[]   = {1, 3, 5, 7,  9};
-const int pRes[] = {0, 1, 4, 9, 16};
-const unsigned sa = sizeof(ia) / sizeof(ia[0]);
-static_assert(sa == sizeof(pRes) / sizeof(pRes[0]));   // just to be 
sure
-
-for (unsigned int i = 0; i < sa; ++i )
-test(Iter(ia), Iter(ia + i), 0, pRes, pRes + i);
-}
-
-int triangle(int n) { return n*(n+1)/2; }
-
-//  Basic sanity
-void basic_tests()
-{
-{
-std::vector v(10);
-std::fill(v.begin(), v.end(), 3);
-std::exclusive_scan(v.begin(), v.end(), v.begin(), 50);
-for (size_t i = 0; i < v.size(); ++i)
-assert(v[i] == 50 + (int) i * 3);
-}
-
-{
-std::vector v(10);
-std::iota(v.begin(), v.end(), 0);
-std::exclusive_scan(v.begin(), v.end(), v.begin(), 30);
-for (size_t i = 0; i < v.size(); ++i)
-assert(v[i] == 30 + triangle(i-1));
-}
-
-{
-std::vector v(10);
-std::iota(v.begin(), v.end(), 1);
-std::exclusive_scan(v.begin(), v.end(), v.begin(), 40);
-for (size_t i = 0; i < v.size(); ++i)
-assert(v[i] == 40 + triangle(i));
-}
-
-}
-
-int main()
-{
-

[PATCH] D34052: [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions

2017-06-14 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a comment.

@dblaikie it turns out that this is a much simpler change now. PTAL?


https://reviews.llvm.org/D34052



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


[libcxx] r305451 - attempt to fix GCC ToT build failures

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 22:50:02 2017
New Revision: 305451

URL: http://llvm.org/viewvc/llvm-project?rev=305451=rev
Log:
attempt to fix GCC ToT build failures

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=305451=305450=305451=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Jun 14 22:50:02 2017
@@ -292,7 +292,7 @@
 # endif
 #endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
 
-#if __has_attribute(__no_sanitize__)
+#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
 #define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
 #else
 #define _LIBCPP_NO_CFI


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


r305450 - Correct documentation about the AfterClass clang-format option

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 22:38:08 2017
New Revision: 305450

URL: http://llvm.org/viewvc/llvm-project?rev=305450=rev
Log:
Correct documentation about the AfterClass clang-format option

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=305450=305449=305450=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Jun 14 22:38:08 2017
@@ -521,12 +521,12 @@ the configuration (without a prefix: ``A
   .. code-block:: c++
 
 true:
-class foo {};
-
-false:
 class foo
 {};
 
+false:
+class foo {};
+
   * ``bool AfterControlStatement`` Wrap control statements 
(``if``/``for``/``while``/``switch``/..).
 
   .. code-block:: c++
@@ -603,12 +603,12 @@ the configuration (without a prefix: ``A
 struct foo
 {
   int x;
-}
+};
 
 false:
 struct foo {
   int x;
-}
+};
 
   * ``bool AfterUnion`` Wrap union definitions.
 


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


[PATCH] D34198: Fix __has_trivial_destructor crash when the type is incomplete with unknown array bounds.

2017-06-14 Thread Puneetha K via Phabricator via cfe-commits
puneetha updated this revision to Diff 102635.
puneetha added a comment.

Added testcase.


https://reviews.llvm.org/D34198

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1572,8 +1572,10 @@
   { int arr[T(__has_trivial_destructor(AllDefaulted))]; }
   { int arr[T(__has_trivial_destructor(AllDeleted))]; }
   { int arr[T(__has_trivial_destructor(DerivesHasRef))]; }
+  { int arr[T(__has_trivial_destructor(ACompleteType[]))]; }
 
   { int arr[F(__has_trivial_destructor(HasDest))]; }
+  { int arr[F(__has_trivial_destructor(AnIncompleteType[]))]; } // 
expected-error {{incomplete type}}
   { int arr[F(__has_trivial_destructor(void))]; }
   { int arr[F(__has_trivial_destructor(cvoid))]; }
   { int arr[F(__has_trivial_destructor(AllPrivate))]; }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4101,6 +4101,11 @@
   case UTT_IsDestructible:
   case UTT_IsNothrowDestructible:
   case UTT_IsTriviallyDestructible:
+if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType())
+  return true;
+
+return !S.RequireCompleteType(
+Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
   // Per the GCC type traits documentation, the same constraints apply to 
these.
   case UTT_HasNothrowAssign:
   case UTT_HasNothrowMoveAssign:
@@ -4113,9 +4118,15 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType())
+if(ArgTy->isVoidType())
   return true;
 
+if (ArgTy->isIncompleteArrayType()) {
+  QualType ElTy = QualType(ArgTy->getBaseElementTypeUnsafe(), 0);
+  if (!ElTy->isIncompleteType())
+return true;
+}
+
 return !S.RequireCompleteType(
 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
   }


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1572,8 +1572,10 @@
   { int arr[T(__has_trivial_destructor(AllDefaulted))]; }
   { int arr[T(__has_trivial_destructor(AllDeleted))]; }
   { int arr[T(__has_trivial_destructor(DerivesHasRef))]; }
+  { int arr[T(__has_trivial_destructor(ACompleteType[]))]; }
 
   { int arr[F(__has_trivial_destructor(HasDest))]; }
+  { int arr[F(__has_trivial_destructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
   { int arr[F(__has_trivial_destructor(void))]; }
   { int arr[F(__has_trivial_destructor(cvoid))]; }
   { int arr[F(__has_trivial_destructor(AllPrivate))]; }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4101,6 +4101,11 @@
   case UTT_IsDestructible:
   case UTT_IsNothrowDestructible:
   case UTT_IsTriviallyDestructible:
+if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType())
+  return true;
+
+return !S.RequireCompleteType(
+Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
   // Per the GCC type traits documentation, the same constraints apply to these.
   case UTT_HasNothrowAssign:
   case UTT_HasNothrowMoveAssign:
@@ -4113,9 +4118,15 @@
   case UTT_HasTrivialCopy:
   case UTT_HasTrivialDestructor:
   case UTT_HasVirtualDestructor:
-if (ArgTy->isIncompleteArrayType() || ArgTy->isVoidType())
+if(ArgTy->isVoidType())
   return true;
 
+if (ArgTy->isIncompleteArrayType()) {
+  QualType ElTy = QualType(ArgTy->getBaseElementTypeUnsafe(), 0);
+  if (!ElTy->isIncompleteType())
+return true;
+}
+
 return !S.RequireCompleteType(
 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r305448 - Fix another test with modules enabled

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 22:03:45 2017
New Revision: 305448

URL: http://llvm.org/viewvc/llvm-project?rev=305448=rev
Log:
Fix another test with modules enabled

Modified:

libcxx/trunk/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp?rev=305448=305447=305448=diff
==
--- 
libcxx/trunk/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
 Wed Jun 14 22:03:45 2017
@@ -14,6 +14,7 @@
 //  However, for backwards compatibility, if 
_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
 //  is defined before including , then they will be restored.
 
+// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
 #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
 
 #include 


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


[libcxx] r305447 - remove incorrectly committed assertion

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 22:02:43 2017
New Revision: 305447

URL: http://llvm.org/viewvc/llvm-project?rev=305447=rev
Log:
remove incorrectly committed assertion

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=305447=305446=305447=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Wed Jun 14 22:02:43 2017
@@ -607,7 +607,6 @@ class Configuration(object):
 return
 config_site_header = os.path.join(self.libcxx_obj_root, 
'__config_site')
 if not os.path.isfile(config_site_header):
-assert False
 return
 contained_macros = self.parse_config_site_and_add_features(
 config_site_header)


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


[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-06-14 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment.

Kindly ping Artem and Anna :)


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


[libcxx] r305446 - Add hack to get --param=enable_modules=true working with a __config_site header

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 21:54:15 2017
New Revision: 305446

URL: http://llvm.org/viewvc/llvm-project?rev=305446=rev
Log:
Add hack to get --param=enable_modules=true working with a __config_site header

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=305446=305445=305446=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Wed Jun 14 21:54:15 2017
@@ -108,6 +108,11 @@ class Configuration(object):
 return check_value(val, env_var)
 return check_value(conf_val, name)
 
+def get_modules_enabled(self):
+return self.get_lit_bool('enable_modules',
+default=False,
+env_var='LIBCXX_ENABLE_MODULES')
+
 def make_static_lib_name(self, name):
 """Return the full filename for the specified library name"""
 if self.is_windows:
@@ -602,6 +607,7 @@ class Configuration(object):
 return
 config_site_header = os.path.join(self.libcxx_obj_root, 
'__config_site')
 if not os.path.isfile(config_site_header):
+assert False
 return
 contained_macros = self.parse_config_site_and_add_features(
 config_site_header)
@@ -631,9 +637,19 @@ class Configuration(object):
 # The __config_site header should be non-empty. Otherwise it should
 # have never been emitted by CMake.
 assert len(feature_macros) > 0
+# FIXME: This is a hack that should be fixed using module maps (or 
something)
+# If modules are enabled then we have to lift all of the definitions
+# in __config_site onto the command line.
+modules_enabled = self.get_modules_enabled()
+self.cxx.compile_flags += ['-Wno-macro-redefined']
 # Transform each macro name into the feature name used in the tests.
 # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads
 for m in feature_macros:
+if modules_enabled:
+define = '-D%s' % m
+if feature_macros[m]:
+define += '=%s' % (feature_macros[m])
+self.cxx.compile_flags += [define]
 if m == '_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS':
 continue
 if m == '_LIBCPP_ABI_VERSION':
@@ -976,9 +992,7 @@ class Configuration(object):
 if platform.system() != 'Darwin':
 modules_flags += ['-Xclang', 
'-fmodules-local-submodule-visibility']
 supports_modules = self.cxx.hasCompileFlag(modules_flags)
-enable_modules = self.get_lit_bool('enable_modules',
-   default=False,
-   env_var='LIBCXX_ENABLE_MODULES')
+enable_modules = self.get_modules_enabled()
 if enable_modules and not supports_modules:
 self.lit_config.fatal(
 '-fmodules is enabled but not supported by the compiler')


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


[libcxx] r305445 - Fix test when modules are enabled

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 21:54:12 2017
New Revision: 305445

URL: http://llvm.org/viewvc/llvm-project?rev=305445=rev
Log:
Fix test when modules are enabled

Modified:

libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp?rev=305445=305444=305445=diff
==
--- 
libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
 Wed Jun 14 21:54:12 2017
@@ -23,6 +23,7 @@
 //  However, for backwards compatibility, if 
_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
 //  is defined before including , then random_shuffle will be 
restored.
 
+// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
 #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
 
 #include 


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


[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler

2017-06-14 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment.

Dear Anna,

Long time no see, miss you :)

> Should this revision be "abandoned" or is the plan to iterate on it?

I wanna the plan to iterate on it, Artem reviewed the patch, and I fixed the 
issue as he suggested, ran `make check-clang-analysis` also used it for 
checking real project K3b 's Copy-paste issue, 
worked!

> Hi Vassil,



> ... Thanks for your reply! Let's do it together and Happy International Labor 
> Day :)

But Vassil and Raphael dis not reply me.

Could you kindly review it, if LGTU, may I commit it? thanks a lot!

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D31320



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


[libcxx] r305442 - Move external instantiation for __vector_base_common to vector.cpp

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 20:53:12 2017
New Revision: 305442

URL: http://llvm.org/viewvc/llvm-project?rev=305442=rev
Log:
Move external instantiation for __vector_base_common to vector.cpp

Previously the explicit instantiation for this was in locale.cpp,
but that didn't make much sense. This patch creates a new vector.cpp
source file to contain the explicit instantiation.

Added:
libcxx/trunk/src/vector.cpp
Modified:
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=305442=305441=305442=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Wed Jun 14 20:53:12 2017
@@ -1,6 +1,7 @@
 set(LIBCXX_LIB_CMAKEFILES_DIR 
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}"  PARENT_SCOPE)
 
 # Get sources
+# FIXME: Don't use glob here
 file(GLOB LIBCXX_SOURCES ../src/*.cpp)
 if(WIN32)
   file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)

Modified: libcxx/trunk/src/locale.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=305442=305441=305442=diff
==
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Wed Jun 14 20:53:12 2017
@@ -6158,6 +6158,4 @@ template class _LIBCPP_CLASS_TEMPLATE_IN
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
codecvt_byname;
 template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
codecvt_byname;
 
-template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
__vector_base_common;
-
 _LIBCPP_END_NAMESPACE_STD

Added: libcxx/trunk/src/vector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/vector.cpp?rev=305442=auto
==
--- libcxx/trunk/src/vector.cpp (added)
+++ libcxx/trunk/src/vector.cpp Wed Jun 14 20:53:12 2017
@@ -0,0 +1,16 @@
+//===- vector.cpp 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "vector"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS 
__vector_base_common;
+
+_LIBCPP_END_NAMESPACE_STD


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


r305439 - [Basic] Use a static_assert instead of using the old array of size -1 trick.

2017-06-14 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jun 14 20:27:58 2017
New Revision: 305439

URL: http://llvm.org/viewvc/llvm-project?rev=305439=rev
Log:
[Basic] Use a static_assert instead of using the old array of size -1 trick.

Modified:
cfe/trunk/include/clang/Basic/AllDiagnostics.h

Modified: cfe/trunk/include/clang/Basic/AllDiagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AllDiagnostics.h?rev=305439=305438=305439=diff
==
--- cfe/trunk/include/clang/Basic/AllDiagnostics.h (original)
+++ cfe/trunk/include/clang/Basic/AllDiagnostics.h Wed Jun 14 20:27:58 2017
@@ -28,7 +28,7 @@
 namespace clang {
 template 
 class StringSizerHelper {
-  char FIELD_TOO_SMALL[SizeOfStr <= FieldType(~0U) ? 1 : -1];
+  static_assert(SizeOfStr <= FieldType(~0U), "Field too small!");
 public:
   enum { Size = SizeOfStr };
 };


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


r305440 - [ODRHash] Hash TemplateArgument::Pack and TemplateTypeParmType

2017-06-14 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jun 14 20:35:06 2017
New Revision: 305440

URL: http://llvm.org/viewvc/llvm-project?rev=305440=rev
Log:
[ODRHash] Hash TemplateArgument::Pack and TemplateTypeParmType

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305440=305439=305440=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Jun 14 20:35:06 2017
@@ -159,6 +159,10 @@ void ODRHash::AddTemplateArgument(Templa
   AddStmt(TA.getAsExpr());
   break;
 case TemplateArgument::Pack:
+  ID.AddInteger(TA.pack_size());
+  for (auto SubTA : TA.pack_elements()) {
+AddTemplateArgument(SubTA);
+  }
   break;
   }
 }
@@ -549,6 +553,13 @@ public:
 Hash.AddTemplateName(T->getTemplateName());
 VisitType(T);
   }
+
+  void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
+ID.AddInteger(T->getDepth());
+ID.AddInteger(T->getIndex());
+Hash.AddBoolean(T->isParameterPack());
+AddDecl(T->getDecl());
+  }
 };
 
 void ODRHash::AddType(const Type *T) {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305440=305439=305440=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Jun 14 20:35:06 2017
@@ -1068,7 +1068,48 @@ S4 s4;
 // expected-error@first.h:* {{'TemplateArgument::S4::x' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 
'SecondModule'}}
 // expected-note@second.h:* {{declaration of 'x' does not match}}
 #endif
+}
+
+namespace TemplateTypeParmType {
+#if defined(FIRST)
+template 
+struct S1 {
+  T1 x;
+};
+#elif defined(SECOND)
+template 
+struct S1 {
+  T2 x;
+};
+#else
+using TemplateTypeParmType::S1;
+// expected-error@first.h:* {{'TemplateTypeParmType::S1::x' from module 
'FirstModule' is not present in definition of 'S1' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
 
+#if defined(FIRST)
+template 
+struct U2 {};
+template 
+class S2 {
+  typedef U2 type;
+  type x;
+};
+#elif defined(SECOND)
+template 
+struct U2 {};
+template 
+class S2 {
+  typedef U2 type;
+  type x;
+};
+#else
+using TemplateTypeParmType::S2;
+// expected-error@first.h:* {{'TemplateTypeParmType::S2::x' from module 
'FirstModule' is not present in definition of 'S2' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+// expected-error@first.h:* {{'TemplateTypeParmType::S2::type' from module 
'FirstModule' is not present in definition of 'S2' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'type' does not match}}
+#endif
 }
 
 // Interesting cases that should not cause errors.  struct S should not error


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


r305437 - [clang-format] Allow git-clang-format to handle empty extensions.

2017-06-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Jun 14 19:54:08 2017
New Revision: 305437

URL: http://llvm.org/viewvc/llvm-project?rev=305437=rev
Log:
[clang-format] Allow git-clang-format to handle empty extensions.

Most of libc++'s header files don't use extension. This prevents
using git-clang-format on them, which is frustrating.

This patch allows empty extensions to be passed using either
the --extensions option, or the clangformat.extensions git-config
value.

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=305437=305436=305437=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Wed Jun 14 19:54:08 2017
@@ -324,6 +324,8 @@ def filter_by_extension(dictionary, allo
   allowed_extensions = frozenset(allowed_extensions)
   for filename in list(dictionary.keys()):
 base_ext = filename.rsplit('.', 1)
+if len(base_ext) == 1 and '' in allowed_extensions:
+continue
 if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions:
   del dictionary[filename]
 


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


r305435 - Fix LexerTest signed/unsigned comparison.

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 19:28:13 2017
New Revision: 305435

URL: http://llvm.org/viewvc/llvm-project?rev=305435=rev
Log:
Fix LexerTest signed/unsigned comparison.

Werror was catching a signed/unsigned compare in 
an assert, correct the signed 'expected' value to be
unsigned.

Modified:
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/unittests/Lex/LexerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=305435=305434=305435=diff
==
--- cfe/trunk/unittests/Lex/LexerTest.cpp (original)
+++ cfe/trunk/unittests/Lex/LexerTest.cpp Wed Jun 14 19:28:13 2017
@@ -383,7 +383,7 @@ TEST_F(LexerTest, DontOverallocateString
   MacroInfo *MI = PP->AllocateMacroInfo({});
   MI->setIsFunctionLike();
   MI->setArgumentList(ArgList, Allocator);
-  EXPECT_EQ(3, MI->getNumArgs());
+  EXPECT_EQ(3u, MI->getNumArgs());
   EXPECT_TRUE(MI->isFunctionLike());
 
   Token Eof;


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


[clang-tools-extra] r305434 - Update Append Argument to more efficiently traverse tokens

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 19:27:23 2017
New Revision: 305434

URL: http://llvm.org/viewvc/llvm-project?rev=305434=rev
Log:
Update Append Argument to more efficiently traverse tokens

This function was previously making (correct) assumptions
without complete knowledge of MacroArgs guarantees for
Arguments.  After going through Macro Args a bunch, I'd
corrected the getNumArguments (and changed its name), 
however didn't realize this was depending on the behavior.

This patch has version that depends on the corrected 
getNumMacroArguments's behavior, with the rest checked against
my knowledge of the MacroArgs' token list.  Commiting no-wait
since the test is broken.

Modified:
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=305434=305433=305434=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Wed Jun 14 19:27:23 
2017
@@ -588,19 +588,16 @@ void PPCallbacksTracker::appendArgument(
   std::string Str;
   llvm::raw_string_ostream SS(Str);
   SS << "[";
-  // The argument tokens might include end tokens, so we reflect how
-  // how getUnexpArgument provides the arguments.
-  for (int I = 0, E = Value->getNumMacroArguments(); I < E; ++I) {
+
+  // Each argument is is a series of contiguous Tokens, terminated by a eof.
+  // Go through each argument printing tokens until we reach eof.
+  for (unsigned I = 0; I < Value->getNumMacroArguments(); ++I) {
 const clang::Token *Current = Value->getUnexpArgument(I);
-int TokenCount = Value->getArgLength(Current) + 1; // include EOF
-E -= TokenCount;
 if (I)
   SS << ", ";
-// We're assuming tokens are contiguous, as otherwise we have no
-// other way to get at them.
---TokenCount;
-for (int TokenIndex = 0; TokenIndex < TokenCount; ++TokenIndex, ++Current) 
{
-  if (TokenIndex)
+bool First = true;
+while (Current->isNot(clang::tok::eof)) {
+  if (!First)
 SS << " ";
   // We need to be careful here because the arguments might not be legal in
   // YAML, so we use the token name for anything but identifiers and
@@ -611,6 +608,8 @@ void PPCallbacksTracker::appendArgument(
   } else {
 SS << "<" << Current->getName() << ">";
   }
+  ++Current;
+  First = false;
 }
   }
   SS << "]";


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


[PATCH] D34179: [Frontend] PR32318 Handle -ast-dump-all properly.

2017-06-14 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

I have, but just haven't heard back yet...  Thanks again...


https://reviews.llvm.org/D34179



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


[PATCH] D34179: [Frontend] PR32318 Handle -ast-dump-all properly.

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

Committed in r305432. You should consider reaching out to Chris Lattner for svn 
access!


https://reviews.llvm.org/D34179



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


r305432 - Handle -ast-dump-all when passed as the only option.

2017-06-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jun 14 19:00:08 2017
New Revision: 305432

URL: http://llvm.org/viewvc/llvm-project?rev=305432=rev
Log:
Handle -ast-dump-all when passed as the only option.

Patch by Don Hinton

Modified:
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/test/Coverage/ast-printing.c
cfe/trunk/test/Coverage/ast-printing.cpp

Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=305432=305431=305432=diff
==
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Wed Jun 14 19:00:08 2017
@@ -142,7 +142,7 @@ std::unique_ptr clang::Crea
 bool DumpDecls,
 bool Deserialize,
 bool DumpLookups) {
-  assert((DumpDecls || DumpLookups) && "nothing to dump");
+  assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
   return llvm::make_unique(nullptr,
Deserialize ? ASTPrinter::DumpFull :
DumpDecls ? ASTPrinter::Dump :

Modified: cfe/trunk/test/Coverage/ast-printing.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/ast-printing.c?rev=305432=305431=305432=diff
==
--- cfe/trunk/test/Coverage/ast-printing.c (original)
+++ cfe/trunk/test/Coverage/ast-printing.c Wed Jun 14 19:00:08 2017
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -ast-print %t.1.c -o %t.2.c
 // RUN: diff %t.1.c %t.2.c
 // RUN: %clang_cc1 -ast-dump %s
+// RUN: %clang_cc1 -ast-dump-all %s
 // RUN: %clang_cc1 -print-decl-contexts %s
 
 #include "c-language-features.inc"

Modified: cfe/trunk/test/Coverage/ast-printing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/ast-printing.cpp?rev=305432=305431=305432=diff
==
--- cfe/trunk/test/Coverage/ast-printing.cpp (original)
+++ cfe/trunk/test/Coverage/ast-printing.cpp Wed Jun 14 19:00:08 2017
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 -ast-print %t.1.cpp -o %t.2.cpp
 // RUN: diff %t.1.cpp %t.2.cpp
 // RUN: %clang_cc1 -std=c++14 -ast-dump %s
+// RUN: %clang_cc1 -std=c++14 -ast-dump-all %s
 // RUN: %clang_cc1 -std=c++14 -print-decl-contexts %s
 // RUN: %clang_cc1 -std=c++14 -fdump-record-layouts %s
 


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


[PATCH] D34179: [Frontend] PR32318 Handle -ast-dump-all properly.

2017-06-14 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Great, thanks Aaron.

Could you commit it for me when you get a chance?


https://reviews.llvm.org/D34179



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


[PATCH] D34225: [clang-format] Teach clang-format how to handle C++ coroutines

2017-06-14 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
Herald added a subscriber: klimek.

This patch (1) enable parsing for coroutines by default and (2) teaches 
clang-format how to properly handle them.


https://reviews.llvm.org/D34225

Files:
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10612,6 +10612,40 @@
   EXPECT_EQ("auto c = u8'a';", format("auto c = u8'a';"));
 }
 
+TEST_F(FormatTest, CoawaitForRangeCpp11) {
+  EXPECT_EQ("for co_await (auto x : range())\n  ;",
+format("for co_await(auto x : range());"));
+}
+
+TEST_F(FormatTest, Coawait) {
+  EXPECT_EQ("int x = co_await foo();",
+format("int x = co_await foo();"));
+  EXPECT_EQ("int x = (co_await foo());",
+format("int x = (co_await foo());"));
+  EXPECT_EQ("co_await (42);",
+format("co_await(42);"));
+  EXPECT_EQ("void operator co_await(int);",
+format("void operator co_await (int);"));
+}
+
+TEST_F(FormatTest, Coyield) {
+  EXPECT_EQ("int x = co_yield foo();",
+format("int x = co_yield foo();"));
+  EXPECT_EQ("int x = (co_yield foo());",
+format("int x = (co_yield foo());"));
+  EXPECT_EQ("co_yield (42);",
+format("co_yield(42);"));
+}
+
+TEST_F(FormatTest, Coreturn) {
+  EXPECT_EQ("int x = co_return foo();",
+format("int x = co_return foo();"));
+  EXPECT_EQ("int x = (co_return foo());",
+format("int x = (co_return foo());"));
+  EXPECT_EQ("co_return (42);",
+format("co_return(42);"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -430,6 +430,7 @@
 case tok::kw_switch:
 case tok::kw_try:
 case tok::kw___try:
+  assert(!Tok->is(tok::kw_co_await));
   if (!LBraceStack.empty() && LBraceStack.back()->BlockKind == BK_Unknown)
 LBraceStack.back()->BlockKind = BK_Block;
   break;
@@ -1674,6 +1675,8 @@
   if (Style.Language == FormatStyle::LK_JavaScript &&
   FormatTok->is(Keywords.kw_await))
 nextToken();
+  if (Style.isCpp() && FormatTok->is(tok::kw_co_await))
+nextToken();
   if (FormatTok->Tok.is(tok::l_paren))
 parseParens();
   if (FormatTok->Tok.is(tok::l_brace)) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -586,6 +586,9 @@
 if (CurrentToken && CurrentToken->is(Keywords.kw_await))
   next();
   }
+  if (Style.isCpp())
+if (CurrentToken && CurrentToken->is(tok::kw_co_await))
+  next();
   Contexts.back().ColonIsForRangeExpr = true;
   next();
   if (!parseParens())
@@ -2206,6 +2209,11 @@
   if (Right.is(tok::l_paren)) {
 if (Left.is(tok::r_paren) && Left.is(TT_AttributeParen))
   return true;
+if (Left.is(tok::kw_co_await) && Left.Previous &&
+Left.Previous->is(tok::kw_operator))
+  return false;
+if (Left.isOneOf(tok::kw_co_await, tok::kw_co_yield, tok::kw_co_return))
+  return true;
 return Line.Type == LT_ObjCDecl || Left.is(tok::semi) ||
(Style.SpaceBeforeParens != FormatStyle::SBPO_Never &&
 (Left.isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, tok::kw_while,
@@ -2252,6 +2260,18 @@
   if (Style.isCpp()) {
 if (Left.is(tok::kw_operator))
   return Right.is(tok::coloncolon);
+// for await ( ...
+if (Right.is(tok::l_paren) && Left.is(tok::kw_co_await) &&
+Left.Previous && Left.Previous->is(tok::kw_for))
+  return true;
+if (Right.is(tok::l_paren) && Left.is(tok::kw_co_await) &&
+Left.Previous && Left.Previous->is(tok::kw_operator))
+  return false;
+if (Right.is(tok::star) && Left.is(tok::kw_co_yield))
+  return false;
+if (Right.isOneOf(tok::l_brace, tok::l_square) &&
+Left.isOneOf(tok::kw_co_yield, tok::kw_co_await))
+  return true;
   } else if (Style.Language == FormatStyle::LK_Proto) {
 if (Right.is(tok::period) &&
 Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1955,6 +1955,7 @@
   LangOpts.ObjC2 = 1;
   LangOpts.MicrosoftExt = 1;// To get kw___try, kw___finally.
   LangOpts.DeclSpecKeyword = 1; // To get __declspec.
+  LangOpts.CoroutinesTS = 1;
   return LangOpts;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D34179: [Frontend] PR32318 Handle -ast-dump-all properly.

2017-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D34179



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


[PATCH] D33904: Add a __has_attribute_enhancement macro to clang

2017-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33904#778165, @george.burgess.iv wrote:

> > Why not just use __has_feature(overloadable_unmarked) or similar?
>
> My impression was that `__has_feature` was was for larger features than 
> tweaks to attributes. If this would be an appropriate use of `__has_feature`, 
> though, I'm happy to keep things simple.
>
> I'll update the other review with `__has_feature`. If it goes in with that, 
> I'll abandon this.


I agree, this need seems more in line with `__has_feature` than adding a new 
feature testing macro.

> Thanks!




https://reviews.llvm.org/D33904



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


[PATCH] D34091: Support for querying the exception specification type through libclang

2017-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang-c/Index.h:185
+   */
+  CXCursor_ExceptionSpecificationKind_None, ///< no exception specification
+

You can drop the trailing comment.



Comment at: include/clang-c/Index.h:208
+  /**
+   * \brief The cursor has exception specification computed noexcept..
+   */

Spurious trailing full stop.



Comment at: include/clang-c/Index.h:213
+  /**
+   * \brief The exception specification has not yet been evaluated..
+   */

Same here.



Comment at: test/Index/get-cursor.cpp:152
+void f_dynamic_noexcept_none() throw();
+void f_dynamic_noexcept() throw(int); // just for testing, throwing int is not 
ideal.
+void f_dynamic_noexcept_any() throw(...);

The comment isn't helpful and can be removed.



Comment at: tools/libclang/CXType.cpp:689
+QualType T = GetQualType(X);
+if (T.isNull()) {
+return -1;

Can elide the braces.



Comment at: tools/libclang/CXType.cpp:693
+
+if (const FunctionProtoType* FD = T->getAs()) {
+return static_cast(FD->getExceptionSpecType());

Use `const auto *` and elide the braces.



Comment at: tools/libclang/CXType.cpp:695
+return static_cast(FD->getExceptionSpecType());
+} else {
+return -1;

No `else` after a `return`; you can just lower this into the function scope and 
remove the `else`.



Comment at: tools/libclang/CXType.cpp:703
+return clang_getExceptionSpecificationType(clang_getCursorType(C));
+} else {
+return -1;

No `else` after a `return` and can elide the braces for the `if`.


Repository:
  rL LLVM

https://reviews.llvm.org/D34091



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


[PATCH] D34224: [NFC] remove trailing WS

2017-06-14 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya created this revision.

https://reviews.llvm.org/D34224

Files:
  include/memory

Index: include/memory
===
--- include/memory
+++ include/memory
@@ -724,7 +724,7 @@
 struct __has_element_type : false_type {};
 
 template 
-struct __has_element_type<_Tp, 
+struct __has_element_type<_Tp,
   typename __void_t::type> : true_type {};
 
 template ::value>
@@ -808,7 +808,7 @@
 struct __has_difference_type : false_type {};
 
 template 
-struct __has_difference_type<_Tp, 
+struct __has_difference_type<_Tp,
 typename __void_t::type> : true_type {};
 
 template ::value>
@@ -994,7 +994,7 @@
 struct __has_pointer_type : false_type {};
 
 template 
-struct __has_pointer_type<_Tp, 
+struct __has_pointer_type<_Tp,
   typename __void_t::type> : true_type {};
 
 namespace __pointer_type_imp
@@ -1024,7 +1024,7 @@
 struct __has_const_pointer : false_type {};
 
 template 
-struct __has_const_pointer<_Tp, 
+struct __has_const_pointer<_Tp,
 typename __void_t::type> : true_type {};
 
 template ::value>
@@ -1047,7 +1047,7 @@
 struct __has_void_pointer : false_type {};
 
 template 
-struct __has_void_pointer<_Tp, 
+struct __has_void_pointer<_Tp,
typename __void_t::type> : true_type {};
 
 template ::value>
@@ -1070,7 +1070,7 @@
 struct __has_const_void_pointer : false_type {};
 
 template 
-struct __has_const_void_pointer<_Tp, 
+struct __has_const_void_pointer<_Tp,
 typename __void_t::type> : true_type {};
 
 template ::value>
@@ -1148,7 +1148,7 @@
 struct __has_propagate_on_container_move_assignment : false_type {};
 
 template 
-struct __has_propagate_on_container_move_assignment<_Tp, 
+struct __has_propagate_on_container_move_assignment<_Tp,
typename __void_t::type>
: true_type {};
 
@@ -1168,7 +1168,7 @@
 struct __has_propagate_on_container_swap : false_type {};
 
 template 
-struct __has_propagate_on_container_swap<_Tp, 
+struct __has_propagate_on_container_swap<_Tp,
typename __void_t::type>
: true_type {};
 
@@ -1188,7 +1188,7 @@
 struct __has_is_always_equal : false_type {};
 
 template 
-struct __has_is_always_equal<_Tp, 
+struct __has_is_always_equal<_Tp,
typename __void_t::type>
: true_type {};
 
@@ -1941,7 +1941,7 @@
 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator  operator++(int)
 {raw_storage_iterator __t(*this); ++__x_; return __t;}
 #if _LIBCPP_STD_VER >= 14
-_LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; } 
+_LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; }
 #endif
 };
 
@@ -3850,7 +3850,7 @@
 _LIBCPP_INLINE_VISIBILITY
 _Dp* __get_deleter() const _NOEXCEPT
 {return static_cast<_Dp*>(__cntrl_
-? const_cast(__cntrl_->__get_deleter(typeid(_Dp))) 
+? const_cast(__cntrl_->__get_deleter(typeid(_Dp)))
   : nullptr);}
 #endif  // _LIBCPP_NO_RTTI
 
@@ -4477,7 +4477,7 @@
 typename enable_if
 <
 !is_array<_Yp>::value &&
-is_convertible::pointer, 
+is_convertible::pointer,
typename shared_ptr<_Tp>::element_type*>::value,
 shared_ptr<_Tp>&
 >::type
@@ -4512,7 +4512,7 @@
 typename enable_if
 <
 !is_array<_Yp>::value &&
-is_convertible::pointer, 
+is_convertible::pointer,
typename shared_ptr<_Tp>::element_type*>::value,
 shared_ptr<_Tp>&
 >::type
@@ -5311,7 +5311,7 @@
 __m.unlock();
 return __q;
 }
-  
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
@@ -5352,7 +5352,7 @@
 __m.unlock();
 return __r;
 }
-  
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
@@ -5484,7 +5484,7 @@
 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
 #endif
 {
-__swap_allocator(__a1, __a2, 
+__swap_allocator(__a1, __a2,
   integral_constant::propagate_on_container_swap::value>());
 }
 
@@ -5506,7 +5506,7 @@
 void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
 
 template  >
-struct __noexcept_move_assign_container : public integral_constant 14
 || _Traits::is_always_equal::value
@@ -5520,17 +5520,17 @@
 template 
 struct __temp_value {
 typedef allocator_traits<_Alloc> _Traits;
-
+
 typename aligned_storage::type __v;
 _Alloc &__a;
 
 _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
 _Tp &   get() { return *__addr(); }
-
+
 template
 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
 { _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
-
+
 

[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:41
+  forEachConstructorInitializer(
+  cxxCtorInitializer(
+  isBaseInitializer(),

It seems like you can hoist out from the `cxxCtorInitializer()` onward and only 
write this code once rather than twice.



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:48
+
+  std::string FixItInitList = "";
+  for (const auto  : Matches) {

No need for the initializer.



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:53
+// Valid when the initializer is written manually (not generated).
+if ((Init->getSourceRange()).isValid()) {
+  const auto *CExpr = Match.getNodeAs("cruct-expr");

Spurious parens.



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:55
+  const auto *CExpr = Match.getNodeAs("cruct-expr");
+  diag(CExpr->getLocEnd(), "Missing parameter in the base initializer!")
+  << FixItHint::CreateInsertion(

Diagnostics are not full sentences, should this should use a lowercase m and 
drop the exclamation mark. Also, it should be "argument" rather than parameter.

I think it might be more clearly rewritten as: `"calling an inherited 
constructor other than the copy constructor"`. Also, it would be helpful to 
point to which constructor *is* being called as a note.



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:63
+  // We want to write in the FixIt the template arguments too.
+  if (auto *Decl = dyn_cast(
+  Init->getBaseClass()->getAsCXXRecordDecl())) {

`const auto *`



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:67
+
+const auto Args = Decl->getTemplateArgs().asArray();
+for (const auto  : Args)

Do not use `auto` here.



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:92
+  // Loop until the beginning of the initialization list.
+  while (!Tok.is(tok::r_paren))
+Lex.LexFromRawLexer(Tok);

This doesn't balance tokens. What about:
```
struct S {
 /* ... */
};

struct T : S {
  T(const T ) : S((1 + 2), O) {}
};
```



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:96
+
+  std::string FixItMsg = "";
+  // There is not initialization list in this constructor.

No initializer needed.



Comment at: clang-tidy/misc/UndelegatedCopyOfBaseClassesCheck.cpp:108-109
+
+  diag(Tok.getLocation(), "Copy constructor should call the copy "
+  "constructor of all copyable base class!")
+  << FixItHint::CreateInsertion(Tok.getLocation(), FixItMsg);

Similar comments about the diagnostic as above. I think the two diagnostics 
should really be the same string. At the end of the day, the check is to ensure 
that a derived copy constructor calls an inherited copy constructor. Whether 
the copy constructor calls an inherited default constructor, or some other kind 
of constructor, is largely immaterial because they're both wrong in the same 
way. I'd recommend using the diagnostic text from my comment above for both.


https://reviews.llvm.org/D33722



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


[PATCH] D34156: [LTO] Add -femit-summary-index flag to emit summary for regular LTO

2017-06-14 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

OK! Thanks both :)


https://reviews.llvm.org/D34156



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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-06-14 Thread Aditya Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305427: [locale] Avoid copy of __atoms when char_type is 
char (authored by hiraditya).

Changed prior to commit:
  https://reviews.llvm.org/D30268?vs=102566=102621#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30268

Files:
  libcxx/trunk/benchmarks/stringstream.bench.cpp
  libcxx/trunk/include/__config
  libcxx/trunk/include/locale

Index: libcxx/trunk/include/locale
===
--- libcxx/trunk/include/locale
+++ libcxx/trunk/include/locale
@@ -372,19 +372,57 @@
 struct __num_get
 : protected __num_get_base
 {
-static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
 static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
   _CharT& __thousands_sep);
-static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
-  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
 static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
char* __a, char*& __a_end,
_CharT __decimal_point, _CharT __thousands_sep,
const string& __grouping, unsigned* __g,
unsigned*& __g_end, unsigned& __dc, _CharT* __atoms);
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
+static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
+#else
+static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep)
+{
+locale __loc = __iob.getloc();
+const numpunct<_CharT>& __np = use_facet >(__loc);
+__thousands_sep = __np.thousands_sep();
+return __np.grouping();
+}
+
+const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const
+{
+  return __do_widen_p(__iob, __atoms);
+}
+
+
+static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms);
+private:
+template
+const T* __do_widen_p(ios_base& __iob, T* __atoms) const
+{
+  locale __loc = __iob.getloc();
+  use_facet(__loc).widen(__src, __src + 26, __atoms);
+  return __atoms;
+}
+
+const char* __do_widen_p(ios_base& __iob, char* __atoms) const
+{
+  (void)__iob;
+  (void)__atoms;
+  return __src;
+}
+#endif
 };
 
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
 template 
 string
 __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
@@ -395,6 +433,7 @@
 __thousands_sep = __np.thousands_sep();
 return __np.grouping();
 }
+#endif
 
 template 
 string
@@ -411,9 +450,16 @@
 
 template 
 int
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
 __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
   unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
   unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
+#else
+__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
+
+#endif
 {
 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
 {
@@ -849,9 +895,16 @@
 // Stage 1
 int __base = this->__get_base(__iob);
 // Stage 2
-char_type __atoms[26];
 char_type __thousands_sep;
+const int __atoms_size = 26;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+char_type __atoms1[__atoms_size];
+const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
+#else
+char_type __atoms[__atoms_size];
 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+#endif
 string __buf;
 __buf.resize(__buf.capacity());
 char* __a = &__buf[0];
@@ -899,9 +952,16 @@
 // Stage 1
 int __base = this->__get_base(__iob);
 // Stage 2
-char_type __atoms[26];
 char_type __thousands_sep;
+const int __atoms_size = 26;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+char_type __atoms1[__atoms_size];
+const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+string 

[libcxx] r305427 - [locale] Avoid copy of __atoms when char_type is char

2017-06-14 Thread Aditya Kumar via cfe-commits
Author: hiraditya
Date: Wed Jun 14 18:17:45 2017
New Revision: 305427

URL: http://llvm.org/viewvc/llvm-project?rev=305427=rev
Log:
[locale] Avoid copy of __atoms when char_type is char

The function num_get<_CharT>::stage2_int_prep makes unnecessary copy of src
into atoms when char_type is char. This can be avoided by creating
a switch on type and just returning __src when char_type is char.

Added the test case to demonstrate performance improvement.
In order to avoid ABI incompatibilities, the changes are guarded
with a macro _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET

Differential Revision: https://reviews.llvm.org/D30268
Reviewed by: EricWF

Added:
libcxx/trunk/benchmarks/stringstream.bench.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/locale

Added: libcxx/trunk/benchmarks/stringstream.bench.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/stringstream.bench.cpp?rev=305427=auto
==
--- libcxx/trunk/benchmarks/stringstream.bench.cpp (added)
+++ libcxx/trunk/benchmarks/stringstream.bench.cpp Wed Jun 14 18:17:45 2017
@@ -0,0 +1,38 @@
+#include "benchmark/benchmark_api.h"
+
+#include 
+double __attribute__((noinline)) istream_numbers();
+
+double istream_numbers() {
+  const char *a[] = {
+"-6  69 -71  2.4882e-02 -100 101 -2.5 500 -5000",
+"-25 71   7 -9.3262e+01 -100 101 -2.5 500 -5000",
+"-14 53  46 -6.7026e-02 -100 101 -2.5 500 -5000"
+  };
+
+  int a1, a2, a3, a4, a5, a6, a7;
+  double f1 = 0.0, f2 = 0.0, q = 0.0;
+  for (int i=0; i < 3; i++) {
+std::istringstream s(a[i]);
+s >> a1
+  >> a2
+  >> a3
+  >> f1
+  >> a4
+  >> a5
+  >> f2
+  >> a6
+  >> a7;
+q += (a1 + a2 + a3 + a4 + a5 + a6 + a7 + f1 + f2)/100;
+  }
+  return q;
+}
+
+static void BM_Istream_numbers(benchmark::State ) {
+  double i = 0;
+  while (state.KeepRunning())
+benchmark::DoNotOptimize(i += istream_numbers());
+}
+
+BENCHMARK(BM_Istream_numbers)->RangeMultiplier(2)->Range(1024, 4096);
+BENCHMARK_MAIN()

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=305427=305426=305427=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Jun 14 18:17:45 2017
@@ -76,6 +76,9 @@
 // its vtable and typeinfo to libc++ rather than having all other libraries
 // using that class define their own copies.
 #define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+
+// Enable optimized version of __do_get_(un)signed which avoids redundant 
copies.
+#define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
 #elif _LIBCPP_ABI_VERSION == 1
 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
 // Enable compiling copies of now inline methods into the dylib to support

Modified: libcxx/trunk/include/locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=305427=305426=305427=diff
==
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Wed Jun 14 18:17:45 2017
@@ -372,19 +372,57 @@ template 
 struct __num_get
 : protected __num_get_base
 {
-static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& 
__thousands_sep);
 static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, 
_CharT& __decimal_point,
   _CharT& __thousands_sep);
-static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& 
__a_end,
-  unsigned& __dc, _CharT __thousands_sep, const string& 
__grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
 static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
char* __a, char*& __a_end,
_CharT __decimal_point, _CharT 
__thousands_sep,
const string& __grouping, unsigned* __g,
unsigned*& __g_end, unsigned& __dc, _CharT* 
__atoms);
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& 
__thousands_sep);
+static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& 
__a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& 
__grouping,
+  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
+#else
+static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep)
+{
+locale __loc = __iob.getloc();
+const numpunct<_CharT>& __np = use_facet >(__loc);
+__thousands_sep = __np.thousands_sep();
+return __np.grouping();
+}
+
+const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) 

[clang-tools-extra] r305426 - Update callbacks tracker to match change in 305425

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 18:15:51 2017
New Revision: 305426

URL: http://llvm.org/viewvc/llvm-project?rev=305426=rev
Log:
Update callbacks tracker to match change in 305425

Modified:
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=305426=305425=305426=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Wed Jun 14 18:15:51 
2017
@@ -590,7 +590,7 @@ void PPCallbacksTracker::appendArgument(
   SS << "[";
   // The argument tokens might include end tokens, so we reflect how
   // how getUnexpArgument provides the arguments.
-  for (int I = 0, E = Value->getNumArguments(); I < E; ++I) {
+  for (int I = 0, E = Value->getNumMacroArguments(); I < E; ++I) {
 const clang::Token *Current = Value->getUnexpArgument(I);
 int TokenCount = Value->getArgLength(Current) + 1; // include EOF
 E -= TokenCount;


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


[PATCH] D32046: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments

2017-06-14 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
erichkeane marked 3 inline comments as done.
Closed by commit rL305425: [Preprocessor]Correct Macro-Arg allocation of 
StringifiedArguments,  (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D32046?vs=102458=102619#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32046

Files:
  cfe/trunk/include/clang/Lex/MacroArgs.h
  cfe/trunk/lib/Lex/MacroArgs.cpp
  cfe/trunk/unittests/Lex/LexerTest.cpp

Index: cfe/trunk/lib/Lex/MacroArgs.cpp
===
--- cfe/trunk/lib/Lex/MacroArgs.cpp
+++ cfe/trunk/lib/Lex/MacroArgs.cpp
@@ -44,20 +44,22 @@
   // Otherwise, use the best fit.
   ClosestMatch = (*Entry)->NumUnexpArgTokens;
 }
-  
+
   MacroArgs *Result;
   if (!ResultEnt) {
 // Allocate memory for a MacroArgs object with the lexer tokens at the end.
-Result = (MacroArgs*)malloc(sizeof(MacroArgs) + 
-UnexpArgTokens.size() * sizeof(Token));
+Result = (MacroArgs *)malloc(sizeof(MacroArgs) +
+ UnexpArgTokens.size() * sizeof(Token));
 // Construct the MacroArgs object.
-new (Result) MacroArgs(UnexpArgTokens.size(), VarargsElided);
+new (Result)
+MacroArgs(UnexpArgTokens.size(), VarargsElided, MI->getNumArgs());
   } else {
 Result = *ResultEnt;
 // Unlink this node from the preprocessors singly linked list.
 *ResultEnt = Result->ArgCache;
 Result->NumUnexpArgTokens = UnexpArgTokens.size();
 Result->VarargsElided = VarargsElided;
+Result->NumMacroArgs = MI->getNumArgs();
   }
 
   // Copy the actual unexpanded tokens to immediately after the result ptr.
@@ -298,12 +300,10 @@
Preprocessor ,
SourceLocation ExpansionLocStart,
SourceLocation ExpansionLocEnd) {
-  assert(ArgNo < NumUnexpArgTokens && "Invalid argument number!");
-  if (StringifiedArgs.empty()) {
-StringifiedArgs.resize(getNumArguments());
-memset((void*)[0], 0,
-   sizeof(StringifiedArgs[0])*getNumArguments());
-  }
+  assert(ArgNo < getNumMacroArguments() && "Invalid argument number!");
+  if (StringifiedArgs.empty())
+StringifiedArgs.resize(getNumMacroArguments(), {});
+
   if (StringifiedArgs[ArgNo].isNot(tok::string_literal))
 StringifiedArgs[ArgNo] = StringifyArgument(getUnexpArgument(ArgNo), PP,
/*Charify=*/false,
Index: cfe/trunk/unittests/Lex/LexerTest.cpp
===
--- cfe/trunk/unittests/Lex/LexerTest.cpp
+++ cfe/trunk/unittests/Lex/LexerTest.cpp
@@ -18,6 +18,8 @@
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/MacroArgs.h"
+#include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/ModuleLoader.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -41,26 +43,33 @@
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
   }
 
-  std::vector Lex(StringRef Source) {
+  std::unique_ptr CreatePP(StringRef Source,
+ TrivialModuleLoader ) {
 std::unique_ptr Buf =
 llvm::MemoryBuffer::getMemBuffer(Source);
 SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
 
-TrivialModuleLoader ModLoader;
 MemoryBufferCache PCMCache;
 HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
 Diags, LangOpts, Target.get());
-Preprocessor PP(std::make_shared(), Diags, LangOpts,
-SourceMgr, PCMCache, HeaderInfo, ModLoader,
-/*IILookup =*/nullptr,
-/*OwnsHeaderSearch =*/false);
-PP.Initialize(*Target);
-PP.EnterMainSourceFile();
+std::unique_ptr PP = llvm::make_unique(
+std::make_shared(), Diags, LangOpts, SourceMgr,
+PCMCache, HeaderInfo, ModLoader,
+/*IILookup =*/nullptr,
+/*OwnsHeaderSearch =*/false);
+PP->Initialize(*Target);
+PP->EnterMainSourceFile();
+return PP;
+  }
+
+  std::vector Lex(StringRef Source) {
+TrivialModuleLoader ModLoader;
+auto PP = CreatePP(Source, ModLoader);
 
 std::vector toks;
 while (1) {
   Token tok;
-  PP.Lex(tok);
+  PP->Lex(tok);
   if (tok.is(tok::eof))
 break;
   toks.push_back(tok);
@@ -365,4 +374,48 @@
   EXPECT_EQ(SourceMgr.getFileIDSize(SourceMgr.getFileID(helper1ArgLoc)), 8U);
 }
 
+TEST_F(LexerTest, DontOverallocateStringifyArgs) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("\"StrArg\", 5, 'C'", ModLoader);
+
+  llvm::BumpPtrAllocator Allocator;
+  std::array ArgList;
+  MacroInfo *MI = PP->AllocateMacroInfo({});
+  MI->setIsFunctionLike();
+  

[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation

2017-06-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:356
QualType ResultTy) {
-  if (!State->isTainted(RHS) && !State->isTainted(LHS))
-return UnknownVal();

I am concerned that removing the guard will regress performance in the vanilla 
case. (Note that Z3 support as well as taint are not on by default.)

I am curious how much of the regression you've measured could be gained back if 
we make this conditional.



Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:363
   // instead of generating an Unknown value and propagate the taint info to it.
-  const unsigned MaxComp = 1; // 10 28X
 

Reducing the MaxComp is going to regress taint analysis..

> I've updated this revision to account for the recent SVal simplification 
> commit by @NoQ, 

Which commit introduced the regression?

> but now there is an exponential blowup problem that prevents testcase 
> PR24184.cpp from terminating, 

What triggers the regression? Removing the if statement above? Does the 
regression only effect the Z3 "mode" (I am guessing not since you said "due to 
an interaction between Simplifier::VisitNonLocSymbolVal() and 
SValBuilder::makeSymExprValNN()")? 



https://reviews.llvm.org/D28953



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


r305425 - [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments,

2017-06-14 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun 14 18:09:01 2017
New Revision: 305425

URL: http://llvm.org/viewvc/llvm-project?rev=305425=rev
Log:
[Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, 
correct getNumArguments

StringifiedArguments is allocated (resized) based on the size the 
getNumArguments function. However, this function ACTUALLY currently 
returns the amount of total UnexpArgTokens which is minimum the same as 
the new implementation of getNumMacroArguments, since empty/omitted arguments 
result in 1 UnexpArgToken, and included ones at minimum include 2 
(1 for the arg itself, 1 for eof).

This patch renames the otherwise unused getNumArguments to be more clear 
that it is the number of arguments that the Macro expects, and thus the maximum 
number that can be stringified. This patch also replaces the explicit memset 
(which results in value instantiation of the new tokens, PLUS clearing the 
memory) with brace initialization.

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

Modified:
cfe/trunk/include/clang/Lex/MacroArgs.h
cfe/trunk/lib/Lex/MacroArgs.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/include/clang/Lex/MacroArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroArgs.h?rev=305425=305424=305425=diff
==
--- cfe/trunk/include/clang/Lex/MacroArgs.h (original)
+++ cfe/trunk/include/clang/Lex/MacroArgs.h Wed Jun 14 18:09:01 2017
@@ -53,9 +53,12 @@ class MacroArgs {
   /// Preprocessor owns which we use to avoid thrashing malloc/free.
   MacroArgs *ArgCache;
 
-  MacroArgs(unsigned NumToks, bool varargsElided)
-: NumUnexpArgTokens(NumToks), VarargsElided(varargsElided),
-  ArgCache(nullptr) {}
+  /// MacroArgs - The number of arguments the invoked macro expects.
+  unsigned NumMacroArgs;
+
+  MacroArgs(unsigned NumToks, bool varargsElided, unsigned MacroArgs)
+  : NumUnexpArgTokens(NumToks), VarargsElided(varargsElided),
+ArgCache(nullptr), NumMacroArgs(MacroArgs) {}
   ~MacroArgs() = default;
 
 public:
@@ -94,10 +97,9 @@ public:
   SourceLocation ExpansionLocStart,
   SourceLocation ExpansionLocEnd);
 
-  /// getNumArguments - Return the number of arguments passed into this macro
-  /// invocation.
-  unsigned getNumArguments() const { return NumUnexpArgTokens; }
-
+  /// getNumMacroArguments - Return the number of arguments the invoked macro
+  /// expects.
+  unsigned getNumMacroArguments() const { return NumMacroArgs; }
 
   /// isVarargsElidedUse - Return true if this is a C99 style varargs macro
   /// invocation and there was no argument specified for the "..." argument.  
If

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=305425=305424=305425=diff
==
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Jun 14 18:09:01 2017
@@ -44,20 +44,22 @@ MacroArgs *MacroArgs::create(const Macro
   // Otherwise, use the best fit.
   ClosestMatch = (*Entry)->NumUnexpArgTokens;
 }
-  
+
   MacroArgs *Result;
   if (!ResultEnt) {
 // Allocate memory for a MacroArgs object with the lexer tokens at the end.
-Result = (MacroArgs*)malloc(sizeof(MacroArgs) + 
-UnexpArgTokens.size() * sizeof(Token));
+Result = (MacroArgs *)malloc(sizeof(MacroArgs) +
+ UnexpArgTokens.size() * sizeof(Token));
 // Construct the MacroArgs object.
-new (Result) MacroArgs(UnexpArgTokens.size(), VarargsElided);
+new (Result)
+MacroArgs(UnexpArgTokens.size(), VarargsElided, MI->getNumArgs());
   } else {
 Result = *ResultEnt;
 // Unlink this node from the preprocessors singly linked list.
 *ResultEnt = Result->ArgCache;
 Result->NumUnexpArgTokens = UnexpArgTokens.size();
 Result->VarargsElided = VarargsElided;
+Result->NumMacroArgs = MI->getNumArgs();
   }
 
   // Copy the actual unexpanded tokens to immediately after the result ptr.
@@ -298,12 +300,10 @@ const Token ::getStringifiedAr
Preprocessor ,
SourceLocation 
ExpansionLocStart,
SourceLocation ExpansionLocEnd) 
{
-  assert(ArgNo < NumUnexpArgTokens && "Invalid argument number!");
-  if (StringifiedArgs.empty()) {
-StringifiedArgs.resize(getNumArguments());
-memset((void*)[0], 0,
-   sizeof(StringifiedArgs[0])*getNumArguments());
-  }
+  assert(ArgNo < getNumMacroArguments() && "Invalid argument number!");
+  if (StringifiedArgs.empty())
+StringifiedArgs.resize(getNumMacroArguments(), {});
+
   if (StringifiedArgs[ArgNo].isNot(tok::string_literal))
 

[PATCH] D33841: [clang-tidy] redundant keyword check

2017-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/RedundantKeywordCheck.cpp:22
+template 
+static bool startsWith(const T , StringRef Value) {
+  Token Result;

Why do you need to do a textual search that the first token in the declaration 
is extern or inline? That seems like it would fail on common cases that you 
would expect to catch:
```
#define FOO_EXTERN extern

FOO_EXTERN void blah();
```



Comment at: test/clang-tidy/readability-redundant-keyword.cpp:22
+
+extern "C" void ok();
+

Why is this okay, but the following is not?
```
extern "C++" void ok2();
```


Repository:
  rL LLVM

https://reviews.llvm.org/D33841



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


[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler

2017-06-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Should this revision be "abandoned" or is the plan to iterate on it?


Repository:
  rL LLVM

https://reviews.llvm.org/D31320



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


[PATCH] D31029: [analyzer] Fix logical not for pointers with different bit width

2017-06-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Looks good with a nit!




Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h:325
 
+  Loc makeNull() { return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth()); }
+

Formatting changes here look inconsistent with the rest of the code around.


Repository:
  rL LLVM

https://reviews.llvm.org/D31029



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


[PATCH] D33645: [analyzer] Add missing documentation for static analyzer checkers

2017-06-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Great cleanup! Some comments below.




Comment at: www/analyzer/alpha_checks.html:91
+(C, C++)
+Check for logical errors for function calls and Objective-C message 
+expressions (e.g., uninitialized arguments, null function pointers, 

for function calls -> in function calls?
After briefly looking into this, the checker only reports the use of 
uninitialized arguments in calls, not the other issues (like null function 
pointers). Could you double check this?



Comment at: www/analyzer/alpha_checks.html:152
+(C, C++, ObjC)
+Loss of sign/precision in implicit conversions
+

sign/precision -> sign or precision



Comment at: www/analyzer/available_checks.html:1423
+(C)
+This checker isn't a independent checker, it is part of
+unix.Malloc with configuration option

I cannot find MallocWithAnnotations checker. Also if it exists, it should not 
be on by default, it should be alpha.

(I do not know if anyone is using Optimistic=true and think we should just 
remove that mode..)



Comment at: www/analyzer/available_checks.html:1556
 
+unix.StdCLibraryFunctions
+(C, C++)

I do not think we should list "modeling" checkers here.


https://reviews.llvm.org/D33645



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


LLVM buildmaster will be updated and restarted tonight

2017-06-14 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time
today.

Thanks

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


[PATCH] D34156: [LTO] Add -femit-summary-index flag to emit summary for regular LTO

2017-06-14 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

In https://reviews.llvm.org/D34156#780714, @mehdi_amini wrote:

> In https://reviews.llvm.org/D34156#780570, @tobiasvk wrote:
>
> > - Change patch to always emit a module summary for regular LTO
> >
> >   I don't see any real downside of having a summary given the marginal time 
> > and space overhead it takes to construct and save it.
>
>
> I think some code/logic needs to be changed in LLVM first:
>
>   bool LTOModule::isThinLTO() {
> // Right now the detection is only based on the summary presence. We may 
> want
> // to add a dedicated flag at some point.
>


Thanks for pointing that out. Right now that function will ignore full LTO 
summaries because they are represented using a different record number, but 
once https://reviews.llvm.org/D33922 lands the `hasGlobalValueSummary` function 
will return true if the module contains a full LTO summary. I will update that 
function as part of https://reviews.llvm.org/D33922 to check for presence of a 
ThinLTO summary.


https://reviews.llvm.org/D34156



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


[PATCH] D34156: [LTO] Add -femit-summary-index flag to emit summary for regular LTO

2017-06-14 Thread Tobias Edler von Koch via Phabricator via cfe-commits
tobiasvk added a comment.

In https://reviews.llvm.org/D34156#780714, @mehdi_amini wrote:

> In https://reviews.llvm.org/D34156#780570, @tobiasvk wrote:
>
> > - Change patch to always emit a module summary for regular LTO
> >
> >   I don't see any real downside of having a summary given the marginal time 
> > and space overhead it takes to construct and save it.
>
>
> I think some code/logic needs to be changed in LLVM first:
>
>   bool LTOModule::isThinLTO() {
> // Right now the detection is only based on the summary presence. We may 
> want
> // to add a dedicated flag at some point.
>


No, that check still works. `hasGlobalValueSummary` returns false for regular 
LTO summaries (since they a have different block ID in the bitcode). I believe 
@pcc is refactoring these APIs in a separate patch, since the name 
`hasGlobalValueSummary` doesn't quite reflect its purpose anymore.


https://reviews.llvm.org/D34156



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


[PATCH] D34175: [driver][macOS] Pick the system version for the deployment target if the SDK is newer than the system

2017-06-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 102607.
arphaman added a comment.

Remove redundant driver version correctness checks.


Repository:
  rL LLVM

https://reviews.llvm.org/D34175

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/darwin-sdkroot.c


Index: test/Driver/darwin-sdkroot.c
===
--- test/Driver/darwin-sdkroot.c
+++ test/Driver/darwin-sdkroot.c
@@ -74,3 +74,12 @@
 // CHECK-MACOSX: "-triple" "x86_64-apple-macosx10.10.0"
 // CHECK-MACOSX: ld
 // CHECK-MACOSX: "-macosx_version_min" "10.10.0"
+
+// Ensure that we never pick a version that's based on the SDK that's newer 
than
+// the system version:
+// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk
+// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk
+// RUN: %clang -target x86_64-apple-darwin -isysroot 
%t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
+
+// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99"
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1118,6 +1118,25 @@
   }
 }
 
+/// Returns the most appropriate macOS target version for the current process.
+///
+/// If the macOS SDK version is the same or earlier than the system version,
+/// then the SDK version is returned. Otherwise the system version is returned.
+static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) {
+  unsigned Major, Minor, Micro;
+  llvm::Triple(llvm::sys::getProcessTriple())
+  .getMacOSXVersion(Major, Minor, Micro);
+  VersionTuple SystemVersion(Major, Minor, Micro);
+  bool HadExtra;
+  if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro,
+ HadExtra))
+return MacOSSDKVersion;
+  VersionTuple SDKVersion(Major, Minor, Micro);
+  if (SDKVersion > SystemVersion)
+return SystemVersion.getAsString();
+  return MacOSSDKVersion;
+}
+
 void Darwin::AddDeploymentTarget(DerivedArgList ) const {
   const OptTable  = getDriver().getOpts();
 
@@ -1210,7 +1229,7 @@
 SDK.startswith("iPhoneSimulator"))
   iOSTarget = Version;
 else if (SDK.startswith("MacOSX"))
-  OSXTarget = Version;
+  OSXTarget = getSystemOrSDKMacOSVersion(Version);
 else if (SDK.startswith("WatchOS") ||
  SDK.startswith("WatchSimulator"))
   WatchOSTarget = Version;


Index: test/Driver/darwin-sdkroot.c
===
--- test/Driver/darwin-sdkroot.c
+++ test/Driver/darwin-sdkroot.c
@@ -74,3 +74,12 @@
 // CHECK-MACOSX: "-triple" "x86_64-apple-macosx10.10.0"
 // CHECK-MACOSX: ld
 // CHECK-MACOSX: "-macosx_version_min" "10.10.0"
+
+// Ensure that we never pick a version that's based on the SDK that's newer than
+// the system version:
+// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk
+// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk
+// RUN: %clang -target x86_64-apple-darwin -isysroot %t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
+
+// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99"
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1118,6 +1118,25 @@
   }
 }
 
+/// Returns the most appropriate macOS target version for the current process.
+///
+/// If the macOS SDK version is the same or earlier than the system version,
+/// then the SDK version is returned. Otherwise the system version is returned.
+static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) {
+  unsigned Major, Minor, Micro;
+  llvm::Triple(llvm::sys::getProcessTriple())
+  .getMacOSXVersion(Major, Minor, Micro);
+  VersionTuple SystemVersion(Major, Minor, Micro);
+  bool HadExtra;
+  if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro,
+ HadExtra))
+return MacOSSDKVersion;
+  VersionTuple SDKVersion(Major, Minor, Micro);
+  if (SDKVersion > SystemVersion)
+return SystemVersion.getAsString();
+  return MacOSSDKVersion;
+}
+
 void Darwin::AddDeploymentTarget(DerivedArgList ) const {
   const OptTable  = getDriver().getOpts();
 
@@ -1210,7 +1229,7 @@
 SDK.startswith("iPhoneSimulator"))
   iOSTarget = Version;
 else if (SDK.startswith("MacOSX"))
-  OSXTarget = Version;
+  OSXTarget = getSystemOrSDKMacOSVersion(Version);
 else if (SDK.startswith("WatchOS") ||
  SDK.startswith("WatchSimulator"))
   WatchOSTarget = Version;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34156: [LTO] Add -femit-summary-index flag to emit summary for regular LTO

2017-06-14 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D34156#780570, @tobiasvk wrote:

> - Change patch to always emit a module summary for regular LTO
>
>   I don't see any real downside of having a summary given the marginal time 
> and space overhead it takes to construct and save it.


I think some code/logic needs to be changed in LLVM first:

  bool LTOModule::isThinLTO() {
// Right now the detection is only based on the summary presence. We may 
want
// to add a dedicated flag at some point.




https://reviews.llvm.org/D34156



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


r305418 - AST: Add missing break at end of switch

2017-06-14 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Wed Jun 14 16:26:31 2017
New Revision: 305418

URL: http://llvm.org/viewvc/llvm-project?rev=305418=rev
Log:
AST: Add missing break at end of switch

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=305418=305417=305418=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jun 14 16:26:31 2017
@@ -8547,6 +8547,7 @@ static QualType DecodeTypeFromStr(const
 HowLong = 2;
 break;
   }
+  break;
 }
   }
 


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


[libcxx] r305417 - Rework some metaprogramming to use the detection idiom; no functional change

2017-06-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jun 14 16:23:57 2017
New Revision: 305417

URL: http://llvm.org/viewvc/llvm-project?rev=305417=rev
Log:
Rework some metaprogramming to use the detection idiom; no functional change

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=305417=305416=305417=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Jun 14 16:23:57 2017
@@ -720,16 +720,12 @@ public:
 
 // pointer_traits
 
+template 
+struct __has_element_type : false_type {};
+
 template 
-struct __has_element_type
-{
-private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::element_type* = 0);
-public:
-static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
+struct __has_element_type<_Tp, 
+  typename __void_t::type> : true_type 
{};
 
 template ::value>
 struct __pointer_traits_element_type;
@@ -808,16 +804,12 @@ struct __pointer_traits_element_type<_Sp
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
+template 
+struct __has_difference_type : false_type {};
+
 template 
-struct __has_difference_type
-{
-private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::difference_type* = 
0);
-public:
-static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
+struct __has_difference_type<_Tp, 
+typename __void_t::type> : 
true_type {};
 
 template ::value>
 struct __pointer_traits_difference_type
@@ -998,17 +990,12 @@ struct __rebind_pointer {
 
 // allocator_traits
 
-struct __has_pointer_type_imp
-{
-template  static __two __test(...);
-template  static char __test(typename _Up::pointer* = 0);
-};
+template 
+struct __has_pointer_type : false_type {};
 
 template 
-struct __has_pointer_type
-: public integral_constant(0)) == 1>
-{
-};
+struct __has_pointer_type<_Tp, 
+  typename __void_t::type> : true_type {};
 
 namespace __pointer_type_imp
 {
@@ -1033,16 +1020,12 @@ struct __pointer_type
 typedef typename __pointer_type_imp::__pointer_type<_Tp, typename 
remove_reference<_Dp>::type>::type type;
 };
 
+template 
+struct __has_const_pointer : false_type {};
+
 template 
-struct __has_const_pointer
-{
-private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::const_pointer* = 0);
-public:
-static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
+struct __has_const_pointer<_Tp, 
+typename __void_t::type> : true_type 
{};
 
 template ::value>
 struct __const_pointer
@@ -1060,16 +1043,12 @@ struct __const_pointer<_Tp, _Ptr, _Alloc
 #endif
 };
 
+template 
+struct __has_void_pointer : false_type {};
+
 template 
-struct __has_void_pointer
-{
-private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::void_pointer* = 0);
-public:
-static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
+struct __has_void_pointer<_Tp, 
+   typename __void_t::type> : 
true_type {};
 
 template ::value>
 struct __void_pointer
@@ -1087,16 +1066,12 @@ struct __void_pointer<_Ptr, _Alloc, fals
 #endif
 };
 
+template 
+struct __has_const_void_pointer : false_type {};
+
 template 
-struct __has_const_void_pointer
-{
-private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::const_void_pointer* 
= 0);
-public:
-static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
+struct __has_const_void_pointer<_Tp, 
+typename __void_t::type> : 
true_type {};
 
 template ::value>
 struct __const_void_pointer
@@ -1130,16 +1105,12 @@ __to_raw_pointer(_Pointer __p) _NOEXCEPT
 return _VSTD::__to_raw_pointer(__p.operator->());
 }
 
+template 
+struct __has_size_type : false_type {};
+
 template 
-struct __has_size_type
-{
-private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::size_type* = 0);
-public:
-static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
+struct __has_size_type<_Tp,
+   typename __void_t::type> : true_type 
{};
 
 template ::value>
 struct __size_type
@@ -1153,16 +1124,13 @@ struct __size_type<_Alloc, _DiffType, tr
 typedef typename _Alloc::size_type type;
 };
 
+template 
+struct __has_propagate_on_container_copy_assignment : false_type {};
+
 template 
-struct __has_propagate_on_container_copy_assignment
-{
-private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename 

[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude

2017-06-14 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 102605.
mibintc added a comment.

Thanks for your review, Fedor.  I moved AddGnuIncludeArgs out of 
GCCInstallation, like you suggested, and put it along where the library 
includes are added.  I also pulled out the change for MipsLinux since I don't 
have a way to verify that.

I still have the same 7 test failures when make check-all on Linux. 3 of the 
fails are from "clangd" unit tests. Not sure why they are failing but i scanned 
the tests a little and it talks about access only to whitelisted directories, 
so I assume they aren't working because the dir where std-predef.h lives is not 
white listed. Maybe I should be sure that "file exists(stdc-predef.h)", e.g. 
using the system include path, before adding the -include into the command 
line--what do you think?


Repository:
  rL LLVM

https://reviews.llvm.org/D34158

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/clang_cpp.c
  test/Driver/gcc-predef.c
  test/Index/IBOutletCollection.m
  test/Index/annotate-macro-args.m
  test/Index/annotate-tokens-pp.c
  test/Index/annotate-tokens.c
  test/Index/c-index-getCursor-test.m
  test/Index/get-cursor-macro-args.m
  test/Index/get-cursor.cpp
  unittests/Tooling/TestVisitor.h

Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -31,6 +31,8 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
+  void AddGnuIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const;
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2329,6 +2329,17 @@
   }
 }
 
+void Generic_GCC::addGnuIncludeArgs(const ArgList , 
+ArgStringList ) const {
+  const Generic_GCC::GCCVersion  = GCCInstallation.getVersion();
+  if (!DriverArgs.hasArg(options::OPT_ffreestanding) &&
+  !DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
+  !Version.isOlderThan(4, 8, 0)) {
+CC1Args.push_back("-include");
+CC1Args.push_back("stdc-predef.h");
+  }
+}
+
 void Generic_GCC::AddClangCXXStdlibIncludeArgs(const ArgList ,
ArgStringList ) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -705,6 +705,8 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+  AddGnuIncludeArgs(DriverArgs, CC1Args);
 }
 
 static std::string DetectLibcxxIncludePath(StringRef base) {
@@ -743,6 +745,13 @@
   return "";
 }
 
+void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const {
+  if (GCCInstallation.isValid())
+addGnuIncludeArgs(DriverArgs, CC1Args);
+}
+
+
 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const {
   // We need a detected GCC installation on Linux to provide libstdc++'s
Index: lib/Driver/ToolChains/Gnu.h
===
--- lib/Driver/ToolChains/Gnu.h
+++ lib/Driver/ToolChains/Gnu.h
@@ -325,6 +325,9 @@
 const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const;
 
+  void addGnuIncludeArgs(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList ) const;
+
   /// @}
 
 private:
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -716,6 +716,9 @@
   return Res;
 }
 
+void ToolChain::AddGnuIncludeArgs(const ArgList ,
+   ArgStringList ) const {}
+
 void ToolChain::AddCudaIncludeArgs(const ArgList ,
ArgStringList ) const {}
 
Index: unittests/Tooling/TestVisitor.h
===
--- unittests/Tooling/TestVisitor.h
+++ unittests/Tooling/TestVisitor.h
@@ -52,6 +52,7 @@
   /// \brief Runs the current AST visitor over the given code.
   bool runOver(StringRef Code, Language L = Lang_CXX) {
 std::vector Args;
+

[PATCH] D32046: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments

2017-06-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM! Please fix the code style issues that I pointed out before committing.




Comment at: unittests/Lex/LexerTest.cpp:24
 #include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/MacroArgs.h"
+#include "clang/Lex/MacroInfo.h"

Please put these two new includes before `#include "clang/Lex/ModuleLoader.h"`



Comment at: unittests/Lex/LexerTest.cpp:46
 
-  std::vector Lex(StringRef Source) {
+  std::unique_ptr CreatePP(StringRef Source, 
TrivialModuleLoader& ModLoader) {
 std::unique_ptr Buf =

I think this violates the 80 columns, please reformat this declaration.



Comment at: unittests/Lex/LexerTest.cpp:62
+return PP;
+  }
+  std::vector Lex(StringRef Source) {

NIT: Please add a new line after '}'.


https://reviews.llvm.org/D32046



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


[PATCH] D34121: [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-06-14 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 102603.
vsk marked an inline comment as done.
vsk added a comment.

Address Adrian's comment about using an enum to simplify some calls.


https://reviews.llvm.org/D34121

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-pointer-overflow.m

Index: test/CodeGen/ubsan-pointer-overflow.m
===
--- test/CodeGen/ubsan-pointer-overflow.m
+++ test/CodeGen/ubsan-pointer-overflow.m
@@ -10,16 +10,20 @@
   ++p;
 
   // CHECK: ptrtoint i8* {{.*}} to i64, !nosanitize
-  // CHECK-NEXT: add i64 {{.*}}, -1, !nosanitize
-  // CHECK: select i1 false{{.*}}, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 {{.*}}, -1, !nosanitize
+  // CHECK: [[NEGVALID:%.*]] = icmp ule i64 [[COMPGEP]], {{.*}}, !nosanitize
+  // CHECK-NOT: select
+  // CHECK: br i1 [[NEGVALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   --p;
 
+  // CHECK: icmp uge i64
   // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   p++;
 
-  // CHECK: select
+  // CHECK: icmp ule i64
+  // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   p--;
 }
@@ -64,7 +68,8 @@
 
   // CHECK: [[OFFSET:%.*]] = sub i64 0, {{.*}}
   // CHECK-NEXT: getelementptr inbounds {{.*}} [[OFFSET]]
-  // CHECK: select
+  // CHECK: icmp ule i64
+  // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   p - i;
 }
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3552,12 +3552,19 @@
   /// nonnull, if \p LHS is marked _Nonnull.
   void EmitNullabilityCheck(LValue LHS, llvm::Value *RHS, SourceLocation Loc);
 
+  /// An enumeration which makes it easier to specify whether or not an
+  /// operation is a subtraction.
+  enum { NotSubtraction = false, IsSubtraction = true };
+
   /// Same as IRBuilder::CreateInBoundsGEP, but additionally emits a check to
   /// detect undefined behavior when the pointer overflow sanitizer is enabled.
   /// \p SignedIndices indicates whether any of the GEP indices are signed.
+  /// \p IsSubtraction indicates whether the expression used to form the GEP
+  /// is a subtraction.
   llvm::Value *EmitCheckedInBoundsGEP(llvm::Value *Ptr,
   ArrayRef IdxList,
   bool SignedIndices,
+  bool IsSubtraction,
   SourceLocation Loc,
   const Twine  = "");
 
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -1851,7 +1851,7 @@
   llvm::Value *input;
 
   int amount = (isInc ? 1 : -1);
-  bool signedIndex = !isInc;
+  bool isSubtraction = !isInc;
 
   if (const AtomicType *atomicTy = type->getAs()) {
 type = atomicTy->getValueType();
@@ -1941,8 +1941,9 @@
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(value, numElts, "vla.inc");
   else
-value = CGF.EmitCheckedInBoundsGEP(value, numElts, signedIndex,
-   E->getExprLoc(), "vla.inc");
+value = CGF.EmitCheckedInBoundsGEP(
+value, numElts, /*SignedIndices=*/false, isSubtraction,
+E->getExprLoc(), "vla.inc");
 
 // Arithmetic on function pointers (!) is just +-1.
 } else if (type->isFunctionType()) {
@@ -1952,18 +1953,20 @@
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(value, amt, "incdec.funcptr");
   else
-value = CGF.EmitCheckedInBoundsGEP(value, amt, signedIndex,
-   E->getExprLoc(), "incdec.funcptr");
+value = CGF.EmitCheckedInBoundsGEP(value, amt, /*SignedIndices=*/false,
+   isSubtraction, E->getExprLoc(),
+   "incdec.funcptr");
   value = Builder.CreateBitCast(value, input->getType());
 
 // For everything else, we can just do a simple increment.
 } else {
   llvm::Value *amt = Builder.getInt32(amount);
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(value, amt, "incdec.ptr");
   else
-value = CGF.EmitCheckedInBoundsGEP(value, amt, signedIndex,
-   E->getExprLoc(), "incdec.ptr");
+value = CGF.EmitCheckedInBoundsGEP(value, amt, /*SignedIndices=*/false,
+   isSubtraction, E->getExprLoc(),
+   "incdec.ptr");
 }
 
   // Vector increment/decrement.
@@ -2044,7 +2047,8 @@
 if 

[PATCH] D34175: [driver][macOS] Pick the system version for the deployment target if the SDK is newer than the system

2017-06-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Driver/ToolChains/Darwin.cpp:1133
+ HadExtra) ||
+  HadExtra || Major != 10 || Minor >= 100 || Micro >= 100)
+return MacOSSDKVersion;

inouehrs wrote:
> What these magic numbers mean (especially minor and micro versions)?
> You may need some comments.
 I actually just took it from the function below which checks if the macOS 
version is valid (so we want 10.XX.XX). But looking at it again, I think that 
we don't really them here as the SDK version should will probably be valid. 
I'll update the patch and remove them from the code.


Repository:
  rL LLVM

https://reviews.llvm.org/D34175



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


[PATCH] D34185: [Parser][ObjC] Avoid crashing when skipping to EOF while parsing an ObjC interface/implementation

2017-06-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D34185#780494, @ahatanak wrote:

> This patch fixes the crash and that is fine, but the users might find the 
> last error ("expected '}'" at the end of the file) confusing. This seems to 
> happen because Parser::ParseLexedObjCMethodDefs consumes all tokens in the 
> file until it sees the EOF after consuming all the cached tokens of 
> LexedMethod.
>
> I wonder whether we can insert a fake EOF token to prevent 
> ParseLexedObjCMethodDefs from going all the way to the end, just like 
> ParseCXXNonStaticMemberInitialize does. Do you think that would work or would 
> it be too hackish?


I think that it would probably work quite well. I've thought about fixing it 
while working on a patch as well, but didn't realize that we could just inject 
EOF into the token stream. I will update this patch with this kind of handling 
then.


Repository:
  rL LLVM

https://reviews.llvm.org/D34185



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


[PATCH] D33308: [analyzer]: Improve test handling with multiple constraint managers

2017-06-14 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This looks good to me.

Sorry of the delay here -- and thanks for your patience. I will review the 
other patches this weekend.


https://reviews.llvm.org/D33308



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


[PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

As of r305410, libc++ passes all the tests w/ -Wcast-qual enabled.


Repository:
  rL LLVM

https://reviews.llvm.org/D33102



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


[libcxx] r305410 - Add some const_casts in places where we were implicitly casting away constness. No functional change, but now they're explicit

2017-06-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jun 14 15:00:36 2017
New Revision: 305410

URL: http://llvm.org/viewvc/llvm-project?rev=305410=rev
Log:
Add some const_casts in places where we were implicitly casting away constness. 
No functional change, but now they're explicit

Modified:
libcxx/trunk/include/__functional_03
libcxx/trunk/include/fstream
libcxx/trunk/include/functional
libcxx/trunk/include/locale
libcxx/trunk/test/support/allocators.h

Modified: libcxx/trunk/include/__functional_03
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_03?rev=305410=305409=305410=diff
==
--- libcxx/trunk/include/__functional_03 (original)
+++ libcxx/trunk/include/__functional_03 Wed Jun 14 15:00:36 2017
@@ -704,7 +704,7 @@ function<_Rp()>::target()
 {
 if (__f_ == 0)
 return (_Tp*)0;
-return (_Tp*)__f_->target(typeid(_Tp));
+return (_Tp*) const_cast(__f_->target(typeid(_Tp)));
 }
 
 template
@@ -980,7 +980,7 @@ function<_Rp(_A0)>::target()
 {
 if (__f_ == 0)
 return (_Tp*)0;
-return (_Tp*)__f_->target(typeid(_Tp));
+return (_Tp*) const_cast(__f_->target(typeid(_Tp)));
 }
 
 template
@@ -1256,7 +1256,7 @@ function<_Rp(_A0, _A1)>::target()
 {
 if (__f_ == 0)
 return (_Tp*)0;
-return (_Tp*)__f_->target(typeid(_Tp));
+return (_Tp*) const_cast(__f_->target(typeid(_Tp)));
 }
 
 template
@@ -1532,7 +1532,7 @@ function<_Rp(_A0, _A1, _A2)>::target()
 {
 if (__f_ == 0)
 return (_Tp*)0;
-return (_Tp*)__f_->target(typeid(_Tp));
+return (_Tp*) const_cast(__f_->target(typeid(_Tp)));
 }
 
 template

Modified: libcxx/trunk/include/fstream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=305410=305409=305410=diff
==
--- libcxx/trunk/include/fstream (original)
+++ libcxx/trunk/include/fstream Wed Jun 14 15:00:36 2017
@@ -617,7 +617,7 @@ basic_filebuf<_CharT, _Traits>::underflo
  static_cast(__extbufend_ - 
__extbufnext_));
 codecvt_base::result __r;
 __st_last_ = __st_;
-size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
+size_t __nr = fread((void*) const_cast(__extbufnext_), 1, 
__nmemb, __file_);
 if (__nr != 0)
 {
 if (!__cv_)
@@ -630,7 +630,8 @@ basic_filebuf<_CharT, _Traits>::underflo
this->eback() + __ibs_, __inext);
 if (__r == codecvt_base::noconv)
 {
-this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, 
(char_type*)__extbufend_);
+this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, 
+  (char_type*)const_cast(__extbufend_));
 __c = traits_type::to_int_type(*this->gptr());
 }
 else if (__inext != this->eback() + __unget_sz)
@@ -722,7 +723,7 @@ basic_filebuf<_CharT, _Traits>::overflow
 return traits_type::eof();
 if (__r == codecvt_base::partial)
 {
-this->setp((char_type*)__e, this->pptr());
+this->setp(const_cast(__e), this->pptr());
 this->pbump(this->epptr() - this->pbase());
 }
 }

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=305410=305409=305410=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Wed Jun 14 15:00:36 2017
@@ -1941,8 +1941,8 @@ _Tp*
 function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
 {
 if (__f_ == 0)
-return (_Tp*)0;
-return (_Tp*)__f_->target(typeid(_Tp));
+return nullptr;
+return (_Tp*) const_cast(__f_->target(typeid(_Tp)));
 }
 
 template
@@ -1951,7 +1951,7 @@ const _Tp*
 function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
 {
 if (__f_ == 0)
-return (const _Tp*)0;
+return nullptr;
 return (const _Tp*)__f_->target(typeid(_Tp));
 }
 

Modified: libcxx/trunk/include/locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=305410=305409=305410=diff
==
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Wed Jun 14 15:00:36 2017
@@ -3960,7 +3960,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::u
this->egptr(), __inext);
 if (__r == codecvt_base::noconv)
 {
-this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, 
(char_type*)__extbufend_);
+

Re: [clang-tools-extra] r303735 - Modify test so that it looks for patterns in stderr as well

2017-06-14 Thread David Blaikie via cfe-commits
On Wed, Jun 14, 2017, 8:17 AM Serge Pavlov  wrote:

> 2017-06-14 4:24 GMT+07:00 David Blaikie :
>
>> Ah, I find that the test passes if I remove the compile_commands.json
>> file from my build directory (I have Ninja configured to generate a
>> compile_commands.json file).
>>
>> Looks like what happens is it finds the compilation database and fails
>> hard when the database doesn't contain a compile command for the file in
>> question. If the database is not found, it falls back to some basic command
>> behavior, perhaps?
>>
>>
> You are right, constructor of `CommonOptionsParser` calls
> `autoDetectFromSource` or `autoDetectFromDirectory` prior to final
> construction of `FixedCompilationDatabase.
>
> Is there some way this test could be fixed to cope with this, otherwise it
>> seems to get in the way of people actually using clang tools in their
>> LLVM/Clang build environment?
>>
>>
> IIUC, presence of stale compilation database file in test directory could
> break many tests. I don't understand why only diagnostic.cpp fails,
> probably there is something wrong with the clang-tidy application cleanup
> in this case?
>

Except it's neither stale nor in the test directory.

It's the up to date/useful/used compile_commands.json generated by ninja in
the root of the build tree.


>
>> On Tue, Jun 13, 2017 at 7:41 AM Serge Pavlov  wrote:
>>
>>> I cannot reproduce such fail, so I can only guess how changes made in
>>> https://reviews.llvm.org/rL303756 and https://reviews.llvm.org/rL303741
>>> could cause such problem. Behavior of `Driver::BuildCompilation` is changed
>>> so that it returns null pointer if errors occur during driver argument
>>> parse. It is called in `CompilationDatabase.cpp` from
>>> `stripPositionalArgs`. The call stack at this point is:
>>> stripPositionalArgs
>>> clang::tooling::FixedCompilationDatabase::loadFromCommandLine
>>> clang::tooling::CommonOptionsParser::CommonOptionsParser
>>> clang::tidy::clangTidyMain
>>> main
>>> `FixedCompilationDatabase::loadFromCommandLine` returns null and
>>> CommonOptionsParser uses another method to create compilation database. The
>>> output "Compile command not found" means that no input file were found in
>>> `ClangTool::run`. Maybe some file names are nulls?
>>>
>>>
>>> Thanks,
>>> --Serge
>>>
>>> 2017-06-13 3:42 GMT+07:00 David Blaikie :
>>>
 I've been seeing errors from this test recently:

 Command Output (stderr):
 --
 1 error generated.
 Error while processing
 /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp.nonexistent.cpp.
 /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp:10:12:
 error: expected string not found in input
 // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double'
 to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
^
 :2:1: note: scanning from here
 Skipping
 /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp.
 Compile command not found.
 ^
 :2:1: note: with expression "@LINE+2" equal to "12"
 Skipping
 /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp.
 Compile command not found.
 ^


 Specifically, the output is:
 $ ./bin/clang-tidy
 -checks='-*,clang-diagnostic-*,google-explicit-constructor'
 /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp
 -- -fan-unknown-option 2>&1error: unknown
 argument: '-fan-unknown-option'
  Skipping
 /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp.
 Compile command not found.


 Does this look like it might be related to any of your changes in this
 area? Perhaps the error due to unknown argument is causing clang-tidy not
 to continue on to run the check & report the warning?


 On Wed, May 24, 2017 at 3:51 AM Serge Pavlov via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: sepavloff
> Date: Wed May 24 05:50:56 2017
> New Revision: 303735
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303735=rev
> Log:
> Modify test so that it looks for patterns in stderr as well
>
> With the change https://reviews.llvm.org/D33013 driver will not build
> compilation object if command line is invalid, in particular, if
> unrecognized option is provided. In such cases it will prints
> diagnostics
> on stderr. The test 'clang-tidy/diagnostic.cpp' checks reaction on
> unrecognized option and will fail when D33013 is applied because it
> checks
> only stdout for test patterns 

[PATCH] D34156: [LTO] Add -femit-summary-index flag to emit summary for regular LTO

2017-06-14 Thread Tobias Edler von Koch via Phabricator via cfe-commits
tobiasvk updated this revision to Diff 102585.
tobiasvk added a comment.

- Change patch to always emit a module summary for regular LTO

I don't see any real downside of having a summary given the marginal time and
space overhead it takes to construct and save it.


https://reviews.llvm.org/D34156

Files:
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/emit-summary-index.c
  clang/test/Misc/thinlto.c

Index: clang/test/Misc/thinlto.c
===
--- clang/test/Misc/thinlto.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s
-// ; Check that the -flto=thin option emits a summary
-// CHECK: getValue();
 if (S == "thin")
-  Opts.EmitSummaryIndex = true;
+  Opts.PrepareForThinLTO = true;
 else if (S != "full")
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
   }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -486,7 +486,7 @@
 PMBuilder.Inliner = createFunctionInliningPass(
 CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize,
 (!CodeGenOpts.SampleProfileFile.empty() &&
- CodeGenOpts.EmitSummaryIndex));
+ CodeGenOpts.PrepareForThinLTO));
   }
 
   PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel;
@@ -497,7 +497,7 @@
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
-  PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex;
+  PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
@@ -733,12 +733,20 @@
 
   std::unique_ptr ThinLinkOS;
 
+  // Emit a module summary by default for Regular LTO except for ld64 targets
+  bool EmitLTOSummary =
+  (CodeGenOpts.PrepareForLTO && !CodeGenOpts.PrepareForThinLTO &&
+   llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
+   llvm::Triple::Apple);
+  if (EmitLTOSummary)
+TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
+
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex) {
+if (CodeGenOpts.PrepareForThinLTO) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 std::error_code EC;
 ThinLinkOS.reset(new llvm::raw_fd_ostream(
@@ -755,7 +763,8 @@
 }
 else
   PerModulePasses.add(
-  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+  EmitLTOSummary));
 break;
 
   case Backend_EmitLL:
@@ -895,6 +904,14 @@
 }
   }
 
+  // Emit a module summary by default for Regular LTO except for ld64 targets
+  bool EmitLTOSummary =
+  (CodeGenOpts.PrepareForLTO && !CodeGenOpts.PrepareForThinLTO &&
+   llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
+   llvm::Triple::Apple);
+  if (EmitLTOSummary)
+TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
+
   // FIXME: We still use the legacy pass manager to do code generation. We
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
@@ -907,7 +924,7 @@
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex) {
+if (CodeGenOpts.PrepareForThinLTO) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 std::error_code EC;
 ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
@@ -922,8 +939,7 @@
   ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));
 } else {
   MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+EmitLTOSummary));
 }
 break;
 
Index: clang/include/clang/Frontend/CodeGenOptions.def
===
--- clang/include/clang/Frontend/CodeGenOptions.def
+++ clang/include/clang/Frontend/CodeGenOptions.def
@@ -88,7 +88,7 @@
  ///< be generated.
 CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
  ///< compile step.
-CODEGENOPT(EmitSummaryIndex, 1, 0)   ///< Set when -flto=thin is enabled on the
+CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the
  ///< compile step.
 CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole

[PATCH] D34210: Add __has_feature(leak_sanitizer)

2017-06-14 Thread Francis Ricci via Phabricator via cfe-commits
fjricci abandoned this revision.
fjricci added a comment.

Weak hooks do provide a good solution, abandoning for now (although it may need 
to be reconsidered if we get a windows LSan port up and running).


https://reviews.llvm.org/D34210



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


[PATCH] D33383: [GSoC] Flag value completion for clang

2017-06-14 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

Overall looking good. Good work! A few minor comments.




Comment at: clang/include/clang/Driver/Options.td:2198
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
-  HelpText<"C++ standard library to use">;
+  HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;

v.g.vassilev wrote:
> `Values` seems too generic, can we use `ArgValues` instead?
I'd keep it as `Values`, as everything is essentially related to command line 
arguments, and `Args` seems redundant. For example, we didn't name `ArgFlags` 
but just `Flags`, and `HelpText` instead of `ArgHelpText`, etc.



Comment at: clang/lib/Driver/Driver.cpp:1224
+SmallVector ListOfPassedFlags;
+// PassedFlags are incomplete flags which format is 
"c,=,-std,-fsyntax-only"
+// So spilit them with "," in order to make list of flags.

nit: insert a blank line before a meaningful code block so that code doesn't 
look too dense.



Comment at: clang/lib/Driver/Driver.cpp:1225
+// PassedFlags are incomplete flags which format is 
"c,=,-std,-fsyntax-only"
+// So spilit them with "," in order to make list of flags.
+PassedFlags.split(ListOfPassedFlags, ",", -1, false);

make a list of flag values.



Comment at: clang/lib/Driver/Driver.cpp:1226
+// So spilit them with "," in order to make list of flags.
+PassedFlags.split(ListOfPassedFlags, ",", -1, false);
+std::vector SuggestedCompletions = 
Opts->findByPrefix(ListOfPassedFlags[0]);

You are using `PassedFlags` only once. Do you want to replace it with 
`StringRef(A->getValue()).split(...)`?



Comment at: clang/test/Driver/autocomplete.c:7
 // NONE: foo
+// RUN: %clang --autocomplete=l,=,-stdlib | FileCheck %s -check-prefix=STDLIB
+// STDLIB: libc++ libstdc++

Why do you want to pass the arguments in the reverse order?


https://reviews.llvm.org/D33383



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


[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

2017-06-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

This generally sounds good. Definitely do submit these changes in small pieces! 
See http://llvm.org/docs/DeveloperPolicy.html#incremental-development for 
rationale.


https://reviews.llvm.org/D27753



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


[PATCH] D34102: [analyzer] Add portability package for the checkers.

2017-06-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:454
+def UnixAPIPortabilityChecker : Checker<"API">,
+  HelpText<"Finds implementation-defined behavior in UNIX/Posix functions">,
+  DescFile<"UnixAPIChecker.cpp">;

NoQ wrote:
> zaks.anna wrote:
> > Does this need to be in unix?
> Well,
>   1. the description still says "UNIX/Posix" and
>   2. even if we believe that `malloc` isn't a UNIX/Posix-specific thing, we'd 
> also need to move our `MallocChecker` out of the `unix` package.
> 
> This is probably the right thing to do, but i didn't try to do it here. If we 
> want this, i'd move the portability checker out of `unix` now and deal with 
> `MallocChecker` in another patch. I can also move the portability checker's 
> code into `MallocChecker.cpp`, because that's what we always wanted to do, 
> according to a `UnixAPIChecker`'s FIXME.
If someone is interested in checking if their code is portable, they'd just 
enable profitability package. I do not think "unix" adds much here. I suggest 
to just add the check to portability package directly, change the name and make 
no other changes.
WDYT?


https://reviews.llvm.org/D34102



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


[PATCH] D34210: Add __has_feature(leak_sanitizer)

2017-06-14 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko added a comment.

In https://reviews.llvm.org/D34210#780520, @fjricci wrote:

> Currently, the way that we tell users to gate on sanitizer-specific behavior 
> is with `__has_feature(foo_sanitizer)`, as far as I know, it's the only way 
> to do so. LSan provides several API functions for users, ie 
> `__lsan_ignore_object`. If a user program wants to use these API functions in 
> their program, they need a way to check that LSan is enabled at compilation 
> time (even if LSan doesn't actually modify the compile step). I'm not sure of 
> a better or more consistent way to allow that to happen.


Can't you use weak hooks in your code for this purpose?


https://reviews.llvm.org/D34210



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


[PATCH] D34210: Add __has_feature(leak_sanitizer)

2017-06-14 Thread Francis Ricci via Phabricator via cfe-commits
fjricci added a comment.

Currently, the way that we tell users to gate on sanitizer-specific behavior is 
with `__has_feature(foo_sanitizer)`, as far as I know, it's the only way to do 
so. LSan provides several API functions for users, ie `__lsan_ignore_object`. 
If a user program wants to use these API functions in their program, they need 
a way to check that LSan is enabled at compilation time (even if LSan doesn't 
actually modify the compile step). I'm not sure of a better or more consistent 
way to allow that to happen.


https://reviews.llvm.org/D34210



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


[PATCH] D34185: [Parser][ObjC] Avoid crashing when skipping to EOF while parsing an ObjC interface/implementation

2017-06-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

This patch fixes the crash and that is fine, but the users might find the last 
error ("expected '}'" at the end of the file) confusing. This seems to happen 
because Parser::ParseLexedObjCMethodDefs consumes all tokens in the file until 
it sees the EOF after consuming all the cached tokens of LexedMethod.

I wonder whether we can insert a fake EOF token to prevent 
ParseLexedObjCMethodDefs from going all the way to the end, just like 
ParseCXXNonStaticMemberInitialize does. Do you think that would work or would 
it be too hackish?


Repository:
  rL LLVM

https://reviews.llvm.org/D34185



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


[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-14 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 102577.
yawanng marked 7 inline comments as done.

https://reviews.llvm.org/D33304

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/FileOpenFlagCheck.cpp
  clang-tidy/android/FileOpenFlagCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/run-clang-tidy.py
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-file-open-flag.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/android-file-open-flag.cpp
  unittests/clang-tidy/CMakeLists.txt

Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -25,6 +25,7 @@
   clangFrontend
   clangLex
   clangTidy
+  clangTidyAndroidModule
   clangTidyGoogleModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: test/clang-tidy/android-file-open-flag.cpp
===
--- /dev/null
+++ test/clang-tidy/android-file-open-flag.cpp
@@ -0,0 +1,110 @@
+// RUN: %check_clang_tidy %s android-file-open-flag %t
+
+#define O_RDWR 1
+#define O_EXCL 2
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+
+extern "C" int open(const char *fn, int flags, ...);
+extern "C" int open64(const char *fn, int flags, ...);
+extern "C" int openat(int dirfd, const char *pathname, int flags, ...);
+
+void a() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'open' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void b() {
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open64("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'open64' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void c() {
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  openat(0, "filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: 'openat' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void f() {
+  open("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  open64("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  openat(0, "filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+
+  int flag = 3;
+  open("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int open(const char *pathname, int flags, ...);
+int open64(const char *pathname, int flags, ...);
+int openat(int dirfd, const char *pathname, int flags, ...);
+
+void d() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  open("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open("filename", O_RDWR | O_CLOEXEC | O_EXCL);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR | O_CLOEXEC | O_EXCL);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR | O_CLOEXEC | O_EXCL);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int open(const char *pathname, int flags, ...);
+  int open64(const char *pathname, int flags, ...);
+  int openat(int dirfd, const char *pathname, int flags, ...);
+
+  void h() {
+open("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+open64("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+openat(0, "filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+  

[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-14 Thread Yan Wang via Phabricator via cfe-commits
yawanng added inline comments.



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:61
+  SourceLocation EndLoc =
+  Lexer::getLocForEndOfToken(FlagArg->getLocEnd(), 0, SM, getLangOpts());
+

hokein wrote:
> Instead of using getLangOpts(), you should use `Result.Context.getLangOpts()`.
May I ask what's the difference between the `Result.Context.getLangOpts()` and 
`getLangOpts()`? Does `Result.Context.getLangOpts()` have a longer lifetime 
than `getLangOpts()`?



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:79
+std::pair ExpansionInfo = SM.getDecomposedLoc(Loc);
+auto MacroName =
+SM.getBufferData(ExpansionInfo.first)

hokein wrote:
> You could use `Lexer::getImmediateMacroName(Loc, SM, Opts);` to get the marco 
> name, or doesn't it work here?
`getImmediateMacroName` sometimes cannot return the `O_CLOEXEC `, like

#define O_CLOEXEC  _O_CLOEXEC
#define _O_CLOEXEC  1

`getImmediateMacroName` will return `_O_CLOEXEC`, whereas `O_CLOEXEC` is what 
we need.  I change this to directly get the source text if it's a macro, which 
seems to be simpler.


https://reviews.llvm.org/D33304



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


[PATCH] D34210: Add __has_feature(leak_sanitizer)

2017-06-14 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

I'm not sure about this one. 
standalone lsan is a link-time feature only, it doesn't change the compilation, 
so the argument of consistency doesn't apply.


https://reviews.llvm.org/D34210



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


[PATCH] D34212: docs: Document binary compatibility issue due to bug in gcc

2017-06-14 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.

Reported in PR33161.


https://reviews.llvm.org/D34212

Files:
  docs/BinaryCompatibilityWithOtherCompilers.rst


Index: docs/BinaryCompatibilityWithOtherCompilers.rst
===
--- /dev/null
+++ docs/BinaryCompatibilityWithOtherCompilers.rst
@@ -0,0 +1,39 @@
+=
+Binary compatibility with other compilers
+=
+
+Introduction
+
+
+This document describes some of the known binary compatibility problems
+when mixing object files built by clang with object files built by
+other compilers.
+
+If you run into a compatibility issue, please file a bug at bugs.llvm.org.
+
+gcc C++ ABI bug with variadic templates
+===
+
+Older versions of gcc incorrectly mangle variadic class/function templates,
+which can lead to undefined symbol errors when linking gcc built objects
+with clang built objects.
+
+gcc does emit the correct symbol name as an alias for the incorrect one,
+so libraries built by gcc are not affected by this bug.  You can only
+hit this bug if you have a library built by clang and you try to link
+against it with a gcc built object that uses a variadic class/function
+template from the library.
+
+workarounds:
+^^^
+
+* Use gcc 5.1.0 or newer.
+* Pass the -fabi-version=6 option to gcc when using versions < 5.1.0.
+
+gcc bug report:
+^^^
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51322
+
+llvm bug report:
+
+https://llvm.org/PR33161


Index: docs/BinaryCompatibilityWithOtherCompilers.rst
===
--- /dev/null
+++ docs/BinaryCompatibilityWithOtherCompilers.rst
@@ -0,0 +1,39 @@
+=
+Binary compatibility with other compilers
+=
+
+Introduction
+
+
+This document describes some of the known binary compatibility problems
+when mixing object files built by clang with object files built by
+other compilers.
+
+If you run into a compatibility issue, please file a bug at bugs.llvm.org.
+
+gcc C++ ABI bug with variadic templates
+===
+
+Older versions of gcc incorrectly mangle variadic class/function templates,
+which can lead to undefined symbol errors when linking gcc built objects
+with clang built objects.
+
+gcc does emit the correct symbol name as an alias for the incorrect one,
+so libraries built by gcc are not affected by this bug.  You can only
+hit this bug if you have a library built by clang and you try to link
+against it with a gcc built object that uses a variadic class/function
+template from the library.
+
+workarounds:
+^^^
+
+* Use gcc 5.1.0 or newer.
+* Pass the -fabi-version=6 option to gcc when using versions < 5.1.0.
+
+gcc bug report:
+^^^
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51322
+
+llvm bug report:
+
+https://llvm.org/PR33161
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305401 - [PPC] Enhance altivec conversion function macros implementation.

2017-06-14 Thread Tony Jiang via cfe-commits
Author: jtony
Date: Wed Jun 14 12:23:43 2017
New Revision: 305401

URL: http://llvm.org/viewvc/llvm-project?rev=305401=rev
Log:
[PPC] Enhance altivec conversion function macros implementation.

Add checking for the second parameter of altivec conversion builtin to make sure
it is compile-time constant int.

This patch fixes PR33212: PPC vec_cst useless at -O0
Differential Revision: https://reviews.llvm.org/D34092

Modified:
cfe/trunk/include/clang/Basic/BuiltinsPPC.def
cfe/trunk/test/CodeGen/builtins-ppc-error.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=305401=305400=305401=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Wed Jun 14 12:23:43 2017
@@ -51,10 +51,10 @@ BUILTIN(__builtin_altivec_vavguw, "V4UiV
 
 BUILTIN(__builtin_altivec_vrfip, "V4fV4f", "")
 
-BUILTIN(__builtin_altivec_vcfsx, "V4fV4ii", "")
-BUILTIN(__builtin_altivec_vcfux, "V4fV4ii", "")
-BUILTIN(__builtin_altivec_vctsxs, "V4SiV4fi", "")
-BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fi", "")
+BUILTIN(__builtin_altivec_vcfsx, "V4fV4iIi", "")
+BUILTIN(__builtin_altivec_vcfux, "V4fV4iIi", "")
+BUILTIN(__builtin_altivec_vctsxs, "V4SiV4fIi", "")
+BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fIi", "")
 
 BUILTIN(__builtin_altivec_dss, "vUi", "")
 BUILTIN(__builtin_altivec_dssall, "v", "")

Modified: cfe/trunk/test/CodeGen/builtins-ppc-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-error.c?rev=305401=305400=305401=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-error.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-error.c Wed Jun 14 12:23:43 2017
@@ -11,6 +11,8 @@
 #include 
 
 extern vector signed int vsi;
+extern vector signed int vui;
+extern vector float vf;
 extern vector unsigned char vuc;
 
 void testInsertWord(void) {
@@ -34,3 +36,34 @@ void testXXSLDWI(int index) {
   vec_xxsldwi(1, 2, 3); //expected-error {{first two arguments to 
'__builtin_vsx_xxsldwi' must be vectors}}
   vec_xxsldwi(vsi, vuc, 2); //expected-error {{first two arguments to 
'__builtin_vsx_xxsldwi' must have the same type}}
 }
+
+void testCTF(int index) {
+  vec_ctf(vsi, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}}
+  vec_ctf(vui, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}}
+}
+
+void testVCFSX(int index) {
+  vec_vcfsx(vsi, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}}
+}
+
+void testVCFUX(int index) {
+  vec_vcfux(vui, index); //expected-error {{argument to 
'__builtin_altivec_vcfux' must be a constant integer}}
+}
+
+void testCTS(int index) {
+  vec_cts(vf, index); //expected-error {{argument to 
'__builtin_altivec_vctsxs' must be a constant integer}}
+
+}
+
+void testVCTSXS(int index) {
+  vec_vctsxs(vf, index); //expected-error {{argument to 
'__builtin_altivec_vctsxs' must be a constant integer}}
+}
+
+void testCTU(int index) {
+  vec_ctu(vf, index); //expected-error {{argument to 
'__builtin_altivec_vctuxs' must be a constant integer}}
+
+}
+
+void testVCTUXS(int index) {
+  vec_vctuxs(vf, index); //expected-error {{argument to 
'__builtin_altivec_vctuxs' must be a constant integer}}
+}


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


[PATCH] D34206: [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.

2017-06-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It'll be good idea to run modernize-make-unique on LLVM/Clang/etc for 
llvm::make_unique.


https://reviews.llvm.org/D34206



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


[PATCH] D33644: Add default values for function parameter chunks

2017-06-14 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:2453
 std::string PlaceholderStr = FormatFunctionParameter(Policy, Param);
+if (Param->hasDefaultArg() && PlaceholderStr.find("=") == 
std::string::npos) {
+std::string DefaultValue =

klimek wrote:
> yvvan wrote:
> > klimek wrote:
> > > Why the check for = in the PlaceholderStr?
> > Not to add default value twice. If there's already "=" in placeholder 
> > string that means we've already added it in FormatFunctionParameter call
> In which cases would the default value not be added in 
> FormatFunctionParameter if there is one, and need to be added here?
If Param->evaluateValue() can evaluate it it will set the default value in 
FormatFunctionParameter (that means it's a primitive type like "void func(int i 
= 0)").
In case it's some kind of non-primitive type like "void func(Foo foo = Foo(0, 
0))" it will not be evaluated and we can use here the source manager to get the 
default value string. In this example it will be Foo(0, 0).


https://reviews.llvm.org/D33644



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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-06-14 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya updated this revision to Diff 102566.
hiraditya added a comment.

Addressed comments from Eric.


https://reviews.llvm.org/D30268

Files:
  libcxx/benchmarks/stringstream.bench.cpp
  libcxx/include/__config
  libcxx/include/locale

Index: libcxx/include/locale
===
--- libcxx/include/locale
+++ libcxx/include/locale
@@ -380,19 +380,57 @@
 struct __num_get
 : protected __num_get_base
 {
-static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
 static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
   _CharT& __thousands_sep);
-static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
-  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
 static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
char* __a, char*& __a_end,
_CharT __decimal_point, _CharT __thousands_sep,
const string& __grouping, unsigned* __g,
unsigned*& __g_end, unsigned& __dc, _CharT* __atoms);
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
+static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
+#else
+static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep)
+{
+locale __loc = __iob.getloc();
+const numpunct<_CharT>& __np = use_facet >(__loc);
+__thousands_sep = __np.thousands_sep();
+return __np.grouping();
+}
+
+const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const
+{
+  return __do_widen_p(__iob, __atoms);
+}
+
+
+static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms);
+private:
+template
+const T* __do_widen_p(ios_base& __iob, T* __atoms) const
+{
+  locale __loc = __iob.getloc();
+  use_facet(__loc).widen(__src, __src + 26, __atoms);
+  return __atoms;
+}
+
+const char* __do_widen_p(ios_base& __iob, char* __atoms) const
+{
+  (void)__iob;
+  (void)__atoms;
+  return __src;
+}
+#endif
 };
 
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
 template 
 string
 __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
@@ -403,6 +441,7 @@
 __thousands_sep = __np.thousands_sep();
 return __np.grouping();
 }
+#endif
 
 template 
 string
@@ -419,9 +458,16 @@
 
 template 
 int
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
 __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
   unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
   unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
+#else
+__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
+
+#endif
 {
 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
 {
@@ -857,9 +903,16 @@
 // Stage 1
 int __base = this->__get_base(__iob);
 // Stage 2
-char_type __atoms[26];
 char_type __thousands_sep;
+const int __atoms_size = 26;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+char_type __atoms1[__atoms_size];
+const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
+#else
+char_type __atoms[__atoms_size];
 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+#endif
 string __buf;
 __buf.resize(__buf.capacity());
 char* __a = &__buf[0];
@@ -907,9 +960,16 @@
 // Stage 1
 int __base = this->__get_base(__iob);
 // Stage 2
-char_type __atoms[26];
 char_type __thousands_sep;
+const int __atoms_size = 26;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+char_type __atoms1[__atoms_size];
+const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
+#else
+char_type __atoms[__atoms_size];
 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+#endif
 string 

[PATCH] D34105: Define _GNU_SOURCE for rtems c++

2017-06-14 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305399: Define _GNU_SOURCE for rtems c++ (authored by 
jyknight).

Changed prior to commit:
  https://reviews.llvm.org/D34105?vs=102188=102565#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34105

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8779,6 +8779,7 @@
 // KFREEBSDI686-DEFINE:#define __GLIBC__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-runtime=gcc -E -dM 
< /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s
+// RUN: %clang_cc1 -x c++ -triple sparc-rtems-elf -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix GNUSOURCE %s
 // GNUSOURCE:#define _GNU_SOURCE 1
 //
 // RUN: %clang_cc1 -x c++ -std=c++98 -fno-rtti -E -dM < /dev/null | FileCheck 
-match-full-lines -check-prefix NORTTI %s
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4734,6 +4734,9 @@
 
 Builder.defineMacro("__rtems__");
 Builder.defineMacro("__ELF__");
+// Required by the libc++ locale support.
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
   }
 
 public:


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8779,6 +8779,7 @@
 // KFREEBSDI686-DEFINE:#define __GLIBC__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-runtime=gcc -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s
+// RUN: %clang_cc1 -x c++ -triple sparc-rtems-elf -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s
 // GNUSOURCE:#define _GNU_SOURCE 1
 //
 // RUN: %clang_cc1 -x c++ -std=c++98 -fno-rtti -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix NORTTI %s
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4734,6 +4734,9 @@
 
 Builder.defineMacro("__rtems__");
 Builder.defineMacro("__ELF__");
+// Required by the libc++ locale support.
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
   }
 
 public:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305399 - Define _GNU_SOURCE for rtems c++

2017-06-14 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Wed Jun 14 12:01:18 2017
New Revision: 305399

URL: http://llvm.org/viewvc/llvm-project?rev=305399=rev
Log:
Define _GNU_SOURCE for rtems c++

This is required by the libc++ locale support.

Patch by Walter Lee.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=305399=305398=305399=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jun 14 12:01:18 2017
@@ -4734,6 +4734,9 @@ protected:
 
 Builder.defineMacro("__rtems__");
 Builder.defineMacro("__ELF__");
+// Required by the libc++ locale support.
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
   }
 
 public:

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=305399=305398=305399=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Jun 14 12:01:18 2017
@@ -8779,6 +8779,7 @@
 // KFREEBSDI686-DEFINE:#define __GLIBC__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-runtime=gcc -E -dM 
< /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s
+// RUN: %clang_cc1 -x c++ -triple sparc-rtems-elf -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix GNUSOURCE %s
 // GNUSOURCE:#define _GNU_SOURCE 1
 //
 // RUN: %clang_cc1 -x c++ -std=c++98 -fno-rtti -E -dM < /dev/null | FileCheck 
-match-full-lines -check-prefix NORTTI %s


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


[libcxx] r305397 - In several places in std::allocator (and one in shared_ptr, we were casting a 'const T*' to a 'void *' - implicitly casting away the const. Add const_cast to make that expl

2017-06-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jun 14 11:54:43 2017
New Revision: 305397

URL: http://llvm.org/viewvc/llvm-project?rev=305397=rev
Log:
In several places in std::allocator (and one in shared_ptr, we were 
casting a 'const T*' to a 'void *' - implicitly casting away the const. Add 
const_cast to make that explicit. No functional change.

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=305397=305396=305397=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Jun 14 11:54:43 2017
@@ -1884,7 +1884,7 @@ public:
 return static_cast(_VSTD::__allocate(__n * sizeof(_Tp)));
 }
 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
-{_VSTD::__libcpp_deallocate((void*)__p);}
+{_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p));}
 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
 {return size_type(~0) / sizeof(_Tp);}
 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && 
!defined(_LIBCPP_HAS_NO_VARIADICS)
@@ -1900,7 +1900,7 @@ public:
 void
 construct(pointer __p)
 {
-::new((void*)__p) _Tp();
+::new((void*) const_cast<_Tp *>(__p)) _Tp();
 }
 # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
 
@@ -1909,14 +1909,14 @@ public:
 void
 construct(pointer __p, _A0& __a0)
 {
-::new((void*)__p) _Tp(__a0);
+::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
 }
 template 
 _LIBCPP_INLINE_VISIBILITY
 void
 construct(pointer __p, const _A0& __a0)
 {
-::new((void*)__p) _Tp(__a0);
+::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
 }
 # endif  // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
 template 
@@ -1924,28 +1924,28 @@ public:
 void
 construct(pointer __p, _A0& __a0, _A1& __a1)
 {
-::new((void*)__p) _Tp(__a0, __a1);
+::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
 }
 template 
 _LIBCPP_INLINE_VISIBILITY
 void
 construct(pointer __p, const _A0& __a0, _A1& __a1)
 {
-::new((void*)__p) _Tp(__a0, __a1);
+::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
 }
 template 
 _LIBCPP_INLINE_VISIBILITY
 void
 construct(pointer __p, _A0& __a0, const _A1& __a1)
 {
-::new((void*)__p) _Tp(__a0, __a1);
+::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
 }
 template 
 _LIBCPP_INLINE_VISIBILITY
 void
 construct(pointer __p, const _A0& __a0, const _A1& __a1)
 {
-::new((void*)__p) _Tp(__a0, __a1);
+::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
 }
 #endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && 
!defined(_LIBCPP_HAS_NO_VARIADICS)
 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
@@ -3890,7 +3890,9 @@ public:
 template 
 _LIBCPP_INLINE_VISIBILITY
 _Dp* __get_deleter() const _NOEXCEPT
-{return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 
0);}
+{return static_cast<_Dp*>(__cntrl_
+? const_cast(__cntrl_->__get_deleter(typeid(_Dp))) 
+  : nullptr);}
 #endif  // _LIBCPP_NO_RTTI
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS


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


[libcxx] r305394 - PR32476: __nop_locale_mgmt.h not needed with newlib 2.5+

2017-06-14 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Wed Jun 14 11:40:03 2017
New Revision: 305394

URL: http://llvm.org/viewvc/llvm-project?rev=305394=rev
Log:
PR32476: __nop_locale_mgmt.h not needed with newlib 2.5+

Newlib 2.5 added the locale management functions, so it should not
include __nop_local_mgmt.h. This change adds proper guard around that
include statement.

For newlib 2.4, some releases contain these functions and some don't,
and they all have the same version numbers. This patch will work
properly with the initial "2.4.0" release which does not include these
functions and require __nop_local_mgmt.h.

This has been tested against newlib 2.2 and 2.5, and also sanity
checks against other different version numbers.

Patch by Martin J. O'Riordan and Walter Lee

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

Modified:
libcxx/trunk/include/support/newlib/xlocale.h

Modified: libcxx/trunk/include/support/newlib/xlocale.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/newlib/xlocale.h?rev=305394=305393=305394=diff
==
--- libcxx/trunk/include/support/newlib/xlocale.h (original)
+++ libcxx/trunk/include/support/newlib/xlocale.h Wed Jun 14 11:40:03 2017
@@ -16,7 +16,10 @@
 #include 
 #include 
 #include 
+#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
+__NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
 #include 
+#endif
 #include 
 #include 
 


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


[PATCH] D32146: PR32476: __nop_locale_mgmt.h not needed with newlib 2.5+

2017-06-14 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305394: PR32476: __nop_locale_mgmt.h not needed with newlib 
2.5+ (authored by jyknight).

Changed prior to commit:
  https://reviews.llvm.org/D32146?vs=102265=102562#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32146

Files:
  libcxx/trunk/include/support/newlib/xlocale.h


Index: libcxx/trunk/include/support/newlib/xlocale.h
===
--- libcxx/trunk/include/support/newlib/xlocale.h
+++ libcxx/trunk/include/support/newlib/xlocale.h
@@ -16,7 +16,10 @@
 #include 
 #include 
 #include 
+#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
+__NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
 #include 
+#endif
 #include 
 #include 
 


Index: libcxx/trunk/include/support/newlib/xlocale.h
===
--- libcxx/trunk/include/support/newlib/xlocale.h
+++ libcxx/trunk/include/support/newlib/xlocale.h
@@ -16,7 +16,10 @@
 #include 
 #include 
 #include 
+#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
+__NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
 #include 
+#endif
 #include 
 #include 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34202: [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

LGTM!




Comment at: clang-tidy/readability/FunctionSizeCheck.cpp:58
+// is already nested NestingThreshold levels deep, record the start 
location
+// of this new compound statement
+if (CurrentNestingLevel == Info.NestingThreshold)

Missing full stop.


Repository:
  rL LLVM

https://reviews.llvm.org/D34202



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


[PATCH] D34202: [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D34202#780424, @malcolm.parsons wrote:

> My coding standards require the `{}`, so while I may not agree with your 
> definition of nesting, it doesn't matter.


Well, seeing `readability-deep-nesting.cpp` in the issue, i suppose the 
definition might be adjusted to fit that too, to avoid having more than one 
check doing just slightly different checking...


Repository:
  rL LLVM

https://reviews.llvm.org/D34202



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


[PATCH] D34202: [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

My coding standards require the `{}`, so while I may not agree with your 
definition of nesting, it doesn't matter.


Repository:
  rL LLVM

https://reviews.llvm.org/D34202



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


[PATCH] D34202: [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D34202#780394, @malcolm.parsons wrote:

> What do you expect for this?
>
>   if (true)
>   if (true)
>   if (true) {
>   int j;
>   }
>


that it is equivalent to

  if (true && true && true) { // 1
int j;
  }

This was the intent of that option. There is only one compound statement in 
your example. All the docs say that it counts compound statements
https://github.com/llvm-mirror/clang-tools-extra/blob/9fd3636de8d7034ca4640939fefebd9833ef9ea0/docs/clang-tidy/checks/readability-function-size.rst

  .. option:: NestingThreshold
  
  Flag compound statements ...


Repository:
  rL LLVM

https://reviews.llvm.org/D34202



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


[PATCH] D34211: Implement the non-execution policy versions of `inclusive_scan` and `transform_ inclusive_scan` for C++17

2017-06-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

This is the last of three patches - https://reviews.llvm.org/D33997 and 
https://reviews.llvm.org/D34038 were the first two.
When this lands, we'll have all of the new (non-parallel) algorithms that were 
added in C++17.


https://reviews.llvm.org/D34211

Files:
  include/numeric
  test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp
  test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp
  test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp
  
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
  
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp

Index: test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
+++ test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
@@ -0,0 +1,160 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template
+//   OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result,
+//   BinaryOperation binary_op,
+//   UnaryOperation unary_op,
+//   T init);
+
+
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+struct identity : std::unary_function<_Tp, _Tp>
+{
+constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
+};
+
+template <>
+struct identity
+{
+template 
+constexpr auto operator()(_Tp&& __x) const
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }
+};
+
+template 
+void
+test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
+{
+std::vector::value_type> v;
+//  Test not in-place
+std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop, init);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+
+//  Test in-place
+v.clear();
+v.assign(first, last);
+std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop, init);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+}
+
+
+template 
+void
+test()
+{
+  int ia[] = {  1,  3,   5,7, 9};
+const int pResI0[] = {  1,  4,   9,   16,25};// with identity
+const int mResI0[] = {  0,  0,   0,0, 0};
+const int pResN0[] = { -1, -4,  -9,  -16,   -25};// with negate
+const int mResN0[] = {  0,  0,   0,0, 0};
+const int pResI2[] = {  3,  6,  11,   18,27};// with identity
+const int mResI2[] = {  2,  6,  30,  210,  1890};
+const int pResN2[] = {  1, -2,  -7,  -14,   -23};// with negate
+const int mResN2[] = { -2,  6, -30,  210, -1890};
+const unsigned sa = sizeof(ia) / sizeof(ia[0]);
+static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0]));   // just to be sure
+static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0]));   // just to be sure
+static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0]));   // just to be sure
+static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0]));   // just to be sure
+static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0]));   // just to be sure
+static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0]));   // just to be sure
+static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0]));   // just to be sure
+static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0]));   // just to be sure
+
+for (unsigned int i = 0; i < sa; ++i ) {
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),0, pResI0, pResI0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),0, mResI0, mResI0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, pResN0, pResN0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),2, pResI2, pResI2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),2, mResI2, mResI2 + i);
+test(Iter(ia), Iter(ia + i), 

[PATCH] D34198: Fix __has_trivial_destructor crash when the type is incomplete with unknown array bounds.

2017-06-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Test cases?


https://reviews.llvm.org/D34198



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


[PATCH] D34202: [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

What do you expect for this?

  if (true)
  if (true)
  if (true) {
  int j;
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D34202



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


[PATCH] D34210: Add __has_feature(leak_sanitizer)

2017-06-14 Thread Francis Ricci via Phabricator via cfe-commits
fjricci created this revision.

Stand-alone leak sanitizer builds are supported with -fsanitize=leak,
adds an attribute for consistency with the rest of the sanitizer attributes.


https://reviews.llvm.org/D34210

Files:
  lib/Lex/PPMacroExpansion.cpp
  test/Lexer/has_feature_leak_sanitizer.cpp


Index: test/Lexer/has_feature_leak_sanitizer.cpp
===
--- /dev/null
+++ test/Lexer/has_feature_leak_sanitizer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fsanitize=leak %s -o - | FileCheck 
--check-prefix=CHECK-LSAN %s
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-LSAN %s
+
+#if __has_feature(leak_sanitizer)
+int LeakSanitizerEnabled();
+#else
+int LeakSanitizerDisabled();
+#endif
+
+// CHECK-LSAN: LeakSanitizerEnabled
+// CHECK-NO-LSAN: LeakSanitizerDisabled
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1133,6 +1133,7 @@
   .Case("enumerator_attributes", true)
   .Case("nullability", true)
   .Case("nullability_on_arrays", true)
+  .Case("leak_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Leak))
   .Case("memory_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Memory))
   .Case("thread_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Thread))
   .Case("dataflow_sanitizer", 
LangOpts.Sanitize.has(SanitizerKind::DataFlow))


Index: test/Lexer/has_feature_leak_sanitizer.cpp
===
--- /dev/null
+++ test/Lexer/has_feature_leak_sanitizer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fsanitize=leak %s -o - | FileCheck --check-prefix=CHECK-LSAN %s
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-LSAN %s
+
+#if __has_feature(leak_sanitizer)
+int LeakSanitizerEnabled();
+#else
+int LeakSanitizerDisabled();
+#endif
+
+// CHECK-LSAN: LeakSanitizerEnabled
+// CHECK-NO-LSAN: LeakSanitizerDisabled
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1133,6 +1133,7 @@
   .Case("enumerator_attributes", true)
   .Case("nullability", true)
   .Case("nullability_on_arrays", true)
+  .Case("leak_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Leak))
   .Case("memory_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Memory))
   .Case("thread_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Thread))
   .Case("dataflow_sanitizer", LangOpts.Sanitize.has(SanitizerKind::DataFlow))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33644: Add default values for function parameter chunks

2017-06-14 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:2453
 std::string PlaceholderStr = FormatFunctionParameter(Policy, Param);
+if (Param->hasDefaultArg() && PlaceholderStr.find("=") == 
std::string::npos) {
+std::string DefaultValue =

yvvan wrote:
> klimek wrote:
> > Why the check for = in the PlaceholderStr?
> Not to add default value twice. If there's already "=" in placeholder string 
> that means we've already added it in FormatFunctionParameter call
In which cases would the default value not be added in FormatFunctionParameter 
if there is one, and need to be added here?


https://reviews.llvm.org/D33644



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-06-14 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.

Hello Daniel & Gabor,
Thank you very much for your work. This patch looks good to me but I think such 
a change should also be approved by maintainers.


https://reviews.llvm.org/D30691



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-06-14 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp added a comment.

Thanks for the reviews so far.
I think we have addressed all major concerns regarding this patch:

-(Anna) Scan-build-py integration of the functionality is nearly finished (see 
https://github.com/rizsotto/scan-build/issues/83) (--ctu switch performs both 
analysis phases at once).  This I think could go in a different patch, but 
until we could keep the ctu-build.py and ctu-analyze.py scripts. Do you agree?

-(Devin,NoQ) In the  externalFnMap.txt (which contains which function 
definitions is located where) Unified Symbol Resolution (USR) is used to 
identify functions instead of mangled names, which seems to work equally well 
for C and C++

-(Anna) Dumping the ASTs to the disk. We tried a version where, ASTs are not 
dumped in the 1st phase, but is recreated each time a function definition is 
needed from an external TU. It works fine, but the analysis time went up by 
20-30% on open source C projects. Is it OK to add this functionality in a next 
patch? Or should we it as an optional feature right now?

Do you see anything else that would prevent this patch to get in?


https://reviews.llvm.org/D30691



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


[PATCH] D34055: Be more strict when checking the -flto option value

2017-06-14 Thread Yuka Takahashi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305392: Be more strict when checking the -flto option value 
(authored by yamaguchi).

Changed prior to commit:
  https://reviews.llvm.org/D34055?vs=102551=102555#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34055

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/thinlto-backend-option.ll


Index: cfe/trunk/test/CodeGen/thinlto-backend-option.ll
===
--- cfe/trunk/test/CodeGen/thinlto-backend-option.ll
+++ cfe/trunk/test/CodeGen/thinlto-backend-option.ll
@@ -8,6 +8,8 @@
 
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
-; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s
+; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN
+; UNKNOWN: clang: Unknown command line argument '-nonexistent'
 
-; CHECK: clang: Unknown command line argument '-nonexistent'
+; RUN: not %clang_cc1 -flto=thinfoo 2>&1 | FileCheck %s -check-prefix=INVALID
+; INVALID: error: invalid value 'thinfoo' in '-flto=thinfoo'
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -649,8 +649,14 @@
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.EmitSummaryIndex = false;
+  if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+StringRef S = A->getValue();
+if (S == "thin")
+  Opts.EmitSummaryIndex = true;
+else if (S != "full")
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
+  }
   Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != InputKind::LLVM_IR)


Index: cfe/trunk/test/CodeGen/thinlto-backend-option.ll
===
--- cfe/trunk/test/CodeGen/thinlto-backend-option.ll
+++ cfe/trunk/test/CodeGen/thinlto-backend-option.ll
@@ -8,6 +8,8 @@
 
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
-; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s
+; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN
+; UNKNOWN: clang: Unknown command line argument '-nonexistent'
 
-; CHECK: clang: Unknown command line argument '-nonexistent'
+; RUN: not %clang_cc1 -flto=thinfoo 2>&1 | FileCheck %s -check-prefix=INVALID
+; INVALID: error: invalid value 'thinfoo' in '-flto=thinfoo'
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -649,8 +649,14 @@
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.EmitSummaryIndex = false;
+  if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+StringRef S = A->getValue();
+if (S == "thin")
+  Opts.EmitSummaryIndex = true;
+else if (S != "full")
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
+  }
   Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != InputKind::LLVM_IR)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305392 - Be more strict when checking the -flto option value

2017-06-14 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Wed Jun 14 10:37:11 2017
New Revision: 305392

URL: http://llvm.org/viewvc/llvm-project?rev=305392=rev
Log:
Be more strict when checking the -flto option value

Summary:
It seems -flto must be either "thin" or "full". I think the use of
containValue is just a typo.

Reviewers: ruiu, tejohnson

Subscribers: mehdi_amini, inglorion

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

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/thinlto-backend-option.ll

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=305392=305391=305392=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jun 14 10:37:11 2017
@@ -649,8 +649,14 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.EmitSummaryIndex = false;
+  if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+StringRef S = A->getValue();
+if (S == "thin")
+  Opts.EmitSummaryIndex = true;
+else if (S != "full")
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
+  }
   Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != InputKind::LLVM_IR)

Modified: cfe/trunk/test/CodeGen/thinlto-backend-option.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-backend-option.ll?rev=305392=305391=305392=diff
==
--- cfe/trunk/test/CodeGen/thinlto-backend-option.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-backend-option.ll Wed Jun 14 10:37:11 2017
@@ -8,6 +8,8 @@
 
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
-; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s
+; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN
+; UNKNOWN: clang: Unknown command line argument '-nonexistent'
 
-; CHECK: clang: Unknown command line argument '-nonexistent'
+; RUN: not %clang_cc1 -flto=thinfoo 2>&1 | FileCheck %s -check-prefix=INVALID
+; INVALID: error: invalid value 'thinfoo' in '-flto=thinfoo'


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


[PATCH] D34121: [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-06-14 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:3010
+return CGF.EmitCheckedInBoundsGEP(ptr, indices, signedIndices,
+  /*IsSubtraction=*/false, loc, name);
   } else {

Might want to define an

`enum { NotSubtraction = false, IsSubtraction = true }` in the header. We do 
this in other places.


https://reviews.llvm.org/D34121



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


[PATCH] D34206: [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.

2017-06-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: xazax.hun.

https://reviews.llvm.org/D34206

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  docs/clang-tidy/checks/modernize-make-shared.rst
  docs/clang-tidy/checks/modernize-make-unique.rst


Index: docs/clang-tidy/checks/modernize-make-unique.rst
===
--- docs/clang-tidy/checks/modernize-make-unique.rst
+++ docs/clang-tidy/checks/modernize-make-unique.rst
@@ -25,3 +25,11 @@
   // becomes
 
   my_ptr = std::make_unique(1, 2);
+
+Options
+---
+
+.. option:: MakeSmartPtrFunction
+
+   A string specifying the name of make-unique-ptr function. Default is
+   `std::make_unique`.
Index: docs/clang-tidy/checks/modernize-make-shared.rst
===
--- docs/clang-tidy/checks/modernize-make-shared.rst
+++ docs/clang-tidy/checks/modernize-make-shared.rst
@@ -25,3 +25,11 @@
   // becomes
 
   my_ptr = std::make_shared(1, 2);
+
+Options
+---
+
+.. option:: MakeSmartPtrFunction
+
+   A string specifying the name of make-shared-ptr function. Default is
+   `std::make_shared`.
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -24,9 +24,10 @@
 class MakeSmartPtrCheck : public ClangTidyCheck {
 public:
   MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
-std::string makeSmartPtrFunctionName);
+StringRef makeSmartPtrFunctionName);
   void registerMatchers(ast_matchers::MatchFinder *Finder) final;
   void check(const ast_matchers::MatchFinder::MatchResult ) final;
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
 
 protected:
   using SmartPtrTypeMatcher = 
ast_matchers::internal::BindableMatcher;
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -21,10 +21,17 @@
 const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
 const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
-MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
- std::string makeSmartPtrFunctionName)
+MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
+ ClangTidyContext* Context,
+ StringRef makeSmartPtrFunctionName)
 : ClangTidyCheck(Name, Context),
-  makeSmartPtrFunctionName(std::move(makeSmartPtrFunctionName)) {}
+  makeSmartPtrFunctionName(
+  Options.get("MakeSmartPtrFunction", makeSmartPtrFunctionName)) {}
+
+void MakeSmartPtrCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "MakeSmartPtrFunction", makeSmartPtrFunctionName);
+}
 
 void MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus11)


Index: docs/clang-tidy/checks/modernize-make-unique.rst
===
--- docs/clang-tidy/checks/modernize-make-unique.rst
+++ docs/clang-tidy/checks/modernize-make-unique.rst
@@ -25,3 +25,11 @@
   // becomes
 
   my_ptr = std::make_unique(1, 2);
+
+Options
+---
+
+.. option:: MakeSmartPtrFunction
+
+   A string specifying the name of make-unique-ptr function. Default is
+   `std::make_unique`.
Index: docs/clang-tidy/checks/modernize-make-shared.rst
===
--- docs/clang-tidy/checks/modernize-make-shared.rst
+++ docs/clang-tidy/checks/modernize-make-shared.rst
@@ -25,3 +25,11 @@
   // becomes
 
   my_ptr = std::make_shared(1, 2);
+
+Options
+---
+
+.. option:: MakeSmartPtrFunction
+
+   A string specifying the name of make-shared-ptr function. Default is
+   `std::make_shared`.
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -24,9 +24,10 @@
 class MakeSmartPtrCheck : public ClangTidyCheck {
 public:
   MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,
-std::string makeSmartPtrFunctionName);
+StringRef makeSmartPtrFunctionName);
   void registerMatchers(ast_matchers::MatchFinder *Finder) final;
   void check(const ast_matchers::MatchFinder::MatchResult ) final;
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
 
 protected:
   using SmartPtrTypeMatcher = ast_matchers::internal::BindableMatcher;
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ 

[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:28
+   hasParameter(1, hasType(isInteger())),
+   hasAnyName("open", "open64"))
+  .bind("funcDecl")))

I'd put the `hasAnyName` matcher in front of `hasParameter` which follows the 
order of function declaration.

The same below.



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:46
+  const Expr *FlagArg;
+  if ((MatchedCall = Result.Nodes.getNodeAs("openFn")))
+FlagArg = MatchedCall->getArg(1);

How about 

```
const Expr *FlagArg = nullptr;
if (const auto* OpenFnCall = Result.Nodes.getXXX()) {
  // ...
} else if (const auto* OpenAtFnCall = Result.Nodes.getXX()) {
  // ...
}
assert(FlagArg);
```
? 



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:61
+  SourceLocation EndLoc =
+  Lexer::getLocForEndOfToken(FlagArg->getLocEnd(), 0, SM, getLangOpts());
+

Instead of using getLangOpts(), you should use `Result.Context.getLangOpts()`.



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:67
+
+bool FileOpenFlagCheck::checkFlags(const Expr *Flags, const SourceManager ) 
{
+  bool IsFlagIn;

No need to be a class member method, put it inside this translation unit. 



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:79
+std::pair ExpansionInfo = SM.getDecomposedLoc(Loc);
+auto MacroName =
+SM.getBufferData(ExpansionInfo.first)

You could use `Lexer::getImmediateMacroName(Loc, SM, Opts);` to get the marco 
name, or doesn't it work here?



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:84
+
+IsFlagIn = (MacroName == "O_CLOEXEC");
+

I think you can use early return here. With that you don't need to maintain the 
flag variable `IsFlagIn`, so the code structure like:

```
if (isa<..>) {
   
return ...;
}

if (isa()) {
// ...
return ...;
}
retrun false;
```



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:88
+  // If it's a binary OR operation.
+  else if ((isa(Flags)) &&
+   (cast(Flags)->getOpcode() ==

You can use `if (const auto* BO = dyn_cast(Flags))`, so that 
you don't call `cast(Flags)` multiple times below.



Comment at: test/clang-tidy/android-file-open-flag.cpp:76
+void e() {
+  open("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:

I would add tests where `O_CLOEXEC` is not at the end of parameter 2 expression 
like `open("filename", O_RDWR |  O_CLOEXEC | O_EXCL)`.


https://reviews.llvm.org/D33304



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


[PATCH] D34055: Be more strict when checking the -flto option value

2017-06-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the fix!


https://reviews.llvm.org/D34055



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


[PATCH] D32146: PR32476: __nop_locale_mgmt.h not needed with newlib 2.5+

2017-06-14 Thread Walter Lee via Phabricator via cfe-commits
waltl added a comment.

In https://reviews.llvm.org/D32146#780231, @bcraig wrote:

> LGTM.
>  @waltl : Do you need me to submit the changes, or will you handle that?


Thanks -- I think jyknight will handle it.


https://reviews.llvm.org/D32146



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


Re: [clang-tools-extra] r303735 - Modify test so that it looks for patterns in stderr as well

2017-06-14 Thread Serge Pavlov via cfe-commits
2017-06-14 4:24 GMT+07:00 David Blaikie :

> Ah, I find that the test passes if I remove the compile_commands.json file
> from my build directory (I have Ninja configured to generate a
> compile_commands.json file).
>
> Looks like what happens is it finds the compilation database and fails
> hard when the database doesn't contain a compile command for the file in
> question. If the database is not found, it falls back to some basic command
> behavior, perhaps?
>
>
You are right, constructor of `CommonOptionsParser` calls
`autoDetectFromSource` or `autoDetectFromDirectory` prior to final
construction of `FixedCompilationDatabase.

Is there some way this test could be fixed to cope with this, otherwise it
> seems to get in the way of people actually using clang tools in their
> LLVM/Clang build environment?
>
>
IIUC, presence of stale compilation database file in test directory could
break many tests. I don't understand why only diagnostic.cpp fails,
probably there is something wrong with the clang-tidy application cleanup
in this case?


> On Tue, Jun 13, 2017 at 7:41 AM Serge Pavlov  wrote:
>
>> I cannot reproduce such fail, so I can only guess how changes made in
>> https://reviews.llvm.org/rL303756 and https://reviews.llvm.org/rL303741
>> could cause such problem. Behavior of `Driver::BuildCompilation` is changed
>> so that it returns null pointer if errors occur during driver argument
>> parse. It is called in `CompilationDatabase.cpp` from
>> `stripPositionalArgs`. The call stack at this point is:
>> stripPositionalArgs
>> clang::tooling::FixedCompilationDatabase::loadFromCommandLine
>> clang::tooling::CommonOptionsParser::CommonOptionsParser
>> clang::tidy::clangTidyMain
>> main
>> `FixedCompilationDatabase::loadFromCommandLine` returns null and
>> CommonOptionsParser uses another method to create compilation database. The
>> output "Compile command not found" means that no input file were found in
>> `ClangTool::run`. Maybe some file names are nulls?
>>
>>
>> Thanks,
>> --Serge
>>
>> 2017-06-13 3:42 GMT+07:00 David Blaikie :
>>
>>> I've been seeing errors from this test recently:
>>>
>>> Command Output (stderr):
>>> --
>>> 1 error generated.
>>> Error while processing /usr/local/google/home/blaikie
>>> /dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/
>>> diagnostic.cpp.nonexistent.cpp.
>>> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/
>>> tools/extra/test/clang-tidy/diagnostic.cpp:10:12: error: expected
>>> string not found in input
>>> // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to
>>> 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
>>>^
>>> :2:1: note: scanning from here
>>> Skipping /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/
>>> tools/extra/test/clang-tidy/diagnostic.cpp. Compile command not found.
>>> ^
>>> :2:1: note: with expression "@LINE+2" equal to "12"
>>> Skipping /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/
>>> tools/extra/test/clang-tidy/diagnostic.cpp. Compile command not found.
>>> ^
>>>
>>>
>>> Specifically, the output is:
>>> $ ./bin/clang-tidy 
>>> -checks='-*,clang-diagnostic-*,google-explicit-constructor'
>>> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/
>>> tools/extra/test/clang-tidy/diagnostic.cpp -- -fan-unknown-option 2>&1
>>>error: unknown argument: '-fan-unknown-option'
>>>
>>>Skipping /usr/local/google/home/blaikie
>>> /dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp.
>>> Compile command not found.
>>>
>>>
>>> Does this look like it might be related to any of your changes in this
>>> area? Perhaps the error due to unknown argument is causing clang-tidy not
>>> to continue on to run the check & report the warning?
>>>
>>>
>>> On Wed, May 24, 2017 at 3:51 AM Serge Pavlov via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: sepavloff
 Date: Wed May 24 05:50:56 2017
 New Revision: 303735

 URL: http://llvm.org/viewvc/llvm-project?rev=303735=rev
 Log:
 Modify test so that it looks for patterns in stderr as well

 With the change https://reviews.llvm.org/D33013 driver will not build
 compilation object if command line is invalid, in particular, if
 unrecognized option is provided. In such cases it will prints
 diagnostics
 on stderr. The test 'clang-tidy/diagnostic.cpp' checks reaction on
 unrecognized option and will fail when D33013 is applied because it
 checks
 only stdout for test patterns and expects the name of diagnostic
 category
 prepared by clang-tidy. With this change the test makes more general
 check
 and must work in either case.

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

 Modified:
 clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp

 Modified: 

[PATCH] D34055: Be more strict when checking the -flto option value

2017-06-14 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 102551.
yamaguchi added a comment.
Herald added a subscriber: eraman.

Update patch. Add testcase and check if argument is valid or not.


https://reviews.llvm.org/D34055

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/thinlto-backend-option.ll


Index: clang/test/CodeGen/thinlto-backend-option.ll
===
--- clang/test/CodeGen/thinlto-backend-option.ll
+++ clang/test/CodeGen/thinlto-backend-option.ll
@@ -8,6 +8,8 @@
 
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
-; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s
+; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN
+; UNKNOWN: clang: Unknown command line argument '-nonexistent'
 
-; CHECK: clang: Unknown command line argument '-nonexistent'
+; RUN: not %clang_cc1 -flto=thinfoo 2>&1 | FileCheck %s -check-prefix=INVALID
+; INVALID: error: invalid value 'thinfoo' in '-flto=thinfoo' 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -649,8 +649,14 @@
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.EmitSummaryIndex = false;
+  if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+StringRef S = A->getValue();
+if (S == "thin")
+  Opts.EmitSummaryIndex = true;
+else if (S != "full")
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
+  }
   Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != InputKind::LLVM_IR)


Index: clang/test/CodeGen/thinlto-backend-option.ll
===
--- clang/test/CodeGen/thinlto-backend-option.ll
+++ clang/test/CodeGen/thinlto-backend-option.ll
@@ -8,6 +8,8 @@
 
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
-; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s
+; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN
+; UNKNOWN: clang: Unknown command line argument '-nonexistent'
 
-; CHECK: clang: Unknown command line argument '-nonexistent'
+; RUN: not %clang_cc1 -flto=thinfoo 2>&1 | FileCheck %s -check-prefix=INVALID
+; INVALID: error: invalid value 'thinfoo' in '-flto=thinfoo' 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -649,8 +649,14 @@
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.EmitSummaryIndex = false;
+  if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+StringRef S = A->getValue();
+if (S == "thin")
+  Opts.EmitSummaryIndex = true;
+else if (S != "full")
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
+  }
   Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != InputKind::LLVM_IR)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34202: [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 102548.
lebedev.ri added a comment.

Simplify it even further by moving the logic into it's proper place - 
`TraverseCompoundStmt()`


Repository:
  rL LLVM

https://reviews.llvm.org/D34202

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  test/clang-tidy/readability-function-size.cpp

Index: test/clang-tidy/readability-function-size.cpp
===
--- test/clang-tidy/readability-function-size.cpp
+++ test/clang-tidy/readability-function-size.cpp
@@ -63,8 +63,9 @@
 #define macro() {int x; {int y; {int z;}}}
 
 void baz0() { // 1
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 9 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
 int b;
@@ -87,5 +88,55 @@
   }
   macro()
 // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
-// CHECK-MESSAGES: :[[@LINE-27]]:25: note: expanded from macro 'macro'
+// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+}
+
+// check that nested if's are not reported. this was broken initially
+void nesting_if() { // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
+  if (true) { // 2
+ int j;
+  } else if (true) { // 2
+ int j;
+ if (true) { // 3
+   // CHECK-MESSAGES: :[[@LINE-1]]:16: note: nesting level 3 starts here (threshold 2)
+   int j;
+ }
+  } else if (true) { // 2
+ int j;
+ if (true) { // 3
+   // CHECK-MESSAGES: :[[@LINE-1]]:16: note: nesting level 3 starts here (threshold 2)
+   int j;
+ }
+  } else if (true) { // 2
+ int j;
+  }
+}
+
+// however this should warn
+void bad_if_nesting() { // 1
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
+// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
+  if (true) {// 2
+int j;
+  } else { // 2
+if (true) { // 3
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: note: nesting level 3 starts here (threshold 2)
+  int j;
+} else { // 3
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: note: nesting level 3 starts here (threshold 2)
+  if (true) { // 4
+int j;
+  } else { // 4
+if (true) { // 5
+  int j;
+}
+  }
+}
+  }
 }
Index: clang-tidy/readability/FunctionSizeCheck.cpp
===
--- clang-tidy/readability/FunctionSizeCheck.cpp
+++ clang-tidy/readability/FunctionSizeCheck.cpp
@@ -36,15 +36,8 @@
 case Stmt::ForStmtClass:
 case Stmt::SwitchStmtClass:
   ++Info.Branches;
-// fallthrough
+  LLVM_FALLTHROUGH;
 case Stmt::CompoundStmtClass:
-  // If this new compound statement is located in a compound statement,
-  // which is already nested NestingThreshold levels deep, record the start
-  // location of this new compound statement
-  if (CurrentNestingLevel == Info.NestingThreshold)
-Info.NestingThresholders.push_back(Node->getLocStart());
-
-  ++CurrentNestingLevel;
   TrackedParent.push_back(true);
   break;
 default:
@@ -54,13 +47,25 @@
 
 Base::TraverseStmt(Node);
 
-if (TrackedParent.back())
-  --CurrentNestingLevel;
 TrackedParent.pop_back();
 
 return true;
   }
 
+  bool TraverseCompoundStmt(CompoundStmt *Node) {
+// If this new compound statement is located in a compound statement, which
+// is already nested NestingThreshold levels deep, record the start location
+// of this new compound statement
+if (CurrentNestingLevel == Info.NestingThreshold)
+  Info.NestingThresholders.push_back(Node->getLocStart());
+
+++CurrentNestingLevel;
+Base::TraverseCompoundStmt(Node);
+--CurrentNestingLevel;
+
+return true;
+  }
+
   bool TraverseDecl(Decl *Node) {
 TrackedParent.push_back(false);
 Base::TraverseDecl(Node);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33644: Add default values for function parameter chunks

2017-06-14 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:2411-2417
+  const SourceLocation StartLoc = SrcRange.getBegin();
+  const SourceLocation EndLoc = SrcRange.getEnd();
+  if (StartLoc != SM.getExpansionLoc(StartLoc) || EndLoc != 
SM.getExpansionLoc(EndLoc))
+  return "";
+  const size_t PtrDiff = EndLoc.getRawEncoding() - StartLoc.getRawEncoding()
+  + Lexer::MeasureTokenLength(EndLoc, SM, LangOpts);
+  return std::string{SM.getCharacterData(StartLoc), PtrDiff};

klimek wrote:
> Can you use Lexer::getSourceText instead?
If that does the same i will use it in the next diff update



Comment at: lib/Sema/SemaCodeComplete.cpp:2453
 std::string PlaceholderStr = FormatFunctionParameter(Policy, Param);
+if (Param->hasDefaultArg() && PlaceholderStr.find("=") == 
std::string::npos) {
+std::string DefaultValue =

klimek wrote:
> Why the check for = in the PlaceholderStr?
Not to add default value twice. If there's already "=" in placeholder string 
that means we've already added it in FormatFunctionParameter call


https://reviews.llvm.org/D33644



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


[PATCH] D33719: Add _Float16 as a C/C++ source language type

2017-06-14 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 102543.
SjoerdMeijer added a comment.

Float16 is added as a native type. Implementing it as some sort of alias to 
fp16 caused too many type issues in expression/literals/etc., and thus was not 
an easier first step, and also in the end we want it to be a native type 
anyway. The tests have been restructured, and now also x86 is tested. It turned 
out I needed a helper function isFloat16Ty, for which I created llvm patch 
https://reviews.llvm.org/D34205.


https://reviews.llvm.org/D33719

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Type.h
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Lex/LiteralSupport.h
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Format/FormatToken.cpp
  lib/Index/USRGeneration.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/CodeGenCXX/float16-declarations.cpp
  test/Lexer/half-literal.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -52,6 +52,7 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
 BTCASE(Overload);
@@ -490,7 +491,7 @@
 TKIND(Char_U);
 TKIND(UChar);
 TKIND(Char16);
-TKIND(Char32);  
+TKIND(Char32);
 TKIND(UShort);
 TKIND(UInt);
 TKIND(ULong);
@@ -508,6 +509,7 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
 TKIND(Overload);
Index: test/Lexer/half-literal.cpp
===
--- test/Lexer/half-literal.cpp
+++ test/Lexer/half-literal.cpp
@@ -1,3 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
 float a = 1.0h; // expected-error{{invalid suffix 'h' on floating constant}}
 float b = 1.0H; // expected-error{{invalid suffix 'H' on floating constant}}
+
+_Float16 c = 1.f166; // expected-error{{invalid suffix 'f166' on floating constant}}
+_Float16 d = 1.f1;   // expected-error{{invalid suffix 'f1' on floating constant}}
Index: test/CodeGenCXX/float16-declarations.cpp
===
--- /dev/null
+++ test/CodeGenCXX/float16-declarations.cpp
@@ -0,0 +1,132 @@
+// RUN: %clang -std=c++11 --target=aarch64-arm--eabi -S -emit-llvm %s -o - | FileCheck %s  --check-prefix=CHECK --check-prefix=CHECK-AARCH64
+// RUN: %clang -std=c++11 --target=x86_64 -S -emit-llvm %s -o - | FileCheck %s  --check-prefix=CHECK --check-prefix=CHECK-X86
+
+/*  Various contexts where type _Float16 can appear. */
+
+
+/*  Namespace */
+
+namespace {
+  _Float16 f1n;
+// CHECK-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global half 0xH, align 2
+
+  _Float16 f2n = 33.f16;
+// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global half 0xH5020, align 2
+// CHECK-X86-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global i16 20512, align 2
+
+  _Float16 arr1n[10];
+// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 2
+// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 16
+
+  _Float16 arr2n[] = { 1.2, 3.0, 3.e4 };
+// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x half] [half 0xH3CCD, half 0xH4200, half 0xH7753], align 2
+// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x i16] [i16 15565, i16 16896, i16 30547], align 2
+
+  const volatile _Float16 func1n(const _Float16 ) {
+return arg + f2n + arr1n[4] - arr2n[1];
+  }
+}
+
+
+/* File */
+
+_Float16 f1f;
+// CHECK-AARCH64-DAG: @f1f = global half 0xH, align 2
+// CHECK-X86-DAG: @f1f = global half 0xH, align 2
+
+_Float16 f2f = 32.4;
+// CHECK-AARCH64-DAG: @f2f = global half 0xH500D, align 2
+// CHECK-X86-DAG: @f2f = global i16 20493, align 2
+
+_Float16 arr1f[10];
+// CHECK-AARCH64-DAG: @arr1f = global [10 x half] zeroinitializer, align 2
+// CHECK-X86-DAG: @arr1f = global [10 x half] zeroinitializer, align 16
+
+_Float16 arr2f[] = { -1.2, -3.0, -3.e4 };
+// CHECK-AARCH64-DAG: @arr2f = global [3 x half] [half 0xHBCCD, half 

  1   2   >