r275154 - [MS ABI] Support throwing/catching __unaligned types

2016-07-11 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Jul 11 23:42:50 2016
New Revision: 275154

URL: http://llvm.org/viewvc/llvm-project?rev=275154=rev
Log:
[MS ABI] Support throwing/catching __unaligned types

We need to mark the appropriate bits in ThrowInfo and HandlerType so
that the personality routine can correctly handle qualification
conversions.

Modified:
cfe/trunk/include/clang/AST/Mangle.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp

Modified: cfe/trunk/include/clang/AST/Mangle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=275154=275153=275154=diff
==
--- cfe/trunk/include/clang/AST/Mangle.h (original)
+++ cfe/trunk/include/clang/AST/Mangle.h Mon Jul 11 23:42:50 2016
@@ -208,7 +208,8 @@ public:
raw_ostream ) = 0;
 
   virtual void mangleCXXThrowInfo(QualType T, bool IsConst, bool IsVolatile,
-  uint32_t NumEntries, raw_ostream ) = 0;
+  bool IsUnaligned, uint32_t NumEntries,
+  raw_ostream ) = 0;
 
   virtual void mangleCXXCatchableTypeArray(QualType T, uint32_t NumEntries,
raw_ostream ) = 0;

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=275154=275153=275154=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Jul 11 23:42:50 2016
@@ -153,7 +153,8 @@ public:
const CXXRecordDecl *DstRD,
raw_ostream ) override;
   void mangleCXXThrowInfo(QualType T, bool IsConst, bool IsVolatile,
-  uint32_t NumEntries, raw_ostream ) override;
+  bool IsUnaligned, uint32_t NumEntries,
+  raw_ostream ) override;
   void mangleCXXCatchableTypeArray(QualType T, uint32_t NumEntries,
raw_ostream ) override;
   void mangleCXXCatchableType(QualType T, const CXXConstructorDecl *CD,
@@ -2654,9 +2655,9 @@ void MicrosoftMangleContextImpl::mangleC
   Mangler.mangleName(DstRD);
 }
 
-void MicrosoftMangleContextImpl::mangleCXXThrowInfo(QualType T,
-bool IsConst,
+void MicrosoftMangleContextImpl::mangleCXXThrowInfo(QualType T, bool IsConst,
 bool IsVolatile,
+bool IsUnaligned,
 uint32_t NumEntries,
 raw_ostream ) {
   msvc_hashing_ostream MHO(Out);
@@ -2666,6 +2667,8 @@ void MicrosoftMangleContextImpl::mangleC
 Mangler.getStream() << 'C';
   if (IsVolatile)
 Mangler.getStream() << 'V';
+  if (IsUnaligned)
+Mangler.getStream() << 'U';
   Mangler.getStream() << NumEntries;
   Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
 }

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=275154=275153=275154=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Mon Jul 11 23:42:50 2016
@@ -3639,7 +3639,8 @@ MSRTTIBuilder::getCompleteObjectLocator(
 }
 
 static QualType decomposeTypeForEH(ASTContext , QualType T,
-   bool , bool ) {
+   bool , bool ,
+   bool ) {
   T = Context.getExceptionObjectType(T);
 
   // C++14 [except.handle]p3:
@@ -3649,10 +3650,12 @@ static QualType decomposeTypeForEH(ASTCo
   // - a qualification conversion
   IsConst = false;
   IsVolatile = false;
+  IsUnaligned = false;
   QualType PointeeType = T->getPointeeType();
   if (!PointeeType.isNull()) {
 IsConst = PointeeType.isConstQualified();
 IsVolatile = PointeeType.isVolatileQualified();
+IsUnaligned = PointeeType.getQualifiers().hasUnaligned();
   }
 
   // Member pointer types like "const int A::*" are represented by having RTTI
@@ -3675,8 +3678,9 @@ MicrosoftCXXABI::getAddrOfCXXCatchHandle
   // TypeDescriptors for exceptions never have qualified pointer types,
   // qualifiers are stored seperately in order to support qualification
   // conversions.
-  bool IsConst, IsVolatile;
-  Type = decomposeTypeForEH(getContext(), Type, IsConst, IsVolatile);
+  bool IsConst, IsVolatile, IsUnaligned;
+  Type =
+  decomposeTypeForEH(getContext(), Type, IsConst, 

Re: [PATCH] D22242: [analyzer] De-duplicate some code for discovering the origin of the symbol.

2016-07-11 Thread Anna Zaks via cfe-commits
zaks.anna added a subscriber: zaks.anna.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h:81
@@ -78,2 +80,3 @@
   unsigned computeComplexity() const;
+  const MemRegion *getOriginRegion() const;
 };

Please, add a doxygen style comment.


http://reviews.llvm.org/D22242



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


Re: [PATCH] D22073: libc++: test lock-free atomic alignment

2016-07-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

- The test should be moved to `test/libcxx/atomics/atomics.align` since it's 
libc++ specific.
- Please give the anonymous struct declarations unique names. `T1`, `T2`, ..., 
`TN` is fine. Currently they all mangle to `main::type` in diagnostic output.
- The test fails to link on my machine unless I manually links `-latomic`. The 
tests currently don't link `-latomic` and I don't want to turn it on by 
default. I'll try and fix this.


http://reviews.llvm.org/D22073



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


Re: [PATCH] D22255: [libcxx] Create __is_alloc_constructible<Alloc, Type, Args...> trait which checks the validity of allocator_traits construction.

2016-07-11 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 63636.
EricWF added a comment.

Add correct tests.


http://reviews.llvm.org/D22255

Files:
  include/memory
  include/type_traits
  include/vector
  
test/libcxx/utilities/memory/allocator.traits/__is_alloc_constructible.pass.cpp
  test/std/containers/sequences/vector/tagging_allocator_instantiation.pass.cpp
  test/support/tagging_allocator.hpp

Index: test/support/tagging_allocator.hpp
===
--- /dev/null
+++ test/support/tagging_allocator.hpp
@@ -0,0 +1,125 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+#ifndef TAGGING_ALLOCATOR_HPP
+#define TAGGING_ALLOCATOR_HPP
+
+# include 
+# include 
+# include 
+
+#include "test_macros.h"
+struct Tag { };
+
+template
+  class TaggingAllocator
+  {
+  public:
+using value_type = T;
+
+TaggingAllocator() = default;
+
+template
+  TaggingAllocator(const TaggingAllocator&) { }
+
+T*
+allocate(std::size_t n) { return std::allocator{}.allocate(n); }
+
+void
+deallocate(T* p, std::size_t n) { std::allocator{}.deallocate(p, n); }
+
+template
+
+  auto construct(U* p, Args&&... args) ->
+decltype((void)::new((void*)p) U(Tag{}, std::forward(args)...))
+  { ::new((void*)p) U(Tag{}, std::forward(args)...); }
+
+template
+auto destroy(U* p) -> decltype((void)p->~U()) { p->~U(); }
+  };
+
+template
+  bool
+  operator==(const TaggingAllocator&, const TaggingAllocator&)
+  { return true; }
+
+template
+  bool
+  operator!=(const TaggingAllocator&, const TaggingAllocator&)
+  { return false; }
+
+template 
+struct TaggedValueType
+{
+  // All constructors must be passed the Tag type.
+
+  // DefaultInsertable into vector,
+  explicit TaggedValueType(Tag) { }
+  // CopyInsertable into vector,
+  TaggedValueType(Tag, const TaggedValueType&) { }
+  // MoveInsertable into vector, and
+  TaggedValueType(Tag, TaggedValueType&&) { }
+
+  // EmplaceConstructible into vector from args.
+  explicit TaggedValueType(Tag, Args...) { }
+
+  // not DefaultConstructible, CopyConstructible or MoveConstructible.
+  TaggedValueType() = delete;
+  TaggedValueType(const TaggedValueType&) = delete;
+  TaggedValueType(TaggedValueType&&) = delete;
+
+  // CopyAssignable.
+  TaggedValueType& operator=(const TaggedValueType&) { return *this; }
+
+  // MoveAssignable.
+  TaggedValueType& operator=(TaggedValueType&&) { return *this; }
+
+private:
+  // Not Destructible.
+  ~TaggedValueType() { }
+
+  // Erasable from vector.
+  template 
+  friend class TaggingAllocator;
+};
+
+
+template <>
+struct TaggedValueType<>
+{
+  // All constructors must be passed the Tag type.
+
+  // DefaultInsertable into vector,
+  explicit TaggedValueType(Tag) { }
+  // CopyInsertable into vector,
+  TaggedValueType(Tag, const TaggedValueType&) { }
+  // MoveInsertable into vector, and
+  TaggedValueType(Tag, TaggedValueType&&) { }
+
+  // not DefaultConstructible, CopyConstructible or MoveConstructible.
+  TaggedValueType() = delete;
+  TaggedValueType(const TaggedValueType&) = delete;
+  TaggedValueType(TaggedValueType&&) = delete;
+
+  // CopyAssignable.
+  TaggedValueType& operator=(const TaggedValueType&) { return *this; }
+
+  // MoveAssignable.
+  TaggedValueType& operator=(TaggedValueType&&) { return *this; }
+
+private:
+  // Not Destructible.
+  ~TaggedValueType() { }
+
+  // Erasable from vector.
+  template 
+  friend class TaggingAllocator;
+};
+
+#endif /* TAGGING_ALLOCATOR_HPP */
Index: test/std/containers/sequences/vector/tagging_allocator_instantiation.pass.cpp
===
--- /dev/null
+++ test/std/containers/sequences/vector/tagging_allocator_instantiation.pass.cpp
@@ -0,0 +1,28 @@
+//===--===//
+//
+// 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
+
+// 
+
+#include 
+#include "tagging_allocator.hpp"
+
+using VT = TaggedValueType;
+using Alloc = TaggingAllocator;
+
+template class std::vector;
+
+int main() {
+  std::vector v;
+  v.reserve(3);
+  v.emplace_back();
+  v.emplace(v.begin());
+  v.emplace(v.begin(), 1, 2, 3);
+}
\ No 

Re: [PATCH] D22255: [libcxx] Create __is_alloc_constructible<Alloc, Type, Args...> trait which checks the validity of allocator_traits construction.

2016-07-11 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 63635.
EricWF added a comment.

- Don't use `is_constructible` in the `__is_alloc_constructible` 
implementation. `is_constructible` requires  `is_destructible`, but 
that isn't required within allocators.  Instead this trait checks the validity 
of the placement new expression.

- Add tests for `__is_alloc_constructible`. Not complete but a good start.

- Implement sample changes to `` that fix PR28412 
(https://llvm.org/bugs/show_bug.cgi?id=28412). See 
`tagging_allocator_instantation.pass.cpp` for the example test.


http://reviews.llvm.org/D22255

Files:
  include/memory
  include/type_traits
  include/vector
  
test/libcxx/utilities/memory/allocator.traits/__is_alloc_constructible.pass.cpp
  test/libcxx/utilities/memory/allocator.traits/vector_instant.pass.cpp
  test/support/tagging_allocator.hpp

Index: test/support/tagging_allocator.hpp
===
--- /dev/null
+++ test/support/tagging_allocator.hpp
@@ -0,0 +1,125 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+#ifndef TAGGING_ALLOCATOR_HPP
+#define TAGGING_ALLOCATOR_HPP
+
+# include 
+# include 
+# include 
+
+#include "test_macros.h"
+struct Tag { };
+
+template
+  class TaggingAllocator
+  {
+  public:
+using value_type = T;
+
+TaggingAllocator() = default;
+
+template
+  TaggingAllocator(const TaggingAllocator&) { }
+
+T*
+allocate(std::size_t n) { return std::allocator{}.allocate(n); }
+
+void
+deallocate(T* p, std::size_t n) { std::allocator{}.deallocate(p, n); }
+
+template
+
+  auto construct(U* p, Args&&... args) ->
+decltype((void)::new((void*)p) U(Tag{}, std::forward(args)...))
+  { ::new((void*)p) U(Tag{}, std::forward(args)...); }
+
+template
+auto destroy(U* p) -> decltype((void)p->~U()) { p->~U(); }
+  };
+
+template
+  bool
+  operator==(const TaggingAllocator&, const TaggingAllocator&)
+  { return true; }
+
+template
+  bool
+  operator!=(const TaggingAllocator&, const TaggingAllocator&)
+  { return false; }
+
+template 
+struct TaggedValueType
+{
+  // All constructors must be passed the Tag type.
+
+  // DefaultInsertable into vector,
+  explicit TaggedValueType(Tag) { }
+  // CopyInsertable into vector,
+  TaggedValueType(Tag, const TaggedValueType&) { }
+  // MoveInsertable into vector, and
+  TaggedValueType(Tag, TaggedValueType&&) { }
+
+  // EmplaceConstructible into vector from args.
+  explicit TaggedValueType(Tag, Args...) { }
+
+  // not DefaultConstructible, CopyConstructible or MoveConstructible.
+  TaggedValueType() = delete;
+  TaggedValueType(const TaggedValueType&) = delete;
+  TaggedValueType(TaggedValueType&&) = delete;
+
+  // CopyAssignable.
+  TaggedValueType& operator=(const TaggedValueType&) { return *this; }
+
+  // MoveAssignable.
+  TaggedValueType& operator=(TaggedValueType&&) { return *this; }
+
+private:
+  // Not Destructible.
+  ~TaggedValueType() { }
+
+  // Erasable from vector.
+  template 
+  friend class TaggingAllocator;
+};
+
+
+template <>
+struct TaggedValueType<>
+{
+  // All constructors must be passed the Tag type.
+
+  // DefaultInsertable into vector,
+  explicit TaggedValueType(Tag) { }
+  // CopyInsertable into vector,
+  TaggedValueType(Tag, const TaggedValueType&) { }
+  // MoveInsertable into vector, and
+  TaggedValueType(Tag, TaggedValueType&&) { }
+
+  // not DefaultConstructible, CopyConstructible or MoveConstructible.
+  TaggedValueType() = delete;
+  TaggedValueType(const TaggedValueType&) = delete;
+  TaggedValueType(TaggedValueType&&) = delete;
+
+  // CopyAssignable.
+  TaggedValueType& operator=(const TaggedValueType&) { return *this; }
+
+  // MoveAssignable.
+  TaggedValueType& operator=(TaggedValueType&&) { return *this; }
+
+private:
+  // Not Destructible.
+  ~TaggedValueType() { }
+
+  // Erasable from vector.
+  template 
+  friend class TaggingAllocator;
+};
+
+#endif /* TAGGING_ALLOCATOR_HPP */
Index: test/libcxx/utilities/memory/allocator.traits/vector_instant.pass.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/allocator.traits/vector_instant.pass.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for 

Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

I don't see successful test for the clause, which prints AST and checks 
serialization/deserialization. Also it should include a template test to check 
that dependent objects are handled correctly



Comment at: include/clang/AST/OpenMPClause.h:4236
@@ +4235,3 @@
+  friend class OMPClauseReader;
+  /// \brief Build clause with number of variables \a N.
+  ///

\brief


Comment at: include/clang/AST/OpenMPClause.h:4258
@@ +4257,3 @@
+public:
+  /// \brief Creates clause with a list of variables \a VL.
+  ///

\brief


Comment at: include/clang/AST/OpenMPClause.h:4269
@@ +4268,3 @@
+ SourceLocation EndLoc, ArrayRef VL);
+  /// \brief Creates an empty clause with the place for \a N variables.
+  ///

\brief


Comment at: lib/Sema/SemaOpenMP.cpp:11648
@@ +11647,3 @@
+// item should be a pointer or reference to pointer
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

What if Type is dependent?


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-11 Thread Jake VanAdrighem via cfe-commits
jakev updated the summary for this revision.
jakev updated this revision to Diff 63634.
jakev added a comment.

Change patch to use `-fprofile-generate` to enable IRPGO.


Repository:
  rL LLVM

http://reviews.llvm.org/D21823

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/clang_f_opts.c
  test/Profile/gcc-flag-compatibility.c

Index: test/Profile/gcc-flag-compatibility.c
===
--- test/Profile/gcc-flag-compatibility.c
+++ test/Profile/gcc-flag-compatibility.c
@@ -7,10 +7,10 @@
 // -fprofile-use=Uses the profile file /default.profdata
 // -fprofile-use=/file   Uses the profile file /file
 
-// Check that -fprofile-generate uses the runtime default profile file.
+// Check that -fprofile-generate overrides the default profraw.
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s
-// PROFILE-GEN-NOT: call void @__llvm_profile_override_default_filename
-// PROFILE-GEN-NOT: declare void @__llvm_profile_override_default_filename(i8*)
+// PROFILE-GEN: call void @__llvm_profile_override_default_filename
+// PROFILE-GEN: declare void @__llvm_profile_override_default_filename(i8*)
 
 // Check that -fprofile-generate=/path/to generates /path/to/default.profraw
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefix=PROFILE-GEN-EQ %s
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -66,7 +66,7 @@
 // CHECK-PROFILE-ARCS: "-femit-coverage-data"
 // CHECK-NO-PROFILE-ARCS-NOT: "-femit-coverage-data"
 
-// RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
+// RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s
 // RUN: %clang -### -S -fprofile-instr-generate=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
@@ -87,17 +87,16 @@
 // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang -### -S -fprofile-instr-generate=file -fno-profile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
-// RUN: %clang -### -S -fprofile-instr-generate=file -fno-profile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
 // RUN: %clang -### -S -fprofile-generate=dir -fno-profile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
-// RUN: %clang -### -S -fprofile-generate=dir -fno-profile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s
 // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fprofile-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fprofile-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s
 // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
 // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
 // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm"
 // CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|}}default.profraw"
 // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3473,24 +3473,39 @@
 static void addPGOAndCoverageFlags(Compilation , const Driver ,
const InputInfo , const ArgList ,
ArgStringList ) {
+
+  auto *PGOGenerateArg = Args.getLastArg(options::OPT_fprofile_generate,
+ options::OPT_fprofile_generate_EQ,
+ options::OPT_fno_profile_generate);
+  if (PGOGenerateArg &&
+  

Re: [PATCH] D21706: [libcxx] refactor for throw

2016-07-11 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

Hi Marshall, do you have any comments?


http://reviews.llvm.org/D21706



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


[PATCH] D22255: [libcxx] Create __is_alloc_constructible<Alloc, Type, Args...> trait which checks the validity of allocator_traits construction.

2016-07-11 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

Example Usage: To check the `EmplaceConstructible` Container requirement you 
would ask:

`__is_alloc_constructible::value` 

http://reviews.llvm.org/D22255

Files:
  include/memory
  include/type_traits

Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -410,6 +410,9 @@
 template 
 struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _Then type;};
 
+template 
+struct _LIBCPP_TYPE_VIS_ONLY __lazy_conditional : conditional<_Pred::value, _If, _Then> {};
+
 #if _LIBCPP_STD_VER > 11
 template  using conditional_t = typename conditional<_Bp, _If, _Then>::type;
 #endif
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -1318,29 +1318,62 @@
 
 #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
 
-#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+#if !defined(_LIBCPP_CXX03_LANG)
 
 template 
-decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(),
-   _VSTD::declval<_Args>()...),
-   true_type())
-__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args);
+auto
+__has_allocator_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args)
+-> decltype(_VSTD::forward<_Alloc>(__a).construct(__p, _VSTD::forward<_Args>(__args)...)
+  , true_type());
 
 template 
 false_type
-__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args);
+__has_allocator_construct_test(const _Alloc&, _Pointer&&, _Args&& ...);
 
 template 
-struct __has_construct
-: integral_constant(),
-  declval<_Pointer>(),
-  declval<_Args>()...)),
-true_type>::value>
+struct __has_allocator_construct : decltype(_VSTD::__has_allocator_construct_test(
+_VSTD::declval<_Alloc>(),
+_VSTD::declval<_Pointer>(),
+_VSTD::declval<_Args>()...))
 {
 };
 
+template 
+using __alloc_construct_tag = typename
+conditional<
+__has_allocator_construct<_Alloc, _Tp*, _Args...>::value,
+integral_constant,
+__lazy_conditional<
+is_constructible<_Tp, _Args...>,
+integral_constant,
+integral_constant
+>
+>::type::type;
+
+template 
+using __is_alloc_constructible = integral_constant::value != 0
+>;
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void __alloc_construct_imp(integral_constant, _Alloc&& __a, _Tp* __p, _Args&&... __args) {
+_VSTD::forward<_Alloc>(__a).construct(__p, _VSTD::forward<_Args>(__args)...);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void __alloc_construct_imp(integral_constant, _Alloc&&, _Tp* __p, _Args&&... __args) {
+::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void __alloc_construct(_Alloc&& __a, _Tp* __p, _Args&&... __args) {
+_VSTD::__alloc_construct_imp(__alloc_construct_tag<_Alloc, _Tp, _Args...>(),
+_VSTD::forward<_Alloc>(__a), __p, _VSTD::forward<_Args>(__args)...);
+}
+
 template 
 auto
 __has_destroy_test(_Alloc&& __a, _Pointer&& __p)
@@ -1399,25 +1432,14 @@
 {
 };
 
-#else  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#else  // _LIBCPP_CXX03_LANG
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-template 
-struct __has_construct
-: false_type
-{
-};
+template 
+struct __has_allocator_construct : false_type {};
 
-#else  // _LIBCPP_HAS_NO_VARIADICS
-
-template 
-struct __has_construct
-: false_type
-{
-};
-
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+template 
+struct __is_alloc_constructible : true_type {};
 
 template 
 struct __has_destroy
@@ -1437,7 +1459,7 @@
 {
 };
 
-#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#endif  // _LIBCPP_CXX03_LANG
 
 template ::value>
 struct __alloc_traits_difference_type
@@ -1497,12 +1519,14 @@
 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
 {__a.deallocate(__p, __n);}
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 template 
-_LIBCPP_INLINE_VISIBILITY
-static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
-{__construct(__has_construct(),
- __a, __p, _VSTD::forward<_Args>(__args)...);}
+_LIBCPP_INLINE_VISIBILITY
+static
+typename enable_if<__is_alloc_constructible

Re: [PATCH] D22189: llvm.noalias - Clang CodeGen - check restrict variable map only for restrict-qualified lvalues

2016-07-11 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer accepted this revision.
majnemer added a reviewer: majnemer.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: lib/CodeGen/CodeGenFunction.h:2725
@@ -2724,3 +2724,3 @@
   void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
- bool Volatile, QualType Ty,
+ bool Volatile, bool Restrict, QualType Ty,
  AlignmentSource AlignSource = AlignmentSource::Type,

Multiple bool parameters aren't super great. Could we make it an enum and `|` 
the two properties as needed?  If it's super painful, this could be done later.


http://reviews.llvm.org/D22189



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


Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread Saleem Abdulrasool via cfe-commits
On Mon, Jul 11, 2016 at 12:29 PM, David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
>
> On Mon, Jul 11, 2016 at 12:18 PM, Nico Weber  wrote:
>
>> On Mon, Jul 11, 2016 at 12:19 PM, David Majnemer <
>> david.majne...@gmail.com> wrote:
>>
>>>
>>>
>>> On Mon, Jul 11, 2016 at 9:03 AM, Nico Weber  wrote:
>>>
 On Mon, Jul 11, 2016 at 11:51 AM, David Majnemer <
 david.majne...@gmail.com> wrote:

>
>
> On Mon, Jul 11, 2016 at 8:42 AM, Nico Weber 
> wrote:
>
>> On Mon, Jul 11, 2016 at 11:36 AM, David Majnemer <
>> david.majne...@gmail.com> wrote:
>>
>>>
>>>
>>> On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber 
>>> wrote:
>>>
 VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This
 means people who want to ask clang-cl for line tables only will have 
 to add
 this flag in some if(is_clang) block in their build file anyways. 
 What's
 the advantage of giving this flag a spelling that's different from 
 both cl
 and clang? With -gline-tables-only, an if(is_clang) works on Linux, 
 Mac,
 Windows.

 (Even if there's a good case for /Zd, I don't think we should
 remove user-exposed flags without a strong reason, so even if we keep 
 /Zd I
 think we should also keep exposing -gline-tables-only.)

>>>
>>> Existing users of -gline-tables-only?  I'd imagine any responsible
>>> users of -gline-tables-only would probably use their build system to 
>>> verify
>>> that the flag exists.  We have never released an official LLVM which
>>> supported it (LLVM 3.8 came out in early March and -gline-tables-only 
>>> was
>>> exposed via clang-cl in mid March).
>>>
>>
>> Ok, but why is /Zd better than -gline-tables-only?
>>
>
> I see a few reasons:
> - It is less surprising for a debug flag in the cl world to be called
> /Zsomething instead of -gsomething.
>

 Eh, you'll have to look it up either way to find the flag.

>>>
>>> I agree.
>>>
>>>
 And when seeing the flag, the -g flag is more self-explanatory.

>>>
>>> I disagree, I had no idea what that flag did until I started working on
>>> debug info.
>>>
>>>
 Also, it is surprising that a clang-cl /-style flag doesn't work with
 cl, so it just moves the surprise around a bit.

>>>
>>> It is surprising when that happens in either direction.  If this is
>>> considered a bug, we will never "fix" it.
>>>
>>>


> - I think that avoiding invasion of their namespace, when possible, is
> a good thing.  It makes it less likely that we will conflict with a flag
> they want to add in the future.
>

 I don't understand this point. Doesn't invading their namespace make
 collisions _more_ likely?


> - I imagine that if they wanted to add support back for
> -gline-tables-only, they'd name it /Zd.
>

 Given they had this flag and removed it, they probably didn't like it
 very much :-)


> I'm sympathetic to the argument that "-gline-tables-only" is more
> familiar to Linux/Mac OS X folks and that /Zd won't work across all
> platforms.
>
> Here why I think that's ok:
> - This is not really a new problem.  If you want to select c++1z you
> get to spell it /std:c++latest for clang-cl and -std=c++14.
>

 Sure, but these are flags that clang/gcc and cl interpret. So if you
 have a gcc build and a visual studio build, it's fairly easy to get each
 going with clang / clang-cl.

 With /Zd, we're needlessly inventing a new spelling for an existing
 clang flag.

>>>
>>> icl also supports /Zd.
>>>
>>
>> That's a big point in favor of this change, I think. Thanks for pointing
>> it out.
>>
>>
>>> As far as I can see, the new name creates a (small) problem without
 solving one.

>>>
>>> This is an attempt to reduce unneeded diversity.
>>>
>>
>> From my point of view, it increased diversity: Before, this feature had
>> one name, now it has two, and the second name is our own invention. (But if
>> icl also uses that flag, then it's less bad.)
>>
>
> It's not out invention, it's Microsoft's.  icl (and now clang-cl) both
> happen to still support it.  If a build system wanted just line table debug
> info for a cl-like driver, they just need /Zd.
>
>
>>
>>
>>> So far, when we wanted to add a flag that cl doesn't have and that clang
 has, we've always gone for the clang spelling of that flag. That seems like
 a good guideline to me.

>>>
>>> Often but not always.  For example, we have /Qvec instead of -fvectorize
>>> because icl has the flag.
>>>
>>
>> Hm, I'd (weakly) argue that that's not ideal either :-)
>>
>
> Why? MSVC has picked up flags from icl. See 

[PATCH] D22248: [Sema] Create a separate group for incompatible function pointer warning

2016-07-11 Thread Bruno Cardoso Lopes via cfe-commits
bruno created this revision.
bruno added reviewers: bob.wilson, doug.gregor, krememek.
bruno added subscribers: cfe-commits, dexonsmith.

Give incompatible pointer warning for function pointers its own diagnostic 
group while leaving it as a subgroup of incompatible-pointer-types. This is in 
preparation to promote -Wincompatible-function-pointer-types to error on some 
darwin targets.

http://reviews.llvm.org/D22248

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/Sema/incompatible-function-pointer-types.c
  test/Sema/initialize-noreturn.c
  test/Sema/overloadable.c

Index: test/Sema/overloadable.c
===
--- test/Sema/overloadable.c
+++ test/Sema/overloadable.c
@@ -109,7 +109,7 @@
   void (*ambiguous)(int *) =  // expected-error{{initializing 'void (*)(int *)' with an expression of incompatible type ''}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
   void *vp_ambiguous =  // expected-error{{initializing 'void *' with an expression of incompatible type ''}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
 
-  void (*specific1)(int *) = (void (*)(void *)) // expected-warning{{incompatible pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}}
+  void (*specific1)(int *) = (void (*)(void *)) // expected-warning{{incompatible function pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}}
   void *specific2 = (void (*)(void *))
 
   void disabled(void *c) __attribute__((overloadable, enable_if(0, "")));
Index: test/Sema/initialize-noreturn.c
===
--- test/Sema/initialize-noreturn.c
+++ test/Sema/initialize-noreturn.c
@@ -8,7 +8,7 @@
 void foo_noret(void)  __attribute__((noreturn));
 
 void test() {
-  Fn_noret fn2 =  // expected-warning {{incompatible pointer types initializing 'Fn_noret'}}
+  Fn_noret fn2 =  // expected-warning {{incompatible function pointer types initializing 'Fn_noret'}}
   Fn_noret fn3 = _noret; 
   Fn_ret fn4 = _noret; 
   Fn_ret fn5 = 
Index: test/Sema/incompatible-function-pointer-types.c
===
--- /dev/null
+++ test/Sema/incompatible-function-pointer-types.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-pointer-types -verify
+// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-function-pointer-types -verify
+
+// This test ensures that the subgroup of -Wincompatible-pointer-types warnings
+// that concern function pointers can be promoted (or not promoted) to an error
+// *separately* from the other -Wincompatible-pointer-type warnings.
+typedef int (*MyFnTyA)(int *, char *);
+
+int bar(char *a, int *b) { return 0; }
+int foo(MyFnTyA x) { return 0; } // expected-note {{passing argument to parameter 'x' here}}
+
+void baz() {
+  foo(); // expected-warning {{incompatible function pointer types passing 'int (*)(char *, int *)' to parameter of type 'MyFnTyA' (aka 'int (*)(int *, char *)')}}
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -12420,10 +12420,14 @@
 MayHaveConvFixit = true;
 break;
   case IncompatiblePointer:
-  DiagKind =
-(Action == AA_Passing_CFAudited ?
-  diag::err_arc_typecheck_convert_incompatible_pointer :
-  diag::ext_typecheck_convert_incompatible_pointer);
+if (Action == AA_Passing_CFAudited)
+  DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
+else if (SrcType->isFunctionPointerType() &&
+ DstType->isFunctionPointerType())
+  DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
+else
+  DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
+
 CheckInferredResultType = DstType->isObjCObjectPointerType() &&
   SrcType->isObjCObjectPointerType();
 if (Hint.isNull() && !CheckInferredResultType) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6344,6 +6344,24 @@
   "; remove *|"
   "; remove &}3">,
   InGroup;
+def ext_typecheck_convert_incompatible_function_pointer : ExtWarn<
+  "incompatible function pointer types "
+  "%select{%diff{assigning to $ from $|assigning to different types}0,1"
+  "|%diff{passing $ to parameter of type $|"
+  "passing to parameter of different type}0,1"
+  "|%diff{returning $ from a function with result type $|"
+  "returning from function with different return type}0,1"
+  "|%diff{converting $ to type $|converting between types}0,1"
+  "|%diff{initializing $ with an expression of type $|"
+  "initializing with expression 

Buildbot numbers for the week of 7/03/2016 - 7/09/2016

2016-07-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 7/03/2016 - 7/09/2016.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time);

Thanks

Galina


The longest time each builder was red during the last week:

 buildername   |  was_red
---+---
 perf-x86_64-penryn-O3 | 64:00:11
 clang-bpf-build   | 53:40:58
 sanitizer-x86_64-linux-bootstrap  | 38:18:34
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 34:15:55
 clang-x86-win2008-selfhost| 19:28:35
 sanitizer-x86_64-linux| 17:41:05
 sanitizer-x86_64-linux-fast   | 13:42:33
 libcxx-libcxxabi-arm-linux| 12:54:51
 lldb-windows7-android | 12:24:13
 lldb-x86_64-ubuntu-14.04-buildserver  | 12:21:03
 lldb-x86_64-ubuntu-14.04-cmake| 12:07:26
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only | 11:45:25
 lldb-amd64-ninja-netbsd7  | 11:44:19
 clang-cmake-mipsel| 11:29:51
 clang-native-aarch64-full | 10:54:43
 clang-ppc64le-linux-multistage| 09:53:16
 perf-x86_64-penryn-O3-polly   | 08:03:34
 lldb-x86_64-darwin-13.4   | 07:42:43
 clang-ppc64le-linux   | 07:26:44
 clang-ppc64be-linux-multistage| 07:04:06
 clang-ppc64be-linux-lnt   | 06:47:26
 clang-ppc64be-linux   | 06:21:08
 clang-ppc64le-linux-lnt   | 06:03:08
 clang-x86_64-linux-selfhost-modules   | 05:59:04
 sanitizer-ppc64be-linux   | 05:52:14
 clang-x64-ninja-win7  | 05:35:04
 llvm-clang-lld-x86_64-debian-fast | 05:26:46
 clang-cuda-build  | 05:07:26
 clang-s390x-linux | 04:59:56
 clang-3stage-ubuntu   | 04:54:06
 llvm-mips-linux   | 04:50:35
 clang-x86_64-debian-fast  | 04:37:34
 sanitizer-ppc64le-linux   | 04:01:52
 clang-atom-d525-fedora-rel| 03:12:21
 lld-x86_64-freebsd| 01:39:32
 lldb-x86_64-ubuntu-14.04-android  | 01:39:24
 clang-cmake-armv7-a15-full| 01:30:09
 perf-x86_64-penryn-O3-polly-fast  | 01:15:12
 polly-amd64-linux | 01:13:20
 perf-x86_64-penryn-O3-polly-parallel-fast | 01:11:10
 perf-x86_64-penryn-O3-polly-unprofitable  | 01:02:11
 sanitizer-x86_64-linux-fuzzer | 00:59:48
 clang-native-arm-lnt  | 00:58:03
 clang-hexagon-elf | 00:53:56
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 00:50:42
 sanitizer-windows | 00:50:33
 clang-cmake-armv7-a15 | 00:43:46
 clang-cmake-thumbv7-a15   | 00:43:40
 clang-cmake-aarch64-42vma | 00:36:08
 clang-cmake-aarch64-quick | 00:35:37
 sanitizer-x86_64-linux-autoconf   | 00:33:55
 lld-x86_64-darwin13   | 00:23:36
 clang-x86_64-linux-abi-test   | 00:20:55
 llvm-hexagon-elf  | 00:13:29
 lld-x86_64-win7   | 00:12:46
(55 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

 buildername| builds |
changes | status change ratio
++-+-
 

Buildbot numbers for the week of 6/26/2016 - 7/02/2016

2016-07-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 6/26/2016 - 7/02/2016.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time);

Thanks

Galina


The longest time each builder was red during the last week:

 buildername   |  was_red
---+---
 sanitizer-windows | 102:23:18
 perf-x86_64-penryn-O3 | 91:23:32
 lldb-x86_64-ubuntu-14.04-android  | 77:28:08
 lldb-x86_64-darwin-13.4   | 76:52:52
 lldb-windows7-android | 76:19:22
 lldb-x86_64-ubuntu-14.04-cmake| 70:35:19
 perf-x86_64-penryn-O3-polly   | 64:16:46
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only | 63:07:50
 perf-x86_64-penryn-O3-polly-unprofitable  | 59:32:27
 perf-x86_64-penryn-O3-polly-parallel-fast | 59:19:32
 perf-x86_64-penryn-O3-polly-fast  | 58:04:34
 clang-ppc64be-linux-lnt   | 44:22:37
 sanitizer-x86_64-linux-bootstrap  | 32:25:00
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 26:27:21
 sanitizer-x86_64-linux-fast   | 26:05:12
 clang-ppc64le-linux-lnt   | 25:45:53
 clang-x86-win2008-selfhost| 24:36:39
 clang-x86_64-linux-selfhost-modules   | 23:20:27
 clang-3stage-ubuntu   | 22:18:49
 sanitizer-x86_64-linux| 21:59:30
 sanitizer-ppc64le-linux   | 21:39:54
 sanitizer-ppc64be-linux   | 21:28:10
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 15:50:16
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 14:48:42
 clang-native-aarch64-full | 14:05:44
 clang-ppc64le-linux-multistage| 13:57:56
 clang-atom-d525-fedora-rel| 09:43:16
 clang-cmake-thumbv7-a15-full-sh   | 09:41:34
 clang-cmake-armv7-a15-selfhost-neon   | 09:25:57
 clang-cmake-mipsel| 08:03:44
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 07:02:55
 lld-x86_64-win7   | 05:56:20
 clang-x64-ninja-win7  | 05:44:52
 polly-amd64-linux | 05:36:39
 llvm-mips-linux   | 05:23:38
 clang-cmake-armv7-a15-full| 04:54:54
 clang-cmake-armv7-a15 | 04:26:13
 clang-cmake-thumbv7-a15   | 04:24:56
 sanitizer-x86_64-linux-autoconf   | 03:04:03
 clang-native-arm-lnt  | 02:58:23
 clang-cmake-armv7-a15-selfhost| 02:58:02
 clang-cmake-aarch64-full  | 02:55:50
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11  | 02:42:35
 sanitizer-x86_64-linux-fuzzer | 02:26:07
 lld-x86_64-darwin13   | 02:16:38
 clang-s390x-linux | 02:10:19
 clang-cuda-build  | 02:10:17
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 02:10:00
 clang-ppc64be-linux   | 02:09:16
 clang-cmake-aarch64-quick | 02:08:22
 clang-ppc64le-linux   | 01:59:50
 llvm-hexagon-elf  | 01:50:28
 clang-hexagon-elf | 01:48:56
 llvm-clang-lld-x86_64-debian-fast | 01:48:20
 clang-x86_64-debian-fast  | 01:44:49
 clang-ppc64be-linux-multistage| 01:37:06
 clang-cmake-aarch64-42vma | 01:28:03
 lldb-amd64-ninja-netbsd7  | 01:16:33
 clang-cmake-mips  | 01:10:59
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 01:09:31
 

r275128 - Correcting the previous fix for test submitted with r275115.

2016-07-11 Thread Wolfgang Pieb via cfe-commits
Author: wolfgangp
Date: Mon Jul 11 18:27:19 2016
New Revision: 275128

URL: http://llvm.org/viewvc/llvm-project?rev=275128=rev
Log:
Correcting the previous fix for test submitted with r275115.

Modified:
cfe/trunk/test/CodeGen/forwarding-blocks-if.c

Modified: cfe/trunk/test/CodeGen/forwarding-blocks-if.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/forwarding-blocks-if.c?rev=275128=275127=275128=diff
==
--- cfe/trunk/test/CodeGen/forwarding-blocks-if.c (original)
+++ cfe/trunk/test/CodeGen/forwarding-blocks-if.c Mon Jul 11 18:27:19 2016
@@ -12,7 +12,7 @@ int f0(int val) {
   return 0;
 }
 
-// CHECK-LABEL: define {{.*}} i32 @f0
+// CHECK-LABEL: define {{.*}}i32 @f0
 // CHECK: call void {{.*}} @func
 // CHECK: call void {{.*}} @func
 // CHECK: br label %[[RETBLOCK1:[^ ]*]]
@@ -28,7 +28,7 @@ int f1(int val, int g) {
   return 0;
 }
 
-// CHECK-LABEL: define {{.*}} i32 @f1
+// CHECK-LABEL: define {{.*}}i32 @f1
 // CHECK: call void {{.*}} @func
 // CHECK: br label %[[RETBLOCK2:[^ ]*]]
 // CHECK: [[RETBLOCK2]]:


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


r275127 - Fix test submitted with r275115 (failed on ppc64 buildbots).

2016-07-11 Thread Wolfgang Pieb via cfe-commits
Author: wolfgangp
Date: Mon Jul 11 18:20:28 2016
New Revision: 275127

URL: http://llvm.org/viewvc/llvm-project?rev=275127=rev
Log:
Fix test submitted with r275115 (failed on ppc64 buildbots).

Modified:
cfe/trunk/test/CodeGen/forwarding-blocks-if.c

Modified: cfe/trunk/test/CodeGen/forwarding-blocks-if.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/forwarding-blocks-if.c?rev=275127=275126=275127=diff
==
--- cfe/trunk/test/CodeGen/forwarding-blocks-if.c (original)
+++ cfe/trunk/test/CodeGen/forwarding-blocks-if.c Mon Jul 11 18:20:28 2016
@@ -12,7 +12,7 @@ int f0(int val) {
   return 0;
 }
 
-// CHECK-LABEL: define i32 @f0
+// CHECK-LABEL: define {{.*}} i32 @f0
 // CHECK: call void {{.*}} @func
 // CHECK: call void {{.*}} @func
 // CHECK: br label %[[RETBLOCK1:[^ ]*]]
@@ -28,7 +28,7 @@ int f1(int val, int g) {
   return 0;
 }
 
-// CHECK-LABEL: define i32 @f1
+// CHECK-LABEL: define {{.*}} i32 @f1
 // CHECK: call void {{.*}} @func
 // CHECK: br label %[[RETBLOCK2:[^ ]*]]
 // CHECK: [[RETBLOCK2]]:


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


r275121 - [Coverage] Do not map regions from system headers

2016-07-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Jul 11 17:57:46 2016
New Revision: 275121

URL: http://llvm.org/viewvc/llvm-project?rev=275121=rev
Log:
[Coverage] Do not map regions from system headers

Do not assign source regions located within system headers file ID's,
and do not construct counter mapping regions out of them.

This makes coverage reports less cluttered and less mysterious. E.g
using the "assert" macro doesn't cause assert.h to appear in reports,
and it no longer shows the "assertion failed" branch as an uncovered
region.

It also makes coverage mapping sections a bit smaller (e.g a 1%
reduction in a stage2 build of bin/llvm-as).

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/system_macro.c

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=275121=275120=275121=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Jul 11 17:57:46 2016
@@ -172,6 +172,10 @@ public:
   if (!Visited.insert(File).second)
 continue;
 
+  // Do not map FileID's associated with system headers.
+  if (SM.isInSystemHeader(SM.getSpellingLoc(Loc)))
+continue;
+
   unsigned Depth = 0;
   for (SourceLocation Parent = getIncludeOrExpansionLoc(Loc);
Parent.isValid(); Parent = getIncludeOrExpansionLoc(Parent))
@@ -251,6 +255,10 @@ public:
   SourceLocation LocStart = Region.getStartLoc();
   assert(SM.getFileID(LocStart).isValid() && "region in invalid file");
 
+  // Ignore regions from system headers.
+  if (SM.isInSystemHeader(SM.getSpellingLoc(LocStart)))
+continue;
+
   auto CovFileID = getCoverageFileID(LocStart);
   // Ignore regions that don't have a file, such as builtin macros.
   if (!CovFileID)

Modified: cfe/trunk/test/CoverageMapping/system_macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/system_macro.c?rev=275121=275120=275121=diff
==
--- cfe/trunk/test/CoverageMapping/system_macro.c (original)
+++ cfe/trunk/test/CoverageMapping/system_macro.c Mon Jul 11 17:57:46 2016
@@ -13,9 +13,8 @@
 
 // CHECK-LABEL: doSomething:
 void doSomething(int x) { // CHECK: File 0, [[@LINE]]:25 -> {{[0-9:]+}} = #0
-  Func(x); // CHECK: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:7
+  Func(x);
   return;
-  // CHECK: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:11
   SomeType *f; // CHECK: File 0, [[@LINE]]:11 -> {{[0-9:]+}} = 0
 }
 


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


[PATCH] D22242: [analyzer] De-duplicate some code for discovering the origin of the symbol.

2016-07-11 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added a reviewer: dcoughlin.
NoQ added a subscriber: cfe-commits.

Or, more importantly, tell the users that there's a way to discover the region, 
value of which - at some moment of time - the symbol was introduced to 
represent. Idea proposed by Devin Coughlin.

Right now this is a simple code de-duplication, but in fact maybe it should be 
extended to support SymbolMetadata, SymbolExtent, and maybe, even more 
importantly, SymbolConjured (if the latter is created during invalidation of a 
region, *and* the symbol's structure is modified to remember that region - 
which i think is a useful idea, but that's another story; there's not much we 
could do for conjured-return-value symbols, even though sometimes even they 
should probably be tied to temporary object regions).

http://reviews.llvm.org/D22242

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -147,6 +147,14 @@
   return R;
 }
 
+const MemRegion *SymExpr::getOriginRegion() const {
+  if (const SymbolRegionValue *SRV = dyn_cast(this))
+return SRV->getRegion();
+  else if (const SymbolDerived *SD = dyn_cast(this))
+return SD->getRegion();
+  return nullptr;
+}
+
 const SymbolRegionValue*
 SymbolManager::getRegionValueSymbol(const TypedValueRegion* R) {
   llvm::FoldingSetNodeID profile;
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -2833,23 +2833,15 @@
   C.addTransition(State);
 }
 
-static bool wasLoadedFromIvar(SymbolRef Sym) {
-  if (auto DerivedVal = dyn_cast(Sym))
-return isa(DerivedVal->getRegion());
-  if (auto RegionVal = dyn_cast(Sym))
-return isa(RegionVal->getRegion());
-  return false;
-}
-
 void RetainCountChecker::checkPostStmt(const ObjCIvarRefExpr *IRE,
CheckerContext ) const {
   Optional IVarLoc = C.getSVal(IRE).getAs();
   if (!IVarLoc)
 return;
 
   ProgramStateRef State = C.getState();
   SymbolRef Sym = State->getSVal(*IVarLoc).getAsSymbol();
-  if (!Sym || !wasLoadedFromIvar(Sym))
+  if (!Sym || !dyn_cast_or_null(Sym->getOriginRegion()))
 return;
 
   // Accessing an ivar directly is unusual. If we've done that, be more
Index: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
===
--- lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
+++ lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
@@ -315,15 +315,7 @@
 /// Returns nullptr if the instance symbol cannot be found.
 const ObjCIvarRegion *
 ObjCDeallocChecker::getIvarRegionForIvarSymbol(SymbolRef IvarSym) const {
-  const MemRegion *RegionLoadedFrom = nullptr;
-  if (auto *DerivedSym = dyn_cast(IvarSym))
-RegionLoadedFrom = DerivedSym->getRegion();
-  else if (auto *RegionSym = dyn_cast(IvarSym))
-RegionLoadedFrom = RegionSym->getRegion();
-  else
-return nullptr;
-
-  return dyn_cast(RegionLoadedFrom);
+  return dyn_cast_or_null(IvarSym->getOriginRegion());
 }
 
 /// Given a symbol for an ivar, return a symbol for the instance containing
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
@@ -22,6 +22,8 @@
 namespace clang {
 namespace ento {
 
+class MemRegion;
+
 /// \brief Symbolic value. These values used to capture symbolic execution of
 /// the program.
 class SymExpr : public llvm::FoldingSetNode {
@@ -76,6 +78,7 @@
   static symbol_iterator symbol_end() { return symbol_iterator(); }
 
   unsigned computeComplexity() const;
+  const MemRegion *getOriginRegion() const;
 };
 
 typedef const SymExpr *SymbolRef;


Index: lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -147,6 +147,14 @@
   return R;
 }
 
+const MemRegion *SymExpr::getOriginRegion() const {
+  if (const SymbolRegionValue *SRV = dyn_cast(this))
+return SRV->getRegion();
+  else if (const SymbolDerived *SD = dyn_cast(this))
+return SD->getRegion();
+  return nullptr;
+}
+
 const SymbolRegionValue*
 SymbolManager::getRegionValueSymbol(const TypedValueRegion* R) {
   llvm::FoldingSetNodeID profile;
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===

Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-07-11 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2170
@@ +2169,3 @@
+  "'flexible_array' attribute only applies to %select{"
+  "the last member of a struct|members of structs or classes|"
+  "fixed sized array members|array members that have at least one element}0">;

aaron.ballman wrote:
> I think "members of structs or classes" and "the last member of a struct" 
> could be combined into "the last member of a non-union class", instead of 
> using separate diagnostic text. What do you think?
I agree, I think these two diagnostics should be combined.


http://reviews.llvm.org/D21453



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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-07-11 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 63596.
ahatanak added a comment.

Change diagnostic messages.


http://reviews.llvm.org/D21453

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/AST/Decl.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/object-size.c
  test/CodeGenCXX/catch-undef-behavior.cpp
  test/SemaCXX/flexible-array-attr.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2641,6 +2641,7 @@
 case GenericRecord:
   return "(S.getLangOpts().CPlusPlus ? ExpectedStructOrUnionOrClass : "
"ExpectedStructOrUnion)";
+case Field: return "ExpectedField";
 case Func | ObjCMethod | Block: return "ExpectedFunctionMethodOrBlock";
 case Func | ObjCMethod | Class: return "ExpectedFunctionMethodOrClass";
 case Func | Param:
Index: test/SemaCXX/flexible-array-attr.cpp
===
--- /dev/null
+++ test/SemaCXX/flexible-array-attr.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int g0[16] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to non-static data members}}
+
+struct S0 {
+  int a[4];
+  int foo1() __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to non-static data members}}
+};
+
+struct S1 {
+  int a[4];
+  int *b __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to a non-flexible array member}}
+};
+
+struct S2 {
+  int a[4];
+  int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to the last member of a non-union class}}
+  int c[4];
+};
+
+struct S3 {
+  int a[4];
+  int b[] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to a non-flexible array member}}
+};
+
+struct S4 {
+  int a[4];
+  int b[0] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to an array member that has at least one element}}
+};
+
+template
+struct S5 {
+  int a[4];
+  int b[N] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to a non-flexible array member}}
+};
+
+struct S6 {
+  int a[4];
+  int b[1] __attribute__((flexible_array));
+};
+
+struct S7 : S6 { // expected-error {{base class 'S6' has a flexible array member}}
+};
+
+struct S8 {
+  int a;
+  S6 s6; // expected-error {{struct with a member marked 'flexible_array' cannot be nested}}
+};
+
+union U0 {
+  int a[4];
+  int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to the last member of a non-union class}}
+};
+
+int lambda_capture(S6 a) { // expected-note {{'a' declared here}}
+  return [a](){ return 0; }(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
+}
Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -327,6 +327,17 @@
   return incomplete[n];
 }
 
+struct FlexibleArray {
+  int a1[4];
+  int a2[4] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @_Z14flexible_array
+int flexible_array(FlexibleArray *p, int n) {
+  // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
+  return p->a2[n];
+}
+
 typedef __attribute__((ext_vector_type(4))) int V4I;
 // CHECK-LABEL: @_Z12vector_index
 int vector_index(V4I v, int n) {
Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -517,3 +517,19 @@
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size([9].snd[0], 1);
 }
+
+struct S0 {
+  int a[16];
+  int b[16] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @test32
+void test32() {
+  struct S0 *s0;
+
+  // CHECK: store i32 64, i32* @gi
+  gi = __builtin_object_size(s0->a, 1);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(s0->b, 1);
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -457,6 +457,7 @@
 void 

[libcxx] r275114 - Don't compute modulus of hash if it is smaller than the bucket count.

2016-07-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 11 17:02:02 2016
New Revision: 275114

URL: http://llvm.org/viewvc/llvm-project?rev=275114=rev
Log:
Don't compute modulus of hash if it is smaller than the bucket count.

This cleans up a previous optimization attempt in hash, and results in
additional performance improvements over that previous attempt. Additionally
this new optimization does not hinder the power of 2 bucket count optimization.

Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=275114=275113=275114=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Mon Jul 11 17:02:02 2016
@@ -90,7 +90,8 @@ inline _LIBCPP_INLINE_VISIBILITY
 size_t
 __constrain_hash(size_t __h, size_t __bc)
 {
-return !(__bc & (__bc - 1)) ? __h & (__bc - 1) : __h % __bc;
+return !(__bc & (__bc - 1)) ? __h & (__bc - 1) :
+(__h < __bc ? __h : __h % __bc);
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -2201,8 +2202,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 if (__nd != nullptr)
 {
 for (__nd = __nd->__next_; __nd != nullptr &&
-(__hash == __nd->__hash_
-|| __constrain_hash(__nd->__hash_, __bc) == __chash);
+__constrain_hash(__nd->__hash_, __bc) == __chash;
__nd = 
__nd->__next_)
 {
 if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
@@ -2231,8 +2231,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 if (__nd != nullptr)
 {
 for (__nd = __nd->__next_; __nd != nullptr &&
-(__hash == __nd->__hash_
-|| __constrain_hash(__nd->__hash_, __bc) == __chash);
+  __constrain_hash(__nd->__hash_, __bc) == __chash;
__nd = 
__nd->__next_)
 {
 if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))


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


[libcxx] r275105 - Always use the allocator to construct/destruct elements of a deque/vector. Fixes PR#28412. Thanks to Jonathan Wakely for the report.

2016-07-11 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jul 11 16:38:08 2016
New Revision: 275105

URL: http://llvm.org/viewvc/llvm-project?rev=275105=rev
Log:
Always use the allocator to construct/destruct elements of a deque/vector. 
Fixes PR#28412. Thanks to Jonathan Wakely for the report.

Modified:
libcxx/trunk/include/deque
libcxx/trunk/include/memory
libcxx/trunk/include/vector

libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
libcxx/trunk/test/support/test_allocator.h

Modified: libcxx/trunk/include/deque
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=275105=275104=275105=diff
==
--- libcxx/trunk/include/deque (original)
+++ libcxx/trunk/include/deque Mon Jul 11 16:38:08 2016
@@ -2026,7 +2026,7 @@ deque<_Tp, _Allocator>::emplace(const_it
 }
 else
 {
-value_type __tmp(_VSTD::forward<_Args>(__args)...);
+__temp_value __tmp(this->__alloc(), 
_VSTD::forward<_Args>(__args)...);
 iterator __b = __base::begin();
 iterator __bm1 = _VSTD::prev(__b);
 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), 
_VSTD::move(*__b));
@@ -2034,7 +2034,7 @@ deque<_Tp, _Allocator>::emplace(const_it
 ++__base::size();
 if (__pos > 1)
 __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
-*__b = _VSTD::move(__tmp);
+*__b = _VSTD::move(__tmp.get());
 }
 }
 else
@@ -2050,14 +2050,14 @@ deque<_Tp, _Allocator>::emplace(const_it
 }
 else
 {
-value_type __tmp(_VSTD::forward<_Args>(__args)...);
+__temp_value __tmp(this->__alloc(), 
_VSTD::forward<_Args>(__args)...);
 iterator __e = __base::end();
 iterator __em1 = _VSTD::prev(__e);
 __alloc_traits::construct(__a, _VSTD::addressof(*__e), 
_VSTD::move(*__em1));
 ++__base::size();
 if (__de > 1)
 __e = _VSTD::move_backward(__e - __de, __em1, __e);
-*--__e = _VSTD::move(__tmp);
+*--__e = _VSTD::move(__tmp.get());
 }
 }
 return __base::begin() + __pos;

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=275105=275104=275105=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Mon Jul 11 16:38:08 2016
@@ -5674,6 +5674,26 @@ struct __noexcept_move_assign_container
 #endif
 > {};
 
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+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)...); }
+
+~__temp_value() { _Traits::destroy(__a, __addr()); }
+};
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_MEMORY

Modified: libcxx/trunk/include/vector
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=275105=275104=275105=diff
==
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Mon Jul 11 16:38:08 2016
@@ -1812,9 +1812,9 @@ vector<_Tp, _Allocator>::emplace(const_i
 }
 else
 {
-value_type __tmp(_VSTD::forward<_Args>(__args)...);
+__temp_value __tmp(this->__alloc(), 
_VSTD::forward<_Args>(__args)...);
 __move_range(__p, this->__end_, __p + 1);
-*__p = _VSTD::move(__tmp);
+*__p = _VSTD::move(__tmp.get());
 }
 __annotator.__done();
 }

Modified: 
libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp?rev=275105=275104=275105=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
 Mon Jul 11 16:38:08 2016
@@ -16,6 +16,7 @@
 
 #include "../../../Emplaceable.h"
 #include "min_allocator.h"
+#include "test_allocator.h"
 
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
@@ -82,6 +83,17 @@ int main()
 for (int j = 

Re: [PATCH] D22208: clang-tidy] Fixes to modernize-use-emplace

2016-07-11 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:21
@@ +20,3 @@
+llvm::Optional
+getHasAnyName(const std::vector ) {
+  llvm::Optional hasMatcher;

aaron.ballman wrote:
> aaron.ballman wrote:
> > Should be `Names` instead.
> Is this needed? We have the `hasAnyName()` matcher already.
The problem is that this matcher takes variadic number of strings. Here I have 
a vector of strings. sbenza did similar thing in performance-fast-string-find.

In the future I would like to add overload of the matcher that would take a 
vector of strings (it is is possible),
or at least move this function somewhere.

Another idea would be to return matcher instead of Optional - if list 
is empty then return unless(anything()) - there should be nothing() matcher :P


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:31-33
@@ +30,5 @@
+
+const std::string defaultContainersWithPushBack =
+"std::vector; std::list; std::deque";
+const std::string defaultSmartPointers =
+"std::shared_ptr; std::unique_ptr; std::auto_ptr; std::weak_ptr";

aaron.ballman wrote:
> These should start with a capital as well (coding standard information 
> pertaining to names can be found at 
> http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly).
thanks, I always though that only local variables have to start with capital.


Repository:
  rL LLVM

http://reviews.llvm.org/D22208



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-11 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 63571.
yaxunl added a comment.

Added test for invalid sampler values.


http://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -13,6 +13,7 @@
   const sampler_t const_smp = 7;
   foo(glb_smp);
   foo(const_smp);
+  foo(argsmp);
   foo(5); // expected-error {{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
Index: test/CodeGenOpenCL/sampler.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/sampler.cl
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 -Wspir-compat -verify -DCHECK_SAMPLER_VALUE | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 -verify | FileCheck %s
+
+#ifndef CHECK_SAMPLER_VALUE
+// expected-no-diagnostics
+#endif
+
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+
+constant sampler_t glb_smp2 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp3 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
+
+// CHECK: %__sampler = type opaque
+
+void fnc4smp(sampler_t s) {}
+// CHECK: define spir_func void @fnc4smp(%__sampler addrspace(2)* %
+
+kernel void foo() {
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
+  // CHECK-LABEL: define spir_kernel void @foo()
+  // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %__sampler addrspace(2)*
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 19)
+  // CHECK: store %__sampler addrspace(2)* [[SAMP]], %__sampler addrspace(2)** [[smp_ptr]]
+
+  fnc4smp(smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 19)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+
+  fnc4smp(glb_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 35)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+
+  fnc4smp(glb_smp2);
+  fnc4smp(glb_smp3);
+}
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -1,39 +1,43 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -o - -O0 | FileCheck %s
 
-constant sampler_t glb_smp = 7;
-// CHECK: constant i32 7
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_NEAREST;
 
 void fnc1(image1d_t img) {}
-// CHECK: @fnc1(%opencl.image1d_ro_t*
+// CHECK: @fnc1(%opencl.image1d_ro_t addrspace(1)*
 
 void fnc1arr(image1d_array_t img) {}
-// CHECK: @fnc1arr(%opencl.image1d_array_ro_t*
+// CHECK: @fnc1arr(%opencl.image1d_array_ro_t addrspace(1)*
 
 void fnc1buff(image1d_buffer_t img) {}
-// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t*
+// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t addrspace(1)*
 
 void fnc2(image2d_t img) {}
-// CHECK: @fnc2(%opencl.image2d_ro_t*
+// CHECK: @fnc2(%opencl.image2d_ro_t addrspace(1)*
 
 void fnc2arr(image2d_array_t img) {}
-// CHECK: @fnc2arr(%opencl.image2d_array_ro_t*
+// CHECK: @fnc2arr(%opencl.image2d_array_ro_t addrspace(1)*
 
 void fnc3(image3d_t img) {}
-// CHECK: @fnc3(%opencl.image3d_ro_t*
+// CHECK: @fnc3(%opencl.image3d_ro_t addrspace(1)*
 
 void fnc4smp(sampler_t s) 

r275095 - [NFC] Reorder fields of VersionTuple to reduce size

2016-07-11 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Jul 11 15:00:48 2016
New Revision: 275095

URL: http://llvm.org/viewvc/llvm-project?rev=275095=rev
Log:
[NFC] Reorder fields of VersionTuple to reduce size

Differential revision: http://reviews.llvm.org/D19934

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

Modified: cfe/trunk/include/clang/Basic/VersionTuple.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VersionTuple.h?rev=275095=275094=275095=diff
==
--- cfe/trunk/include/clang/Basic/VersionTuple.h (original)
+++ cfe/trunk/include/clang/Basic/VersionTuple.h Mon Jul 11 15:00:48 2016
@@ -25,39 +25,44 @@ namespace clang {
 /// \brief Represents a version number in the form 
major[.minor[.subminor[.build]]].
 class VersionTuple {
   unsigned Major : 31;
+
+  unsigned UsesUnderscores : 1;
+
   unsigned Minor : 31;
-  unsigned Subminor : 31;
-  unsigned Build : 31;
   unsigned HasMinor : 1;
+
+  unsigned Subminor : 31;
   unsigned HasSubminor : 1;
+
+  unsigned Build : 31;
   unsigned HasBuild : 1;
-  unsigned UsesUnderscores : 1;
 
 public:
   VersionTuple()
-  : Major(0), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major)
-  : Major(Major), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(0), Build(0), HasMinor(true),
-HasSubminor(false), HasBuild(false), UsesUnderscores(UsesUnderscores) 
{}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
+HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(0),
-HasMinor(true), HasSubminor(true), HasBuild(false),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0),
+HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 unsigned Build, bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(Build),
-HasMinor(true), HasSubminor(true), HasBuild(true),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build),
+HasBuild(true) {}
 
   /// \brief Determine whether this version information is empty
   /// (e.g., all version components are zero).


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


Re: r274246 - [codeview] Emit qualified display names if -gline-tables-only is on

2016-07-11 Thread Reid Kleckner via cfe-commits
On Mon, Jul 11, 2016 at 10:35 AM, David Blaikie  wrote:
>
> I believe so, but don't have specific numbers. Alexey made this choice
> when it was originally implemented & I believe had the data back then.
>

I don't think we made an explicit choice to use short names. gdb and
addr2line just give you short names if you lack information about
parameters, classes, and namespaces. I could be wrong though.

-- we can't use -fline-tables-only 'cause they make stacks look very bad,
>>
>
> Also I'm curious why your use case/tolerance for "badness" here is
> different from what we've been using at Google for ASan, etc, for several
> years now. Do you have different requirements/needs here? Then maybe we
> need to figure out names for those needs & enshrine them in flags.
>

I don't think our requirements are that surprising: users should be able to
take a stack dump with a standard stack dumping tool (gdb, addr2line, or
chrome's breakpad crash server) and get usable symbols (names that include
their scope).

Anyway, we all agree it requires measurement. I was mostly trying to gauge
interest, to see if this is a problem that other users are encountering.

I'd forgotten about Nico's RFC for -gmlt, so yes, it sounds like there is
interest in revisiting this tradeoff.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r275094 - Allow is_swappable to SFINAE on deleted/ambiguous swap functions

2016-07-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 11 14:57:13 2016
New Revision: 275094

URL: http://llvm.org/viewvc/llvm-project?rev=275094=rev
Log:
Allow is_swappable to SFINAE on deleted/ambiguous swap functions

Modified:
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=275094=275093=275094=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Jul 11 14:57:13 2016
@@ -4446,15 +4446,20 @@ iter_swap(_ForwardIterator1 __a, _Forwar
 namespace __detail
 {
 // ALL generic swap overloads MUST already have a declaration available at 
this point.
-using _VSTD::swap;
-__nat swap(__any, __any);
 
 template ::value && !is_void<_Up>::value>
 struct __swappable_with
 {
-typedef decltype(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>())) 
__swap1;
-typedef decltype(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>())) 
__swap2;
+template 
+static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
+__test_swap(int);
+template 
+static __nat __test_swap(long);
+
+// Extra parens are needed for the C++03 definition of decltype.
+typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
+typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
 
 static const bool value = !is_same<__swap1, __nat>::value
&& !is_same<__swap2, __nat>::value;

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp?rev=275094=275093=275094=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_swappable.pass.cpp
 Mon Jul 11 14:57:13 2016
@@ -49,8 +49,21 @@ struct M {
 
 void swap(M&&, M&&) {}
 
+struct DeletedSwap {
+  friend void swap(DeletedSwap&, DeletedSwap&) = delete;
+};
+
 } // namespace MyNS
 
+namespace MyNS2 {
+
+struct AmbiguousSwap {};
+
+template 
+void swap(T&, T&) {}
+
+} // end namespace MyNS2
+
 int main()
 {
 using namespace MyNS;
@@ -70,6 +83,14 @@ int main()
 static_assert(!std::is_swappable::value, "");
 }
 {
+// test that a deleted swap is correctly handled.
+static_assert(!std::is_swappable::value, "");
+}
+{
+// test that a swap with ambiguous overloads is handled correctly.
+static_assert(!std::is_swappable::value, "");
+}
+{
 // test for presence of is_swappable_v
 static_assert(std::is_swappable_v, "");
 static_assert(!std::is_swappable_v, "");


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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-11 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 63556.
yaxunl marked 3 inline comments as done.
yaxunl added a comment.

Revised by Anastia's comments. Disabled warning for sampler enum value by 
default.


http://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -13,6 +13,7 @@
   const sampler_t const_smp = 7;
   foo(glb_smp);
   foo(const_smp);
+  foo(argsmp);
   foo(5); // expected-error {{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
Index: test/CodeGenOpenCL/sampler.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/sampler.cl
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
+
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+
+// CHECK: %__sampler = type opaque
+
+void fnc4smp(sampler_t s) {}
+// CHECK: define spir_func void @fnc4smp(%__sampler addrspace(2)* %
+
+kernel void foo() {
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
+  // CHECK-LABEL: define spir_kernel void @foo()
+  // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %__sampler addrspace(2)*
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 19)
+  // CHECK: store %__sampler addrspace(2)* [[SAMP]], %__sampler addrspace(2)** [[smp_ptr]]
+
+  fnc4smp(smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 19)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+
+  fnc4smp(glb_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(i32 35)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+}
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -1,39 +1,43 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -o - -O0 | FileCheck %s
 
-constant sampler_t glb_smp = 7;
-// CHECK: constant i32 7
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_NEAREST;
 
 void fnc1(image1d_t img) {}
-// CHECK: @fnc1(%opencl.image1d_ro_t*
+// CHECK: @fnc1(%opencl.image1d_ro_t addrspace(1)*
 
 void fnc1arr(image1d_array_t img) {}
-// CHECK: @fnc1arr(%opencl.image1d_array_ro_t*
+// CHECK: @fnc1arr(%opencl.image1d_array_ro_t addrspace(1)*
 
 void fnc1buff(image1d_buffer_t img) {}
-// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t*
+// CHECK: @fnc1buff(%opencl.image1d_buffer_ro_t addrspace(1)*
 
 void fnc2(image2d_t img) {}
-// CHECK: @fnc2(%opencl.image2d_ro_t*
+// CHECK: @fnc2(%opencl.image2d_ro_t addrspace(1)*
 
 void fnc2arr(image2d_array_t img) {}
-// CHECK: @fnc2arr(%opencl.image2d_array_ro_t*
+// CHECK: @fnc2arr(%opencl.image2d_array_ro_t addrspace(1)*
 
 void fnc3(image3d_t img) {}
-// CHECK: @fnc3(%opencl.image3d_ro_t*
+// CHECK: @fnc3(%opencl.image3d_ro_t addrspace(1)*
 
 void fnc4smp(sampler_t s) {}
-// CHECK-LABEL: define {{.*}}void @fnc4smp(i32
+// CHECK-LABEL: define {{.*}}void @fnc4smp(%__sampler addrspace(2)*
 
 kernel void foo(image1d_t img) {
-  sampler_t smp = 5;
-  // CHECK: alloca i32
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_LINEAR;
+  // CHECK: alloca %__sampler addrspace(2)*
   event_t evt;
   // CHECK: alloca %opencl.event_t*
-  // CHECK: store i32 5,
+  // CHECK: store %__sampler addrspace(2)*
   

Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread David Majnemer via cfe-commits
On Mon, Jul 11, 2016 at 12:18 PM, Nico Weber  wrote:

> On Mon, Jul 11, 2016 at 12:19 PM, David Majnemer  > wrote:
>
>>
>>
>> On Mon, Jul 11, 2016 at 9:03 AM, Nico Weber  wrote:
>>
>>> On Mon, Jul 11, 2016 at 11:51 AM, David Majnemer <
>>> david.majne...@gmail.com> wrote:
>>>


 On Mon, Jul 11, 2016 at 8:42 AM, Nico Weber 
 wrote:

> On Mon, Jul 11, 2016 at 11:36 AM, David Majnemer <
> david.majne...@gmail.com> wrote:
>
>>
>>
>> On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber 
>> wrote:
>>
>>> VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This
>>> means people who want to ask clang-cl for line tables only will have to 
>>> add
>>> this flag in some if(is_clang) block in their build file anyways. What's
>>> the advantage of giving this flag a spelling that's different from both 
>>> cl
>>> and clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
>>> Windows.
>>>
>>> (Even if there's a good case for /Zd, I don't think we should remove
>>> user-exposed flags without a strong reason, so even if we keep /Zd I 
>>> think
>>> we should also keep exposing -gline-tables-only.)
>>>
>>
>> Existing users of -gline-tables-only?  I'd imagine any responsible
>> users of -gline-tables-only would probably use their build system to 
>> verify
>> that the flag exists.  We have never released an official LLVM which
>> supported it (LLVM 3.8 came out in early March and -gline-tables-only was
>> exposed via clang-cl in mid March).
>>
>
> Ok, but why is /Zd better than -gline-tables-only?
>

 I see a few reasons:
 - It is less surprising for a debug flag in the cl world to be called
 /Zsomething instead of -gsomething.

>>>
>>> Eh, you'll have to look it up either way to find the flag.
>>>
>>
>> I agree.
>>
>>
>>> And when seeing the flag, the -g flag is more self-explanatory.
>>>
>>
>> I disagree, I had no idea what that flag did until I started working on
>> debug info.
>>
>>
>>> Also, it is surprising that a clang-cl /-style flag doesn't work with
>>> cl, so it just moves the surprise around a bit.
>>>
>>
>> It is surprising when that happens in either direction.  If this is
>> considered a bug, we will never "fix" it.
>>
>>
>>>
>>>
 - I think that avoiding invasion of their namespace, when possible, is
 a good thing.  It makes it less likely that we will conflict with a flag
 they want to add in the future.

>>>
>>> I don't understand this point. Doesn't invading their namespace make
>>> collisions _more_ likely?
>>>
>>>
 - I imagine that if they wanted to add support back for
 -gline-tables-only, they'd name it /Zd.

>>>
>>> Given they had this flag and removed it, they probably didn't like it
>>> very much :-)
>>>
>>>
 I'm sympathetic to the argument that "-gline-tables-only" is more
 familiar to Linux/Mac OS X folks and that /Zd won't work across all
 platforms.

 Here why I think that's ok:
 - This is not really a new problem.  If you want to select c++1z you
 get to spell it /std:c++latest for clang-cl and -std=c++14.

>>>
>>> Sure, but these are flags that clang/gcc and cl interpret. So if you
>>> have a gcc build and a visual studio build, it's fairly easy to get each
>>> going with clang / clang-cl.
>>>
>>> With /Zd, we're needlessly inventing a new spelling for an existing
>>> clang flag.
>>>
>>
>> icl also supports /Zd.
>>
>
> That's a big point in favor of this change, I think. Thanks for pointing
> it out.
>
>
>> As far as I can see, the new name creates a (small) problem without
>>> solving one.
>>>
>>
>> This is an attempt to reduce unneeded diversity.
>>
>
> From my point of view, it increased diversity: Before, this feature had
> one name, now it has two, and the second name is our own invention. (But if
> icl also uses that flag, then it's less bad.)
>

It's not out invention, it's Microsoft's.  icl (and now clang-cl) both
happen to still support it.  If a build system wanted just line table debug
info for a cl-like driver, they just need /Zd.


>
>
>> So far, when we wanted to add a flag that cl doesn't have and that clang
>>> has, we've always gone for the clang spelling of that flag. That seems like
>>> a good guideline to me.
>>>
>>
>> Often but not always.  For example, we have /Qvec instead of -fvectorize
>> because icl has the flag.
>>
>
> Hm, I'd (weakly) argue that that's not ideal either :-)
>

Why? MSVC has picked up flags from icl. See /Qvec-report.


>
> Anyhow, I think this isn't a good change, and it sounds like you disagree
> with that. So I guess the next step here is that Hans gets to make a
> decision once he's back?
>

More opinions are always better.


>
>
>>
>>
>>>
>>>
 - People who want harmony between Mac OS X, 

[libcxx] r275089 - Hide some internal symbols for memory resource.

2016-07-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jul 11 14:22:09 2016
New Revision: 275089

URL: http://llvm.org/viewvc/llvm-project?rev=275089=rev
Log:
Hide some internal symbols for memory resource.

Modified:
libcxx/trunk/src/experimental/memory_resource.cpp

Modified: libcxx/trunk/src/experimental/memory_resource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=275089=275088=275089=diff
==
--- libcxx/trunk/src/experimental/memory_resource.cpp (original)
+++ libcxx/trunk/src/experimental/memory_resource.cpp Mon Jul 11 14:22:09 2016
@@ -61,6 +61,8 @@ protected:
 { return &__other == this; }
 };
 
+namespace {
+
 union ResourceInitHelper {
   struct {
 __new_delete_memory_resource_imp new_delete_res;
@@ -74,6 +76,9 @@ union ResourceInitHelper {
 // Only in C++11 is "init_priority" needed to ensure initialization order.
 ResourceInitHelper res_init __attribute__((init_priority (101)));
 
+} // end namespace
+
+
 memory_resource * new_delete_resource() _NOEXCEPT {
 return _init.resources.new_delete_res;
 }


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


Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread Nico Weber via cfe-commits
On Mon, Jul 11, 2016 at 12:19 PM, David Majnemer 
wrote:

>
>
> On Mon, Jul 11, 2016 at 9:03 AM, Nico Weber  wrote:
>
>> On Mon, Jul 11, 2016 at 11:51 AM, David Majnemer <
>> david.majne...@gmail.com> wrote:
>>
>>>
>>>
>>> On Mon, Jul 11, 2016 at 8:42 AM, Nico Weber  wrote:
>>>
 On Mon, Jul 11, 2016 at 11:36 AM, David Majnemer <
 david.majne...@gmail.com> wrote:

>
>
> On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber 
> wrote:
>
>> VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This
>> means people who want to ask clang-cl for line tables only will have to 
>> add
>> this flag in some if(is_clang) block in their build file anyways. What's
>> the advantage of giving this flag a spelling that's different from both 
>> cl
>> and clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
>> Windows.
>>
>> (Even if there's a good case for /Zd, I don't think we should remove
>> user-exposed flags without a strong reason, so even if we keep /Zd I 
>> think
>> we should also keep exposing -gline-tables-only.)
>>
>
> Existing users of -gline-tables-only?  I'd imagine any responsible
> users of -gline-tables-only would probably use their build system to 
> verify
> that the flag exists.  We have never released an official LLVM which
> supported it (LLVM 3.8 came out in early March and -gline-tables-only was
> exposed via clang-cl in mid March).
>

 Ok, but why is /Zd better than -gline-tables-only?

>>>
>>> I see a few reasons:
>>> - It is less surprising for a debug flag in the cl world to be called
>>> /Zsomething instead of -gsomething.
>>>
>>
>> Eh, you'll have to look it up either way to find the flag.
>>
>
> I agree.
>
>
>> And when seeing the flag, the -g flag is more self-explanatory.
>>
>
> I disagree, I had no idea what that flag did until I started working on
> debug info.
>
>
>> Also, it is surprising that a clang-cl /-style flag doesn't work with cl,
>> so it just moves the surprise around a bit.
>>
>
> It is surprising when that happens in either direction.  If this is
> considered a bug, we will never "fix" it.
>
>
>>
>>
>>> - I think that avoiding invasion of their namespace, when possible, is a
>>> good thing.  It makes it less likely that we will conflict with a flag they
>>> want to add in the future.
>>>
>>
>> I don't understand this point. Doesn't invading their namespace make
>> collisions _more_ likely?
>>
>>
>>> - I imagine that if they wanted to add support back for
>>> -gline-tables-only, they'd name it /Zd.
>>>
>>
>> Given they had this flag and removed it, they probably didn't like it
>> very much :-)
>>
>>
>>> I'm sympathetic to the argument that "-gline-tables-only" is more
>>> familiar to Linux/Mac OS X folks and that /Zd won't work across all
>>> platforms.
>>>
>>> Here why I think that's ok:
>>> - This is not really a new problem.  If you want to select c++1z you get
>>> to spell it /std:c++latest for clang-cl and -std=c++14.
>>>
>>
>> Sure, but these are flags that clang/gcc and cl interpret. So if you have
>> a gcc build and a visual studio build, it's fairly easy to get each going
>> with clang / clang-cl.
>>
>> With /Zd, we're needlessly inventing a new spelling for an existing clang
>> flag.
>>
>
> icl also supports /Zd.
>

That's a big point in favor of this change, I think. Thanks for pointing it
out.


> As far as I can see, the new name creates a (small) problem without
>> solving one.
>>
>
> This is an attempt to reduce unneeded diversity.
>

>From my point of view, it increased diversity: Before, this feature had one
name, now it has two, and the second name is our own invention. (But if icl
also uses that flag, then it's less bad.)


> So far, when we wanted to add a flag that cl doesn't have and that clang
>> has, we've always gone for the clang spelling of that flag. That seems like
>> a good guideline to me.
>>
>
> Often but not always.  For example, we have /Qvec instead of -fvectorize
> because icl has the flag.
>

Hm, I'd (weakly) argue that that's not ideal either :-)

Anyhow, I think this isn't a good change, and it sounds like you disagree
with that. So I guess the next step here is that Hans gets to make a
decision once he's back?


>
>
>>
>>
>>> - People who want harmony between Mac OS X, Linux and Windows on the
>>> driver side can just use clang++.
>>>
>>>


>
> I'd consider it in poor form for users to take a hard dependency on a
> flag which only exists in a compiler which has never been released.
>
> I'd agree with you if -gline-tables-only had made its way to an actual
> release.
>
>
>>
>> On Mon, Jul 11, 2016 at 10:08 AM, Nico Weber 
>> wrote:
>>
>>> This breaks existing users of -gline-tables-only. What's the
>>> motivation for 

Re: [PATCH] D20786: Fix undefined behavior in __tree

2016-07-11 Thread Eric Fiselier via cfe-commits
EricWF added a reviewer: howard.hinnant.
EricWF added a subscriber: howard.hinnant.
EricWF added a comment.

Adding Howard to the reviewers. @howard.hinnant Feel free to take a look if 
your interested.

@mclow.lists Any comments?


http://reviews.llvm.org/D20786



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


Re: [PATCH] D19679: Method pool in modules: sync up out of date selectors before writing the module

2016-07-11 Thread Manman Ren via cfe-commits
manmanren closed this revision.
manmanren marked an inline comment as done.
manmanren added a comment.

In r268091.


http://reviews.llvm.org/D19679



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


Re: [PATCH] D19934: [NFC] Reorder fields of VersionTuple to reduce size

2016-07-11 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


http://reviews.llvm.org/D19934



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


Re: [PATCH] D22171: [ObjC Availability] Implement parser support for Objective-C's @available

2016-07-11 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks for working on this, Erik.

Manman



Comment at: include/clang/AST/Availability.h:32
@@ +31,3 @@
+class AvailabilitySpec {
+  VersionTuple Version;
+  StringRef Platform;

Can you put a description for "Version"? i.e if it represents a range, specify 
the range here.


Comment at: include/clang/AST/Availability.h:42
@@ +41,3 @@
+
+  // Constructor for '*'
+  AvailabilitySpec(SourceLocation StarLoc)

Can you make this comment a full sentence?


Comment at: include/clang/AST/Availability.h:51
@@ +50,3 @@
+
+  // true when this represents the '*' case.
+  bool isOtherPlatformSpec() const { return Version.empty(); }

Same here.


Comment at: include/clang/Basic/VersionTuple.h:29
@@ +28,3 @@
+
+  unsigned UsesUnderscores : 1;
+

If this changes in this file are not related to @available, please commit it 
separately.


Comment at: lib/AST/StmtPrinter.cpp:502
@@ +501,3 @@
+ObjCAvailabilityCheckExpr *Node) {
+  OS << "@available(...)";
+}

Why not print other information of Node?


Comment at: lib/Parse/ParseDecl.cpp:723
@@ -722,3 +722,3 @@
 VersionTuple Parser::ParseVersionTuple(SourceRange ) {
-  Range = Tok.getLocation();
+  Range.setBegin(Tok.getLocation());
 

I don't quite get what motivates this change. Are we not setting the range 
correctly before, for version tuples?


Comment at: lib/Parse/ParseExpr.cpp:2875
@@ +2874,3 @@
+
+/// Validate availability spec list, emitting diagnostics if necessary.
+static bool CheckAvailabilitySpecList(Parser ,

Please comment on the return value, i.e return true if invalid.


Comment at: lib/Parse/ParseExpr.cpp:2957
@@ +2956,3 @@
+  bool HasError = false;
+  for (;;) {
+Optional Spec = ParseAvailabilitySpec();

Why use "for (;;)" instead of "while(true)"?


Comment at: lib/Parse/ParseExpr.cpp:2964
@@ +2963,3 @@
+
+if (!TryConsumeToken(tok::comma))
+  break;

Can you verify that when having error parsing a single spec, the compiler can 
still reasonably continue? Should we skip until the next comma, or the next 
right paren? 


Comment at: lib/Parse/ParseObjc.cpp:2863
@@ +2862,3 @@
+  ConsumeToken();
+  return ParseAvailabilityCheckExpr(AtLoc);
+default: {

Should we move ConsumeToken to inside ParseAvailabilityCheckExpr, or at least 
provide a comment on skipping "@available", to be consistent with other parsing 
functions?


Comment at: lib/Parse/ParseObjc.cpp:2865
@@ +2864,3 @@
+default: {
+  const char *str = nullptr;
+  if (GetLookAheadToken(1).is(tok::l_brace)) {

Is this a format change for "default:"? If yes, can you commit it before this 
@available change?


http://reviews.llvm.org/D22171



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


Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-11 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.
Prazek added a comment.

Very usefull check!
I don't have enough time right now to check everything, so better wait for 
review of Alexfh or someone else. I just wanted to leave some thoughts.



Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:34
@@ +33,3 @@
+  if (CallRange.isValid()) {
+const std::string ForwardName =
+"forward<" + TypeParmType->getDecl()->getName().str() + ">";

you could probably use llvm::StringRef here, but I am not sure about it - ask 
Alex.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:71
@@ +70,3 @@
+void MoveForwardingReferenceCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

Use CPlusPlus11 here


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:92
@@ +91,3 @@
+   argumentCountIs(1),
+   hasArgument(0, ignoringParenCasts(declRefExpr(
+  to(ForwardingReferenceParmMatcher)

maybe use ignoringImplicit or if you won't need that use ignoringParenImpCasts 
(or something similar).

I am not sure if it is needed it, but it might help in some cases.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.h:19
@@ +18,3 @@
+
+class MoveForwardingReferenceCheck : public ClangTidyCheck {
+public:

Please add doc comment.


Comment at: docs/clang-tidy/checks/misc-move-forwarding-reference.rst:29
@@ +28,3 @@
+
+Background
+--

Very nice section! good idea.

So I have a thoughts about multiple sections in documentation (which is not a 
issue for you).
I think the check lists doc should not include sections - it doesn't look good 
and it also prevents people from using sections in docs.


Comment at: test/clang-tidy/misc-move-forwarding-reference.cpp:68
@@ +67,2 @@
+  void f(U &) { T SomeT(std::move(SomeU)); }
+};

Please add some tests that checks if fixes doesn't happen inside macro.


http://reviews.llvm.org/D0



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-07-11 Thread Pirama Arumuga Nainar via cfe-commits
pirama added a comment.

Ping...


http://reviews.llvm.org/D20602



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


Re: [PATCH] D22190: cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode

2016-07-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D22190#479921, @mgehre wrote:

> Even if we change isIntegerConstantExpr() to return true instead of 
> asserting, we still need this fix to the check. Because
>  we call isIntegerConstantExpr() to find out if we can possibly calculate the 
> (constant) value of the index expression.
>  If it is value dependent, we cannot.


You can on instantiation, can you not?


http://reviews.llvm.org/D22190



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


Re: [PATCH] D22208: clang-tidy] Fixes to modernize-use-emplace

2016-07-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:21
@@ +20,3 @@
+llvm::Optional
+getHasAnyName(const std::vector ) {
+  llvm::Optional hasMatcher;

Should be `Names` instead.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:21
@@ +20,3 @@
+llvm::Optional
+getHasAnyName(const std::vector ) {
+  llvm::Optional hasMatcher;

aaron.ballman wrote:
> Should be `Names` instead.
Is this needed? We have the `hasAnyName()` matcher already.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:31-33
@@ +30,5 @@
+
+const std::string defaultContainersWithPushBack =
+"std::vector; std::list; std::deque";
+const std::string defaultSmartPointers =
+"std::shared_ptr; std::unique_ptr; std::auto_ptr; std::weak_ptr";

These should start with a capital as well (coding standard information 
pertaining to names can be found at 
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly).


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:32-34
@@ +31,5 @@
+const std::string defaultContainersWithPushBack =
+"std::vector; std::list; std::deque";
+const std::string defaultSmartPointers =
+"std::shared_ptr; std::unique_ptr; std::auto_ptr; std::weak_ptr";
+} // namespace

These should be using `::std::` instead of `std::` just in case people do awful 
things like embed `namespace std` inside of their own namespaces.


Comment at: clang-tidy/modernize/UseEmplaceCheck.h:36
@@ -32,1 +35,3 @@
+private:
+  std::vector containersWithPushBack, smartPointers;
 };

Should be Containers and Smart (capital letters).


Repository:
  rL LLVM

http://reviews.llvm.org/D22208



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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-07-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/AST/Decl.h:3249
@@ -3248,1 +3248,3 @@
 
+  /// This is true if this struct ends with an array marked 'flexible_array'.
+  bool HasFlexibleArrayAttr : 1;

ahatanak wrote:
> Probably it can be looked up although it would require incrementing the 
> field_iterator until it reaches the last non-static data member of the record.
Ah shoot, I forgot that these are forward iterators, not bidirectional ones. I 
think the bit is probably the better way to go; we have bits to spare here.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2170
@@ +2169,3 @@
+  "'flexible_array' attribute only applies to %select{"
+  "the last member of a struct|members of structs or classes|"
+  "fixed sized array members|array members that have at least one element}0">;

I think "members of structs or classes" and "the last member of a struct" could 
be combined into "the last member of a non-union class", instead of using 
separate diagnostic text. What do you think?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2171
@@ +2170,3 @@
+  "the last member of a struct|members of structs or classes|"
+  "fixed sized array members|array members that have at least one element}0">;
+def err_flexible_array_nested : Error<

Since you can only have one such member, I think we want to drop the plural 
from both of these. I think the first may read better as "a non-flexible array 
member" (since there are "arrays" and "flexible arrays", but not "fixed-sized 
arrays" in our diagnostics), and the second may read better as "an array member 
that has at least one element".


Comment at: lib/AST/ExprConstant.cpp:170
@@ +169,3 @@
+/// Indicator of whether the last array added is marked flexible_array.
+bool IsFlexibleArray : 1;
+

ahatanak wrote:
> I don't think there is a way to do that reliably. The FieldDecl for the array 
> isn't always available in struct LValue, as far as I can tell, so it looks 
> like we'll need a bit here.
Okay, that seems reasonable to me -- I don't think anyone is relying on that 
bit being stolen from `MostDerivedPathLength`.


http://reviews.llvm.org/D21453



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


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-11 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 63539.
ashi1 marked 2 inline comments as done.
ashi1 added a comment.

Moved cl-strict-aliasing testing to a new file cl-strict-aliasing.cl


Repository:
  rL LLVM

http://reviews.llvm.org/D22170

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/opencl.cl
  test/Frontend/cl-strict-aliasing.cl

Index: test/Frontend/cl-strict-aliasing.cl
===
--- test/Frontend/cl-strict-aliasing.cl
+++ test/Frontend/cl-strict-aliasing.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+
+// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
+
+kernel void func(void);
\ No newline at end of file
Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -1,42 +1,35 @@
-// XFAIL: *
-// RUN: %clang -S -### -cl-std=CL %s | FileCheck --check-prefix=CHECK-CL %s
-// RUN: %clang -S -### -cl-std=CL1.1 %s | FileCheck --check-prefix=CHECK-CL11 %s
-// RUN: %clang -S -### -cl-std=CL1.2 %s | FileCheck --check-prefix=CHECK-CL12 %s
-// RUN: %clang -S -### -cl-std=CL2.0 %s | FileCheck --check-prefix=CHECK-CL20 %s
-// RUN: %clang -S -### -cl-opt-disable %s | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
-// RUN: %clang -S -### -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
-// RUN: %clang -S -### -cl-std=CL1.1 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
-// RUN: %clang -S -### -cl-std=CL1.2 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
-// RUN: %clang -S -### -cl-std=CL2.0 -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
-// RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
-// RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
-// RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
-// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
-// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
-// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
-// RUN: %clang -S -### -cl-no-signed-zeros %s | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
-// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
-// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
-// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// RUN: %clang -S -### -cl-std=CL %s 2>&1 | FileCheck --check-prefix=CHECK-CL %s
+// RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck --check-prefix=CHECK-CL11 %s
+// RUN: %clang -S -### -cl-std=CL1.2 %s 2>&1 | FileCheck --check-prefix=CHECK-CL12 %s
+// RUN: %clang -S -### -cl-std=CL2.0 %s 2>&1 | FileCheck --check-prefix=CHECK-CL20 %s
+// RUN: %clang -S -### -cl-opt-disable %s 2>&1 | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
+// RUN: %clang -S -### -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
+// RUN: %clang -S -### -cl-single-precision-constant %s 2>&1 | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
+// RUN: %clang -S -### -cl-finite-math-only %s 2>&1 | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
+// RUN: %clang -S -### -cl-kernel-arg-info %s 2>&1 | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
+// RUN: %clang -S -### -cl-unsafe-math-optimizations %s 2>&1 | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
+// RUN: %clang -S -### -cl-fast-relaxed-math %s 2>&1 | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
+// RUN: %clang -S -### -cl-mad-enable %s 2>&1 | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-no-signed-zeros %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
+// RUN: %clang -S -### -cl-denorms-are-zero %s 2>&1 | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
+// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
-// CHECK-CL: 

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-11 Thread Yaxun Liu via cfe-commits
yaxunl marked 20 inline comments as done.


Comment at: lib/CodeGen/CGExprConstant.cpp:694
@@ +693,3 @@
+case CK_IntToOCLSampler:
+  llvm_unreachable("global sampler variables are not generated");
+

Anastasia wrote:
> Does this only apply to global variable samplers?
Yes. The translation of local sampler is like

   sampler_t p = X;

->

   __sampler** p = alloca __sampler*;
   store __translate_sampler_initializer(X), p


Comment at: lib/CodeGen/CodeGenModule.cpp:4309
@@ +4308,3 @@
+  // in SPIR spec v1.2 and also opencl-c.h
+  unsigned AddressingMode  = (0x0E & SamplerValue) >> 1;
+  unsigned FilterMode  = (0x30 & SamplerValue) >> 4;

Anastasia wrote:
> Seems like this code is specific to SPIR and not OpenCL?
This warning msg is emitted for SPIR incompatible sampler value. It belongs to 
a category spir-compat. How about we turn off this category of warning by 
default and only enable it for SPIR target by default?


Comment at: lib/Sema/SemaInit.cpp:6907
@@ -6906,3 +6907,1 @@
 case SK_OCLSamplerInit: {
-  assert(Step->Type->isSamplerT() && 
- "Sampler initialization on non-sampler type.");

Anastasia wrote:
> Is the assert no longer needed?
This assert is unlikely to happen. not so useful.


Comment at: test/CodeGenOpenCL/sampler.cl:23
@@ +22,3 @@
+  fnc4smp(smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* 
@__translate_sampler_initializer(i32 19)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])

Anastasia wrote:
> Why does the initialization  happen second time here?
We cannot call function in the initializer of an LLVM global variable, so each 
reference of the global variable is replaced by a call of 
`__transform_sampler_initializer` and the original global variable is 
eliminated.


Comment at: test/CodeGenOpenCL/sampler.cl:26
@@ +25,3 @@
+
+  fnc4smp(glb_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* 
@__translate_sampler_initializer(i32 35)

Anastasia wrote:
> Could we check definition of global sampler variable in IR too?
The original global variable is eliminated and its references are replaced by 
call of `__transform_sampler_initializer`.


http://reviews.llvm.org/D21567



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


Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-11 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).


http://reviews.llvm.org/D0



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


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-11 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: test/Frontend/opencl-blocks.cl:9
@@ -8,1 +8,3 @@
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s

ashi1 wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > yaxunl wrote:
> > > > Better separate these tests to another file, e.g. cl-strict-aliasing.cl
> > > I think it was right to have this in test/Driver/opencl.cl. Why was it 
> > > moved in here?
> > This is a frontend option and the warning is emitted by frontend, not the 
> > driver. The driver does not consume the option. It just passes it to the 
> > frontend.
> > 
> > The driver test is mostly testing whether the option is correctly passed to 
> > the compiler invocation by using -###.
> should it be called opencl-strict-aliasing.cl or cl-strict-aliasing.cl
either is OK.


Repository:
  rL LLVM

http://reviews.llvm.org/D22170



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


Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-11 Thread Matthias Gehre via cfe-commits
mgehre added a subscriber: mgehre.
mgehre added a comment.

Nice check. This should be mentioned in docs/ReleaseNotes.rst


http://reviews.llvm.org/D0



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


[PATCH] D22227: [ubsan] Disable bounds-check for flexible array ivars

2016-07-11 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added reviewers: rsmith, samsonov.
vsk added a subscriber: cfe-commits.

Ubsan does not emit bounds checks for flexible array members, e.g:




   
  struct Foo { char arr[0]; };
  char bar(struct Foo *F) { return F->arr[1]; }

Teach ubsan to skip the bounds check for flexible array ivars as well.

This reduces the false-positive rate when instrumenting Objective-C frameworks.

Ubsan tests are typically added to compiler-rt. I chose to create a test in 
clang instead because I didn't want to introduce a libobjc dependency. The test 
works by checking for the "nosanitize" attribute: hopefully this is less 
brittle than checking for the name of the relevant runtime handler.

http://reviews.llvm.org/D7

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenObjC/ubsan.m

Index: test/CodeGenObjC/ubsan.m
===
--- /dev/null
+++ test/CodeGenObjC/ubsan.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple 
x86_64-apple-macosx10.10.0 -Wno-objc-root-class -fsanitize=array-bounds %s -o - 
| FileCheck %s
+
+@interface HasFlexibleArray {
+  @public char chars[0];
+}
+@end
+@implementation HasFlexibleArray @end
+
+// CHECK-LABEL: do_not_instrument_flexible_array_members
+char do_not_instrument_flexible_array_members(HasFlexibleArray *HFA) {
+// CHECK-NOT: !nosanitize
+  return HFA->chars[1];
+// CHECK: }
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -708,6 +708,8 @@
   DeclContext::decl_iterator(const_cast(FD)));
   return ++FI == FD->getParent()->field_end();
 }
+  } else if (const auto *IRE = dyn_cast(E)) {
+return IRE->getDecl()->getNextIvar() == nullptr;
   }
 
   return false;


Index: test/CodeGenObjC/ubsan.m
===
--- /dev/null
+++ test/CodeGenObjC/ubsan.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -Wno-objc-root-class -fsanitize=array-bounds %s -o - | FileCheck %s
+
+@interface HasFlexibleArray {
+  @public char chars[0];
+}
+@end
+@implementation HasFlexibleArray @end
+
+// CHECK-LABEL: do_not_instrument_flexible_array_members
+char do_not_instrument_flexible_array_members(HasFlexibleArray *HFA) {
+// CHECK-NOT: !nosanitize
+  return HFA->chars[1];
+// CHECK: }
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -708,6 +708,8 @@
   DeclContext::decl_iterator(const_cast(FD)));
   return ++FI == FD->getParent()->field_end();
 }
+  } else if (const auto *IRE = dyn_cast(E)) {
+return IRE->getDecl()->getNextIvar() == nullptr;
   }
 
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r274246 - [codeview] Emit qualified display names if -gline-tables-only is on

2016-07-11 Thread David Blaikie via cfe-commits
On Fri, Jul 8, 2016 at 1:04 PM, Nico Weber  wrote:

> On Fri, Jul 8, 2016 at 3:57 PM, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>>
>> On Thu, Jul 7, 2016 at 4:10 PM, Reid Kleckner  wrote:
>>
>>> On Thu, Jul 7, 2016 at 3:45 PM, David Blaikie 
>>> wrote:
>>>
 Yeah - is this necessary for CodeView? (does something break, or do you
 just get simple names where you'd prefer full mangled or qualified names)

 It was chosen pretty deliberately to do it this way (use unqualified
 names) for gmlt to keep size down. Have you got numbers for the size delta
 for CodeView with this change? I'd really prefer to make the same choice
 for both - it'd seem a bit arbitrary to choose our size optimization based
 on differences in the kind of workloads we happen to have on these two
 platforms.

>>>
>>> It's problematic for CodeView because there is no equivalent field like
>>> DW_AT_linkage_name in any of the symbol records. There is only the display
>>> name, which includes scope qualifiers.
>>>
>>> I'm suggesting we reverse our decision for DWARF because our space
>>> saving optimization breaks standard stack dumpers on Linux (gdb and
>>> addr2line),
>>>
>>
>> What breakage are you referring to here?
>>
>> If we're talking about printing out the simple name - that comes up even
>> in llvm-symbolizer if a function is inlined. So I think that's an
>> intentional tradeoff that would apply to CV as well.
>>
>>
>>> and that seems like a Bad Thing. Instead we've told users to user
>>> llvm-symbolizer, which is OK, but kind of crappy.
>>>
>>
>> I imagine that depends on how much it costs us - we've been pretty
>> careful about binary size growth/minimization/etc for a while now
>>
>
> Does this add much size?
>

I believe so, but don't have specific numbers. Alexey made this choice when
it was originally implemented & I believe had the data back then.


> This only makes strings longer and doesn't force emission of types, right?
>

Right


> (From what I understand, types are what makes -fline-tables-only output
> much smaller.)
>

That's the first step, yes, though even gmlt data is in the order of 10s of
% (actually much worse in an optimized build - I think I measure it still
at 200% or somesuch, that was motivating Cary's work on 2 level line
tables), and most of that is strings, so making bigger (much bigger)
strings can have a significant impact.


> Sorry about the uninformed question :-) If that's roughly correct though,
> maybe it'd be good to get an idea how much bigger debug info would get with
> qualified names
>

For sure - that's the basic question: If you're going to change this,
please measure it & make sure the change isn't going to have a drastically
adverse effect on the size of the output.


> -- we can't use -fline-tables-only 'cause they make stacks look very bad,
>

Also I'm curious why your use case/tolerance for "badness" here is
different from what we've been using at Google for ASan, etc, for several
years now. Do you have different requirements/needs here? Then maybe we
need to figure out names for those needs & enshrine them in flags.


> and if qualified names in debug info would give us decent stacks while
> still being smaller,
>

Smaller than full debug info, you mean? Or smaller than something else?


> that'd be cool. (See also thread "rfc: Adding a mode to -gline-tables-only
> to include parameter names, namespaces" from a while ago.)
>
>
>> , so it may be worth the tradeoff to say that llvm-symbolizer produces a
>> better experience on this extra minimized data.
>>
>>
>>> For CodeView, because the linkage name isn't present anywhere, we can't
>>> actually do any better with llvm-symbolizer, and we need the fully scoped
>>> name.
>>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-11 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Your code is well-written and easy to understand, and makes me want to use it 
on my code! Added some minor comments, and there seems to be a small logic 
error in the compound statement hasher.

Not sure if that was already explained in detail, but i seem to agree that the 
only point for this project to integrate into Clang Static Analyzer is to 
integrate with the `BugReporter` facility - at least optionally: it would allow 
the reports of the clone detector checker to be gathered and viewed in a manner 
similar to other checkers - i.e. through scan-build/scan-view, probably 
CodeChecker and other tools. That should make the check easier to run and 
attract more users. However, the `BugReporter` mechanism is tweaked for the 
analyzer's path-sensitive checkers, so it'd need to be modified to suit your 
purpose, so in my opinion this is not critical for the initial commit.



Comment at: lib/AST/CloneDetection.cpp:52
@@ +51,3 @@
+  Other.getEndLoc() == getEndLoc();
+  return StartIsInBounds && EndIsInBounds;
+}

Perhaps we could early-return when we see that `StartIsInBounds` is false (for 
performance, because `isBeforeInTranslationUnit` looks heavy).


Comment at: lib/AST/CloneDetection.cpp:88
@@ +87,3 @@
+/// It is defined as:
+///   H(D) = PrimeFactor^(N-1) * D[0] + PrimeFactor^(N-2) * D[1] + ... + D[N]
+/// where

It seems that the last index is off-by-one, i think you meant something like:

```
H(D) = PrimeFactor^(N-1) * D[0] + PrimeFactor^(N-2) * D[1] + ... + D[N-1]
```


Comment at: lib/AST/CloneDetection.cpp:175
@@ +174,3 @@
+  ++StartIterator;
+auto EndIterator = Iterator;
+for (unsigned I = 0; I < Length; ++I)

Shouldn't it say something like "`EndIterator = StartIterator`"? Because when 
`StartPos` is non-zero, in your code we get [`StartPos`, `Length`) instead of 
[`StartPos`, `StartPos` + `Length`). In your code, `Length` acts as some kind 
of `EndPos` instead.


Comment at: lib/AST/CloneDetection.cpp:194
@@ +193,3 @@
+  } else {
+StmtSequence ChildSequence(StmtSequence(Child, Context));
+

Simplifies to:

```
StmtSequence ChildSequence(Child, Context);
```


Comment at: lib/AST/CloneDetection.cpp:238
@@ +237,3 @@
+  // the CompoundStmt.
+  auto CS = dyn_cast(CurrentStmt.front());
+  if (!CS)

I think that the code that deals with //computing// data for sections of 
compound statements (as opposed to //saving// this data) should be moved to 
`VisitStmt()`. Or, even better, to `VisitCompoundStmt()` - that's the whole 
point of having a visitor, after all. Upon expanding the complexity of the 
hash, you'd probably provide more special cases for special statement classes, 
which would all sit in their own Visit method.

That's for the future though, not really critical.


Comment at: lib/AST/CloneDetection.cpp:262
@@ +261,3 @@
+
+  CloneDetector::StmtData SubData(SubHash.getValue(), SubComplexity);
+  CD.add(Sequence, SubData);

This code is duplicated from the beginning of the function, which synergizes 
with my point above: if `SaveData()` contained only that much, then it could 
have been re-used on both call sites.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:40
@@ +39,3 @@
+  CloneDetector.AnalyzeTranslationUnitDecl(
+  TU->getASTContext().getTranslationUnitDecl());
+

`TU->getASTContext().getTranslationUnitDecl()` is always equal to `TU` - there 
should, in most cases, be only one TranslationUnitDecl object around, but even 
if there'd be more some day, i think this invariant would still hold. 


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:43
@@ +42,3 @@
+  std::vector CloneGroups;
+  CloneDetector.findClones(CloneGroups);
+

An idea: because this function optionally accepts `MinGroupComplexity`, you may 
probably want to expose this feature as a //checker-specific option// - see 
`MallocChecker::IsOptimistic` as an example, shouldn't be hard.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:45
@@ +44,3 @@
+
+  DiagnosticsEngine  = Mgr.getDiagnostic();
+

zaks.anna wrote:
> Is it possible to report these through BugReporter?
I think that'd require changes in the BugReporter to allow easily adding extra 
pieces to path-insensitive reports (which is quite a wanted feature in many 
AST-based checkers - assuming we want more AST-based checkers to be moved into 
the analyzer specifically for better reporting, integration with scan-build, 
and stuff like that).


Comment at: test/Analysis/copypaste/test-min-max.cpp:39
@@ +38,3 @@
+
+int foo(int a, int b) {
+  return a + b;

Perhaps add a `// no-warning` comment to spots that should not cause a warning? 
This comment has no effect on 

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-11 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7868
@@ +7867,3 @@
+def warn_sampler_initializer_invalid_bits : Warning<
+  "Sampler initializer has invalid %0 bits">, InGroup;
+def err_sampler_initializer_not_constant : Error<

start in lower case as all other messages!


Comment at: lib/CodeGen/CGExprConstant.cpp:694
@@ +693,3 @@
+case CK_IntToOCLSampler:
+  llvm_unreachable("global sampler variables are not generated");
+

Does this only apply to global variable samplers?


Comment at: lib/CodeGen/CodeGenModule.cpp:4309
@@ +4308,3 @@
+  // in SPIR spec v1.2 and also opencl-c.h
+  unsigned AddressingMode  = (0x0E & SamplerValue) >> 1;
+  unsigned FilterMode  = (0x30 & SamplerValue) >> 4;

Seems like this code is specific to SPIR and not OpenCL?


Comment at: lib/Sema/SemaInit.cpp:6907
@@ -6906,3 +6907,1 @@
 case SK_OCLSamplerInit: {
-  assert(Step->Type->isSamplerT() && 
- "Sampler initialization on non-sampler type.");

Is the assert no longer needed?


Comment at: lib/Sema/SemaInit.cpp:6909
@@ +6908,3 @@
+  Expr *Init = CurInit.get();
+  Init->dump();
+  QualType SourceType = Init->getType();

Debug output?


Comment at: test/CodeGenOpenCL/sampler.cl:23
@@ +22,3 @@
+  fnc4smp(smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* 
@__translate_sampler_initializer(i32 19)
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])

Why does the initialization  happen second time here?


Comment at: test/CodeGenOpenCL/sampler.cl:26
@@ +25,3 @@
+
+  fnc4smp(glb_smp);
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* 
@__translate_sampler_initializer(i32 35)

Could we check definition of global sampler variable in IR too?


http://reviews.llvm.org/D21567



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


r275078 - [Sema] Don't artificially forbid BuiltinTemplateDecls in CheckTemplateArgument

2016-07-11 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Jul 11 12:09:56 2016
New Revision: 275078

URL: http://llvm.org/viewvc/llvm-project?rev=275078=rev
Log:
[Sema] Don't artificially forbid BuiltinTemplateDecls in CheckTemplateArgument

After thinking about it, we don't really need to forbid
BuiltinTemplateDecls explicitly.  The restriction doesn't really buy us
anything.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/make_integer_seq.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=275078=275077=275078=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jul 11 12:09:56 2016
@@ -5377,14 +5377,13 @@ bool Sema::CheckTemplateArgument(Templat
   // partial specializations.
   if (!isa(Template) &&
   !isa(Template) &&
-  !isa(Template)) {
-assert((isa(Template) ||
-isa(Template)) &&
-   "Only function or builtin templates are possible here");
+  !isa(Template) &&
+  !isa(Template)) {
+assert(isa(Template) &&
+   "Only function templates are possible here");
 Diag(Arg.getLocation(), diag::err_template_arg_not_valid_template);
-if (isa(Template))
-  Diag(Template->getLocation(), diag::note_template_arg_refers_here_func)
-  << Template;
+Diag(Template->getLocation(), diag::note_template_arg_refers_here_func)
+  << Template;
   }
 
   TemplateParameterList *Params = Param->getTemplateParameters();

Modified: cfe/trunk/test/SemaCXX/make_integer_seq.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/make_integer_seq.cpp?rev=275078=275077=275078=diff
==
--- cfe/trunk/test/SemaCXX/make_integer_seq.cpp (original)
+++ cfe/trunk/test/SemaCXX/make_integer_seq.cpp Mon Jul 11 12:09:56 2016
@@ -48,6 +48,6 @@ using illformed2 = ErrorSeq;
 template  void f() {}
 __make_integer_seq x; // expected-error{{template template 
parameter must be a class template or type alias template}}
 
-__make_integer_seq<__make_integer_seq, int, 10> PR28494; // 
expected-error{{does not refer to a class or alias template, or template 
template parameter}} expected-error{{different template parameters}}
+__make_integer_seq<__make_integer_seq, int, 10> PR28494; // 
expected-error{{different template parameters}}
 // expected-note@make_integer_seq.cpp:* {{template parameter has a different 
kind}}
 // expected-note@make_integer_seq.cpp:* {{previous template template parameter 
is here}}


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


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-11 Thread Aaron En Ye Shi via cfe-commits
ashi1 marked 4 inline comments as done.


Comment at: lib/Frontend/CompilerInvocation.cpp:1681
@@ -1692,1 +1680,3 @@
 
+  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
+  // This option should be deprecated for CL > 1.0 because

Anastasia wrote:
> Was this code moved intensionally?
Yes this had to be moved intentionally, due to Opts.OpenCLVersion not being 
correctly set up until after the above function call to 
CompilerInvocation::setLangDefaults(


Comment at: test/Frontend/opencl-blocks.cl:9
@@ -8,1 +8,3 @@
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s

yaxunl wrote:
> Anastasia wrote:
> > yaxunl wrote:
> > > Better separate these tests to another file, e.g. cl-strict-aliasing.cl
> > I think it was right to have this in test/Driver/opencl.cl. Why was it 
> > moved in here?
> This is a frontend option and the warning is emitted by frontend, not the 
> driver. The driver does not consume the option. It just passes it to the 
> frontend.
> 
> The driver test is mostly testing whether the option is correctly passed to 
> the compiler invocation by using -###.
should it be called opencl-strict-aliasing.cl or cl-strict-aliasing.cl


Repository:
  rL LLVM

http://reviews.llvm.org/D22170



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


r275075 - [man page] Fix two sphinx build errors.

2016-07-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Jul 11 12:03:13 2016
New Revision: 275075

URL: http://llvm.org/viewvc/llvm-project?rev=275075=rev
Log:
[man page] Fix two sphinx build errors.
These options were referenced by other paragraphs, but never specified.

Modified:
cfe/trunk/docs/CommandGuide/clang.rst

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=275075=275074=275075=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Mon Jul 11 12:03:13 2016
@@ -184,7 +184,7 @@ Language Selection and Mode Options
  (either via :option:`-fobjc-nonfragile-abi`, or because it is the platform
  default).
 
-.. option:: -fobjc-nonfragile-abi
+.. option:: -fobjc-nonfragile-abi, -fno-objc-nonfragile-abi
 
  Enable use of the Objective-C non-fragile ABI. On platforms for which this is
  the default ABI, it can be disabled with :option:`-fno-objc-nonfragile-abi`.
@@ -300,7 +300,7 @@ Code Generation Options
 
   This flag sets the default visibility level.
 
-.. option:: -fcommon
+.. option:: -fcommon, -fno-common
 
   This flag specifies that variables without initializers get common linkage.
   It can be disabled with :option:`-fno-common`.


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


r275076 - [man page] Document -gline-tables-only in the clang man page.

2016-07-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Jul 11 12:03:16 2016
New Revision: 275076

URL: http://llvm.org/viewvc/llvm-project?rev=275076=rev
Log:
[man page] Document -gline-tables-only in the clang man page.

Modified:
cfe/trunk/docs/CommandGuide/clang.rst

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=275076=275075=275076=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Mon Jul 11 12:03:16 2016
@@ -253,22 +253,32 @@ Code Generation Options
 
   Currently equivalent to :option:`-O3`
 
-.. option:: -g
+.. option:: -g, -gline-tables-only, -gmodules
 
-  Generate debug information.  Note that Clang debug information works best at 
-O0.
+  Control debug information output.  Note that Clang debug information works
+  best at :option:`-O0`.  When more than one option starting with `-g` is
+  specified, the last one wins:
+
+:option:`-g` Generate debug information.
+
+:option:`-gline-tables-only` Generate only line table debug information. 
This
+allows for symbolicated backtraces with inlining information, but does not
+include any information about variables, their locations or types.
+
+:option:`-gmodules` Generate debug information that contains external
+references to types defined in Clang modules or precompiled headers instead
+of emitting redundant debug type information into every object file.  This
+option transparently switches the Clang module format to object file
+containers that hold the Clang module together with the debug information.
+When compiling a program that uses Clang modules or precompiled headers,
+this option produces complete debug information with faster compile
+times and much smaller object files.
+
+This option should not be used when building static libraries for
+distribution to other machines because the debug info will contain
+references to the module cache on the machine the object files in the
+library were built on.
 
-.. option:: -gmodules
-
-  Generate debug information that contains external references to
-  types defined in clang modules or precompiled headers instead of
-  emitting redundant debug type information into every object file.
-  This option implies :option:`-fmodule-format=obj`.
-
-  This option should not be used when building static libraries for
-  distribution to other machines because the debug info will contain
-  references to the module cache on the machine the object files in
-  the library were built on.
-  
 .. option:: -fstandalone-debug -fno-standalone-debug
 
   Clang supports a number of optimizations to reduce the size of debug


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


Re: [PATCH] D22222: [ASTMatchers] isSignedInteger() and isUnsignedInteger()

2016-07-11 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Please regenerate the public docs (using dump_ast_matchers.py). Otherwise, LGTM!


http://reviews.llvm.org/D2



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 63527.
carlo.bertolli added a comment.

[OpenMP] Apply comments: remove creation of private variable and update 
regression tests to include references to pointers.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2275,6 +2275,9 @@
 void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(const OMPUseDevicePtrClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_data_use_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
+struct ST {
+  int *a;
+};
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  void func(int arg) {
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+{}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr() // expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+{}
+#pragma omp target data map(i) use_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(i) // expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(j) // expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(z) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(aa) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(e) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(g) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k,i,j) // expected-error2 {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(d) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(da) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+  return;
+ }
+};
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return [0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef int from;
+
+template 
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T i;
+  T  = i;
+  T *k = 
+  T * = k;
+  T aa[10];
+#pragma omp target data map(i) use_device_ptr 

Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked an inline comment as done.
carlo.bertolli added a comment.

> No positive tests for the construct


Do you mean in the regression test? I thought I covered all negative and 
positive cases, but please let me know if I missed anything.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8333
@@ -8332,1 +8332,3 @@
   "expected at least one 'to' clause or 'from' clause specified to '#pragma 
omp target update'">;
+def  err_omp_usedeviceptr_not_a_pointer : Error<
+  "expected pointer in 'use_device_ptr' clause">;

ABataev wrote:
> Shall we accept refs to pointers and arrays?
I think that people of the OpenMP committee agreed that we can accept 
references to pointers. There is no indication in the specifications about 
arrays, so I will leave them out for the time being.
I will add a mention of references here.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


RE: r275040 - [CodeGen] Treat imported static local variables as declarations

2016-07-11 Thread Robinson, Paul via cfe-commits
This changes the IR but not the debug-info metadata?
--paulr

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> David Majnemer via cfe-commits
> Sent: Sunday, July 10, 2016 9:28 PM
> To: cfe-commits@lists.llvm.org
> Subject: r275040 - [CodeGen] Treat imported static local variables as
> declarations
> 
> Author: majnemer
> Date: Sun Jul 10 23:28:21 2016
> New Revision: 275040
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=275040=rev
> Log:
> [CodeGen] Treat imported static local variables as declarations
> 
> Imported variables cannot really be definitions for the purposes of
> IR generation.
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/test/CodeGenCXX/dllimport.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=275040=275039=275040
> =diff
> ==
> 
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Jul 10 23:28:21 2016
> @@ -323,10 +323,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
> D->hasAttr()))
>  return;
> 
> -  // DLL imported variables will be initialized by the export side.
> -  if (D->hasAttr())
> -return;
> -
>// Check if we've already initialized this decl.
>auto I = DelayedCXXInitPosition.find(D);
>if (I != DelayedCXXInitPosition.end() && I->second == ~0U)
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=275040=275039=27
> 5040=diff
> ==
> 
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Jul 10 23:28:21 2016
> @@ -2851,6 +2851,10 @@ static void ReplaceUsesOfNonProtoTypeWit
>  }
> 
>  void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
> +  auto DK = VD->isThisDeclarationADefinition();
> +  if (DK == VarDecl::Definition && VD->hasAttr())
> +return;
> +
>TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();
>// If we have a definition, this might be a deferred decl. If the
>// instantiation is explicit, make sure we emit it at the end.
> 
> Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=275040=275039=27
> 5040=diff
> ==
> 
> --- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Sun Jul 10 23:28:21 2016
> @@ -676,7 +676,7 @@ namespace ClassTemplateStaticDef {
>  static int x;
>};
>template  int S::x;
> -  // MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" =
> available_externally dllimport global i32 0
> +  // MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" = external
> dllimport global i32
>int f() { return S::x; }
> 
>// Partial class template specialization static field:
> @@ -685,7 +685,7 @@ namespace ClassTemplateStaticDef {
>  static int x;
>};
>template  int T::x;
> -  // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE =
> available_externally dllimport global i32 0
> +  // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE = external dllimport
> global i32
>int g() { return T::x; }
>  }
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-11 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: test/Frontend/opencl-blocks.cl:9
@@ -8,1 +8,3 @@
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s

Anastasia wrote:
> yaxunl wrote:
> > Better separate these tests to another file, e.g. cl-strict-aliasing.cl
> I think it was right to have this in test/Driver/opencl.cl. Why was it moved 
> in here?
This is a frontend option and the warning is emitted by frontend, not the 
driver. The driver does not consume the option. It just passes it to the 
frontend.

The driver test is mostly testing whether the option is correctly passed to the 
compiler invocation by using -###.


Repository:
  rL LLVM

http://reviews.llvm.org/D22170



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


Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-11 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:1681
@@ -1692,1 +1680,3 @@
 
+  // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
+  // This option should be deprecated for CL > 1.0 because

Was this code moved intensionally?


Comment at: test/Frontend/opencl-blocks.cl:9
@@ -8,1 +8,3 @@
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s

yaxunl wrote:
> Better separate these tests to another file, e.g. cl-strict-aliasing.cl
I think it was right to have this in test/Driver/opencl.cl. Why was it moved in 
here?


Repository:
  rL LLVM

http://reviews.llvm.org/D22170



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


Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread David Majnemer via cfe-commits
On Mon, Jul 11, 2016 at 9:03 AM, Nico Weber  wrote:

> On Mon, Jul 11, 2016 at 11:51 AM, David Majnemer  > wrote:
>
>>
>>
>> On Mon, Jul 11, 2016 at 8:42 AM, Nico Weber  wrote:
>>
>>> On Mon, Jul 11, 2016 at 11:36 AM, David Majnemer <
>>> david.majne...@gmail.com> wrote:
>>>


 On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber 
 wrote:

> VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This
> means people who want to ask clang-cl for line tables only will have to 
> add
> this flag in some if(is_clang) block in their build file anyways. What's
> the advantage of giving this flag a spelling that's different from both cl
> and clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
> Windows.
>
> (Even if there's a good case for /Zd, I don't think we should remove
> user-exposed flags without a strong reason, so even if we keep /Zd I think
> we should also keep exposing -gline-tables-only.)
>

 Existing users of -gline-tables-only?  I'd imagine any responsible
 users of -gline-tables-only would probably use their build system to verify
 that the flag exists.  We have never released an official LLVM which
 supported it (LLVM 3.8 came out in early March and -gline-tables-only was
 exposed via clang-cl in mid March).

>>>
>>> Ok, but why is /Zd better than -gline-tables-only?
>>>
>>
>> I see a few reasons:
>> - It is less surprising for a debug flag in the cl world to be called
>> /Zsomething instead of -gsomething.
>>
>
> Eh, you'll have to look it up either way to find the flag.
>

I agree.


> And when seeing the flag, the -g flag is more self-explanatory.
>

I disagree, I had no idea what that flag did until I started working on
debug info.


> Also, it is surprising that a clang-cl /-style flag doesn't work with cl,
> so it just moves the surprise around a bit.
>

It is surprising when that happens in either direction.  If this is
considered a bug, we will never "fix" it.


>
>
>> - I think that avoiding invasion of their namespace, when possible, is a
>> good thing.  It makes it less likely that we will conflict with a flag they
>> want to add in the future.
>>
>
> I don't understand this point. Doesn't invading their namespace make
> collisions _more_ likely?
>
>
>> - I imagine that if they wanted to add support back for
>> -gline-tables-only, they'd name it /Zd.
>>
>
> Given they had this flag and removed it, they probably didn't like it very
> much :-)
>
>
>> I'm sympathetic to the argument that "-gline-tables-only" is more
>> familiar to Linux/Mac OS X folks and that /Zd won't work across all
>> platforms.
>>
>> Here why I think that's ok:
>> - This is not really a new problem.  If you want to select c++1z you get
>> to spell it /std:c++latest for clang-cl and -std=c++14.
>>
>
> Sure, but these are flags that clang/gcc and cl interpret. So if you have
> a gcc build and a visual studio build, it's fairly easy to get each going
> with clang / clang-cl.
>
> With /Zd, we're needlessly inventing a new spelling for an existing clang
> flag.
>

icl also supports /Zd.


> As far as I can see, the new name creates a (small) problem without
> solving one.
>

This is an attempt to reduce unneeded diversity.


>
> So far, when we wanted to add a flag that cl doesn't have and that clang
> has, we've always gone for the clang spelling of that flag. That seems like
> a good guideline to me.
>

Often but not always.  For example, we have /Qvec instead of -fvectorize
because icl has the flag.


>
>
>> - People who want harmony between Mac OS X, Linux and Windows on the
>> driver side can just use clang++.
>>
>>
>>>
>>>

 I'd consider it in poor form for users to take a hard dependency on a
 flag which only exists in a compiler which has never been released.

 I'd agree with you if -gline-tables-only had made its way to an actual
 release.


>
> On Mon, Jul 11, 2016 at 10:08 AM, Nico Weber 
> wrote:
>
>> This breaks existing users of -gline-tables-only. What's the
>> motivation for this change?
>>
>
>> On Sat, Jul 9, 2016 at 5:49 PM, David Majnemer via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: majnemer
>>> Date: Sat Jul  9 16:49:16 2016
>>> New Revision: 274991
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=274991=rev
>>> Log:
>>> [clang-cl] Add support for /Zd
>>>
>>> MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe)
>>> support a
>>> flag called /Zd which is more-or-less -gline-tables-only.
>>>
>>> It seems nicer to support this flag instead of exposing
>>> -gline-tables-only.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Driver/CLCompatOptions.td
>>> cfe/trunk/include/clang/Driver/Options.td

[PATCH] D22222: [ASTMatchers] isSignedInteger() and isUnsignedInteger()

2016-07-11 Thread Clement Courbet via cfe-commits
courbet created this revision.
courbet added a reviewer: aaron.ballman.
courbet added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

I could not find a way to match signedness of integers in the AST, so I'm 
adding these two matchers.

http://reviews.llvm.org/D2

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -723,6 +723,18 @@
to(varDecl(hasType(isInteger();
 }
 
+TEST(IsSignedInteger, MatchesSignedIntegers) {
+  EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isSignedInteger();
+  EXPECT_TRUE(notMatches("unsigned i = 0;",
+ varDecl(hasType(isSignedInteger();
+}
+
+TEST(IsUnsignedInteger, MatchesUnsignedIntegers) {
+  EXPECT_TRUE(notMatches("int i = 0;", varDecl(hasType(isUnsignedInteger();
+  EXPECT_TRUE(matches("unsigned i = 0;",
+  varDecl(hasType(isUnsignedInteger();
+}
+
 TEST(IsAnyPointer, MatchesPointers) {
   EXPECT_TRUE(matches("int* i = nullptr;", varDecl(hasType(isAnyPointer();
 }
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -321,9 +321,11 @@
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
   REGISTER_MATCHER(isPure);
+  REGISTER_MATCHER(isSignedInteger);
   REGISTER_MATCHER(isStruct);
   REGISTER_MATCHER(isTemplateInstantiation);
   REGISTER_MATCHER(isUnion);
+  REGISTER_MATCHER(isUnsignedInteger);
   REGISTER_MATCHER(isVariadic);
   REGISTER_MATCHER(isVirtual);
   REGISTER_MATCHER(isVirtualAsWritten);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4067,6 +4067,34 @@
 return Node->isIntegerType();
 }
 
+/// \brief Matches QualType nodes that are of unsigned integer type.
+///
+/// Given
+/// \code
+///   void a(int);
+///   void b(unsigned long);
+///   void c(double);
+/// \endcode
+/// functionDecl(hasAnyParameter(hasType(isInteger(
+/// matches "b(unsigned long)", but not "a(int)" and "c(double)".
+AST_MATCHER(QualType, isUnsignedInteger) {
+return Node->isUnsignedIntegerType();
+}
+
+/// \brief Matches QualType nodes that are of signed integer type.
+///
+/// Given
+/// \code
+///   void a(int);
+///   void b(unsigned long);
+///   void c(double);
+/// \endcode
+/// functionDecl(hasAnyParameter(hasType(isInteger(
+/// matches "a(int)", but not "b(unsigned long)" and "c(double)".
+AST_MATCHER(QualType, isSignedInteger) {
+return Node->isSignedIntegerType();
+}
+
 /// \brief Matches QualType nodes that are of character type.
 ///
 /// Given


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -723,6 +723,18 @@
to(varDecl(hasType(isInteger();
 }
 
+TEST(IsSignedInteger, MatchesSignedIntegers) {
+  EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isSignedInteger();
+  EXPECT_TRUE(notMatches("unsigned i = 0;",
+ varDecl(hasType(isSignedInteger();
+}
+
+TEST(IsUnsignedInteger, MatchesUnsignedIntegers) {
+  EXPECT_TRUE(notMatches("int i = 0;", varDecl(hasType(isUnsignedInteger();
+  EXPECT_TRUE(matches("unsigned i = 0;",
+  varDecl(hasType(isUnsignedInteger();
+}
+
 TEST(IsAnyPointer, MatchesPointers) {
   EXPECT_TRUE(matches("int* i = nullptr;", varDecl(hasType(isAnyPointer();
 }
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -321,9 +321,11 @@
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
   REGISTER_MATCHER(isPure);
+  REGISTER_MATCHER(isSignedInteger);
   REGISTER_MATCHER(isStruct);
   REGISTER_MATCHER(isTemplateInstantiation);
   REGISTER_MATCHER(isUnion);
+  REGISTER_MATCHER(isUnsignedInteger);
   REGISTER_MATCHER(isVariadic);
   REGISTER_MATCHER(isVirtual);
   REGISTER_MATCHER(isVirtualAsWritten);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4067,6 +4067,34 @@
 return Node->isIntegerType();
 }
 
+/// \brief Matches QualType nodes that are of unsigned integer type.
+///
+/// Given
+/// 

Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread Nico Weber via cfe-commits
On Mon, Jul 11, 2016 at 11:51 AM, David Majnemer 
wrote:

>
>
> On Mon, Jul 11, 2016 at 8:42 AM, Nico Weber  wrote:
>
>> On Mon, Jul 11, 2016 at 11:36 AM, David Majnemer <
>> david.majne...@gmail.com> wrote:
>>
>>>
>>>
>>> On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber  wrote:
>>>
 VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This
 means people who want to ask clang-cl for line tables only will have to add
 this flag in some if(is_clang) block in their build file anyways. What's
 the advantage of giving this flag a spelling that's different from both cl
 and clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
 Windows.

 (Even if there's a good case for /Zd, I don't think we should remove
 user-exposed flags without a strong reason, so even if we keep /Zd I think
 we should also keep exposing -gline-tables-only.)

>>>
>>> Existing users of -gline-tables-only?  I'd imagine any responsible users
>>> of -gline-tables-only would probably use their build system to verify that
>>> the flag exists.  We have never released an official LLVM which supported
>>> it (LLVM 3.8 came out in early March and -gline-tables-only was exposed via
>>> clang-cl in mid March).
>>>
>>
>> Ok, but why is /Zd better than -gline-tables-only?
>>
>
> I see a few reasons:
> - It is less surprising for a debug flag in the cl world to be called
> /Zsomething instead of -gsomething.
>

Eh, you'll have to look it up either way to find the flag. And when seeing
the flag, the -g flag is more self-explanatory. Also, it is surprising that
a clang-cl /-style flag doesn't work with cl, so it just moves the surprise
around a bit.


> - I think that avoiding invasion of their namespace, when possible, is a
> good thing.  It makes it less likely that we will conflict with a flag they
> want to add in the future.
>

I don't understand this point. Doesn't invading their namespace make
collisions _more_ likely?


> - I imagine that if they wanted to add support back for
> -gline-tables-only, they'd name it /Zd.
>

Given they had this flag and removed it, they probably didn't like it very
much :-)


> I'm sympathetic to the argument that "-gline-tables-only" is more familiar
> to Linux/Mac OS X folks and that /Zd won't work across all platforms.
>
> Here why I think that's ok:
> - This is not really a new problem.  If you want to select c++1z you get
> to spell it /std:c++latest for clang-cl and -std=c++14.
>

Sure, but these are flags that clang/gcc and cl interpret. So if you have a
gcc build and a visual studio build, it's fairly easy to get each going
with clang / clang-cl.

With /Zd, we're needlessly inventing a new spelling for an existing clang
flag. As far as I can see, the new name creates a (small) problem without
solving one.

So far, when we wanted to add a flag that cl doesn't have and that clang
has, we've always gone for the clang spelling of that flag. That seems like
a good guideline to me.


> - People who want harmony between Mac OS X, Linux and Windows on the
> driver side can just use clang++.
>
>
>>
>>
>>>
>>> I'd consider it in poor form for users to take a hard dependency on a
>>> flag which only exists in a compiler which has never been released.
>>>
>>> I'd agree with you if -gline-tables-only had made its way to an actual
>>> release.
>>>
>>>

 On Mon, Jul 11, 2016 at 10:08 AM, Nico Weber 
 wrote:

> This breaks existing users of -gline-tables-only. What's the
> motivation for this change?
>

> On Sat, Jul 9, 2016 at 5:49 PM, David Majnemer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: majnemer
>> Date: Sat Jul  9 16:49:16 2016
>> New Revision: 274991
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=274991=rev
>> Log:
>> [clang-cl] Add support for /Zd
>>
>> MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe)
>> support a
>> flag called /Zd which is more-or-less -gline-tables-only.
>>
>> It seems nicer to support this flag instead of exposing
>> -gline-tables-only.
>>
>> Modified:
>> cfe/trunk/include/clang/Driver/CLCompatOptions.td
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/Driver/Tools.cpp
>> cfe/trunk/test/Driver/cl-options.c
>>
>> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=274991=274990=274991=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
>> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Jul  9
>> 16:49:16 2016
>> @@ -166,6 +166,8 @@ def _SLASH_Zc_trigraphs_off : CLFlag<"Zc
>>

Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread David Majnemer via cfe-commits
On Mon, Jul 11, 2016 at 8:42 AM, Nico Weber  wrote:

> On Mon, Jul 11, 2016 at 11:36 AM, David Majnemer  > wrote:
>
>>
>>
>> On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber  wrote:
>>
>>> VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This
>>> means people who want to ask clang-cl for line tables only will have to add
>>> this flag in some if(is_clang) block in their build file anyways. What's
>>> the advantage of giving this flag a spelling that's different from both cl
>>> and clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
>>> Windows.
>>>
>>> (Even if there's a good case for /Zd, I don't think we should remove
>>> user-exposed flags without a strong reason, so even if we keep /Zd I think
>>> we should also keep exposing -gline-tables-only.)
>>>
>>
>> Existing users of -gline-tables-only?  I'd imagine any responsible users
>> of -gline-tables-only would probably use their build system to verify that
>> the flag exists.  We have never released an official LLVM which supported
>> it (LLVM 3.8 came out in early March and -gline-tables-only was exposed via
>> clang-cl in mid March).
>>
>
> Ok, but why is /Zd better than -gline-tables-only?
>

I see a few reasons:
- It is less surprising for a debug flag in the cl world to be called
/Zsomething instead of -gsomething.
- I think that avoiding invasion of their namespace, when possible, is a
good thing.  It makes it less likely that we will conflict with a flag they
want to add in the future.
- I imagine that if they wanted to add support back for -gline-tables-only,
they'd name it /Zd.

I'm sympathetic to the argument that "-gline-tables-only" is more familiar
to Linux/Mac OS X folks and that /Zd won't work across all platforms.

Here why I think that's ok:
- This is not really a new problem.  If you want to select c++1z you get to
spell it /std:c++latest for clang-cl and -std=c++14.
- People who want harmony between Mac OS X, Linux and Windows on the driver
side can just use clang++.


>
>
>>
>> I'd consider it in poor form for users to take a hard dependency on a
>> flag which only exists in a compiler which has never been released.
>>
>> I'd agree with you if -gline-tables-only had made its way to an actual
>> release.
>>
>>
>>>
>>> On Mon, Jul 11, 2016 at 10:08 AM, Nico Weber 
>>> wrote:
>>>
 This breaks existing users of -gline-tables-only. What's the motivation
 for this change?

>>>
 On Sat, Jul 9, 2016 at 5:49 PM, David Majnemer via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: majnemer
> Date: Sat Jul  9 16:49:16 2016
> New Revision: 274991
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274991=rev
> Log:
> [clang-cl] Add support for /Zd
>
> MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe) support
> a
> flag called /Zd which is more-or-less -gline-tables-only.
>
> It seems nicer to support this flag instead of exposing
> -gline-tables-only.
>
> Modified:
> cfe/trunk/include/clang/Driver/CLCompatOptions.td
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/cl-options.c
>
> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=274991=274990=274991=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Jul  9
> 16:49:16 2016
> @@ -166,6 +166,8 @@ def _SLASH_Zc_trigraphs_off : CLFlag<"Zc
>HelpText<"Disable trigraphs (default)">, Alias;
>  def _SLASH_Z7 : CLFlag<"Z7">,
>HelpText<"Enable CodeView debug information in object files">;
> +def _SLASH_Zd : CLFlag<"Zd">,
> +  HelpText<"Emit debug line number tables only">;
>  def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
>HelpText<"Alias for /Z7. Does not produce PDBs.">;
>  def _SLASH_Zp : CLJoined<"Zp">,
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=274991=274990=274991=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Sat Jul  9 16:49:16 2016
> @@ -1229,7 +1229,7 @@ def fdebug_prefix_map_EQ
>  def g_Flag : Flag<["-"], "g">, Group,
>HelpText<"Generate source-level debug information">;
>  def gline_tables_only : Flag<["-"], "gline-tables-only">,
> Group,
> -  Flags<[CoreOption]>, HelpText<"Emit debug line number tables only">;
> +  

Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread Nico Weber via cfe-commits
On Mon, Jul 11, 2016 at 11:36 AM, David Majnemer 
wrote:

>
>
> On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber  wrote:
>
>> VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This means
>> people who want to ask clang-cl for line tables only will have to add this
>> flag in some if(is_clang) block in their build file anyways. What's the
>> advantage of giving this flag a spelling that's different from both cl and
>> clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
>> Windows.
>>
>> (Even if there's a good case for /Zd, I don't think we should remove
>> user-exposed flags without a strong reason, so even if we keep /Zd I think
>> we should also keep exposing -gline-tables-only.)
>>
>
> Existing users of -gline-tables-only?  I'd imagine any responsible users
> of -gline-tables-only would probably use their build system to verify that
> the flag exists.  We have never released an official LLVM which supported
> it (LLVM 3.8 came out in early March and -gline-tables-only was exposed via
> clang-cl in mid March).
>

Ok, but why is /Zd better than -gline-tables-only?


>
> I'd consider it in poor form for users to take a hard dependency on a flag
> which only exists in a compiler which has never been released.
>
> I'd agree with you if -gline-tables-only had made its way to an actual
> release.
>
>
>>
>> On Mon, Jul 11, 2016 at 10:08 AM, Nico Weber  wrote:
>>
>>> This breaks existing users of -gline-tables-only. What's the motivation
>>> for this change?
>>>
>>
>>> On Sat, Jul 9, 2016 at 5:49 PM, David Majnemer via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: majnemer
 Date: Sat Jul  9 16:49:16 2016
 New Revision: 274991

 URL: http://llvm.org/viewvc/llvm-project?rev=274991=rev
 Log:
 [clang-cl] Add support for /Zd

 MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe) support a
 flag called /Zd which is more-or-less -gline-tables-only.

 It seems nicer to support this flag instead of exposing
 -gline-tables-only.

 Modified:
 cfe/trunk/include/clang/Driver/CLCompatOptions.td
 cfe/trunk/include/clang/Driver/Options.td
 cfe/trunk/lib/Driver/Tools.cpp
 cfe/trunk/test/Driver/cl-options.c

 Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=274991=274990=274991=diff

 ==
 --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
 +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Jul  9
 16:49:16 2016
 @@ -166,6 +166,8 @@ def _SLASH_Zc_trigraphs_off : CLFlag<"Zc
HelpText<"Disable trigraphs (default)">, Alias;
  def _SLASH_Z7 : CLFlag<"Z7">,
HelpText<"Enable CodeView debug information in object files">;
 +def _SLASH_Zd : CLFlag<"Zd">,
 +  HelpText<"Emit debug line number tables only">;
  def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
HelpText<"Alias for /Z7. Does not produce PDBs.">;
  def _SLASH_Zp : CLJoined<"Zp">,

 Modified: cfe/trunk/include/clang/Driver/Options.td
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=274991=274990=274991=diff

 ==
 --- cfe/trunk/include/clang/Driver/Options.td (original)
 +++ cfe/trunk/include/clang/Driver/Options.td Sat Jul  9 16:49:16 2016
 @@ -1229,7 +1229,7 @@ def fdebug_prefix_map_EQ
  def g_Flag : Flag<["-"], "g">, Group,
HelpText<"Generate source-level debug information">;
  def gline_tables_only : Flag<["-"], "gline-tables-only">,
 Group,
 -  Flags<[CoreOption]>, HelpText<"Emit debug line number tables only">;
 +  HelpText<"Emit debug line number tables only">;
  def gmlt : Flag<["-"], "gmlt">, Alias;
  def g0 : Flag<["-"], "g0">, Group;
  def g1 : Flag<["-"], "g1">, Group, Alias;

 Modified: cfe/trunk/lib/Driver/Tools.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274991=274990=274991=diff

 ==
 --- cfe/trunk/lib/Driver/Tools.cpp (original)
 +++ cfe/trunk/lib/Driver/Tools.cpp Sat Jul  9 16:49:16 2016
 @@ -6269,12 +6269,18 @@ void Clang::AddClangCLArgs(const ArgList

  CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
}

 -  // Emit CodeView if -Z7 is present.
 -  *EmitCodeView = Args.hasArg(options::OPT__SLASH_Z7);
 -  if (*EmitCodeView)
 -*DebugInfoKind = codegenoptions::LimitedDebugInfo;
 -  if (*EmitCodeView)
 +  // Emit CodeView if -Z7 or -Zd are present.
 +  if (Arg 

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-11 Thread Diego Novillo via cfe-commits
On Sat, Jul 9, 2016 at 7:39 PM Sean Silva  wrote:

> silvas added a comment.
>
> In http://reviews.llvm.org/D21823#479418, @davidxl wrote:
>
> > I should have brought it up earlier, but I forgot.I think a better
> (and simpler) proposal is to make -fprofile-generate and -fprofile-use turn
> on IR based PGO.
> >
> > -fprofile-generate and -fprofile-use options were introduced by Diego
> (cc'ed) recently for GCC option compatibility. At that time, IR based PGO
> was not yet ready, so they were made aliases to FE instrumentation options
> -fprofile-instr-generate and -fprofile-instr-use.Now I think it is time
> to make it right.   The documentation only says that these two options are
> gcc compatible options to control profile generation and use, but does not
> specify the underlying implementation. It is also likely that Google is the
> only user of this option. If a user using this option really want FE
> instrumentation, there is always -fprofile-instr-generate to use.  It also
> more likely that IR instrumentation is what user wants when using GCC
> compatible options (as they behave more similarly).
>
>
> This SGTM.
>

Likewise.


>
> It may cause some user confusion since there is no obvious distinction
> between "profile generate" and "profile instr generate" from a user
> perspective. But we can avoid that with improved documentation.
>
> My main concern is that the existing documentation already says that
> -fprofile-generate behaves identically to -fprofile-instr-generate
> http://clang.llvm.org/docs/UsersManual.html#cmdoption-fprofile-generate
> However, I think it is reasonable to change this behavior (and of course
> the documentation), as users of this option are likely using it for
> compatibility with GCC and so they likely don't care about the specifics of
> clang FEPGO.
> We probably want to at least leave a small note in the documentation
> regarding this change of behavior.
>

I think the change in behaviour is needed.  Better to make a clean break
now that it is early enough in the PGO life cycle.  Adding a note about it
will help current users.


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


Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread David Majnemer via cfe-commits
On Mon, Jul 11, 2016 at 7:18 AM, Nico Weber  wrote:

> VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This means
> people who want to ask clang-cl for line tables only will have to add this
> flag in some if(is_clang) block in their build file anyways. What's the
> advantage of giving this flag a spelling that's different from both cl and
> clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
> Windows.
>
> (Even if there's a good case for /Zd, I don't think we should remove
> user-exposed flags without a strong reason, so even if we keep /Zd I think
> we should also keep exposing -gline-tables-only.)
>

Existing users of -gline-tables-only?  I'd imagine any responsible users of
-gline-tables-only would probably use their build system to verify that the
flag exists.  We have never released an official LLVM which supported it
(LLVM 3.8 came out in early March and -gline-tables-only was exposed via
clang-cl in mid March).

I'd consider it in poor form for users to take a hard dependency on a flag
which only exists in a compiler which has never been released.

I'd agree with you if -gline-tables-only had made its way to an actual
release.


>
> On Mon, Jul 11, 2016 at 10:08 AM, Nico Weber  wrote:
>
>> This breaks existing users of -gline-tables-only. What's the motivation
>> for this change?
>>
>
>> On Sat, Jul 9, 2016 at 5:49 PM, David Majnemer via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: majnemer
>>> Date: Sat Jul  9 16:49:16 2016
>>> New Revision: 274991
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=274991=rev
>>> Log:
>>> [clang-cl] Add support for /Zd
>>>
>>> MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe) support a
>>> flag called /Zd which is more-or-less -gline-tables-only.
>>>
>>> It seems nicer to support this flag instead of exposing
>>> -gline-tables-only.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Driver/CLCompatOptions.td
>>> cfe/trunk/include/clang/Driver/Options.td
>>> cfe/trunk/lib/Driver/Tools.cpp
>>> cfe/trunk/test/Driver/cl-options.c
>>>
>>> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=274991=274990=274991=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
>>> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Jul  9
>>> 16:49:16 2016
>>> @@ -166,6 +166,8 @@ def _SLASH_Zc_trigraphs_off : CLFlag<"Zc
>>>HelpText<"Disable trigraphs (default)">, Alias;
>>>  def _SLASH_Z7 : CLFlag<"Z7">,
>>>HelpText<"Enable CodeView debug information in object files">;
>>> +def _SLASH_Zd : CLFlag<"Zd">,
>>> +  HelpText<"Emit debug line number tables only">;
>>>  def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
>>>HelpText<"Alias for /Z7. Does not produce PDBs.">;
>>>  def _SLASH_Zp : CLJoined<"Zp">,
>>>
>>> Modified: cfe/trunk/include/clang/Driver/Options.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=274991=274990=274991=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>>> +++ cfe/trunk/include/clang/Driver/Options.td Sat Jul  9 16:49:16 2016
>>> @@ -1229,7 +1229,7 @@ def fdebug_prefix_map_EQ
>>>  def g_Flag : Flag<["-"], "g">, Group,
>>>HelpText<"Generate source-level debug information">;
>>>  def gline_tables_only : Flag<["-"], "gline-tables-only">,
>>> Group,
>>> -  Flags<[CoreOption]>, HelpText<"Emit debug line number tables only">;
>>> +  HelpText<"Emit debug line number tables only">;
>>>  def gmlt : Flag<["-"], "gmlt">, Alias;
>>>  def g0 : Flag<["-"], "g0">, Group;
>>>  def g1 : Flag<["-"], "g1">, Group, Alias;
>>>
>>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274991=274990=274991=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>>> +++ cfe/trunk/lib/Driver/Tools.cpp Sat Jul  9 16:49:16 2016
>>> @@ -6269,12 +6269,18 @@ void Clang::AddClangCLArgs(const ArgList
>>>
>>>  CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
>>>}
>>>
>>> -  // Emit CodeView if -Z7 is present.
>>> -  *EmitCodeView = Args.hasArg(options::OPT__SLASH_Z7);
>>> -  if (*EmitCodeView)
>>> -*DebugInfoKind = codegenoptions::LimitedDebugInfo;
>>> -  if (*EmitCodeView)
>>> +  // Emit CodeView if -Z7 or -Zd are present.
>>> +  if (Arg *DebugInfoArg =
>>> +  Args.getLastArg(options::OPT__SLASH_Z7,
>>> options::OPT__SLASH_Zd)) {
>>> +*EmitCodeView = true;
>>> +if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
>>> +  *DebugInfoKind = codegenoptions::LimitedDebugInfo;
>>> +  

Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-07-11 Thread John Brawn via cfe-commits
john.brawn added a comment.

> Plugins tests are still disabled by lit.cfg I think, as it only checks for 
> enable_shared, which is disabled. I suppose we could wait for both this and 
> the SampleAnalyzerPlugin to be patched before enabling plugins tests if we 
> have LLVM_EXPORT_SYMBOLS_FOR_PLUGINS, as every plugin test should work after 
> this.


http://reviews.llvm.org/D1 for enabling the tests.

Also: you said LGTM, but didn't mark the review as accepted. OK to commit?


Repository:
  rL LLVM

http://reviews.llvm.org/D21385



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


Re: [PATCH] D22129: [clang-rename] add documentation

2016-07-11 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: docs/clang-rename.rst:17
@@ +16,3 @@
+
+The tool development is in very early stage, so you might encounter bugs and
+crashes. Submitting reports with information about how to reproduce the issue

maybe 'is in a very early development stage"?


Comment at: docs/clang-rename.rst:19
@@ +18,3 @@
+crashes. Submitting reports with information about how to reproduce the issue
+to `llvm bugtracker `_ will definitely help the project.
+If you have any ideas or suggestions, you might want to put a feature request

to the LLVM bug tracker


Comment at: docs/clang-rename.rst:50
@@ +49,3 @@
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim, and improve workflow of users.
+

... the workflow ...


Comment at: docs/clang-rename.rst:52
@@ +51,3 @@
+
+Although command line interface exists, it is highly recommended to use text
+editors interface instead for better experience.

... a command line interface exists, it is highly recommended to use the text 
editor interface ...


http://reviews.llvm.org/D22129



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


[PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-11 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: sbenza.
mboehme added a subscriber: cfe-commits.

The check emits a warning if std::move() is applied to a forwarding reference, 
i.e. an rvalue reference of a function template argument type.

If a developer is unaware of the special rules for template argument deduction 
on forwarding references, it will seem reasonable to apply std::move() to the 
forwarding reference, in the same way that this would be done for a "normal" 
rvalue reference.

This has a consequence that is usually unwanted and possibly surprising: If the 
function that takes the forwarding reference as its parameter is called with an 
lvalue, that lvalue will be moved from (and hence placed into an indeterminate 
state) even though no std::move() was applied to the lvalue at the callsite.

As a fix, the check will suggest replacing the std::move() with a 
std::forward().

http://reviews.llvm.org/D0

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MoveForwardingReferenceCheck.cpp
  clang-tidy/misc/MoveForwardingReferenceCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-move-forwarding-reference.rst
  test/clang-tidy/misc-move-forwarding-reference.cpp

Index: test/clang-tidy/misc-move-forwarding-reference.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-move-forwarding-reference.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s misc-move-forwarding-reference %t
+
+namespace std {
+template  struct remove_reference;
+
+template  struct remove_reference { typedef _Tp type; };
+
+template  struct remove_reference<_Tp &> { typedef _Tp type; };
+
+template  struct remove_reference<_Tp &&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t);
+
+} // namespace std
+
+// Standard case.
+template  void f(U &) {
+  T SomeT(std::move(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+  // CHECK-FIXES: T SomeT(std::forward(SomeU));
+}
+
+// Ignore parentheses around the argument to std::move().
+template  void f2(U &) {
+  T SomeT(std::move((SomeU)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+  // CHECK-FIXES: T SomeT(std::forward((SomeU)));
+}
+
+// Handle the case correctly where std::move() is being used through a using
+// declaration.
+template  void f3(U &) {
+  using std::move;
+  T SomeT(move(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+  // CHECK-FIXES: T SomeT(std::forward(SomeU));
+}
+
+// Handle the case correctly where a global specifier is prepended to
+// std::move().
+template  void f4(U &) {
+  T SomeT(::std::move(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+  // CHECK-FIXES: T SomeT(::std::forward(SomeU));
+}
+
+// Ignore const rvalue reference parameters.
+template  void f5(const U &) {
+  T SomeT(std::move(SomeU));
+}
+
+// Ignore the case where the argument to std::move() is a lambda parameter (and
+// thus not actually a parameter of the function template).
+template  void f6() {
+  [](U &) { T SomeT(std::move(SomeU)); };
+}
+
+// Ignore the case where the argument is a lvalue reference.
+template  void f7(U ) {
+  T SomeT(std::move(SomeU));
+}
+
+// Ignore the case where the template parameter is a class template parameter
+// (i.e. no template argument deduction is taking place).
+template  class SomeClass {
+  void f(U &) { T SomeT(std::move(SomeU)); }
+};
Index: docs/clang-tidy/checks/misc-move-forwarding-reference.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-move-forwarding-reference.rst
@@ -0,0 +1,60 @@
+.. title:: clang-tidy - misc-move-forwarding-reference
+
+misc-move-forwarding-reference
+==
+
+Warns if ``std::move`` is called on a forwarding reference, for example:
+
+  .. code-block:: c++
+
+template 
+void foo(T&& t) {
+  bar(std::move(t));
+}
+
+`Forwarding references
+`_ should
+typically be passed to ``std::forward`` instead of ``std::move``, and this is
+the fix that will be suggested.
+
+(A forwarding reference is an rvalue reference of a type that is a deduced
+function template argument.)
+
+In this example, the suggested fix would be
+
+  .. code-block:: c++
+
+bar(std::forward(t));
+
+Background
+--
+
+Code like the example above is often written in the expectation that ``T&&``
+will always end up being an rvalue reference, no matter what type is deduced for
+``T``, and that it is therefore not possible to pass an lvalue to ``foo()``.
+However, this is not true. Consider this example:
+
+  .. code-block:: c++
+
+std::string s = "Hello, world";
+foo(s);
+
+This code compiles and, after the call to ``foo()``, 

Re: [PATCH] D22170: [OpenCL] Fixes opencl.cl testcase issues and cl-strict-aliasing only allowed with cl-std=CL

2016-07-11 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: test/Frontend/opencl-blocks.cl:9
@@ -8,1 +8,3 @@
 // RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify 
-fsyntax-only
+// RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s

Better separate these tests to another file, e.g. cl-strict-aliasing.cl


Repository:
  rL LLVM

http://reviews.llvm.org/D22170



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


Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread Nico Weber via cfe-commits
VS2013's cl.exe doesn't understand /Zd, 2015's doesn't either. This means
people who want to ask clang-cl for line tables only will have to add this
flag in some if(is_clang) block in their build file anyways. What's the
advantage of giving this flag a spelling that's different from both cl and
clang? With -gline-tables-only, an if(is_clang) works on Linux, Mac,
Windows.

(Even if there's a good case for /Zd, I don't think we should remove
user-exposed flags without a strong reason, so even if we keep /Zd I think
we should also keep exposing -gline-tables-only.)

On Mon, Jul 11, 2016 at 10:08 AM, Nico Weber  wrote:

> This breaks existing users of -gline-tables-only. What's the motivation
> for this change?
>
> On Sat, Jul 9, 2016 at 5:49 PM, David Majnemer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: majnemer
>> Date: Sat Jul  9 16:49:16 2016
>> New Revision: 274991
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=274991=rev
>> Log:
>> [clang-cl] Add support for /Zd
>>
>> MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe) support a
>> flag called /Zd which is more-or-less -gline-tables-only.
>>
>> It seems nicer to support this flag instead of exposing
>> -gline-tables-only.
>>
>> Modified:
>> cfe/trunk/include/clang/Driver/CLCompatOptions.td
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/Driver/Tools.cpp
>> cfe/trunk/test/Driver/cl-options.c
>>
>> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=274991=274990=274991=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
>> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Jul  9 16:49:16
>> 2016
>> @@ -166,6 +166,8 @@ def _SLASH_Zc_trigraphs_off : CLFlag<"Zc
>>HelpText<"Disable trigraphs (default)">, Alias;
>>  def _SLASH_Z7 : CLFlag<"Z7">,
>>HelpText<"Enable CodeView debug information in object files">;
>> +def _SLASH_Zd : CLFlag<"Zd">,
>> +  HelpText<"Emit debug line number tables only">;
>>  def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
>>HelpText<"Alias for /Z7. Does not produce PDBs.">;
>>  def _SLASH_Zp : CLJoined<"Zp">,
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=274991=274990=274991=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Sat Jul  9 16:49:16 2016
>> @@ -1229,7 +1229,7 @@ def fdebug_prefix_map_EQ
>>  def g_Flag : Flag<["-"], "g">, Group,
>>HelpText<"Generate source-level debug information">;
>>  def gline_tables_only : Flag<["-"], "gline-tables-only">,
>> Group,
>> -  Flags<[CoreOption]>, HelpText<"Emit debug line number tables only">;
>> +  HelpText<"Emit debug line number tables only">;
>>  def gmlt : Flag<["-"], "gmlt">, Alias;
>>  def g0 : Flag<["-"], "g0">, Group;
>>  def g1 : Flag<["-"], "g1">, Group, Alias;
>>
>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274991=274990=274991=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> +++ cfe/trunk/lib/Driver/Tools.cpp Sat Jul  9 16:49:16 2016
>> @@ -6269,12 +6269,18 @@ void Clang::AddClangCLArgs(const ArgList
>>  CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
>>}
>>
>> -  // Emit CodeView if -Z7 is present.
>> -  *EmitCodeView = Args.hasArg(options::OPT__SLASH_Z7);
>> -  if (*EmitCodeView)
>> -*DebugInfoKind = codegenoptions::LimitedDebugInfo;
>> -  if (*EmitCodeView)
>> +  // Emit CodeView if -Z7 or -Zd are present.
>> +  if (Arg *DebugInfoArg =
>> +  Args.getLastArg(options::OPT__SLASH_Z7,
>> options::OPT__SLASH_Zd)) {
>> +*EmitCodeView = true;
>> +if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
>> +  *DebugInfoKind = codegenoptions::LimitedDebugInfo;
>> +else
>> +  *DebugInfoKind = codegenoptions::DebugLineTablesOnly;
>>  CmdArgs.push_back("-gcodeview");
>> +  } else {
>> +*EmitCodeView = false;
>> +  }
>>
>>const Driver  = getToolChain().getDriver();
>>EHFlags EH = parseClangCLEHFlags(D, Args);
>> @@ -9964,7 +9970,8 @@ void visualstudio::Linker::ConstructJob(
>>
>>CmdArgs.push_back("-nologo");
>>
>> -  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
>> +  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
>> +  options::OPT__SLASH_Zd))
>>  CmdArgs.push_back("-debug");
>>
>>bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd,
>>
>> Modified: cfe/trunk/test/Driver/cl-options.c
>> 

Re: r274991 - [clang-cl] Add support for /Zd

2016-07-11 Thread Nico Weber via cfe-commits
This breaks existing users of -gline-tables-only. What's the motivation for
this change?

On Sat, Jul 9, 2016 at 5:49 PM, David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: majnemer
> Date: Sat Jul  9 16:49:16 2016
> New Revision: 274991
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274991=rev
> Log:
> [clang-cl] Add support for /Zd
>
> MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe) support a
> flag called /Zd which is more-or-less -gline-tables-only.
>
> It seems nicer to support this flag instead of exposing
> -gline-tables-only.
>
> Modified:
> cfe/trunk/include/clang/Driver/CLCompatOptions.td
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/cl-options.c
>
> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=274991=274990=274991=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Jul  9 16:49:16
> 2016
> @@ -166,6 +166,8 @@ def _SLASH_Zc_trigraphs_off : CLFlag<"Zc
>HelpText<"Disable trigraphs (default)">, Alias;
>  def _SLASH_Z7 : CLFlag<"Z7">,
>HelpText<"Enable CodeView debug information in object files">;
> +def _SLASH_Zd : CLFlag<"Zd">,
> +  HelpText<"Emit debug line number tables only">;
>  def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
>HelpText<"Alias for /Z7. Does not produce PDBs.">;
>  def _SLASH_Zp : CLJoined<"Zp">,
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=274991=274990=274991=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Sat Jul  9 16:49:16 2016
> @@ -1229,7 +1229,7 @@ def fdebug_prefix_map_EQ
>  def g_Flag : Flag<["-"], "g">, Group,
>HelpText<"Generate source-level debug information">;
>  def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,
> -  Flags<[CoreOption]>, HelpText<"Emit debug line number tables only">;
> +  HelpText<"Emit debug line number tables only">;
>  def gmlt : Flag<["-"], "gmlt">, Alias;
>  def g0 : Flag<["-"], "g0">, Group;
>  def g1 : Flag<["-"], "g1">, Group, Alias;
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274991=274990=274991=diff
>
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Sat Jul  9 16:49:16 2016
> @@ -6269,12 +6269,18 @@ void Clang::AddClangCLArgs(const ArgList
>  CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
>}
>
> -  // Emit CodeView if -Z7 is present.
> -  *EmitCodeView = Args.hasArg(options::OPT__SLASH_Z7);
> -  if (*EmitCodeView)
> -*DebugInfoKind = codegenoptions::LimitedDebugInfo;
> -  if (*EmitCodeView)
> +  // Emit CodeView if -Z7 or -Zd are present.
> +  if (Arg *DebugInfoArg =
> +  Args.getLastArg(options::OPT__SLASH_Z7,
> options::OPT__SLASH_Zd)) {
> +*EmitCodeView = true;
> +if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
> +  *DebugInfoKind = codegenoptions::LimitedDebugInfo;
> +else
> +  *DebugInfoKind = codegenoptions::DebugLineTablesOnly;
>  CmdArgs.push_back("-gcodeview");
> +  } else {
> +*EmitCodeView = false;
> +  }
>
>const Driver  = getToolChain().getDriver();
>EHFlags EH = parseClangCLEHFlags(D, Args);
> @@ -9964,7 +9970,8 @@ void visualstudio::Linker::ConstructJob(
>
>CmdArgs.push_back("-nologo");
>
> -  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
> +  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
> +  options::OPT__SLASH_Zd))
>  CmdArgs.push_back("-debug");
>
>bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd,
>
> Modified: cfe/trunk/test/Driver/cl-options.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=274991=274990=274991=diff
>
> ==
> --- cfe/trunk/test/Driver/cl-options.c (original)
> +++ cfe/trunk/test/Driver/cl-options.c Sat Jul  9 16:49:16 2016
> @@ -420,7 +420,7 @@
>  // Z7: "-gcodeview"
>  // Z7: "-debug-info-kind=limited"
>
> -// RUN: %clang_cl -gline-tables-only /Z7 /c -### -- %s 2>&1 | FileCheck
> -check-prefix=Z7GMLT %s
> +// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT
> %s
>  // Z7GMLT: "-gcodeview"
>  // Z7GMLT: "-debug-info-kind=line-tables-only"
>
>
>
> ___
> cfe-commits mailing list
> 

Re: [PATCH] D21602: Changes related to tooling::applyAllReplacements interface change in D21601.

2016-07-11 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275063: Changes related to tooling::applyAllReplacements 
interface change in D21601. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D21602?vs=63504=63506#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21602

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixer.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
@@ -17,6 +17,7 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include 
 #include 
 
@@ -121,7 +122,13 @@
 Fixes.insert(Error.Fix.begin(), Error.Fix.end());
   if (Errors)
 *Errors = Context.getErrors();
-  return tooling::applyAllReplacements(Code, Fixes);
+  auto Result = tooling::applyAllReplacements(Code, Fixes);
+  if (!Result) {
+// FIXME: propogate the error.
+llvm::consumeError(Result.takeError());
+return "";
+  }
+  return *Result;
 }
 
 #define EXPECT_NO_CHANGES(Check, Code) \
Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -86,14 +86,17 @@
   runOnCode(, Code, FakeFileName, ExtraArgs);
   if (FixerContext.getMatchedSymbols().empty())
 return Code;
-  tooling::Replacements Replacements =
-  clang::include_fixer::createInsertHeaderReplacements(
-  Code, FakeFileName, FixerContext.getHeaders().front());
+  auto Replaces = clang::include_fixer::createInsertHeaderReplacements(
+  Code, FakeFileName, FixerContext.getHeaders().front());
+  EXPECT_TRUE(static_cast(Replaces))
+  << llvm::toString(Replaces.takeError()) << "\n";
+  if (!Replaces)
+return "";
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile(FakeFileName, Code);
   if (FixerContext.getSymbolRange().getLength() > 0)
-Replacements.insert(FixerContext.createSymbolReplacement(FakeFileName, 0));
-  clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
+Replaces->insert(FixerContext.createSymbolReplacement(FakeFileName, 0));
+  clang::tooling::applyAllReplacements(*Replaces, Context.Rewrite);
   return Context.getRewrittenText(ID);
 }
 
Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
@@ -349,7 +349,7 @@
   return !Compiler.getDiagnostics().hasFatalErrorOccurred();
 }
 
-tooling::Replacements
+llvm::Expected
 createInsertHeaderReplacements(StringRef Code, StringRef FilePath,
StringRef Header,
const clang::format::FormatStyle ) {
@@ -360,8 +360,10 @@
   clang::tooling::Replacements Insertions = {
   tooling::Replacement(FilePath, UINT_MAX, 0, IncludeName)};
 
-  return formatReplacements(
-  Code, cleanupAroundReplacements(Code, Insertions, Style), Style);
+  auto CleanReplaces = cleanupAroundReplacements(Code, Insertions, Style);
+  if (!CleanReplaces)
+return CleanReplaces;
+  return formatReplacements(Code, *CleanReplaces, Style);
 }
 
 } // namespace include_fixer
Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -209,13 +209,20 @@
   return 1;
 }
 
-tooling::Replacements Replacements =
-clang::include_fixer::createInsertHeaderReplacements(
-Code->getBuffer(), FilePath, Context.getHeaders().front(),
-InsertStyle);
-std::string ChangedCode =
-tooling::applyAllReplacements(Code->getBuffer(), Replacements);
-llvm::outs() << ChangedCode;
+auto Replacements = clang::include_fixer::createInsertHeaderReplacements(
+Code->getBuffer(), FilePath, Context.getHeaders().front(), InsertStyle);
+if (!Replacements) {
+  errs() << "Failed to create header insertion replacement: "
+ << llvm::toString(Replacements.takeError()) << "\n";
+  return 1;
+}
+auto 

Re: [PATCH] D21601: Make tooling::applyAllReplacements return llvm::Expected instead of empty string to indicate potential error.

2016-07-11 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275062: Make tooling::applyAllReplacements return 
llvm::Expected instead of… (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D21601?vs=61823=63505#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21601

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/include/clang/Tooling/Core/Replacement.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Tooling/Core/Replacement.cpp
  cfe/trunk/lib/Tooling/Refactoring.cpp
  cfe/trunk/tools/clang-format/ClangFormat.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp
  cfe/trunk/unittests/Format/FormatTestJava.cpp
  cfe/trunk/unittests/Format/FormatTestProto.cpp
  cfe/trunk/unittests/Format/FormatTestSelective.cpp
  cfe/trunk/unittests/Format/SortImportsTestJS.cpp
  cfe/trunk/unittests/Format/SortIncludesTest.cpp
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp
  cfe/trunk/unittests/Tooling/RewriterTest.cpp

Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1393,45 +1393,49 @@
 }
 
 template 
-static tooling::Replacements
+static llvm::Expected
 processReplacements(T ProcessFunc, StringRef Code,
 const tooling::Replacements ,
 const FormatStyle ) {
   if (Replaces.empty())
 return tooling::Replacements();
 
-  std::string NewCode = applyAllReplacements(Code, Replaces);
+  auto NewCode = applyAllReplacements(Code, Replaces);
+  if (!NewCode)
+return NewCode.takeError();
   std::vector ChangedRanges =
   tooling::calculateChangedRanges(Replaces);
   StringRef FileName = Replaces.begin()->getFilePath();
 
   tooling::Replacements FormatReplaces =
-  ProcessFunc(Style, NewCode, ChangedRanges, FileName);
+  ProcessFunc(Style, *NewCode, ChangedRanges, FileName);
 
   return mergeReplacements(Replaces, FormatReplaces);
 }
 
-tooling::Replacements formatReplacements(StringRef Code,
- const tooling::Replacements ,
- const FormatStyle ) {
+llvm::Expected
+formatReplacements(StringRef Code, const tooling::Replacements ,
+   const FormatStyle ) {
   // We need to use lambda function here since there are two versions of
   // `sortIncludes`.
   auto SortIncludes = [](const FormatStyle , StringRef Code,
  std::vector Ranges,
  StringRef FileName) -> tooling::Replacements {
 return sortIncludes(Style, Code, Ranges, FileName);
   };
-  tooling::Replacements SortedReplaces =
+  auto SortedReplaces =
   processReplacements(SortIncludes, Code, Replaces, Style);
+  if (!SortedReplaces)
+return SortedReplaces.takeError();
 
   // We need to use lambda function here since there are two versions of
   // `reformat`.
   auto Reformat = [](const FormatStyle , StringRef Code,
  std::vector Ranges,
  StringRef FileName) -> tooling::Replacements {
 return reformat(Style, Code, Ranges, FileName);
   };
-  return processReplacements(Reformat, Code, SortedReplaces, Style);
+  return processReplacements(Reformat, Code, *SortedReplaces, Style);
 }
 
 namespace {
@@ -1591,7 +1595,7 @@
 
 } // anonymous namespace
 
-tooling::Replacements
+llvm::Expected
 cleanupAroundReplacements(StringRef Code, const tooling::Replacements ,
   const FormatStyle ) {
   // We need to use lambda function here since there are two versions of
Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -249,8 +249,10 @@
   return Result;
 }
 
-std::string applyAllReplacements(StringRef Code, const Replacements ) {
-  if (Replaces.empty()) return Code;
+llvm::Expected applyAllReplacements(StringRef Code,
+const Replacements ) {
+  if (Replaces.empty())
+return Code.str();
 
   IntrusiveRefCntPtr InMemoryFileSystem(
   new vfs::InMemoryFileSystem);
@@ -269,7 +271,9 @@
 Replacement Replace("", I->getOffset(), I->getLength(),
 I->getReplacementText());
 if (!Replace.apply(Rewrite))
-  return "";
+  return llvm::make_error(
+  "Failed to apply replacement: " + Replace.toString(),
+  llvm::inconvertibleErrorCode());
   }
   std::string Result;
   llvm::raw_string_ostream OS(Result);
Index: cfe/trunk/lib/Tooling/Refactoring.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring.cpp
+++ cfe/trunk/lib/Tooling/Refactoring.cpp
@@ -79,9 +79,13 @@
 StringRef Code = SM.getBufferData(ID);
 
   

[clang-tools-extra] r275063 - Changes related to tooling::applyAllReplacements interface change in D21601.

2016-07-11 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Jul 11 08:53:21 2016
New Revision: 275063

URL: http://llvm.org/viewvc/llvm-project?rev=275063=rev
Log:
Changes related to tooling::applyAllReplacements interface change in D21601.

Summary:
this patch contains changes related to the interface change from
http://reviews.llvm.org/D21601. Only submit this patch after D21601 is
submitted.

Reviewers: djasper, klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D21602

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=275063=275062=275063=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Mon Jul 11 08:53:21 
2016
@@ -349,7 +349,7 @@ bool IncludeFixerActionFactory::runInvoc
   return !Compiler.getDiagnostics().hasFatalErrorOccurred();
 }
 
-tooling::Replacements
+llvm::Expected
 createInsertHeaderReplacements(StringRef Code, StringRef FilePath,
StringRef Header,
const clang::format::FormatStyle ) {
@@ -360,8 +360,10 @@ createInsertHeaderReplacements(StringRef
   clang::tooling::Replacements Insertions = {
   tooling::Replacement(FilePath, UINT_MAX, 0, IncludeName)};
 
-  return formatReplacements(
-  Code, cleanupAroundReplacements(Code, Insertions, Style), Style);
+  auto CleanReplaces = cleanupAroundReplacements(Code, Insertions, Style);
+  if (!CleanReplaces)
+return CleanReplaces;
+  return formatReplacements(Code, *CleanReplaces, Style);
 }
 
 } // namespace include_fixer

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.h?rev=275063=275062=275063=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.h Mon Jul 11 08:53:21 
2016
@@ -68,8 +68,9 @@ private:
 /// \param Header The header being inserted.
 /// \param Style clang-format style being used.
 ///
-/// \return Replacements for inserting and sorting headers.
-tooling::Replacements createInsertHeaderReplacements(
+/// \return Replacements for inserting and sorting headers on success;
+/// otherwise, an llvm::Error carrying llvm::StringError is returned.
+llvm::Expected createInsertHeaderReplacements(
 StringRef Code, StringRef FilePath, StringRef Header,
 const clang::format::FormatStyle  = clang::format::getLLVMStyle());
 

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=275063=275062=275063=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Mon Jul 11 
08:53:21 2016
@@ -209,13 +209,20 @@ int includeFixerMain(int argc, const cha
   return 1;
 }
 
-tooling::Replacements Replacements =
-clang::include_fixer::createInsertHeaderReplacements(
-Code->getBuffer(), FilePath, Context.getHeaders().front(),
-InsertStyle);
-std::string ChangedCode =
-tooling::applyAllReplacements(Code->getBuffer(), Replacements);
-llvm::outs() << ChangedCode;
+auto Replacements = clang::include_fixer::createInsertHeaderReplacements(
+Code->getBuffer(), FilePath, Context.getHeaders().front(), 
InsertStyle);
+if (!Replacements) {
+  errs() << "Failed to create header insertion replacement: "
+ << llvm::toString(Replacements.takeError()) << "\n";
+  return 1;
+}
+auto ChangedCode =
+tooling::applyAllReplacements(Code->getBuffer(), *Replacements);
+if (!ChangedCode) {
+  llvm::errs() << llvm::toString(ChangedCode.takeError()) << "\n";
+  return 1;
+}
+llvm::outs() << *ChangedCode;
 return 0;
   }
 
@@ -250,17 +257,22 @@ int includeFixerMain(int argc, const cha
 return 1;
   }
 
-  tooling::Replacements Replacements =
-  clang::include_fixer::createInsertHeaderReplacements(
-  /*Code=*/Buffer.get()->getBuffer(), FilePath,
-  Context.getHeaders().front(), InsertStyle);
+  // FIXME: Rank the results and pick the best one instead of the first one.
+  auto Replacements = 

r275061 - [OpenCL] Improved diagnostics of OpenCL types.

2016-07-11 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Mon Jul 11 08:46:02 2016
New Revision: 275061

URL: http://llvm.org/viewvc/llvm-project?rev=275061=rev
Log:
[OpenCL] Improved diagnostics of OpenCL types.

 - Changes diagnostics for Blocks to be implicitly
const qualified OpenCL v2.0 s6.12.5.

 - Added and unified diagnostics of some OpenCL special types:
blocks, images, samplers, pipes. These types are intended for use
with the OpenCL builtin functions only and, therefore, most regular
uses are not allowed including assignments, arithmetic operations,
pointer dereferencing, etc.

Review: http://reviews.llvm.org/D21989


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/invalid-block.cl
cfe/trunk/test/SemaOpenCL/invalid-image.cl
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
cfe/trunk/test/SemaOpenCL/sampler_t.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275061=275060=275061=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul 11 08:46:02 
2016
@@ -7893,8 +7893,6 @@ def err_atomic_init_constant : Error<
   " in the declaration statement in the program scope">;
 def err_opencl_implicit_vector_conversion : Error<
   "implicit conversions between vector types (%0 and %1) are not permitted">;
-def err_opencl_dereferencing : Error<
-  "dereferencing pointer of type %0 is not allowed in OpenCL">;
 def err_opencl_block_proto_variadic : Error<
   "invalid block prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_invalid_type_array : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=275061=275060=275061=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jul 11 08:46:02 2016
@@ -11032,16 +11032,6 @@ ParmVarDecl *Sema::CheckParameter(DeclCo
 }
   }
 
-  // OpenCL v2.0 s6.9b - Pointer to image/sampler cannot be used.
-  // OpenCL v2.0 s6.13.16.1 - Pointer to pipe cannot be used.
-  if (getLangOpts().OpenCL && T->isPointerType()) {
-const QualType PTy = T->getPointeeType();
-if (PTy->isImageType() || PTy->isSamplerT() || PTy->isPipeType()) {
-  Diag(NameLoc, diag::err_opencl_pointer_to_type) << PTy;
-  New->setInvalidDecl();
-}
-  }
-
   return New;
 }
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=275061=275060=275061=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul 11 08:46:02 2016
@@ -10534,13 +10534,6 @@ QualType Sema::CheckAddressOfOperand(Exp
   if (op->getType()->isObjCObjectType())
 return Context.getObjCObjectPointerType(op->getType());
 
-  // OpenCL v2.0 s6.12.5 - The unary operators & cannot be used with a block.
-  if (getLangOpts().OpenCL && OrigOp.get()->getType()->isBlockPointerType()) {
-Diag(OpLoc, diag::err_typecheck_unary_expr) << OrigOp.get()->getType()
-<< op->getSourceRange();
-return QualType();
-  }
-
   return Context.getPointerType(op->getType());
 }
 
@@ -10584,12 +10577,6 @@ static QualType CheckIndirectionOperand(
   if (const PointerType *PT = OpTy->getAs())
   {
 Result = PT->getPointeeType();
-// OpenCL v2.0 s6.12.5 - The unary operators * cannot be used with a block.
-if (S.getLangOpts().OpenCLVersion >= 200 && Result->isBlockPointerType()) {
-  S.Diag(OpLoc, diag::err_opencl_dereferencing) << OpTy
-<< Op->getSourceRange();
-  return QualType();
-}
   }
   else if (const ObjCObjectPointerType *OPT =
  OpTy->getAs())
@@ -10828,10 +10815,11 @@ ExprResult Sema::CreateBuiltinBinOp(Sour
   }
 
   if (getLangOpts().OpenCL) {
+QualType LHSTy = LHSExpr->getType();
+QualType RHSTy = RHSExpr->getType();
 // OpenCLC v2.0 s6.13.11.1 allows atomic variables to be initialized by
 // the ATOMIC_VAR_INIT macro.
-if (LHSExpr->getType()->isAtomicType() ||
-RHSExpr->getType()->isAtomicType()) {
+if (LHSTy->isAtomicType() || RHSTy->isAtomicType()) {
   SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
   if (BO_Assign == Opc)
 Diag(OpLoc, diag::err_atomic_init_constant) << SR;
@@ -10839,6 +10827,16 @@ ExprResult Sema::CreateBuiltinBinOp(Sour
 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
   return ExprError();
 }
+
+// OpenCL 

Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-07-11 Thread Ben Harper via cfe-commits
bmharper added a comment.

kaPING!


Repository:
  rL LLVM

http://reviews.llvm.org/D21279



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


[PATCH] D22212: [X86][AVX512] Constants for integer comparison predicates

2016-07-11 Thread Asaf Badouh via cfe-commits
AsafBadouh created this revision.
AsafBadouh added reviewers: guyblank, m_zuckerman, delena.
AsafBadouh added a subscriber: cfe-commits.
AsafBadouh set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

http://reviews.llvm.org/D22212

Files:
  ../tunkClang/tools/clang/lib/Headers/avx512fintrin.h
  ../tunkClang/tools/clang/test/CodeGen/avx512f-builtins.c
  ../tunkClang/tools/clang/test/CodeGen/avx512vl-builtins.c

Index: ../tunkClang/tools/clang/lib/Headers/avx512fintrin.h
===
--- ../tunkClang/tools/clang/lib/Headers/avx512fintrin.h
+++ ../tunkClang/tools/clang/lib/Headers/avx512fintrin.h
@@ -54,6 +54,19 @@
 #define _MM_FROUND_TO_ZERO  0x03
 #define _MM_FROUND_CUR_DIRECTION0x04
 
+/* Constants for integer comparison predicates */
+typedef enum {
+_MM_CMPINT_EQ,  /* Equal */
+_MM_CMPINT_LT,  /* Less than */
+_MM_CMPINT_LE,  /* Less than or Equal */
+_MM_CMPINT_UNUSED,
+_MM_CMPINT_NE,  /* Not Equal */
+_MM_CMPINT_NLT, /* Not Less than */
+#define _MM_CMPINT_GE   _MM_CMPINT_NLT  /* Greater than or Equal */
+_MM_CMPINT_NLE  /* Not Less than or Equal */
+#define _MM_CMPINT_GT   _MM_CMPINT_NLE  /* Greater than */
+} _MM_CMPINT_ENUM;
+
 typedef enum
 {
   _MM_PERM_ = 0x00, _MM_PERM_AAAB = 0x01, _MM_PERM_AAAC = 0x02,
Index: ../tunkClang/tools/clang/test/CodeGen/avx512f-builtins.c
===
--- ../tunkClang/tools/clang/test/CodeGen/avx512f-builtins.c
+++ ../tunkClang/tools/clang/test/CodeGen/avx512f-builtins.c
@@ -1359,27 +1359,27 @@
 __mmask16 test_mm512_cmp_epi32_mask(__m512i __a, __m512i __b) {
   // CHECK-LABEL: @test_mm512_cmp_epi32_mask
   // CHECK: icmp eq <16 x i32> %{{.*}}, %{{.*}}
-  return (__mmask16)_mm512_cmp_epi32_mask(__a, __b, 0);
+  return (__mmask16)_mm512_cmp_epi32_mask(__a, __b, _MM_CMPINT_EQ);
 }
 
 __mmask16 test_mm512_mask_cmp_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
   // CHECK-LABEL: @test_mm512_mask_cmp_epi32_mask
   // CHECK: icmp eq <16 x i32> %{{.*}}, %{{.*}}
   // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
-  return (__mmask16)_mm512_mask_cmp_epi32_mask(__u, __a, __b, 0);
+  return (__mmask16)_mm512_mask_cmp_epi32_mask(__u, __a, __b, _MM_CMPINT_EQ);
 }
 
 __mmask8 test_mm512_cmp_epi64_mask(__m512i __a, __m512i __b) {
   // CHECK-LABEL: @test_mm512_cmp_epi64_mask
   // CHECK: icmp eq <8 x i64> %{{.*}}, %{{.*}}
-  return (__mmask8)_mm512_cmp_epi64_mask(__a, __b, 0);
+  return (__mmask8)_mm512_cmp_epi64_mask(__a, __b, _MM_CMPINT_EQ);
 }
 
 __mmask8 test_mm512_mask_cmp_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
   // CHECK-LABEL: @test_mm512_mask_cmp_epi64_mask
   // CHECK: icmp eq <8 x i64> %{{.*}}, %{{.*}}
   // CHECK: and <8 x i1> %{{.*}}, %{{.*}}
-  return (__mmask8)_mm512_mask_cmp_epi64_mask(__u, __a, __b, 0);
+  return (__mmask8)_mm512_mask_cmp_epi64_mask(__u, __a, __b, _MM_CMPINT_EQ);
 }
 
 __mmask16 test_mm512_cmp_epu32_mask(__m512i __a, __m512i __b) {
Index: ../tunkClang/tools/clang/test/CodeGen/avx512vl-builtins.c
===
--- ../tunkClang/tools/clang/test/CodeGen/avx512vl-builtins.c
+++ ../tunkClang/tools/clang/test/CodeGen/avx512vl-builtins.c
@@ -504,53 +504,53 @@
 __mmask8 test_mm_cmp_epi32_mask(__m128i __a, __m128i __b) {
   // CHECK-LABEL: @test_mm_cmp_epi32_mask
   // CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}}
-  return (__mmask8)_mm_cmp_epi32_mask(__a, __b, 0);
+  return (__mmask8)_mm_cmp_epi32_mask(__a, __b, _MM_CMPINT_EQ);
 }
 
 __mmask8 test_mm_mask_cmp_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
   // CHECK-LABEL: @test_mm_mask_cmp_epi32_mask
-  // CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: icmp slt <4 x i32> %{{.*}}, %{{.*}}
   // CHECK: and <4 x i1> %{{.*}}, %{{.*}}
-  return (__mmask8)_mm_mask_cmp_epi32_mask(__u, __a, __b, 0);
+  return (__mmask8)_mm_mask_cmp_epi32_mask(__u, __a, __b, _MM_CMPINT_LT);
 }
 
 __mmask8 test_mm_cmp_epi64_mask(__m128i __a, __m128i __b) {
   // CHECK-LABEL: @test_mm_cmp_epi64_mask
-  // CHECK: icmp eq <2 x i64> %{{.*}}, %{{.*}}
-  return (__mmask8)_mm_cmp_epi64_mask(__a, __b, 0);
+  // CHECK: icmp slt <2 x i64> %{{.*}}, %{{.*}}
+  return (__mmask8)_mm_cmp_epi64_mask(__a, __b, _MM_CMPINT_LT);
 }
 
 __mmask8 test_mm_mask_cmp_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
   // CHECK-LABEL: @test_mm_mask_cmp_epi64_mask
   // CHECK: icmp eq <2 x i64> %{{.*}}, %{{.*}}
   // CHECK: and <2 x i1> %{{.*}}, %{{.*}}
-  return (__mmask8)_mm_mask_cmp_epi64_mask(__u, __a, __b, 0);
+  return (__mmask8)_mm_mask_cmp_epi64_mask(__u, __a, __b, _MM_CMPINT_EQ);
 }
 
 __mmask8 test_mm256_cmp_epi32_mask(__m256i __a, __m256i __b) {
   // CHECK-LABEL: @test_mm256_cmp_epi32_mask
   // CHECK: icmp eq <8 x i32> %{{.*}}, %{{.*}}
-  return (__mmask8)_mm256_cmp_epi32_mask(__a, __b, 0);
+  return (__mmask8)_mm256_cmp_epi32_mask(__a, __b, _MM_CMPINT_EQ);
 }
 
 

Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-11 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Add
// FIXME: 
to tests that do not work yet.

I'd personally not check in the XFAIL tests for now, and just add them when you 
implement the missing functionality; the problem with XFAIL here is that (due 
to the offsets involved) they can easily switch into a mode where they fail not 
because the feature is not implemented, but because the test is incorrect.


http://reviews.llvm.org/D22102



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


Re: [PATCH] D22075: [OpenMP] Fix incorrect diagnostics in map clause

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:10667-10668
@@ +10666,4 @@
+  if (Type.isNull() || Type->isAnyPointerType() ||
+  CheckArrayExpressionDoesNotReferToWholeSize(SemaRef,
+  SI->getAssociatedExpression(),Type))
+break;

Seems to me the code is not formatted properly.


http://reviews.llvm.org/D22075



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

No positive tests for the construct



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8333
@@ -8332,1 +8332,3 @@
   "expected at least one 'to' clause or 'from' clause specified to '#pragma 
omp target update'">;
+def  err_omp_usedeviceptr_not_a_pointer : Error<
+  "expected pointer in 'use_device_ptr' clause">;

Shall we accept refs to pointers and arrays?


Comment at: lib/Sema/SemaOpenMP.cpp:11644-11646
@@ +11643,5 @@
+Type = Type.getUnqualifiedType();
+DeclRefExpr *Ref = nullptr;
+if (!VD)
+  Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/false);
+Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);

It is better to add this code in codegen part


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D22096: [OpenMP] Sema and parsing for 'target parallel for simd' pragma

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D22096



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


Re: [PATCH] D22169: [OpenMP] add more tests for 'distribute parallel for simd' pragma

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D22169



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


Re: [PATCH] D22176: [OpenMP] add more tests for 'distribute simd' pragma

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D22176



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


Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-11 Thread Clement Courbet via cfe-commits
courbet added a comment.

I've ran this check on llvm. There are 0 instances of virtual function slicing 
(which is not surprising since these usually result in actual bugs) and 71 
instances of member varaible slicing:

- 'FullSourceLoc' to 'SourceLocation': 57
- 'APSInt' to 'APInt': 5
- 'DeducedTemplateArgument' to 'TemplateArgument': 3
- 'SemaDiagnosticBuilder' to 'DiagnosticBuilder': 2
- 'RegHalf' to 'RegisterRef': 2
- 'PathDiagnosticRange' to 'SourceRange': 2

Most are harmless (but still true positives). The 'SemaDiagnosticBuilder' and 
'APSInt' are actually interesting:

llvm/llvm/tools/clang/lib/Sema/SemaExprObjC.cpp:3555
``DiagnosticBuilder DiagB = …`` should be: ``SemaDiagnosticBuilder DiagB = …``
DiagB is then passed by reference to a function, so there really is no reason 
to slice it.

AST/ExprConstant.cpp:3150
``explicit APSInt(APInt I, bool isUnsigned = true)``
Here it’s easy to write: ``APSInt MyInt(MyOtherInt);`` and think it’s a copy, 
but it’s not (it just changed the signedness). ``APSInt 
MyInt(MyOtherInt.toAPInt());`` would make it clear what’s happening.


http://reviews.llvm.org/D21992



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


Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-11 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks for the comments.



Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:48
@@ +47,3 @@
+
+  // Assignement slicing: "a = b;" and "a = std::move(b);" variants.
+  const auto SlicesObjectInAssignment =

hokein wrote:
> Looks like you are missing some cases here, like assigning a Subclass object 
> from a function call to a Baseclass object, passing a Subclass object to a 
> function whose parameter is a BaseClass.
> 
> But I think it's fine to implement in a separate patch, but you'd better to 
> add a TODO here.
> 
> ```
> SubClass f1();
> BaseClass a = f1();
> 
> void f1(BaseClass a);
> SubClass sc;
> f1(sc);
> ```
Actually these will still create a CXXConstructExpr in the AST, e.g for case 
(2):

```
CallExpr 0x3d6e560  'void'
|-ImplicitCastExpr 0x3d6e548  'void (*)(class A)' 

| `-DeclRefExpr 0x3d6e4f8  'void (class A)' lvalue Function 0x3d66550 
'g' 'void (class A)'
`-CXXConstructExpr 0x3d6e5c8  'class A' 'void (const class A &) throw()'
  `-ImplicitCastExpr 0x3d6e5b0  'const class A' lvalue 
`-ImplicitCastExpr 0x3d6e590  'class A' lvalue 
  `-DeclRefExpr 0x3d6e4d0  'class B' lvalue Var 0x3d6e300 'b' 'class 
B'
```

I alreagy have a test to case (2) and I've added one for case (1).



Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:84
@@ +83,3 @@
+  diag(Call.getExprLoc(),
+   "slicing object from type %0 to %1 discards override %2")
+  <<  <<  << Method;

hokein wrote:
> There are two diagnostic messages in the code. For subclasses with override 
> base class methods and extra member, this will print two messages, which is a 
> bit of redundant.
I think we still want to point out to the user which overrides are going to be 
discarded:

class A { virtual void f();  virtual void g(); }
class B : public A { void f() override;  void g() override; int a; }

The messages will be:
"slicing object from type 'B' to 'A' discards override 'f' "
"slicing object from type 'B' to 'A' discards override 'g' "
"slicing object from type 'B' to 'A' discards 4*sizeof(char) bytes of state"





http://reviews.llvm.org/D21992



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


Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-11 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 63477.
courbet marked 4 inline comments as done.
courbet added a comment.

- Add a test case following comments.
- Add more comments in tests.
- Add examples in doc.
- Simplify code a bit.


http://reviews.llvm.org/D21992

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/SlicingCheck.cpp
  clang-tidy/cppcoreguidelines/SlicingCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
  test/clang-tidy/cppcoreguidelines-slicing.cpp

Index: test/clang-tidy/cppcoreguidelines-slicing.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-slicing.cpp
@@ -0,0 +1,100 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-slicing %t
+
+class Base {
+  int i;
+  void f() {}
+  virtual void g() {}
+};
+
+class DerivedWithMemberVariables : public Base {
+  void f();
+  int j;
+};
+
+class TwiceDerivedWithNoMemberVariables : public DerivedWithMemberVariables {
+  void f();
+};
+
+class DerivedWithOverride : public Base {
+  void f();
+  void g() override {}
+};
+
+class TwiceDerivedWithNoOverride : public DerivedWithOverride {
+  void f();
+};
+
+void TakesBaseByValue(Base base);
+
+DerivedWithMemberVariables ReturnsDerived();
+
+void positivesWithMemberVariables() {
+  DerivedWithMemberVariables b;
+  Base a{b};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state [cppcoreguidelines-slicing]
+  a = b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+  TakesBaseByValue(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+
+  TwiceDerivedWithNoMemberVariables c;
+  a = c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'TwiceDerivedWithNoMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+
+  a = ReturnsDerived();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards 4*sizeof(char) bytes of state
+}
+
+void positivesWithOverride() {
+  DerivedWithOverride b;
+  Base a{b};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+  a = b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+  TakesBaseByValue(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+
+  TwiceDerivedWithNoOverride c;
+  a = c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+}
+
+void TakesBaseByReference(Base );
+
+class DerivedThatAddsVirtualH : public Base {
+  virtual void h();
+};
+
+class DerivedThatOverridesH : public DerivedThatAddsVirtualH {
+  void h() override;
+};
+
+void negatives() {
+  // OK, simple copying from the same type.
+  Base a;
+  TakesBaseByValue(a);
+  DerivedWithMemberVariables b;
+  DerivedWithMemberVariables c{b};
+  b = c;
+
+  // OK, derived type does not have extra state.
+  TwiceDerivedWithNoMemberVariables d;
+  DerivedWithMemberVariables e{d};
+  e = d;
+
+  // OK, derived does not override any method.
+  TwiceDerivedWithNoOverride f;
+  DerivedWithOverride g{f};
+  g = f;
+
+  // OK, no copying.
+  TakesBaseByReference(d);
+  TakesBaseByReference(f);
+
+  // Derived type overrides methods, but these methods are not in the base type,
+  // so cannot be called accidentally. Righ tnow this triggers, but we might
+  // want to allow it.
+  DerivedThatOverridesH h;
+  a = h;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedThatOverridesH' to 'Base' discards override 'h'
+}
Index: docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
@@ -0,0 +1,24 @@
+.. title:: clang-tidy - cppcoreguidelines-slicing
+
+cppcoreguidelines-slicing
+=
+
+Flags slicing of member variables or vtable. Slicing happens when copying a
+derived object into a base object: the members of the derived object (both
+member variables and virtual member functions) will be discarded.
+This can be misleading especially for member function slicing, for example:
+
+.. code:: c++
+
+	struct B { int a; virtual int f(); };
+	struct D : B { int b; int f() override; };
+	void use(B b) {  // Missing reference, intended ?
+	  b.f();  // Calls B::f.
+	}
+	D d;
+	use(d);  // Slice.
+
+See the relevant 

Re: [PATCH] D21744: [OpenCL] Fix code generation of kernel pipe parameters.

2016-07-11 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.

Sorry for the late reply, I was busy with some backend problem.
LGTM, thanks for the fix!


http://reviews.llvm.org/D21744



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


Re: [PATCH] D21834: Implementing 'If statement with Initializer'

2016-07-11 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 63475.
AntonBikineev added a comment.

Moved stars to the right side of declarations


http://reviews.llvm.org/D21834

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGenCXX/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.h
  test/Parser/cxx1z-init-statement.cpp
  test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
  test/SemaCXX/cxx1z-init-statement.cpp

Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+void testIf() {
+  int x = 0;
+  if (x; x) ++x;
+  if (int t = 0; t) ++t; else --t;
+
+  if (int x, y = 0; y) // expected-note 2 {{previous definition is here}}
+int x = 0; // expected-error {{redefinition of 'x'}}
+  else
+int x = 0; // expected-error {{redefinition of 'x'}}
+
+  if (x; int a = 0) ++a;
+  if (x, +x; int a = 0) // expected-note 2 {{previous definition is here}} expected-warning {{unused}}
+int a = 0; // expected-error {{redefinition of 'a'}}
+  else
+int a = 0; // expected-error {{redefinition of 'a'}}
+
+  if (int b = 0; b)
+;
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+void testSwitch() {
+  int x = 0;
+  switch (x; x) {
+case 1:
+  ++x;
+  }
+
+  switch (int x, y = 0; y) {
+case 1:
+  ++x;
+default:
+  ++y;
+  }
+
+  switch (int x, y = 0; y) { // expected-note 2 {{previous definition is here}}
+case 0:
+  int x = 0; // expected-error {{redefinition of 'x'}}
+case 1:
+  int y = 0; // expected-error {{redefinition of 'y'}}
+  };
+
+  switch (x; int a = 0) {
+case 0:
+  ++a;
+  }
+
+  switch (x, +x; int a = 0) { // expected-note {{previous definition is here}} expected-warning {{unused}}
+case 0:
+  int a = 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
+case 1:
+  int a = 0; // expected-error {{redefinition of 'a'}}
+  }
+
+  switch (int b = 0; b) {
+case 0:
+  break;
+  }
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+constexpr bool constexpr_if_init(int n) {
+  if (int a = n; ++a > 0)
+return true;
+  else
+return false;
+}
+
+constexpr int constexpr_switch_init(int n) {
+  switch (int p = n + 2; p) {
+case 0:
+  return 0;
+case 1:
+  return 1;
+default:
+  return -1;
+  }
+}
+
+void test_constexpr_init_stmt() {
+  constexpr bool a = constexpr_if_init(-2);
+  static_assert(!a, "");
+  static_assert(constexpr_if_init(1), "");
+
+  constexpr int b = constexpr_switch_init(-1);
+  static_assert(b == 1, "");
+  static_assert(constexpr_switch_init(-2) == 0, "");
+  static_assert(constexpr_switch_init(-5) == -1, "");
+}
Index: test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
===
--- test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
+++ test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++1z -verify -Wuninitialized %s
+
+void testIf() {
+  if (bool b; b) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  if (int a, b = 2; a) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  int a;
+  if (a = 0; a) {} // OK
+}
+
+void testSwitch() {
+  switch (bool b; b) { // expected-warning {{uninitialized}} expected-warning {{boolean value}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  switch (int a, b = 7; a) { // expected-warning {{uninitialized}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  int c;
+  switch (c = 0; c) { // OK
+case 0:
+  break;
+  }
+}
Index: test/Parser/cxx1z-init-statement.cpp
===
--- test/Parser/cxx1z-init-statement.cpp
+++ test/Parser/cxx1z-init-statement.cpp
@@ -4,18 +4,18 @@
 typedef int T;
 int f() {
   // init-statement declarations
-  if (T n = 0; n != 0) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T(f()); f()) {} // expected-error {{not yet supported}}
-  if (T(f()), g, h; f()) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T f(), g, h; f()) {} // expected-error {{not yet supported}}
-  if (T(n) = 0; n) {} // expected-error {{not yet supported}}
+  if (T n = 0; n != 0) {}
+  if (T f(); f()) {}
+  if (T(f()); f()) 

Re: [PATCH] D21834: Implementing 'If statement with Initializer'

2016-07-11 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 63474.

http://reviews.llvm.org/D21834

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGenCXX/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.h
  test/Parser/cxx1z-init-statement.cpp
  test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
  test/SemaCXX/cxx1z-init-statement.cpp

Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+void testIf() {
+  int x = 0;
+  if (x; x) ++x;
+  if (int t = 0; t) ++t; else --t;
+
+  if (int x, y = 0; y) // expected-note 2 {{previous definition is here}}
+int x = 0; // expected-error {{redefinition of 'x'}}
+  else
+int x = 0; // expected-error {{redefinition of 'x'}}
+
+  if (x; int a = 0) ++a;
+  if (x, +x; int a = 0) // expected-note 2 {{previous definition is here}} expected-warning {{unused}}
+int a = 0; // expected-error {{redefinition of 'a'}}
+  else
+int a = 0; // expected-error {{redefinition of 'a'}}
+
+  if (int b = 0; b)
+;
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+void testSwitch() {
+  int x = 0;
+  switch (x; x) {
+case 1:
+  ++x;
+  }
+
+  switch (int x, y = 0; y) {
+case 1:
+  ++x;
+default:
+  ++y;
+  }
+
+  switch (int x, y = 0; y) { // expected-note 2 {{previous definition is here}}
+case 0:
+  int x = 0; // expected-error {{redefinition of 'x'}}
+case 1:
+  int y = 0; // expected-error {{redefinition of 'y'}}
+  };
+
+  switch (x; int a = 0) {
+case 0:
+  ++a;
+  }
+
+  switch (x, +x; int a = 0) { // expected-note {{previous definition is here}} expected-warning {{unused}}
+case 0:
+  int a = 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
+case 1:
+  int a = 0; // expected-error {{redefinition of 'a'}}
+  }
+
+  switch (int b = 0; b) {
+case 0:
+  break;
+  }
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+constexpr bool constexpr_if_init(int n) {
+  if (int a = n; ++a > 0)
+return true;
+  else
+return false;
+}
+
+constexpr int constexpr_switch_init(int n) {
+  switch (int p = n + 2; p) {
+case 0:
+  return 0;
+case 1:
+  return 1;
+default:
+  return -1;
+  }
+}
+
+void test_constexpr_init_stmt() {
+  constexpr bool a = constexpr_if_init(-2);
+  static_assert(!a, "");
+  static_assert(constexpr_if_init(1), "");
+
+  constexpr int b = constexpr_switch_init(-1);
+  static_assert(b == 1, "");
+  static_assert(constexpr_switch_init(-2) == 0, "");
+  static_assert(constexpr_switch_init(-5) == -1, "");
+}
Index: test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
===
--- test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
+++ test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++1z -verify -Wuninitialized %s
+
+void testIf() {
+  if (bool b; b) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  if (int a, b = 2; a) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  int a;
+  if (a = 0; a) {} // OK
+}
+
+void testSwitch() {
+  switch (bool b; b) { // expected-warning {{uninitialized}} expected-warning {{boolean value}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  switch (int a, b = 7; a) { // expected-warning {{uninitialized}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  int c;
+  switch (c = 0; c) { // OK
+case 0:
+  break;
+  }
+}
Index: test/Parser/cxx1z-init-statement.cpp
===
--- test/Parser/cxx1z-init-statement.cpp
+++ test/Parser/cxx1z-init-statement.cpp
@@ -4,18 +4,18 @@
 typedef int T;
 int f() {
   // init-statement declarations
-  if (T n = 0; n != 0) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T(f()); f()) {} // expected-error {{not yet supported}}
-  if (T(f()), g, h; f()) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T f(), g, h; f()) {} // expected-error {{not yet supported}}
-  if (T(n) = 0; n) {} // expected-error {{not yet supported}}
+  if (T n = 0; n != 0) {}
+  if (T f(); f()) {}
+  if (T(f()); f()) {}
+  if (T(f()), g, h; f()) {}
+  if (T f(); f()) {}
+  if (T f(), g, h; f()) 

Re: [PATCH] D21834: Implementing 'If statement with Initializer'

2016-07-11 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 63473.
AntonBikineev added a comment.

removed a leftover from parser/cxx1z-init-stmt.cpp test


http://reviews.llvm.org/D21834

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGenCXX/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.h
  test/Parser/cxx1z-init-statement.cpp
  test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
  test/SemaCXX/cxx1z-init-statement.cpp

Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+void testIf() {
+  int x = 0;
+  if (x; x) ++x;
+  if (int t = 0; t) ++t; else --t;
+
+  if (int x, y = 0; y) // expected-note 2 {{previous definition is here}}
+int x = 0; // expected-error {{redefinition of 'x'}}
+  else
+int x = 0; // expected-error {{redefinition of 'x'}}
+
+  if (x; int a = 0) ++a;
+  if (x, +x; int a = 0) // expected-note 2 {{previous definition is here}} expected-warning {{unused}}
+int a = 0; // expected-error {{redefinition of 'a'}}
+  else
+int a = 0; // expected-error {{redefinition of 'a'}}
+
+  if (int b = 0; b)
+;
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+void testSwitch() {
+  int x = 0;
+  switch (x; x) {
+case 1:
+  ++x;
+  }
+
+  switch (int x, y = 0; y) {
+case 1:
+  ++x;
+default:
+  ++y;
+  }
+
+  switch (int x, y = 0; y) { // expected-note 2 {{previous definition is here}}
+case 0:
+  int x = 0; // expected-error {{redefinition of 'x'}}
+case 1:
+  int y = 0; // expected-error {{redefinition of 'y'}}
+  };
+
+  switch (x; int a = 0) {
+case 0:
+  ++a;
+  }
+
+  switch (x, +x; int a = 0) { // expected-note {{previous definition is here}} expected-warning {{unused}}
+case 0:
+  int a = 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
+case 1:
+  int a = 0; // expected-error {{redefinition of 'a'}}
+  }
+
+  switch (int b = 0; b) {
+case 0:
+  break;
+  }
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+constexpr bool constexpr_if_init(int n) {
+  if (int a = n; ++a > 0)
+return true;
+  else
+return false;
+}
+
+constexpr int constexpr_switch_init(int n) {
+  switch (int p = n + 2; p) {
+case 0:
+  return 0;
+case 1:
+  return 1;
+default:
+  return -1;
+  }
+}
+
+void test_constexpr_init_stmt() {
+  constexpr bool a = constexpr_if_init(-2);
+  static_assert(!a, "");
+  static_assert(constexpr_if_init(1), "");
+
+  constexpr int b = constexpr_switch_init(-1);
+  static_assert(b == 1, "");
+  static_assert(constexpr_switch_init(-2) == 0, "");
+  static_assert(constexpr_switch_init(-5) == -1, "");
+}
Index: test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
===
--- test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
+++ test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++1z -verify -Wuninitialized %s
+
+void testIf() {
+  if (bool b; b) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  if (int a, b = 2; a) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  int a;
+  if (a = 0; a) {} // OK
+}
+
+void testSwitch() {
+  switch (bool b; b) { // expected-warning {{uninitialized}} expected-warning {{boolean value}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  switch (int a, b = 7; a) { // expected-warning {{uninitialized}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  int c;
+  switch (c = 0; c) { // OK
+case 0:
+  break;
+  }
+}
Index: test/Parser/cxx1z-init-statement.cpp
===
--- test/Parser/cxx1z-init-statement.cpp
+++ test/Parser/cxx1z-init-statement.cpp
@@ -4,18 +4,18 @@
 typedef int T;
 int f() {
   // init-statement declarations
-  if (T n = 0; n != 0) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T(f()); f()) {} // expected-error {{not yet supported}}
-  if (T(f()), g, h; f()) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T f(), g, h; f()) {} // expected-error {{not yet supported}}
+  if (T n = 0; n != 0) {}
+  if (T f(); f()) {}
+  if (T(f()); f()) {}
+  if (T(f()), g, h; f()) {}
+  if (T f(); f()) {}

Re: [PATCH] D22190: cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode

2016-07-11 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

Even if we change isIntegerConstantExpr() to return true instead of asserting, 
we still need this fix to the check. Because
we call isIntegerConstantExpr() to find out if we can possibly calculate the 
(constant) value of the index expression.
If it is value dependent, we cannot.


http://reviews.llvm.org/D22190



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


Re: [PATCH] D21834: Implementing 'If statement with Initializer'

2016-07-11 Thread Anton Bikineev via cfe-commits
AntonBikineev updated this revision to Diff 63472.

http://reviews.llvm.org/D21834

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGenCXX/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.h
  test/Parser/cxx1z-init-statement.cpp
  test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
  test/SemaCXX/cxx1z-init-statement.cpp

Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+void testIf() {
+  int x = 0;
+  if (x; x) ++x;
+  if (int t = 0; t) ++t; else --t;
+
+  if (int x, y = 0; y) // expected-note 2 {{previous definition is here}}
+int x = 0; // expected-error {{redefinition of 'x'}}
+  else
+int x = 0; // expected-error {{redefinition of 'x'}}
+
+  if (x; int a = 0) ++a;
+  if (x, +x; int a = 0) // expected-note 2 {{previous definition is here}} expected-warning {{unused}}
+int a = 0; // expected-error {{redefinition of 'a'}}
+  else
+int a = 0; // expected-error {{redefinition of 'a'}}
+
+  if (int b = 0; b)
+;
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+void testSwitch() {
+  int x = 0;
+  switch (x; x) {
+case 1:
+  ++x;
+  }
+
+  switch (int x, y = 0; y) {
+case 1:
+  ++x;
+default:
+  ++y;
+  }
+
+  switch (int x, y = 0; y) { // expected-note 2 {{previous definition is here}}
+case 0:
+  int x = 0; // expected-error {{redefinition of 'x'}}
+case 1:
+  int y = 0; // expected-error {{redefinition of 'y'}}
+  };
+
+  switch (x; int a = 0) {
+case 0:
+  ++a;
+  }
+
+  switch (x, +x; int a = 0) { // expected-note {{previous definition is here}} expected-warning {{unused}}
+case 0:
+  int a = 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
+case 1:
+  int a = 0; // expected-error {{redefinition of 'a'}}
+  }
+
+  switch (int b = 0; b) {
+case 0:
+  break;
+  }
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+constexpr bool constexpr_if_init(int n) {
+  if (int a = n; ++a > 0)
+return true;
+  else
+return false;
+}
+
+constexpr int constexpr_switch_init(int n) {
+  switch (int p = n + 2; p) {
+case 0:
+  return 0;
+case 1:
+  return 1;
+default:
+  return -1;
+  }
+}
+
+void test_constexpr_init_stmt() {
+  constexpr bool a = constexpr_if_init(-2);
+  static_assert(!a, "");
+  static_assert(constexpr_if_init(1), "");
+
+  constexpr int b = constexpr_switch_init(-1);
+  static_assert(b == 1, "");
+  static_assert(constexpr_switch_init(-2) == 0, "");
+  static_assert(constexpr_switch_init(-5) == -1, "");
+}
Index: test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
===
--- test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
+++ test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++1z -verify -Wuninitialized %s
+
+void testIf() {
+  if (bool b; b) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  if (int a, b = 2; a) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  int a;
+  if (a = 0; a) {} // OK
+}
+
+void testSwitch() {
+  switch (bool b; b) { // expected-warning {{uninitialized}} expected-warning {{boolean value}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  switch (int a, b = 7; a) { // expected-warning {{uninitialized}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  int c;
+  switch (c = 0; c) { // OK
+case 0:
+  break;
+  }
+}
Index: test/Parser/cxx1z-init-statement.cpp
===
--- test/Parser/cxx1z-init-statement.cpp
+++ test/Parser/cxx1z-init-statement.cpp
@@ -4,18 +4,18 @@
 typedef int T;
 int f() {
   // init-statement declarations
-  if (T n = 0; n != 0) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T(f()); f()) {} // expected-error {{not yet supported}}
-  if (T(f()), g, h; f()) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T f(), g, h; f()) {} // expected-error {{not yet supported}}
+  if (T n = 0; n != 0) {}
+  if (T f(); f()) {}
+  if (T(f()); f()) {}
+  if (T(f()), g, h; f()) {}
+  if (T f(); f()) {}
+  if (T f(), g, h; f()) {}
   if (T(n) = 0; n) {} // expected-error {{not yet 

Re: [PATCH] D21834: Implementing 'If statement with Initializer'

2016-07-11 Thread Anton Bikineev via cfe-commits
AntonBikineev updated the summary for this revision.
AntonBikineev updated this revision to Diff 63471.
AntonBikineev added a comment.

@rsmith,
Richard, again, thank you for guiding. I've addressed your comments.


http://reviews.llvm.org/D21834

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGenCXX/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.cpp
  test/PCH/cxx1z-init-statement.h
  test/Parser/cxx1z-init-statement.cpp
  test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
  test/SemaCXX/cxx1z-init-statement.cpp

Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+void testIf() {
+  int x = 0;
+  if (x; x) ++x;
+  if (int t = 0; t) ++t; else --t;
+
+  if (int x, y = 0; y) // expected-note 2 {{previous definition is here}}
+int x = 0; // expected-error {{redefinition of 'x'}}
+  else
+int x = 0; // expected-error {{redefinition of 'x'}}
+
+  if (x; int a = 0) ++a;
+  if (x, +x; int a = 0) // expected-note 2 {{previous definition is here}} expected-warning {{unused}}
+int a = 0; // expected-error {{redefinition of 'a'}}
+  else
+int a = 0; // expected-error {{redefinition of 'a'}}
+
+  if (int b = 0; b)
+;
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+void testSwitch() {
+  int x = 0;
+  switch (x; x) {
+case 1:
+  ++x;
+  }
+
+  switch (int x, y = 0; y) {
+case 1:
+  ++x;
+default:
+  ++y;
+  }
+
+  switch (int x, y = 0; y) { // expected-note 2 {{previous definition is here}}
+case 0:
+  int x = 0; // expected-error {{redefinition of 'x'}}
+case 1:
+  int y = 0; // expected-error {{redefinition of 'y'}}
+  };
+
+  switch (x; int a = 0) {
+case 0:
+  ++a;
+  }
+
+  switch (x, +x; int a = 0) { // expected-note {{previous definition is here}} expected-warning {{unused}}
+case 0:
+  int a = 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
+case 1:
+  int a = 0; // expected-error {{redefinition of 'a'}}
+  }
+
+  switch (int b = 0; b) {
+case 0:
+  break;
+  }
+  b = 2; // expected-error {{use of undeclared identifier}}
+}
+
+constexpr bool constexpr_if_init(int n) {
+  if (int a = n; ++a > 0)
+return true;
+  else
+return false;
+}
+
+constexpr int constexpr_switch_init(int n) {
+  switch (int p = n + 2; p) {
+case 0:
+  return 0;
+case 1:
+  return 1;
+default:
+  return -1;
+  }
+}
+
+void test_constexpr_init_stmt() {
+  constexpr bool a = constexpr_if_init(-2);
+  static_assert(!a, "");
+  static_assert(constexpr_if_init(1), "");
+
+  constexpr int b = constexpr_switch_init(-1);
+  static_assert(b == 1, "");
+  static_assert(constexpr_switch_init(-2) == 0, "");
+  static_assert(constexpr_switch_init(-5) == -1, "");
+}
Index: test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
===
--- test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
+++ test/SemaCXX/cxx1z-init-statement-warn-unused.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++1z -verify -Wuninitialized %s
+
+void testIf() {
+  if (bool b; b) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  if (int a, b = 2; a) // expected-warning {{uninitialized}} expected-note {{to silence}}
+;
+  int a;
+  if (a = 0; a) {} // OK
+}
+
+void testSwitch() {
+  switch (bool b; b) { // expected-warning {{uninitialized}} expected-warning {{boolean value}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  switch (int a, b = 7; a) { // expected-warning {{uninitialized}} expected-note {{to silence}}
+case 0:
+  break;
+  }
+  int c;
+  switch (c = 0; c) { // OK
+case 0:
+  break;
+  }
+}
Index: test/Parser/cxx1z-init-statement.cpp
===
--- test/Parser/cxx1z-init-statement.cpp
+++ test/Parser/cxx1z-init-statement.cpp
@@ -4,18 +4,18 @@
 typedef int T;
 int f() {
   // init-statement declarations
-  if (T n = 0; n != 0) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T(f()); f()) {} // expected-error {{not yet supported}}
-  if (T(f()), g, h; f()) {} // expected-error {{not yet supported}}
-  if (T f(); f()) {} // expected-error {{not yet supported}}
-  if (T f(), g, h; f()) {} // expected-error {{not yet supported}}
+  if (T n = 0; n != 0) {}
+  if (T f(); f()) {}

Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-11 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 63470.
omtcyf0 added a comment.

add XFAIL test with virtual function renaming


http://reviews.llvm.org/D22102

Files:
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/TemplateTypename.cpp
  test/clang-rename/VariableMacro.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,17 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=175 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+// XFAIL: *
+
+class A {
+public:
+  virtual void foo(); // CHECK: virtual void boo();
+};
+
+class B : public A {
+public:
+  void foo(); // CHECK: void boo();
+};
+
+// Use grep -FUbo 'Cla'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/VariableMacro.cpp
===
--- /dev/null
+++ test/clang-rename/VariableMacro.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define Y X // CHECK: #define Y Z
+
+void foo(int value) {}
+
+void macro() {
+  int X;// CHECK: int Z;
+  X = 42;   // CHECK: Z = 42;
+  Y -= 0;
+  foo(X);   // CHECK: foo(Z);
+  foo(Y);
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/TemplateTypename.cpp
===
--- /dev/null
+++ test/clang-rename/TemplateTypename.cpp
@@ -0,0 +1,16 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=152 -new-name=U %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+// XFAIL: *
+
+template  // CHECK: template 
+T foo(T arg, T& ref, T* ptr) {// CHECK: U foo(U arg, U& ref, U* ptr) {
+  T value;// CHECK: U value;
+  int number = 42;
+  value = (T)number;  // CHECK: value = (U)number;
+  value = static_cast(number); // CHECK: value = static_cast(number);
+  return value;
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/Namespace.cpp
===
--- /dev/null
+++ test/clang-rename/Namespace.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace foo { // CHECK: namespace llvm {
+  int x;
+}
+
+void boo() {
+  foo::x = 42;  // CHECK: llvm::x = 42;
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/FunctionMacro.cpp
===
--- /dev/null
+++ test/clang-rename/FunctionMacro.cpp
@@ -0,0 +1,21 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define moo foo // CHECK: #define moo macro_function
+
+int foo() { // CHECK: int macro_function() {
+  return 42;
+}
+
+void boo(int value) {}
+
+void qoo() {
+  foo();// CHECK: macro_function();
+  boo(foo());   // CHECK: boo(macro_function());
+  moo();
+  boo(moo());
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22154: [clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.

2016-07-11 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275051: [clang-tidy] Pass absolute path to 
OptionsProvider::getOptions/getRawOptions. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D22154?vs=63282=63469#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22154

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp

Index: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
@@ -313,13 +313,19 @@
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
-  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
+
+  SmallString<256> FilePath(FileName);
+  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
+llvm::errs() << "Can't make absolute path from " << FileName << ": "
+ << EC.message() << "\n";
+  }
+  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
   if (ExplainConfig) {
 //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
 std::vector
-RawOptions = OptionsProvider->getRawOptions(FileName);
+RawOptions = OptionsProvider->getRawOptions(FilePath);
 for (const std::string  : EnabledChecks) {
   for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
 if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
Index: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
@@ -218,15 +218,6 @@
 std::vector
 FileOptionsProvider::getRawOptions(StringRef FileName) {
   DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
-  SmallString<256> FilePath(FileName);
-
-  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
-llvm::errs() << "Can't make absolute path from " << FileName << ": "
- << EC.message() << "\n";
-// FIXME: Figure out what to do.
-  } else {
-FileName = FilePath;
-  }
 
   std::vector RawOptions =
   DefaultOptionsProvider::getRawOptions(FileName);
Index: clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
@@ -0,0 +1,5 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/clang-tidy/list-checks/
+// RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
+// RUN: cd %T/clang-tidy/list-checks
+// RUN: clang-tidy -list-checks | grep "^ *google-"


Index: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
@@ -313,13 +313,19 @@
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
-  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
+
+  SmallString<256> FilePath(FileName);
+  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
+llvm::errs() << "Can't make absolute path from " << FileName << ": "
+ << EC.message() << "\n";
+  }
+  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
   if (ExplainConfig) {
 //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
 std::vector
-RawOptions = OptionsProvider->getRawOptions(FileName);
+RawOptions = OptionsProvider->getRawOptions(FilePath);
 for (const std::string  : EnabledChecks) {
   for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
 if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
Index: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
@@ -218,15 +218,6 @@
 std::vector
 FileOptionsProvider::getRawOptions(StringRef FileName) {
   DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
-  SmallString<256> FilePath(FileName);
-
-  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
-llvm::errs() << "Can't make absolute path from " << FileName << ": "
- << EC.message() << "\n";
-// FIXME: Figure out what to 

[clang-tools-extra] r275051 - [clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.

2016-07-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Jul 11 02:47:04 2016
New Revision: 275051

URL: http://llvm.org/viewvc/llvm-project?rev=275051=rev
Log:
[clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.

Summary:
Although there is no guarantee of getOptions/getRawOptions receiving an
absolute path, we try to make it if possible. So FileOptionProvider subclasses
don't have to convert the path to an absolute path.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D22154

Added:
clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp?rev=275051=275050=275051=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Mon Jul 11 02:47:04 
2016
@@ -218,15 +218,6 @@ FileOptionsProvider::FileOptionsProvider
 std::vector
 FileOptionsProvider::getRawOptions(StringRef FileName) {
   DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
-  SmallString<256> FilePath(FileName);
-
-  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
-llvm::errs() << "Can't make absolute path from " << FileName << ": "
- << EC.message() << "\n";
-// FIXME: Figure out what to do.
-  } else {
-FileName = FilePath;
-  }
 
   std::vector RawOptions =
   DefaultOptionsProvider::getRawOptions(FileName);

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=275051=275050=275051=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Mon Jul 11 
02:47:04 2016
@@ -313,13 +313,19 @@ static int clangTidyMain(int argc, const
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
-  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
+
+  SmallString<256> FilePath(FileName);
+  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
+llvm::errs() << "Can't make absolute path from " << FileName << ": "
+ << EC.message() << "\n";
+  }
+  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
   if (ExplainConfig) {
 //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
 std::vector
-RawOptions = OptionsProvider->getRawOptions(FileName);
+RawOptions = OptionsProvider->getRawOptions(FilePath);
 for (const std::string  : EnabledChecks) {
   for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
 if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {

Added: clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp?rev=275051=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp Mon Jul 11 02:47:04 
2016
@@ -0,0 +1,5 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/clang-tidy/list-checks/
+// RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
+// RUN: cd %T/clang-tidy/list-checks
+// RUN: clang-tidy -list-checks | grep "^ *google-"


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


Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-11 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:48
@@ +47,3 @@
+
+  // Assignement slicing: "a = b;" and "a = std::move(b);" variants.
+  const auto SlicesObjectInAssignment =

Looks like you are missing some cases here, like assigning a Subclass object 
from a function call to a Baseclass object, passing a Subclass object to a 
function whose parameter is a BaseClass.

But I think it's fine to implement in a separate patch, but you'd better to add 
a TODO here.

```
SubClass f1();
BaseClass a = f1();

void f1(BaseClass a);
SubClass sc;
f1(sc);
```


Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:84
@@ +83,3 @@
+  diag(Call.getExprLoc(),
+   "slicing object from type %0 to %1 discards override %2")
+  <<  <<  << Method;

There are two diagnostic messages in the code. For subclasses with override 
base class methods and extra member, this will print two messages, which is a 
bit of redundant.


Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:94
@@ +93,3 @@
+CXXRecordDecl *BaseRecord =
+
cast_or_null(BaseRecordType->getDecl()->getDefinition());
+if (!BaseRecord)

The code can be simplified like:

```
if (const auto *BR = 
cast_or_null(BaseRecordType->getDecl()->getDefinition())) {
  DiagnoseSlicedOverriddenMethods(Call, *BR, BaseDecl); 
}
```


Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:112
@@ +111,3 @@
+  // We're looking through all the methods in the derived class and see if they
+  // override some method in the base class.
+  // It's not enough to just test whether the class is polymorphic because we

s/method/methods


http://reviews.llvm.org/D21992



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


Re: [PATCH] D21472: [clang-tidy] readability-identifier-naming - support for other case types

2016-07-11 Thread James Reynolds via cfe-commits
JamesReynolds updated the summary for this revision.
JamesReynolds updated this revision to Diff 63462.
JamesReynolds added a comment.

> You mean Upper_Separated and upper_Separated_Back? ;) Actually, these names 
> are not particularly clear. I've managed to find "Camel_Snake_Case"

>  used for exactly this naming convention (in the 
> https://github.com/t6/camel_snake_kebab library). Maybe "camel_Snake_Back" as 
> well?


Thank you, a very good find! I've changed the patch accordingly.


http://reviews.llvm.org/D21472

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tidy/readability/IdentifierNamingCheck.h
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -59,10 +59,10 @@
 // RUN: {key: readability-identifier-naming.UsingCase, value: lower_case}, \
 // RUN: {key: readability-identifier-naming.ValueTemplateParameterCase, value: camelBack}, \
 // RUN: {key: readability-identifier-naming.VariableCase, value: lower_case}, \
-// RUN: {key: readability-identifier-naming.VirtualMethodCase, value: UPPER_CASE}, \
+// RUN: {key: readability-identifier-naming.VirtualMethodCase, value: Camel_Snake_Case}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \
 // RUN: {key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE}, \
-// RUN: {key: readability-identifier-naming.TypeAliasCase, value: lower_case}, \
+// RUN: {key: readability-identifier-naming.TypeAliasCase, value: camel_Snake_Back}, \
 // RUN: {key: readability-identifier-naming.TypeAliasSuffix, value: '_t'}, \
 // RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
 // RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing \
@@ -261,7 +261,7 @@
 // CHECK-FIXES: {{^}}virtual ~AAbstractClass() = 0;{{$}}
 virtual void VIRTUAL_METHOD();
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for virtual method 'VIRTUAL_METHOD'
-// CHECK-FIXES: {{^}}virtual void v_VIRTUAL_METHOD();{{$}}
+// CHECK-FIXES: {{^}}virtual void v_Virtual_Method();{{$}}
 void non_Virtual_METHOD() {}
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for private method 'non_Virtual_METHOD'
 // CHECK-FIXES: {{^}}void __non_Virtual_METHOD() {}{{$}}
@@ -316,12 +316,12 @@
 
 using my_struct_type = THIS___Structure;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'my_struct_type'
-// CHECK-FIXES: {{^}}using my_struct_type_t = this_structure;{{$}}
+// CHECK-FIXES: {{^}}using my_Struct_Type_t = this_structure;{{$}}
 
 template
 using SomeOtherTemplate = my_other_templated_class  <:: FOO_NS  ::my_class>;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for type alias 'SomeOtherTemplate'
-// CHECK-FIXES: {{^}}using some_other_template_t = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}}
+// CHECK-FIXES: {{^}}using some_Other_Template_t = CMyOtherTemplatedClass  <:: foo_ns  ::CMyClass>;{{$}}
 
 static void static_Function() {
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for function 'static_Function'
Index: clang-tidy/readability/IdentifierNamingCheck.h
===
--- clang-tidy/readability/IdentifierNamingCheck.h
+++ clang-tidy/readability/IdentifierNamingCheck.h
@@ -48,6 +48,8 @@
 CT_CamelBack,
 CT_UpperCase,
 CT_CamelCase,
+CT_CamelSnakeCase,
+CT_CamelSnakeBack
   };
 
   struct NamingStyle {
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -163,6 +163,8 @@
 .Case("UPPER_CASE", CT_UpperCase)
 .Case("camelBack", CT_CamelBack)
 .Case("CamelCase", CT_CamelCase)
+.Case("Camel_Snake_Case", CT_CamelSnakeCase)
+.Case("camel_Snake_Back", CT_CamelSnakeBack)
 .Default(CT_AnyCase);
   };
 
@@ -189,6 +191,10 @@
   return "UPPER_CASE";
 case CT_CamelCase:
   return "CamelCase";
+case CT_CamelSnakeCase:
+  return "Camel_Snake_Case";
+case CT_CamelSnakeBack:
+  return "camel_Snake_Back";
 }
 
 llvm_unreachable("Unknown Case Type");
@@ -230,6 +236,8 @@
   llvm::Regex("^[a-z][a-zA-Z0-9]*$"),
   llvm::Regex("^[A-Z][A-Z0-9_]*$"),
   llvm::Regex("^[A-Z][a-zA-Z0-9]*$"),
+  llvm::Regex("^[A-Z]([a-z0-9]*(_[A-Z])?)*"),
+  llvm::Regex("^[a-z]([a-z0-9]*(_[A-Z])?)*"),
   };
 
   bool Matches = true;
@@ -319,6 +327,27 @@
   }
 }
 break;
+
+  case IdentifierNamingCheck::CT_CamelSnakeCase:
+for (auto const  : Words) {
+  if ( != ())
+Fixup += "_";
+  

Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-11 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 63463.
omtcyf0 added a comment.

Add new test, which ensures clang-rename failure if new name is not passed.


http://reviews.llvm.org/D22091

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/USRLocFinder.cpp
  clang-rename/USRLocFinder.h
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- /dev/null
+++ test/clang-rename/NoNewName.cpp
@@ -0,0 +1,20 @@
+// This test is a copy of ConstCastExpr.cpp with a single change:
+// -new-name hasn't been passed to clang-rename, so this test should give an
+// error.
+// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
+// CHECK: clang-rename: no new name provided.
+
+class Cla {
+public:
+  int getValue() {
+return 0;
+  }
+};
+
+int main() {
+  const Cla *C = new Cla();
+  const_cast(C)->getValue();
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -36,7 +36,6 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Host.h"
-#include 
 #include 
 
 using namespace llvm;
@@ -83,7 +82,7 @@
 #define CLANG_RENAME_VERSION "0.0.1"
 
 static void PrintVersion() {
-  outs() << "clang-rename version " << CLANG_RENAME_VERSION << "\n";
+  outs() << "clang-rename version " << CLANG_RENAME_VERSION << '\n';
 }
 
 using namespace clang;
@@ -101,7 +100,6 @@
 
   if (NewName.empty()) {
 errs() << "clang-rename: no new name provided.\n\n";
-cl::PrintHelpMessage();
 exit(1);
   }
 
@@ -115,12 +113,14 @@
   const auto  = USRAction.getUSRs();
   const auto  = USRAction.getUSRSpelling();
 
-  if (PrevName.empty())
+  if (PrevName.empty()) {
 // An error should have already been printed.
 exit(1);
+  }
 
-  if (PrintName)
-errs() << "clang-rename: found name: " << PrevName << "\n";
+  if (PrintName) {
+errs() << "clang-rename: found name: " << PrevName << '\n';
+  }
 
   // Perform the renaming.
   rename::RenamingAction RenameAction(NewName, PrevName, USRs,
Index: clang-rename/USRLocFinder.h
===
--- clang-rename/USRLocFinder.h
+++ clang-rename/USRLocFinder.h
@@ -29,9 +29,8 @@
 namespace rename {
 
 // FIXME: make this an AST matcher. Wouldn't that be awesome??? I agree!
-std::vector getLocationsOfUSR(llvm::StringRef usr,
-  llvm::StringRef PrevName,
-  Decl *decl);
+std::vector
+getLocationsOfUSR(llvm::StringRef usr, llvm::StringRef PrevName, Decl *decl);
 }
 }
 
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -34,8 +34,8 @@
 class USRLocFindingASTVisitor
 : public clang::RecursiveASTVisitor {
 public:
-  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : USR(USR), PrevName(PrevName) {
-  }
+  explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName)
+  : USR(USR), PrevName(PrevName) {}
 
   // Declaration visitors:
 
@@ -60,8 +60,7 @@
 
   bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
 const ASTContext  = ConstructorDecl->getASTContext();
-for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
-  const clang::CXXCtorInitializer* Initializer = *it;
+for (auto  : ConstructorDecl->inits()) {
   if (Initializer->getSourceOrder() == -1) {
 // Ignore implicit initializers.
 continue;
@@ -71,9 +70,12 @@
 if (getUSRForDecl(FieldDecl) == USR) {
   // The initializer refers to a field that is to be renamed.
   SourceLocation Location = Initializer->getSourceLocation();
-  StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(Location), Context.getSourceManager(), Context.getLangOpts());
+  StringRef TokenName = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(Location),
+  Context.getSourceManager(), Context.getLangOpts());
   if (TokenName == PrevName) {
-// The token of the source location we find actually has the old name.
+// The token of the source location we find actually has the old
+// name.
 LocationsFound.push_back(Initializer->getSourceLocation());
   }
 }
@@ -183,14 +185,15 @@
   bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) {
 clang::QualType Type = Expr->getType();
 // See if this a cast of a pointer.
-const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
+

  1   2   >