Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I think we should entirely drop this implementation of the check and let it 
just check #includes with clang-format. clang-format's implementation isn't a 
strict superset, e.g. won't sort between multiple blocks, but that's 
intentional for now.


https://reviews.llvm.org/D23434



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-08-12 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278483: This patch implements PR#22821. (authored by 
rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D20561?vs=64114&id=67807#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D20561

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp

Index: cfe/trunk/lib/Sema/SemaCast.cpp
===
--- cfe/trunk/lib/Sema/SemaCast.cpp
+++ cfe/trunk/lib/Sema/SemaCast.cpp
@@ -256,6 +256,7 @@
   Op.CheckConstCast();
   if (Op.SrcExpr.isInvalid())
 return ExprError();
+  DiscardMisalignedMemberAddress(DestType.getTypePtr(), E);
 }
 return Op.complete(CXXConstCastExpr::Create(Context, Op.ResultType,
   Op.ValueKind, Op.SrcExpr.get(), DestTInfo,
@@ -279,6 +280,7 @@
   Op.CheckReinterpretCast();
   if (Op.SrcExpr.isInvalid())
 return ExprError();
+  DiscardMisalignedMemberAddress(DestType.getTypePtr(), E);
 }
 return Op.complete(CXXReinterpretCastExpr::Create(Context, Op.ResultType,
 Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
@@ -291,6 +293,7 @@
   Op.CheckStaticCast();
   if (Op.SrcExpr.isInvalid())
 return ExprError();
+  DiscardMisalignedMemberAddress(DestType.getTypePtr(), E);
 }
 
 return Op.complete(CXXStaticCastExpr::Create(Context, Op.ResultType,
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -6022,7 +6022,9 @@
   CheckTollFreeBridgeCast(castType, CastExpr);
   
   CheckObjCBridgeRelatedCast(castType, CastExpr);
-  
+
+  DiscardMisalignedMemberAddress(castType.getTypePtr(), CastExpr);
+
   return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
 }
 
@@ -10614,6 +10616,8 @@
   if (op->getType()->isObjCObjectType())
 return Context.getObjCObjectPointerType(op->getType());
 
+  CheckAddressOfPackedMember(op);
+
   return Context.getPointerType(op->getType());
 }
 
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8383,6 +8383,8 @@
 
   DiagnoseNullConversion(S, E, T, CC);
 
+  S.DiscardMisalignedMemberAddress(Target, E);
+
   if (!Source->isIntegerType() || !Target->isIntegerType())
 return;
 
@@ -9453,6 +9455,7 @@
 CheckUnsequencedOperations(E);
   if (!IsConstexpr && !E->isValueDependent())
 CheckForIntOverflow(E);
+  DiagnoseMisalignedMembers();
 }
 
 void Sema::CheckBitFieldInitialization(SourceLocation InitLoc,
@@ -10998,3 +11001,67 @@
 << ArgumentExpr->getSourceRange()
 << TypeTagExpr->getSourceRange();
 }
+
+void Sema::AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment) {
+  MisalignedMembers.emplace_back(E, RD, MD, Alignment);
+}
+
+void Sema::DiagnoseMisalignedMembers() {
+  for (MisalignedMember &m : MisalignedMembers) {
+Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
+<< m.MD << m.RD << m.E->getSourceRange();
+  }
+  MisalignedMembers.clear();
+}
+
+void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
+  if (!T->isPointerType())
+return;
+  if (isa(E) &&
+  cast(E)->getOpcode() == UO_AddrOf) {
+auto *Op = cast(E)->getSubExpr()->IgnoreParens();
+if (isa(Op)) {
+  auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
+  MisalignedMember(Op));
+  if (MA != MisalignedMembers.end() &&
+  Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)
+MisalignedMembers.erase(MA);
+}
+  }
+}
+
+void Sema::RefersToMemberWithReducedAlignment(
+Expr *E,
+std::function Action) {
+  const auto *ME = dyn_cast(E);
+  while (ME && isa(ME->getMemberDecl())) {
+QualType BaseType = ME->getBase()->getType();
+if (ME->isArrow())
+  BaseType = BaseType->getPointeeType();
+RecordDecl *RD = BaseType->getAs()->getDecl();
+
+ValueDecl *MD = ME->getMemberDecl();
+bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
+if (ByteAligned) // Attribute packed does not have any effect.
+  break;
+
+if (!ByteAligned &&
+(RD->hasAttr() || (MD->hasAttr( {
+  CharUnits Alignment = std::min(Context.getTypeAlignInChars(MD->getType()),
+ Context.getTypeAlignInChars(BaseType));
+  // Notify that this expression designates a member with reduced alignment
+  Action(E, RD, MD, Alignment);
+  b

r278483 - This patch implements PR#22821.

2016-08-12 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Fri Aug 12 03:04:13 2016
New Revision: 278483

URL: http://llvm.org/viewvc/llvm-project?rev=278483&view=rev
Log:
This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
will silence the warning.

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



Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=278483&r1=278482&r2=278483&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 12 03:04:13 
2016
@@ -5489,6 +5489,9 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
+def warn_taking_address_of_packed_member : Warning<
+  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
+  InGroup>;
 
 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=278483&r1=278482&r2=278483&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Aug 12 03:04:13 2016
@@ -9570,6 +9570,10 @@ private:
   void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
 const Expr * const *ExprArgs);
 
+  /// \brief Check if we are taking the address of a packed field
+  /// as this may be a problem if the pointer value is dereferenced.
+  void CheckAddressOfPackedMember(Expr *rhs);
+
   /// \brief The parser's current scope.
   ///
   /// The parser maintains this state here.
@@ -9664,6 +9668,51 @@ public:
   // Emitting members of dllexported classes is delayed until the class
   // (including field initializers) is fully parsed.
   SmallVector DelayedDllExportClasses;
+
+private:
+  /// \brief Helper class that collects misaligned member designations and
+  /// their location info for delayed diagnostics.
+  struct MisalignedMember {
+Expr *E;
+RecordDecl *RD;
+ValueDecl *MD;
+CharUnits Alignment;
+
+MisalignedMember() : E(), RD(), MD(), Alignment() {}
+MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment)
+: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
+explicit MisalignedMember(Expr *E)
+: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
+
+bool operator==(const MisalignedMember &m) { return this->E == m.E; }
+  };
+  /// \brief Small set of gathered accesses to potentially misaligned members
+  /// due to the packed attribute.
+  SmallVector MisalignedMembers;
+
+  /// \brief Adds an expression to the set of gathered misaligned members.
+  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment);
+
+public:
+  /// \brief Diagnoses the current set of gathered accesses. This typically
+  /// happens at full expression level. The set is cleared after emitting the
+  /// diagnostics.
+  void DiagnoseMisalignedMembers();
+
+  /// \brief This function checks if the expression is in the sef of 
potentially
+  /// misaligned members and it is converted to some pointer type T with lower
+  /// or equal alignment requirements.  If so it removes it. This is used when
+  /// we do not want to diagnose such misaligned access (e.g. in conversions 
to void*).
+  void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
+
+  /// \brief This function calls Action when it determines that E designates a
+  /// misaligned member due to the packed attribute. This is used to emit
+  /// local diagnostics like in reference binding.
+  void RefersToMemberWithReducedAlignment(
+  Expr *E,
+  std::function 
Action);
 };
 
 /// \brief RAII object that en

Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-08-12 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a reviewer: Hahnfeld.
Hahnfeld added a comment.
This revision is now accepted and ready to land.

LGTM with only some minor nits on some of the comments and a CMake question



Comment at: test/CMakeLists.txt:27-33
@@ -26,8 +26,9 @@
 
 list(APPEND CLANG_TEST_DEPS
   clang clang-headers
   clang-format
   c-index-test diagtool
   clang-tblgen
+  clang-offload-bundler
   )
   

I think `clang-offload-bundler` needs to be added as dependency for the `clang` 
target because it will really need the bundler at runtime, not only when 
testing...

(Disclaimer: I'm no CMake expert)


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:102-104
@@ +101,5 @@
+  virtual void ReadHeader(MemoryBuffer &Input) = 0;
+  /// Read the marker of the next bundled to be read in the file. The triple of
+  /// the target associated with that bundled is returned. An empty string is
+  /// returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0;

s/bundled/bundle/?


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:151
@@ +150,3 @@
+
+/// Read 8-byte integers to/from a buffer in little-endian format.
+static uint64_t Read8byteIntegerFromBuffer(StringRef Buffer, size_t pos) {

`to/from`?


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:164
@@ +163,3 @@
+
+/// Write and write 8-byte integers to/from a buffer in little-endian format.
+static void Write8byteIntegerToBuffer(raw_fd_ostream &OS, uint64_t Val) {

Duplicate `and write`? `to/from`?


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:568
@@ +567,3 @@
+  if (!FoundHostBundle) {
+llvm::errs() << "error: Can't find bundles for all requested targets\n";
+return true;

Better say that we haven't found the bundle for the host?


https://reviews.llvm.org/D13909



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


Re: r278140 - [CUDA] Regression test to make sure C++ include path are forwarded to host and device frontends.

2016-08-12 Thread Ismail Donmez via cfe-commits
Hi,

On Tue, Aug 9, 2016 at 8:27 PM, Samuel Antao via cfe-commits
 wrote:
> Author: sfantao
> Date: Tue Aug  9 12:27:24 2016
> New Revision: 278140
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278140&view=rev
> Log:
> [CUDA] Regression test to make sure C++ include path are forwarded to host 
> and device frontends.
>
> Summary: Add test to detect the C++ include paths are passed to both CUDA 
> host and device frontends.
>
> Reviewers: tra
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D22946
>
> Modified:
> cfe/trunk/test/Driver/cuda-detect.cu
>
> Modified: cfe/trunk/test/Driver/cuda-detect.cu
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=278140&r1=278139&r2=278140&view=diff
> ==
> --- cfe/trunk/test/Driver/cuda-detect.cu (original)
> +++ cfe/trunk/test/Driver/cuda-detect.cu Tue Aug  9 12:27:24 2016
> @@ -72,6 +72,11 @@
>  // RUN:   | FileCheck %s -check-prefix COMMON \
>  // RUN: -check-prefix NOCUDAINC -check-prefix NOLIBDEVICE
>
> +// Verify that C++ include paths are passed for both host and device 
> frontends.
> +// RUN: %clang -### -target x86_64-linux-gnu %s \
> +// RUN: --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 2>&1 \
> +// RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE
> +
>  // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
>  // NOCUDA-NOT: Found CUDA installation:
>
> @@ -92,3 +97,8 @@
>  // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
>  // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
>  // COMMON-SAME: "-x" "cuda"
> +// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
> +// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
> +// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "x86_64--linux-gnu"
> +// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
> +// CHECK-CXXINCLUDE: ld{{.*}}"

This needs -stdlib=libstdc++ otherwise it fails on hosts defaulting to libc++.

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


r278487 - [C++1z] Fix crash when decomposing structs with anonymous members.

2016-08-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Aug 12 04:19:34 2016
New Revision: 278487

URL: http://llvm.org/viewvc/llvm-project?rev=278487&view=rev
Log:
[C++1z] Fix crash when decomposing structs with anonymous members.

The diagnostic format was invalid.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=278487&r1=278486&r2=278487&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 12 04:19:34 
2016
@@ -405,8 +405,8 @@ def err_decomp_decl_non_public_base : Er
 def err_decomp_decl_non_public_member : Error<
   "cannot decompose non-public member %0 of %1">;
 def err_decomp_decl_anon_union_member : Error<
-  "cannot decompose class type %1 because it has an anonymous "
-  "%select{struct|union} member">;
+  "cannot decompose class type %0 because it has an anonymous "
+  "%select{struct|union}1 member">;
 def err_decomp_decl_std_tuple_element_not_specialized : Error<
   "cannot decompose this type; 'std::tuple_element<%0>::type' "
   "does not name a type">;

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp?rev=278487&r1=278486&r2=278487&view=diff
==
--- cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp Fri Aug 12 04:19:34 2016
@@ -32,6 +32,25 @@ namespace NonPublicMembers {
   }
 }
 
+namespace AnonymousMember {
+  struct Struct {
+struct { // expected-note {{declared here}}
+  int i;
+};
+  };
+
+  struct Union {
+union { // expected-note {{declared here}}
+  int i;
+};
+  };
+
+  void test() {
+auto [a1] = Struct(); // expected-error {{cannot decompose class type 
'AnonymousMember::Struct' because it has an anonymous struct member}}
+auto [a2] = Union(); // expected-error {{cannot decompose class type 
'AnonymousMember::Union' because it has an anonymous union member}}
+  }
+}
+
 namespace MultipleClasses {
   struct B : A {
 int a;


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


Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-08-12 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a reviewer: Hahnfeld.
Hahnfeld added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:432
@@ +431,3 @@
+
+return;
+  }

Unnecessary `return`, please remove as Alexey requested on the other patch


https://reviews.llvm.org/D21851



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


r278488 - Prune unused diagnostics. NFC.

2016-08-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Aug 12 04:23:14 2016
New Revision: 278488

URL: http://llvm.org/viewvc/llvm-project?rev=278488&view=rev
Log:
Prune unused diagnostics. NFC.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=278488&r1=278487&r2=278488&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Aug 12 04:23:14 
2016
@@ -828,8 +828,6 @@ def warn_availability_and_unavailable :
   InGroup;
 
 // @available(...)
-def err_avail_query_expected_condition : Error<
-  "expected an availability condition here">;
 def err_avail_query_expected_platform_name : Error<
   "expected a platform name here">;
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=278488&r1=278487&r2=278488&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 12 04:23:14 
2016
@@ -4316,8 +4316,6 @@ def note_availability_specified_here : N
   "%select{unavailable|deleted|deprecated|partial}1 here">;
 def note_implicitly_deleted : Note<
   "explicitly defaulted function was implicitly deleted here">;
-def note_inherited_deleted_here : Note<
-  "deleted constructor was inherited here">;
 def warn_not_enough_argument : Warning<
   "not enough variable arguments in %0 declaration to fit a sentinel">,
   InGroup;


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


Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-12 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment.

In https://reviews.llvm.org/D22666#513465, @compnerd wrote:

> No, the inserted character is a literal SOH, not the string "\01".


I don't know why the string is passed in a different way but '\01' is shown in 
IR previously as below

  $ clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o - 
test-mcount.c
...
  define i32 @f() #0 {
call void @"\01__gnu_mcount_nc"() #1
ret i32 0
  }
...

But it doesn't show '\01' in IR with this modifiction.

  $ clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o - 
test-mcount.c
...
  attributes #0 = { nounwind "counting-function"="__gnu_mcount_nc" ... }
...

The expected result is as follows. '\01' is clearly shown in IR.

  $ clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o - 
test-mcount.c
...
  attributes #0 = { nounwind "counting-function"="\01__gnu_mcount_nc" ... }
...

Since I couldn't find why string passing is handled in a different way with 
previous version, I just put double backslash in "\\01__gnu_mcount_nc" because 
it generates the expected IR output. I know that we should have clear reason 
for this.
Do you have any idea why this problem happens?


https://reviews.llvm.org/D22666



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


Re: [PATCH] D23427: [Clang-tidy] Comparison Misuse

2016-08-12 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/misc/ComparisonMisuseCheck.cpp:31
@@ +30,3 @@
+  unless(anyOf(hasOperatorName("=="), hasOperatorName("!="))),
+  hasEitherOperand(ignoringImpCasts(gnuNullExpr(
+  .bind("compareToNull"),

We should use `nullPointerConstant()` here to cover more null cases.


Comment at: clang-tidy/misc/ComparisonMisuseCheck.cpp:39
@@ +38,3 @@
+  Result.Nodes.getNodeAs("charToLiteral");
+  if (CharToLiteral)
+diag(CharToLiteral->getOperatorLoc(),

The code can be simplified as follows:

```
if (const auto * a = Result.Nodes.getNodeAs("charToLiteral")) {
  ...
} else if (const auto *CompareToNull =
  Result.Nodes.getNodeAs("compareToNull")) {
  ...
}
```


Comment at: clang-tidy/misc/ComparisonMisuseCheck.cpp:41
@@ +40,3 @@
+diag(CharToLiteral->getOperatorLoc(),
+ "char* is compared to a string literal");
+

I'm wondering if we can automatically fix this case. Use `strcmp()` function is 
sufficient to fix it, IMO?


Comment at: clang-tidy/misc/ComparisonMisuseCheck.cpp:52
@@ +51,2 @@
+} // namespace clang
+

an extra blank line.


Comment at: clang-tidy/misc/ComparisonMisuseCheck.h:20
@@ +19,3 @@
+/// This checker reports errors related to the misuse of the comparison 
operator.
+/// It should warn for the following cases:
+///   - strcmp,strncmp,memcmp misuse.

s/should warn/warns


Comment at: clang-tidy/misc/ComparisonMisuseCheck.h:21
@@ +20,3 @@
+/// It should warn for the following cases:
+///   - strcmp,strncmp,memcmp misuse.
+///   - char* is compared to a string literal

Eugene.Zelenko wrote:
> Spaces after commas,
Seems like your check doesn't warn any usage about the strcmp family functions.


Comment at: docs/clang-tidy/checks/misc-comparison-misuse.rst:3
@@ +2,3 @@
+
+misc-comparison-misuse
+==

Please also update `docs/ReleaseNotes.rst`.


Comment at: docs/clang-tidy/checks/misc-comparison-misuse.rst:10
@@ +9,3 @@
+Case 1:
+  ``char*`` is compared to a string literal.
+

Does the case cover `char[]` ?


Comment at: test/clang-tidy/misc-comparison-misuse.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s misc-comparison-misuse %t
+

Also clang-format this example.


Comment at: test/clang-tidy/misc-comparison-misuse.cpp:13
@@ +12,3 @@
+void test_null_to_pointer(int *p){
+  if (NULL>=p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: comparison to nullptr 
[misc-comparison-misuse]

Add `if (p <= NULL);` test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D23427



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


Re: [PATCH] D23421: [Clang-tidy] CERT-MSC53-CPP (checker for std namespace modification)

2016-08-12 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/cert/DontModifyStdNamespaceCheck.cpp:20
@@ +19,3 @@
+
+void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(namespaceDecl(unless(isExpansionInSystemHeader()),

This check should be only available in cpp code. 

```
  if (!getLangOpts().CPlusPlus)
return;
```




Comment at: docs/clang-tidy/checks/cert-msc53-cpp.rst:4
@@ +3,3 @@
+cert-msc53-cpp
+==
+

`===` should be the same with `cert-msc53-cpp`.


Comment at: docs/clang-tidy/checks/cert-msc53-cpp.rst:6
@@ +5,2 @@
+
+Modification of the std or posix namespace can result to undefined behavior. 
This checker warns for such modifications.

Eugene.Zelenko wrote:
> Please highlight std and posix with ``.
Adding an example explaining the check would make the doc more clear. An 
example is worth a thousand words :)


Comment at: test/clang-tidy/cert-dont-modify-std-namespace.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s cert-msc53-cpp %t -- -- -std=c++1z
+

Do we need `c++1z` flag here?


Repository:
  rL LLVM

https://reviews.llvm.org/D23421



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


Re: [PATCH] D23421: [Clang-tidy] CERT-MSC53-CPP (checker for std namespace modification)

2016-08-12 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: test/clang-tidy/cert-dont-modify-std-namespace.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s cert-msc53-cpp %t -- -- -std=c++1z
+

hokein wrote:
> Do we need `c++1z` flag here?
I think it is there for the following code snippet:

```
namespace posix::a {
```




Repository:
  rL LLVM

https://reviews.llvm.org/D23421



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


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-08-12 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 67817.
danielmarjamaki added a comment.

fixed review comments


https://reviews.llvm.org/D13126

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  test/Analysis/conversion.c

Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -Wno-conversion -analyze -analyzer-checker=core,alpha.core.Conversion -verify %s
+
+unsigned char U8;
+signed char S8;
+
+void assign(unsigned U, signed S) {
+  if (S < -10)
+U8 = S; // expected-warning {{Loss of sign in implicit conversion}}
+  if (U > 300)
+S8 = U; // expected-warning {{Loss of precision in implicit conversion}}
+  if (S > 10)
+U8 = S;
+  if (U < 200)
+S8 = U;
+}
+
+void init1() {
+  long long A = 1LL << 60;
+  short X = A; // expected-warning {{Loss of precision in implicit conversion}}
+}
+
+void relational(unsigned U, signed S) {
+  if (S > 10) {
+if (U < S) {
+}
+  }
+  if (S < -10) {
+if (U < S) { // expected-warning {{Loss of sign in implicit conversion}}
+}
+  }
+}
+
+void multiplication(unsigned U, signed S) {
+  if (S > 5)
+S = U * S;
+  if (S < -10)
+S = U * S; // expected-warning {{Loss of sign}}
+}
+
+void division(unsigned U, signed S) {
+  if (S > 5)
+S = U / S;
+  if (S < -10)
+S = U / S; // expected-warning {{Loss of sign}}
+}
+
+void dontwarn1(unsigned U, signed S) {
+  U8 = S; // It might be known that S is always 0x00-0xff.
+  S8 = U; // It might be known that U is always 0x00-0xff.
+
+  U8 = -1;  // Explicit conversion.
+  S8 = ~0U; // Explicit conversion.
+  if (U > 300)
+U8 &= U; // No loss of precision since there is &=.
+}
+
+void dontwarn2(unsigned int U) {
+  if (U <= 4294967295) {
+  }
+  if (U <= (2147483647 * 2U + 1U)) {
+  }
+}
+
+void dontwarn3(int X) {
+  S8 = X ? 'a' : 'b';
+}
+
+// don't warn for macros
+#define DOSTUFF ({ unsigned X = 1000; U8 = X; })
+void dontwarn4() {
+  DOSTUFF;
+}
+
+// don't warn for calculations
+// seen some fp. For instance:  c2 = (c2 >= 'A' && c2 <= 'Z') ? c2 - 'A' + 'a' : c2;
+// there is a todo in the checker to handle calculations
+void dontwarn5() {
+  signed S = -32;
+  U8 = S + 10;
+}
+
+
+// false positives..
+
+int isascii(int c);
+void falsePositive1() {
+  char kb2[5];
+  int X = 1000;
+  if (isascii(X)) {
+// FIXME: should not warn here:
+kb2[0] = X; // expected-warning {{Loss of precision}}
+  }
+}
+
+
+typedef struct FILE {} FILE; int getc(FILE *stream);
+# define EOF (-1)
+char reply_string[8192];
+FILE *cin;
+extern int dostuff (void);
+int falsePositive2() {
+  int c, n;
+  int dig;
+  char *cp = reply_string;
+  int pflag = 0;
+  int code;
+
+  for (;;) {
+dig = n = code = 0;
+while ((c = getc(cin)) != '\n') {
+  if (dig < 4 && dostuff())
+code = code * 10 + (c - '0');
+  if (!pflag && code == 227)
+pflag = 1;
+  if (n == 0)
+n = c;
+  if (c == EOF)
+return(4);
+  if (cp < &reply_string[sizeof(reply_string) - 1])
+// FIXME: should not warn here:
+*cp++ = c; // expected-warning {{Loss of precision}}
+}
+  }
+}
+
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -0,0 +1,192 @@
+//=== ConversionChecker.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Check that there is no loss of sign/precision in assignments, comparisons
+// and multiplications.
+//
+// ConversionChecker uses path sensitive analysis to determine possible values
+// of expressions. A warning is reported when:
+// * a negative value is implicitly converted to an unsigned value in an
+//   assignment, comparison or multiplication.
+// * assignment / initialization when source value is greater than the max
+//   value of target
+//
+// Many compilers and tools have similar checks that are based on semantic
+// analysis. Those checks are sound but have poor precision. ConversionChecker
+// is an alternative to those checks.
+//
+//===--===//
+#include "ClangSACheckers.h"
+#include "clang/AST/ParentMap.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using

Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-08-12 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked 3 inline comments as done.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:67
@@ +66,3 @@
+  const Stmt *Parent = PM.getParent(Cast);
+  if (!Parent)
+return;

I get assertion failure then when running this test:  
Analysis/misc-ps-region-store.cpp

Command that fails:

/home/danielm/llvm/build/./bin/clang -cc1 -internal-isystem 
/home/danielm/llvm/build/bin/../lib/clang/4.0.0/include -nostdsysteminc -triple 
i386-apple-darwin9 -analyze 
-analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region 
-verify -fblocks -analyzer-opt-analyze-nested-blocks 
/home/danielm/llvm/tools/clang/test/Analysis/misc-ps-region-store.cpp 
-fexceptions -fcxx-exceptions -Wno-tautological-undefined-compare



https://reviews.llvm.org/D13126



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


r278497 - Fix cuda-detect.cu when CLANG_DEFAULT_CXX_STDLIB is set

2016-08-12 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Fri Aug 12 05:36:04 2016
New Revision: 278497

URL: http://llvm.org/viewvc/llvm-project?rev=278497&view=rev
Log:
Fix cuda-detect.cu when CLANG_DEFAULT_CXX_STDLIB is set

Reported by Ismail Donmez!

Modified:
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/test/Driver/cuda-detect.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=278497&r1=278496&r2=278497&view=diff
==
--- cfe/trunk/test/Driver/cuda-detect.cu (original)
+++ cfe/trunk/test/Driver/cuda-detect.cu Fri Aug 12 05:36:04 2016
@@ -74,7 +74,7 @@
 
 // Verify that C++ include paths are passed for both host and device frontends.
 // RUN: %clang -### -no-canonical-prefixes -target x86_64-linux-gnu %s \
-// RUN: --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 2>&1 \
+// RUN: --stdlib=libstdc++ --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 
2>&1 \
 // RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE
 
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda


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


RE: r278140 - [CUDA] Regression test to make sure C++ include path are forwarded to host and device frontends.

2016-08-12 Thread Hahnfeld, Jonas via cfe-commits
Hi,

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Ismail Donmez via cfe-commits
> Sent: Friday, August 12, 2016 11:05 AM
> To: Samuel Antao
> Cc: cfe-commits
> Subject: Re: r278140 - [CUDA] Regression test to make sure C++ include path
> are forwarded to host and device frontends.
>
> Hi,
>
> On Tue, Aug 9, 2016 at 8:27 PM, Samuel Antao via cfe-commits  comm...@lists.llvm.org> wrote:
> > Author: sfantao
> > Date: Tue Aug  9 12:27:24 2016
> > New Revision: 278140
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=278140&view=rev
> > Log:
> > [CUDA] Regression test to make sure C++ include path are forwarded to
> host and device frontends.
> >
> > Summary: Add test to detect the C++ include paths are passed to both
> CUDA host and device frontends.
> >
> > Reviewers: tra
> >
> > Subscribers: cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D22946
> >
> > Modified:
> > cfe/trunk/test/Driver/cuda-detect.cu
> >
> > Modified: cfe/trunk/test/Driver/cuda-detect.cu
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.
> > cu?rev=278140&r1=278139&r2=278140&view=diff
> >
> ==
> 
> > 
> > --- cfe/trunk/test/Driver/cuda-detect.cu (original)
> > +++ cfe/trunk/test/Driver/cuda-detect.cu Tue Aug  9 12:27:24 2016
> > @@ -72,6 +72,11 @@
> >  // RUN:   | FileCheck %s -check-prefix COMMON \
> >  // RUN: -check-prefix NOCUDAINC -check-prefix NOLIBDEVICE
> >
> > +// Verify that C++ include paths are passed for both host and device
> frontends.
> > +// RUN: %clang -### -target x86_64-linux-gnu %s \ // RUN:
> > +--sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 2>&1 \ // RUN: |
> > +FileCheck %s --check-prefix CHECK-CXXINCLUDE
> > +
> >  // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
> > // NOCUDA-NOT: Found CUDA installation:
> >
> > @@ -92,3 +97,8 @@
> >  // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
> >  // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
> >  // COMMON-SAME: "-x" "cuda"
> > +// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
> > +// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem"
> "{{.+}}/include/c++/4.8"
> > +// CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "x86_64--linux-gnu"
> > +// CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem"
> "{{.+}}/include/c++/4.8"
> > +// CHECK-CXXINCLUDE: ld{{.*}}"
>
> This needs -stdlib=libstdc++ otherwise it fails on hosts defaulting to 
> libc++.
>
> ismail
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Right, I also noticed that but forgot to commit the fix.
Should work with r278497.

Thanks,
Jonas


smime.p7s
Description: S/MIME cryptographic signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23423: [Clang-tidy] Comparison Function Address

2016-08-12 Thread Haojian Wu via cfe-commits
hokein added a comment.

> This check looks like specific case of https://reviews.llvm.org/D23427. May 
> be they should be merged?


+1, I think this check can be merged there.



Comment at: test/clang-tidy/misc-comparison-function-address.cpp:20
@@ +19,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Address of function is compared 
[misc-comparison-function-address]
+  
+  if (0 == getc);

How about the case `if (getc == func)`?


Repository:
  rL LLVM

https://reviews.llvm.org/D23423



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


r278501 - Fix For pr28288 - Error message in shift of vector values

2016-08-12 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Aug 12 06:22:12 2016
New Revision: 278501

URL: http://llvm.org/viewvc/llvm-project?rev=278501&view=rev
Log:
Fix For pr28288 - Error message in shift of vector values

This fixes an error in type checking of shift of vector values.

Patch by Vladimir Yakovlev.

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/shift.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=278501&r1=278500&r2=278501&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Aug 12 06:22:12 2016
@@ -8684,11 +8684,10 @@ static void DiagnoseBadShiftValues(Sema&
 << RHS.get()->getSourceRange();
 }
 
-/// \brief Return the resulting type when an OpenCL vector is shifted
+/// \brief Return the resulting type when a vector is shifted
 ///by a scalar or vector shift amount.
-static QualType checkOpenCLVectorShift(Sema &S,
-   ExprResult &LHS, ExprResult &RHS,
-   SourceLocation Loc, bool IsCompAssign) {
+static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
+ SourceLocation Loc, bool IsCompAssign) {
   // OpenCL v1.1 s6.3.j says RHS can be a vector only if LHS is a vector.
   if (!LHS.get()->getType()->isVectorType()) {
 S.Diag(Loc, diag::err_shift_rhs_only_vector)
@@ -8756,11 +8755,9 @@ QualType Sema::CheckShiftOperands(ExprRe
   // Vector shifts promote their scalar inputs to vector type.
   if (LHS.get()->getType()->isVectorType() ||
   RHS.get()->getType()->isVectorType()) {
-if (LangOpts.OpenCL)
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 if (LangOpts.ZVector) {
   // The shift operators for the z vector extensions work basically
-  // like OpenCL shifts, except that neither the LHS nor the RHS is
+  // like general shifts, except that neither the LHS nor the RHS is
   // allowed to be a "vector bool".
   if (auto LHSVecType = LHS.get()->getType()->getAs())
 if (LHSVecType->getVectorKind() == VectorType::AltiVecBool)
@@ -8768,11 +8765,8 @@ QualType Sema::CheckShiftOperands(ExprRe
   if (auto RHSVecType = RHS.get()->getType()->getAs())
 if (RHSVecType->getVectorKind() == VectorType::AltiVecBool)
   return InvalidOperands(Loc, LHS, RHS);
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 }
-return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
-   /*AllowBothBool*/true,
-   /*AllowBoolConversions*/false);
+return checkVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
   }
 
   // Shifts don't perform usual arithmetic conversions, they just do integer

Modified: cfe/trunk/test/Sema/shift.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/shift.c?rev=278501&r1=278500&r2=278501&view=diff
==
--- cfe/trunk/test/Sema/shift.c (original)
+++ cfe/trunk/test/Sema/shift.c Fri Aug 12 06:22:12 2016
@@ -67,3 +67,14 @@ void test_shift_too_much(char x) {
 (void) (x >> 80); // no-warning
   (void) (x >> 80); // expected-warning {{shift count >= width of type}}
 }
+
+typedef unsigned vec16 __attribute__((vector_size(16)));
+typedef unsigned vec8 __attribute__((vector_size(8)));
+
+void vect_shift_1(vec16 *x) { *x = *x << 4; }
+
+void vect_shift_2(vec16 *x, vec16 y) { *x = *x << y; }
+
+void vect_shift_3(vec16 *x, vec8 y) {
+  *x = *x << y; // expected-error {{vector operands do not have the same 
number of elements}}
+}


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


Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of vector values

2016-08-12 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278501: Fix For pr28288 - Error message in shift of vector 
values (authored by asbokhan).

Changed prior to commit:
  https://reviews.llvm.org/D21678?vs=67140&id=67820#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21678

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Sema/shift.c

Index: cfe/trunk/test/Sema/shift.c
===
--- cfe/trunk/test/Sema/shift.c
+++ cfe/trunk/test/Sema/shift.c
@@ -67,3 +67,14 @@
 (void) (x >> 80); // no-warning
   (void) (x >> 80); // expected-warning {{shift count >= width of type}}
 }
+
+typedef unsigned vec16 __attribute__((vector_size(16)));
+typedef unsigned vec8 __attribute__((vector_size(8)));
+
+void vect_shift_1(vec16 *x) { *x = *x << 4; }
+
+void vect_shift_2(vec16 *x, vec16 y) { *x = *x << y; }
+
+void vect_shift_3(vec16 *x, vec8 y) {
+  *x = *x << y; // expected-error {{vector operands do not have the same 
number of elements}}
+}
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -8684,11 +8684,10 @@
 << RHS.get()->getSourceRange();
 }
 
-/// \brief Return the resulting type when an OpenCL vector is shifted
+/// \brief Return the resulting type when a vector is shifted
 ///by a scalar or vector shift amount.
-static QualType checkOpenCLVectorShift(Sema &S,
-   ExprResult &LHS, ExprResult &RHS,
-   SourceLocation Loc, bool IsCompAssign) {
+static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
+ SourceLocation Loc, bool IsCompAssign) {
   // OpenCL v1.1 s6.3.j says RHS can be a vector only if LHS is a vector.
   if (!LHS.get()->getType()->isVectorType()) {
 S.Diag(Loc, diag::err_shift_rhs_only_vector)
@@ -8756,23 +8755,18 @@
   // Vector shifts promote their scalar inputs to vector type.
   if (LHS.get()->getType()->isVectorType() ||
   RHS.get()->getType()->isVectorType()) {
-if (LangOpts.OpenCL)
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 if (LangOpts.ZVector) {
   // The shift operators for the z vector extensions work basically
-  // like OpenCL shifts, except that neither the LHS nor the RHS is
+  // like general shifts, except that neither the LHS nor the RHS is
   // allowed to be a "vector bool".
   if (auto LHSVecType = LHS.get()->getType()->getAs())
 if (LHSVecType->getVectorKind() == VectorType::AltiVecBool)
   return InvalidOperands(Loc, LHS, RHS);
   if (auto RHSVecType = RHS.get()->getType()->getAs())
 if (RHSVecType->getVectorKind() == VectorType::AltiVecBool)
   return InvalidOperands(Loc, LHS, RHS);
-  return checkOpenCLVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
 }
-return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
-   /*AllowBothBool*/true,
-   /*AllowBoolConversions*/false);
+return checkVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
   }
 
   // Shifts don't perform usual arithmetic conversions, they just do integer


Index: cfe/trunk/test/Sema/shift.c
===
--- cfe/trunk/test/Sema/shift.c
+++ cfe/trunk/test/Sema/shift.c
@@ -67,3 +67,14 @@
 (void) (x >> 80); // no-warning
   (void) (x >> 80); // expected-warning {{shift count >= width of type}}
 }
+
+typedef unsigned vec16 __attribute__((vector_size(16)));
+typedef unsigned vec8 __attribute__((vector_size(8)));
+
+void vect_shift_1(vec16 *x) { *x = *x << 4; }
+
+void vect_shift_2(vec16 *x, vec16 y) { *x = *x << y; }
+
+void vect_shift_3(vec16 *x, vec8 y) {
+  *x = *x << y; // expected-error {{vector operands do not have the same number of elements}}
+}
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -8684,11 +8684,10 @@
 << RHS.get()->getSourceRange();
 }
 
-/// \brief Return the resulting type when an OpenCL vector is shifted
+/// \brief Return the resulting type when a vector is shifted
 ///by a scalar or vector shift amount.
-static QualType checkOpenCLVectorShift(Sema &S,
-   ExprResult &LHS, ExprResult &RHS,
-   SourceLocation Loc, bool IsCompAssign) {
+static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
+ SourceLocation Loc, bool IsCompAssign) {
   // OpenCL v1.1 s6.3.j says RHS can be a vector only if LHS is a vector.
   if (!LHS.get()->getType()->isVectorType()) {
 S.Diag(Loc, diag::err_shift_rhs_only_vector)
@@ -8756,23 +8755,18 @@

Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Zachary Turner via cfe-commits
Neither does clang-tidy's right?

Incidentally that's exactly what i was trying to add support for. Lldb has
a mass reformat coming up, and as part of that we are defining an include
ordering. But at the moment it won't do this, so we will be left fixing
this by hand or not fixing it at all


On Fri, Aug 12, 2016 at 12:36 AM Daniel Jasper  wrote:

> djasper added a comment.
>
> I think we should entirely drop this implementation of the check and let
> it just check #includes with clang-format. clang-format's implementation
> isn't a strict superset, e.g. won't sort between multiple blocks, but
> that's intentional for now.
>
>
> https://reviews.llvm.org/D23434
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278503 - Fix Wdocumentation unknown parameter warning

2016-08-12 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Aug 12 06:43:57 2016
New Revision: 278503

URL: http://llvm.org/viewvc/llvm-project?rev=278503&view=rev
Log:
Fix Wdocumentation unknown parameter warning

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=278503&r1=278502&r2=278503&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Aug 12 06:43:57 2016
@@ -863,12 +863,12 @@ static bool hasInconsistentOrSupersetQua
 
   if (ParamQs == ArgQs)
 return false;
-   
+
   // Mismatched (but not missing) Objective-C GC attributes.
-  if (ParamQs.getObjCGCAttr() != ArgQs.getObjCGCAttr() && 
+  if (ParamQs.getObjCGCAttr() != ArgQs.getObjCGCAttr() &&
   ParamQs.hasObjCGCAttr())
 return true;
-  
+
   // Mismatched (but not missing) address spaces.
   if (ParamQs.getAddressSpace() != ArgQs.getAddressSpace() &&
   ParamQs.hasAddressSpace())
@@ -878,7 +878,7 @@ static bool hasInconsistentOrSupersetQua
   if (ParamQs.getObjCLifetime() != ArgQs.getObjCLifetime() &&
   ParamQs.hasObjCLifetime())
 return true;
-  
+
   // CVR qualifier superset.
   return (ParamQs.getCVRQualifiers() != ArgQs.getCVRQualifiers()) &&
   ((ParamQs.getCVRQualifiers() | ArgQs.getCVRQualifiers())
@@ -1060,7 +1060,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema
 // Just skip any attempts to deduce from a placeholder type.
 if (Arg->isPlaceholderType())
   return Sema::TDK_Success;
-
+
 unsigned Index = TemplateTypeParm->getIndex();
 bool RecanonicalizeArg = false;
 
@@ -1100,7 +1100,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   DeducedQs.removeAddressSpace();
 if (ParamQs.hasObjCLifetime())
   DeducedQs.removeObjCLifetime();
-
+
 // Objective-C ARC:
 //   If template deduction would produce a lifetime qualifier on a type
 //   that is not a lifetime type, template argument deduction fails.
@@ -1109,9 +1109,9 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   Info.Param = cast(TemplateParams->getParam(Index));
   Info.FirstArg = TemplateArgument(Param);
   Info.SecondArg = TemplateArgument(Arg);
-  return Sema::TDK_Underqualified;  
+  return Sema::TDK_Underqualified;
 }
-
+
 // Objective-C ARC:
 //   If template deduction would produce an argument type with lifetime 
type
 //   but no lifetime qualifier, the __strong lifetime qualifier is 
inferred.
@@ -1119,10 +1119,10 @@ DeduceTemplateArgumentsByTypeMatch(Sema
 DeducedType->isObjCLifetimeType() &&
 !DeducedQs.hasObjCLifetime())
   DeducedQs.setObjCLifetime(Qualifiers::OCL_Strong);
-
+
 DeducedType = S.Context.getQualifiedType(DeducedType.getUnqualifiedType(),
  DeducedQs);
-
+
 if (RecanonicalizeArg)
   DeducedType = S.Context.getCanonicalType(DeducedType);
 
@@ -1163,7 +1163,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   if (Param.getCVRQualifiers() != Arg.getCVRQualifiers())
 return Sema::TDK_NonDeducedMismatch;
 }
-
+
 // If the parameter type is not dependent, there is nothing to deduce.
 if (!Param->isDependentType()) {
   if (!(TDF & TDF_SkipNonDependent)) {
@@ -1193,7 +1193,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   case Type::Class: llvm_unreachable("deducing non-canonical type: " #Class);
 #define TYPE(Class, Base)
 #include "clang/AST/TypeNodes.def"
-  
+
 case Type::TemplateTypeParm:
 case Type::SubstTemplateTypeParmPack:
   llvm_unreachable("Type nodes handled above");
@@ -1211,20 +1211,20 @@ DeduceTemplateArgumentsByTypeMatch(Sema
 case Type::ObjCObjectPointer: {
   if (TDF & TDF_SkipNonDependent)
 return Sema::TDK_Success;
-  
+
   if (TDF & TDF_IgnoreQualifiers) {
 Param = Param.getUnqualifiedType();
 Arg = Arg.getUnqualifiedType();
   }
-
+
   return Param == Arg? Sema::TDK_Success : Sema::TDK_NonDeducedMismatch;
 }
-  
-// _Complex T   [placeholder extension]  
+
+// _Complex T   [placeholder extension]
 case Type::Complex:
   if (const ComplexType *ComplexArg = Arg->getAs())
-return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams, 
-
cast(Param)->getElementType(), 
+return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams,
+cast(Param)->getElementType(),
 ComplexArg->getElementType(),
 Info, Deduced, TDF);
 
@@ -1549,7 +1549,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams,
QualType(MemP

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) attribute

2016-08-12 Thread Eric Fiselier via cfe-commits
EricWF retitled this revision from "Implement __has_constant_initializer(obj) 
expression traits." to "Implement 
__attribute__((require_constant_initialization)) attribute".
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 67821.
EricWF added a comment.

Switch to an attribute based implementation as suggested by @rsmith.


https://reviews.llvm.org/D23385

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Lexer/has_extension_cxx.cpp
  test/SemaCXX/attr-require-constant-initialization.cpp

Index: test/SemaCXX/attr-require-constant-initialization.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-require-constant-initialization.cpp
@@ -0,0 +1,221 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++14 %s
+//
+// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
+//
+
+#if !__has_feature(cxx_static_assert)
+# define CONCAT_(X_, Y_) CONCAT1_(X_, Y_)
+# define CONCAT1_(X_, Y_) X_ ## Y_
+
+// This emulation can be used multiple times on one line (and thus in
+// a macro), except at class scope
+# define static_assert(b_, m_) \
+  typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1]
+#endif
+
+int ReturnInt();
+
+#define ATTR __attribute__((require_constant_initialization))
+struct PODType {
+int value;
+int value2;
+};
+#if __cplusplus >= 201103L
+struct LitType {
+constexpr LitType() : value(0) {}
+constexpr LitType(int x) : value(x) {}
+LitType(void*) : value(-1) {}
+int value;
+};
+#endif
+
+struct NonLit {
+#if __cplusplus >= 201402L
+constexpr NonLit() : value(0) {}
+constexpr NonLit(int x ) : value(x) {}
+#else
+NonLit() : value(0) {}
+NonLit(int x) : value(x) {}
+#endif
+NonLit(void*) : value(-1) {}
+~NonLit() {}
+int value;
+};
+
+struct StoresNonLit {
+#if __cplusplus >= 201402L
+constexpr StoresNonLit() : obj() {}
+constexpr StoresNonLit(int x) : obj(x) {}
+#else
+StoresNonLit() : obj() {}
+StoresNonLit(int x) : obj(x) {}
+#endif
+StoresNonLit(void* p) : obj(p) {}
+NonLit obj;
+};
+
+const bool NonLitHasConstInit =
+#if __cplusplus >= 201402L
+true;
+#else
+false;
+#endif
+
+// [basic.start.static]p2.1
+// if each full-expression (including implicit conversions) that appears in
+// the initializer of a reference with static or thread storage duration is
+// a constant expression (5.20) and the reference is bound to a glvalue
+// designating an object with static storage duration, to a temporary object
+// (see 12.2) or subobject thereof, or to a function;
+
+// Test binding to a static glvalue
+const int glvalue_int = 42;
+const int glvalue_int2 = ReturnInt();
+ATTR const int& glvalue_ref ATTR = glvalue_int;
+ATTR const int& glvalue_ref2 ATTR = glvalue_int2;
+ATTR __thread const int& glvalue_ref_tl = glvalue_int;
+
+void test_basic_start_static_2_1() {
+const int non_global = 42;
+ATTR static const int& local_init = non_global; // expected-error {{variable does not have a constant initializer}}
+ATTR static const int& global_init = glvalue_int;
+ATTR static const int& temp_init = 42;
+#if 0
+/// FIXME: Why is this failing?
+__thread const int& tl_init = 42;
+static_assert(__has_constant_initializer(tl_init), "");
+#endif
+}
+
+ATTR const int& temp_ref = 42;
+ATTR const int& temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
+ATTR const NonLit& nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
+
+#if __cplusplus >= 201103L
+ATTR const LitType& lit_temp_ref = 42;
+ATTR const int& subobj_ref = LitType{}.value;
+#endif
+
+ATTR const int& nl_subobj_ref = NonLit().value;  // expected-error {{variable does not have a constant initializer}}
+
+struct TT1 {
+  ATTR static const int& no_init;
+  ATTR static const int& glvalue_init;
+  ATTR static const int& temp_init;
+  ATTR static const int& subobj_init;
+#if __cplusplus >= 201103L
+  ATTR static thread_local const int& tl_glvalue_init;
+  ATTR static thread_local const int& tl_temp_init;
+#endif
+};
+const int& TT1::glvalue_init = glvalue_int;
+const int& TT1::temp_init = 42;
+const int& TT1::subobj_init = PODType().value;
+#if __cplusplus >= 201103L
+thread_local const int& TT1::tl_glvalue_init = glvalue_int;
+thread_local const int& TT1::tl_temp_init = 42; // expected-error {{variable does not have a constant initializer}}
+#endif
+
+// [basic.start.static]p2.2
+// if an object with static or thread storage duration is initialized by a
+// constructor call, and if the initialization full-expression is a constant
+// initializer for the object;
+
+void test_basic_start_static_2_2()
+{
+ 

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread Eric Fiselier via cfe-commits
EricWF retitled this revision from "Implement 
__attribute__((require_constant_initialization)) attribute" to "Implement 
__attribute__((require_constant_initialization)) for safe static 
initialization.".
EricWF updated this revision to Diff 67822.
EricWF added a comment.

- Remove test from previous implementation.


https://reviews.llvm.org/D23385

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-require-constant-initialization.cpp

Index: test/SemaCXX/attr-require-constant-initialization.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-require-constant-initialization.cpp
@@ -0,0 +1,221 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++14 %s
+//
+// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
+//
+
+#if !__has_feature(cxx_static_assert)
+# define CONCAT_(X_, Y_) CONCAT1_(X_, Y_)
+# define CONCAT1_(X_, Y_) X_ ## Y_
+
+// This emulation can be used multiple times on one line (and thus in
+// a macro), except at class scope
+# define static_assert(b_, m_) \
+  typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1]
+#endif
+
+int ReturnInt();
+
+#define ATTR __attribute__((require_constant_initialization))
+struct PODType {
+int value;
+int value2;
+};
+#if __cplusplus >= 201103L
+struct LitType {
+constexpr LitType() : value(0) {}
+constexpr LitType(int x) : value(x) {}
+LitType(void*) : value(-1) {}
+int value;
+};
+#endif
+
+struct NonLit {
+#if __cplusplus >= 201402L
+constexpr NonLit() : value(0) {}
+constexpr NonLit(int x ) : value(x) {}
+#else
+NonLit() : value(0) {}
+NonLit(int x) : value(x) {}
+#endif
+NonLit(void*) : value(-1) {}
+~NonLit() {}
+int value;
+};
+
+struct StoresNonLit {
+#if __cplusplus >= 201402L
+constexpr StoresNonLit() : obj() {}
+constexpr StoresNonLit(int x) : obj(x) {}
+#else
+StoresNonLit() : obj() {}
+StoresNonLit(int x) : obj(x) {}
+#endif
+StoresNonLit(void* p) : obj(p) {}
+NonLit obj;
+};
+
+const bool NonLitHasConstInit =
+#if __cplusplus >= 201402L
+true;
+#else
+false;
+#endif
+
+// [basic.start.static]p2.1
+// if each full-expression (including implicit conversions) that appears in
+// the initializer of a reference with static or thread storage duration is
+// a constant expression (5.20) and the reference is bound to a glvalue
+// designating an object with static storage duration, to a temporary object
+// (see 12.2) or subobject thereof, or to a function;
+
+// Test binding to a static glvalue
+const int glvalue_int = 42;
+const int glvalue_int2 = ReturnInt();
+ATTR const int& glvalue_ref ATTR = glvalue_int;
+ATTR const int& glvalue_ref2 ATTR = glvalue_int2;
+ATTR __thread const int& glvalue_ref_tl = glvalue_int;
+
+void test_basic_start_static_2_1() {
+const int non_global = 42;
+ATTR static const int& local_init = non_global; // expected-error {{variable does not have a constant initializer}}
+ATTR static const int& global_init = glvalue_int;
+ATTR static const int& temp_init = 42;
+#if 0
+/// FIXME: Why is this failing?
+__thread const int& tl_init = 42;
+static_assert(__has_constant_initializer(tl_init), "");
+#endif
+}
+
+ATTR const int& temp_ref = 42;
+ATTR const int& temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
+ATTR const NonLit& nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
+
+#if __cplusplus >= 201103L
+ATTR const LitType& lit_temp_ref = 42;
+ATTR const int& subobj_ref = LitType{}.value;
+#endif
+
+ATTR const int& nl_subobj_ref = NonLit().value;  // expected-error {{variable does not have a constant initializer}}
+
+struct TT1 {
+  ATTR static const int& no_init;
+  ATTR static const int& glvalue_init;
+  ATTR static const int& temp_init;
+  ATTR static const int& subobj_init;
+#if __cplusplus >= 201103L
+  ATTR static thread_local const int& tl_glvalue_init;
+  ATTR static thread_local const int& tl_temp_init;
+#endif
+};
+const int& TT1::glvalue_init = glvalue_int;
+const int& TT1::temp_init = 42;
+const int& TT1::subobj_init = PODType().value;
+#if __cplusplus >= 201103L
+thread_local const int& TT1::tl_glvalue_init = glvalue_int;
+thread_local const int& TT1::tl_temp_init = 42; // expected-error {{variable does not have a constant initializer}}
+#endif
+
+// [basic.start.static]p2.2
+// if an object with static or thread storage duration is initialized by a
+// constructor call, and if the initialization full-expression is a constant
+// initializer for the object;
+
+void test_basic_start_static_2_2()
+{
+ATTR static PODType pod;
+ATTR static PODType pot2 = {ReturnInt()}; 

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread Eric Fiselier via cfe-commits
EricWF marked an inline comment as done.


Comment at: lib/AST/Expr.cpp:2653-2662
@@ -2651,4 +2652,12 @@
 }
-
+if (CE->getConstructor()->isConstexpr() &&
+(CE->getConstructor()->getParent()->hasTrivialDestructor() ||
+AllowNonLiteral)) {
+for (auto *Arg : CE->arguments()) {
+  if (!Arg->isConstantInitializer(Ctx, false, Culprit))
+return false;
+}
+return true;
+}
 break;
   }

rsmith wrote:
> This doesn't look right: just because we're calling a constexpr constructor 
> with constant arguments doesn't imply that the initializer is constant.
I changed this to use `VD->checkInitICE()` when evaluating a constexpr 
constructor or if `VD->isInitKnownICE()`. Otherwise it falls back on 
`isConstantInitializer()`


https://reviews.llvm.org/D23385



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


Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/Attr.td:1384
@@ +1383,3 @@
+def RequireConstantInit : InheritableAttr {
+  let Spellings = [GCC<"require_constant_initialization">];
+  let Subjects = SubjectList<[Var]>;

This should not use the GCC spelling because GCC doesn't support the attribute. 
Do you expect this attribute to do anything useful in C? If not, this should 
just be a CXX11 spelling in the clang namespace.


Comment at: include/clang/Basic/Attr.td:1385
@@ +1384,3 @@
+  let Spellings = [GCC<"require_constant_initialization">];
+  let Subjects = SubjectList<[Var]>;
+  let Documentation = [RequireConstantInitDocs];

You might want to make a custom `SubsetSubject` for this. Check out 
`NormalVar`, `SharedVar`, and the likes in Attr.td. Then you can get rid of the 
custom handling in SemaDeclAttr.cpp.


Comment at: include/clang/Basic/AttrDocs.td:835
@@ +834,3 @@
+  let Category = DocCatVariable;
+  let Heading = "require_constant_initialization";
+  let Content = [{

Should be no need to specify the heading manually since there's only one 
spelling for the attribute.


Comment at: include/clang/Basic/AttrDocs.td:847
@@ +846,3 @@
+
+This attribute acts an a compile time assertion that the requirements
+for constant initialization have been met. Since these requirements change

s/acts an a/acts as a


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6842
@@ +6841,3 @@
+def err_require_constant_init_var_not_static_tls : Error<
+  "'require_constant_initialization' attribute can only be applied to 
variables "
+  "static or thread-local storage duration">;

I would reword this to: "'require_constant_initialization' attribute only 
applies to variables with static or thread-local storage duration"


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++11 %s

This file should also get tests that ensure we properly diagnose the attribute 
when it doesn't apply to a declaration (such as a local variable, as well as 
nonsense like a function), test that it does not accept arguments, etc.


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:4-6
@@ +3,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++14 %s
+//
+// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
+//
+

Does this comment actually apply?


https://reviews.llvm.org/D23385



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


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-08-12 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

In https://reviews.llvm.org/D21695#510788, @vsk wrote:

> After reading through the discussion in https://reviews.llvm.org/D19668, I 
> don't think I understood the pros/cons of using a single ABI check (like asan 
> does) versus adding version numbers to each handler routine. With the latter 
> approach, wouldn't users only be able to link old object files with new 
> runtimes if we never delete old checks? If that's the case, and assuming that 
> we'd like to delete old checks, a single version symbol check would 
> accomplish the same thing.


With ASan it's very easy to add a single symbol for all of it, since it's a 
single pass, and when it runs, instrumentation is added. For UBSan it depends 
on it being enabled and you hitting a place where it checks for it. We can emit 
the version check symbol in emitCheckHandlerCall, though.

With split versioning, as long as the checks you enable don't get different 
versions (it's rare that we change checks, too), they'll still work (arguably 
this is not as valuable as I think it is, but things like Android frameworks 
enabling UBSan checks in production might make it more valuable).
With a single version for "UBSan", you get more problems:

- Should you rev when *adding* check handlers?
  - If so, why would I need a newer lib just because it includes a new check, 
even if I don't use that?
- You'll need to rev up, and use a newer version of the library even if the 
checks' interface (for the ones you're using) hasn't changed.



Comment at: lib/CodeGen/CGExpr.cpp:2473
@@ +2472,3 @@
+  ("__ubsan_handle_" + CheckName +
+   (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "") +
+   (NeedsAbortSuffix ? "_abort" : ""))

vsk wrote:
> Wdyt of dropping the "_vN" component if the version is 0? That's one less 
> compiler-rt change that we'd need.
That's what it's doing:
  (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "")



https://reviews.llvm.org/D21695



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


Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 67827.
EricWF marked 7 inline comments as done.
EricWF added a comment.

Address @aaron.ballman's review comments.


https://reviews.llvm.org/D23385

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-require-constant-initialization.cpp

Index: test/SemaCXX/attr-require-constant-initialization.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-require-constant-initialization.cpp
@@ -0,0 +1,228 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++14 %s
+
+#if !__has_feature(cxx_static_assert)
+# define CONCAT_(X_, Y_) CONCAT1_(X_, Y_)
+# define CONCAT1_(X_, Y_) X_ ## Y_
+
+// This emulation can be used multiple times on one line (and thus in
+// a macro), except at class scope
+# define static_assert(b_, m_) \
+  typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1]
+#endif
+
+#define ATTR __attribute__((require_constant_initialization))
+
+// Test diagnostics when attribute is applied to non-static declarations.
+void test_func_local(ATTR int param) { // expected-error {{only applies to variables with static or thread-local}}
+ATTR int x = 42; // expected-error {{only applies to variables with static or thread-local}}
+ATTR extern int y;
+}
+struct ATTR class_mem { // expected-error {{only applies to variables with static or thread-local}}
+  ATTR int x; // expected-error {{only applies to variables with static or thread-local}}
+};
+
+int ReturnInt();
+
+struct PODType {
+int value;
+int value2;
+};
+#if __cplusplus >= 201103L
+struct LitType {
+constexpr LitType() : value(0) {}
+constexpr LitType(int x) : value(x) {}
+LitType(void*) : value(-1) {}
+int value;
+};
+#endif
+
+struct NonLit {
+#if __cplusplus >= 201402L
+constexpr NonLit() : value(0) {}
+constexpr NonLit(int x ) : value(x) {}
+#else
+NonLit() : value(0) {}
+NonLit(int x) : value(x) {}
+#endif
+NonLit(void*) : value(-1) {}
+~NonLit() {}
+int value;
+};
+
+struct StoresNonLit {
+#if __cplusplus >= 201402L
+constexpr StoresNonLit() : obj() {}
+constexpr StoresNonLit(int x) : obj(x) {}
+#else
+StoresNonLit() : obj() {}
+StoresNonLit(int x) : obj(x) {}
+#endif
+StoresNonLit(void* p) : obj(p) {}
+NonLit obj;
+};
+
+const bool NonLitHasConstInit =
+#if __cplusplus >= 201402L
+true;
+#else
+false;
+#endif
+
+// [basic.start.static]p2.1
+// if each full-expression (including implicit conversions) that appears in
+// the initializer of a reference with static or thread storage duration is
+// a constant expression (5.20) and the reference is bound to a glvalue
+// designating an object with static storage duration, to a temporary object
+// (see 12.2) or subobject thereof, or to a function;
+
+// Test binding to a static glvalue
+const int glvalue_int = 42;
+const int glvalue_int2 = ReturnInt();
+ATTR const int& glvalue_ref ATTR = glvalue_int;
+ATTR const int& glvalue_ref2 ATTR = glvalue_int2;
+ATTR __thread const int& glvalue_ref_tl = glvalue_int;
+
+void test_basic_start_static_2_1() {
+const int non_global = 42;
+ATTR static const int& local_init = non_global; // expected-error {{variable does not have a constant initializer}}
+ATTR static const int& global_init = glvalue_int;
+ATTR static const int& temp_init = 42;
+#if 0
+/// FIXME: Why is this failing?
+__thread const int& tl_init = 42;
+static_assert(__has_constant_initializer(tl_init), "");
+#endif
+}
+
+ATTR const int& temp_ref = 42;
+ATTR const int& temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
+ATTR const NonLit& nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
+
+#if __cplusplus >= 201103L
+ATTR const LitType& lit_temp_ref = 42;
+ATTR const int& subobj_ref = LitType{}.value;
+#endif
+
+ATTR const int& nl_subobj_ref = NonLit().value;  // expected-error {{variable does not have a constant initializer}}
+
+struct TT1 {
+  ATTR static const int& no_init;
+  ATTR static const int& glvalue_init;
+  ATTR static const int& temp_init;
+  ATTR static const int& subobj_init;
+#if __cplusplus >= 201103L
+  ATTR static thread_local const int& tl_glvalue_init;
+  ATTR static thread_local const int& tl_temp_init;
+#endif
+};
+const int& TT1::glvalue_init = glvalue_int;
+const int& TT1::temp_init = 42;
+const int& TT1::subobj_init = PODType().value;
+#if __cplusplus >= 201103L
+thread_local const int& TT1::tl_glvalue_init = glvalue_int;
+thread_local const int& TT1::tl_temp_init = 42; // expected-error {{variable does not have a constant initializer}}
+#endif
+
+// [basic.start.static]p2

Re: [PATCH] D23387: [Analyzer] Report found fields order in PaddingChecker.

2016-08-12 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM.  Thanks for the patch!



Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:217
@@ +216,3 @@
+// then large field indices to small field indices
+return std::make_tuple(Align, -Size,
+   Field ? 
-static_cast(Field->getFieldIndex())

Nit:
I think std::tie is the more idiomatic way to do this (not that I had it right 
before either).  You get less copying of values, though that doesn't matter 
much for the types we are using here.


https://reviews.llvm.org/D23387



___
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-08-12 Thread Martin Böhme via cfe-commits
mboehme updated this revision to Diff 67828.
mboehme added a comment.

Handle case where the forwarding reference is a parameter of a generic lambda.


https://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/ReleaseNotes.rst
  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,125 @@
+// RUN: %check_clang_tidy %s misc-move-forwarding-reference %t -- -- -std=c++14
+
+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 &&move(_Tp &&__t);
+
+} // namespace std
+
+// Standard case.
+template  void f1(U &&SomeU) {
+  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 &&SomeU) {
+  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 &&SomeU) {
+  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 &&SomeU) {
+  T SomeT(::std::move(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+  // CHECK-FIXES: T SomeT(::std::forward(SomeU));
+}
+
+// Create a correct fix if there are spaces around the overload resolution
+// operator.
+template  void f5(U &&SomeU) {
+  {
+T SomeT(::std::move(SomeU));
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: forwarding reference passed to
+// CHECK-FIXES: T SomeT(::std::forward(SomeU));
+  }
+  {
+T SomeT(std::move(SomeU));
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: forwarding reference passed to
+// CHECK-FIXES: T SomeT(std::forward(SomeU));
+  }
+}
+
+// Ignore const rvalue reference parameters.
+template  void f6(const U &&SomeU) {
+  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 f7() {
+  [](U &&SomeU) { T SomeT(std::move(SomeU)); };
+}
+
+// Ignore the case where the argument is a lvalue reference.
+template  void f8(U &SomeU) {
+  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 &&SomeU) { T SomeT(std::move(SomeU)); }
+};
+
+// Ignore the case where the function parameter in the template isn't an rvalue
+// reference but the template argument is explicitly set to be an rvalue
+// reference.
+class A {};
+template  void foo(T);
+void f8() {
+  A a;
+  foo(std::move(a));
+}
+
+// A warning is output, but no fix is suggested, if a macro is used to rename
+// std::move.
+#define MOVE(x) std::move((x))
+template  void f9(U &&SomeU) {
+  T SomeT(MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Same result if the argument is passed outside of the macro.
+#undef MOVE
+#define MOVE std::move
+template  void f10(U &&SomeU) {
+  T SomeT(MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Same result if the macro does not include the "std" namespace.
+#undef MOVE
+#define MOVE move
+template  void f11(U &&SomeU) {
+  T SomeT(std::MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Handle the case correctly where the forwarding reference is a parameter of a
+// generic lambda.
+template  void f12() {
+  [] (auto&& x) { T SomeT(std::move(x)); };
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference passed to
+  // CHECK-FIXES: [] (auto&& x) { T SomeT(std::forward(x)); }
+}
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 - m

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

2016-08-12 Thread Martin Böhme via cfe-commits
mboehme updated this revision to Diff 67830.
mboehme added a comment.

Restore spaces around scope resolution operator in test case


https://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/ReleaseNotes.rst
  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,125 @@
+// RUN: %check_clang_tidy %s misc-move-forwarding-reference %t -- -- -std=c++14
+
+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 &&move(_Tp &&__t);
+
+} // namespace std
+
+// Standard case.
+template  void f1(U &&SomeU) {
+  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 &&SomeU) {
+  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 &&SomeU) {
+  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 &&SomeU) {
+  T SomeT(::std::move(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+  // CHECK-FIXES: T SomeT(::std::forward(SomeU));
+}
+
+// Create a correct fix if there are spaces around the scope resolution
+// operator.
+template  void f5(U &&SomeU) {
+  {
+T SomeT(::  std  ::  move(SomeU));
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: forwarding reference passed to
+// CHECK-FIXES: T SomeT(::std::forward(SomeU));
+  }
+  {
+T SomeT(std  ::  move(SomeU));
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: forwarding reference passed to
+// CHECK-FIXES: T SomeT(std::forward(SomeU));
+  }
+}
+
+// Ignore const rvalue reference parameters.
+template  void f6(const U &&SomeU) {
+  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 f7() {
+  [](U &&SomeU) { T SomeT(std::move(SomeU)); };
+}
+
+// Ignore the case where the argument is a lvalue reference.
+template  void f8(U &SomeU) {
+  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 &&SomeU) { T SomeT(std::move(SomeU)); }
+};
+
+// Ignore the case where the function parameter in the template isn't an rvalue
+// reference but the template argument is explicitly set to be an rvalue
+// reference.
+class A {};
+template  void foo(T);
+void f8() {
+  A a;
+  foo(std::move(a));
+}
+
+// A warning is output, but no fix is suggested, if a macro is used to rename
+// std::move.
+#define MOVE(x) std::move((x))
+template  void f9(U &&SomeU) {
+  T SomeT(MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Same result if the argument is passed outside of the macro.
+#undef MOVE
+#define MOVE std::move
+template  void f10(U &&SomeU) {
+  T SomeT(MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Same result if the macro does not include the "std" namespace.
+#undef MOVE
+#define MOVE move
+template  void f11(U &&SomeU) {
+  T SomeT(std::MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Handle the case correctly where the forwarding reference is a parameter of a
+// generic lambda.
+template  void f12() {
+  [] (auto&& x) { T SomeT(std::move(x)); };
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference passed to
+  // CHECK-FIXES: [] (auto&& x) { T SomeT(std::forward(x)); }
+}
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-fo

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: include/clang/Basic/Attr.td:1384
@@ +1383,3 @@
+def RequireConstantInit : InheritableAttr {
+  let Spellings = [GCC<"require_constant_initialization">];
+  let Subjects = SubjectList<[Var]>;

aaron.ballman wrote:
> This should not use the GCC spelling because GCC doesn't support the 
> attribute. Do you expect this attribute to do anything useful in C? If not, 
> this should just be a CXX11 spelling in the clang namespace.
Are CXX11 attributes usable in C++03? If not perhaps we should provide both?


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:4-6
@@ +3,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++14 %s
+//
+// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
+//
+

aaron.ballman wrote:
> Does this comment actually apply?
No. 


https://reviews.llvm.org/D23385



___
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-08-12 Thread Martin Böhme via cfe-commits
mboehme added inline comments.


Comment at: test/clang-tidy/misc-move-forwarding-reference.cpp:50
@@ +49,3 @@
+// operator.
+template  void f5(U &&SomeU) {
+  {

Sorry, that should have been "scope resolution operator". Comment changed.

What this is trying to test is that the replacements still happen as desired 
even if there are spaces around the scope resolution operator. Unfortunately, I 
inadvertently deleted those spaces when I clang-formatted this entire file... 
I've now restored the spaces.


Comment at: test/clang-tidy/misc-move-forwarding-reference.cpp:118
@@ +117,3 @@
+}
+
+// Handle the case correctly where the forwarding reference is a parameter of a

Good point. Done.

As it turns out, the detection didn't yet work quite correctly. This was due to 
the special format of LambdaExprs for generic lambdas. In particular, what 
tripped my test up is that the same TemplateTypeParmDecl is contained in two 
different FunctionTemplateDecls -- one for operator() and one for __invoke.

As a result, I've needed to rewrite the detection to do a little more work 
outside of the matcher. (There was no way to do it inside the matcher as the 
FunctionTemplateDecl for operator() is actually not visited by the 
RecursiveASTVisitor.)


https://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] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-08-12 Thread Martin Böhme via cfe-commits
mboehme updated this revision to Diff 67829.
mboehme marked 2 inline comments as done.
mboehme added a comment.

Fix typo in comment


https://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/ReleaseNotes.rst
  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,125 @@
+// RUN: %check_clang_tidy %s misc-move-forwarding-reference %t -- -- -std=c++14
+
+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 &&move(_Tp &&__t);
+
+} // namespace std
+
+// Standard case.
+template  void f1(U &&SomeU) {
+  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 &&SomeU) {
+  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 &&SomeU) {
+  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 &&SomeU) {
+  T SomeT(::std::move(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+  // CHECK-FIXES: T SomeT(::std::forward(SomeU));
+}
+
+// Create a correct fix if there are spaces around the scope resolution
+// operator.
+template  void f5(U &&SomeU) {
+  {
+T SomeT(::std::move(SomeU));
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: forwarding reference passed to
+// CHECK-FIXES: T SomeT(::std::forward(SomeU));
+  }
+  {
+T SomeT(std::move(SomeU));
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: forwarding reference passed to
+// CHECK-FIXES: T SomeT(std::forward(SomeU));
+  }
+}
+
+// Ignore const rvalue reference parameters.
+template  void f6(const U &&SomeU) {
+  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 f7() {
+  [](U &&SomeU) { T SomeT(std::move(SomeU)); };
+}
+
+// Ignore the case where the argument is a lvalue reference.
+template  void f8(U &SomeU) {
+  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 &&SomeU) { T SomeT(std::move(SomeU)); }
+};
+
+// Ignore the case where the function parameter in the template isn't an rvalue
+// reference but the template argument is explicitly set to be an rvalue
+// reference.
+class A {};
+template  void foo(T);
+void f8() {
+  A a;
+  foo(std::move(a));
+}
+
+// A warning is output, but no fix is suggested, if a macro is used to rename
+// std::move.
+#define MOVE(x) std::move((x))
+template  void f9(U &&SomeU) {
+  T SomeT(MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Same result if the argument is passed outside of the macro.
+#undef MOVE
+#define MOVE std::move
+template  void f10(U &&SomeU) {
+  T SomeT(MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Same result if the macro does not include the "std" namespace.
+#undef MOVE
+#define MOVE move
+template  void f11(U &&SomeU) {
+  T SomeT(std::MOVE(SomeU));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: forwarding reference passed to
+}
+
+// Handle the case correctly where the forwarding reference is a parameter of a
+// generic lambda.
+template  void f12() {
+  [] (auto&& x) { T SomeT(std::move(x)); };
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference passed to
+  // CHECK-FIXES: [] (auto&& x) { T SomeT(std::forward(x)); }
+}
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-

[PATCH] D23448: [ASTMatchers] Add templateTypeParmDecl() to Registry.cpp

2016-08-12 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: alexfh.
mboehme added a subscriber: cfe-commits.
Herald added subscribers: samparker, rengolin, aemerson, klimek.

This appears to have been forgotten when templateTypeParmDecl() was initially
added.

https://reviews.llvm.org/D23448

Files:
  lib/ASTMatchers/Dynamic/Registry.cpp

Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -396,6 +396,7 @@
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateArgumentCountIs);
   REGISTER_MATCHER(templateSpecializationType);
+  REGISTER_MATCHER(templateTypeParmDecl);
   REGISTER_MATCHER(templateTypeParmType);
   REGISTER_MATCHER(throughUsingDecl);
   REGISTER_MATCHER(to);


Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -396,6 +396,7 @@
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateArgumentCountIs);
   REGISTER_MATCHER(templateSpecializationType);
+  REGISTER_MATCHER(templateTypeParmDecl);
   REGISTER_MATCHER(templateTypeParmType);
   REGISTER_MATCHER(throughUsingDecl);
   REGISTER_MATCHER(to);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23448: [ASTMatchers] Add templateTypeParmDecl() to Registry.cpp

2016-08-12 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D23448



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


r278507 - [ASTMatchers] Add templateTypeParmDecl() to Registry.cpp

2016-08-12 Thread Martin Bohme via cfe-commits
Author: mboehme
Date: Fri Aug 12 08:51:00 2016
New Revision: 278507

URL: http://llvm.org/viewvc/llvm-project?rev=278507&view=rev
Log:
[ASTMatchers] Add templateTypeParmDecl() to Registry.cpp

Summary:
This appears to have been forgotten when templateTypeParmDecl() was initially
added.

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, klimek, aemerson, rengolin, samparker, cfe-commits

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

Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=278507&r1=278506&r2=278507&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Fri Aug 12 08:51:00 2016
@@ -396,6 +396,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateArgumentCountIs);
   REGISTER_MATCHER(templateSpecializationType);
+  REGISTER_MATCHER(templateTypeParmDecl);
   REGISTER_MATCHER(templateTypeParmType);
   REGISTER_MATCHER(throughUsingDecl);
   REGISTER_MATCHER(to);


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


Re: [PATCH] D23448: [ASTMatchers] Add templateTypeParmDecl() to Registry.cpp

2016-08-12 Thread Martin Böhme via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278507: [ASTMatchers] Add templateTypeParmDecl() to 
Registry.cpp (authored by mboehme).

Changed prior to commit:
  https://reviews.llvm.org/D23448?vs=67831&id=67832#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23448

Files:
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp

Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -396,6 +396,7 @@
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateArgumentCountIs);
   REGISTER_MATCHER(templateSpecializationType);
+  REGISTER_MATCHER(templateTypeParmDecl);
   REGISTER_MATCHER(templateTypeParmType);
   REGISTER_MATCHER(throughUsingDecl);
   REGISTER_MATCHER(to);


Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -396,6 +396,7 @@
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateArgumentCountIs);
   REGISTER_MATCHER(templateSpecializationType);
+  REGISTER_MATCHER(templateTypeParmDecl);
   REGISTER_MATCHER(templateTypeParmType);
   REGISTER_MATCHER(throughUsingDecl);
   REGISTER_MATCHER(to);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Adhemerval Zanella via cfe-commits
zatrazz updated this revision to Diff 67835.
zatrazz added a comment.

What about this version? The only difference is for libunwind libgcc is still 
included.


https://reviews.llvm.org/D23420

Files:
  test/libcxx/test/target_info.py

Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -179,8 +179,7 @@
 flags += ['-lc']
 if llvm_unwinder:
 flags += ['-lunwind', '-ldl']
-else:
-flags += ['-lgcc_s', '-lgcc']
+flags += ['-lgcc_s', '-lgcc']
 use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
 if use_libatomic:
 flags += ['-latomic']


Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -179,8 +179,7 @@
 flags += ['-lc']
 if llvm_unwinder:
 flags += ['-lunwind', '-ldl']
-else:
-flags += ['-lgcc_s', '-lgcc']
+flags += ['-lgcc_s', '-lgcc']
 use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
 if use_libatomic:
 flags += ['-latomic']
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23449: libcxx: Fix path.compare.pass expected result

2016-08-12 Thread Adhemerval Zanella via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: jroelofs, danalbert, EricWF.
zatrazz added subscribers: rmaprath, aemerson, rengolin, cfe-commits.

The expected 'filesystem::path::compare' result states that for different
only the sign of result integer contains the information about passed
arguments.  This is because it uses the output of other compare function
(basic_string_view and char_traits) without further handling and
char_traits uses memcmp for final buffer comparison.

However for GLIBC on AArch64 the code:

  int ret = memcmp ("b/a/c", "a/b/c", 1);

Results in '64' where for x86_64 it results in '1'.

This patch fixes the expected 'filesystem::path::compare' by normalizing
all the results before assert comparison.

https://reviews.llvm.org/D23449

Files:
  test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp

Index: 
test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
===
--- 
test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
+++ 
test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
@@ -73,6 +73,11 @@
 #undef LONGC
 #undef LONGD
 
+static inline int normalize_ret(int ret)
+{
+  return ret < 0 ? -1 : (ret > 0 ? 1 : 0);
+}
+
 int main()
 {
   using namespace fs;
@@ -86,13 +91,12 @@
   DisableAllocationGuard g; // none of these operations should allocate
 
   // check runtime results
-  int ret1 = p1.compare(p2);
-  int ret2 = p1.compare(R);
-  int ret3 = p1.compare(TC.RHS);
-  int ret4 = p1.compare(RV);
+  int ret1 = normalize_ret(p1.compare(p2));
+  int ret2 = normalize_ret(p1.compare(R));
+  int ret3 = normalize_ret(p1.compare(TC.RHS));
+  int ret4 = normalize_ret(p1.compare(RV));
   assert(ret1 == ret2 && ret1 == ret3 && ret1 == ret4);
-  int normalized_ret = ret1 < 0 ? -1 : (ret1 > 0 ? 1 : 0);
-  assert(normalized_ret == E);
+  assert(ret1 == E);
 
   // check signatures
   ASSERT_NOEXCEPT(p1.compare(p2));


Index: test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
===
--- test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
+++ test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
@@ -73,6 +73,11 @@
 #undef LONGC
 #undef LONGD
 
+static inline int normalize_ret(int ret)
+{
+  return ret < 0 ? -1 : (ret > 0 ? 1 : 0);
+}
+
 int main()
 {
   using namespace fs;
@@ -86,13 +91,12 @@
   DisableAllocationGuard g; // none of these operations should allocate
 
   // check runtime results
-  int ret1 = p1.compare(p2);
-  int ret2 = p1.compare(R);
-  int ret3 = p1.compare(TC.RHS);
-  int ret4 = p1.compare(RV);
+  int ret1 = normalize_ret(p1.compare(p2));
+  int ret2 = normalize_ret(p1.compare(R));
+  int ret3 = normalize_ret(p1.compare(TC.RHS));
+  int ret4 = normalize_ret(p1.compare(RV));
   assert(ret1 == ret2 && ret1 == ret3 && ret1 == ret4);
-  int normalized_ret = ret1 < 0 ? -1 : (ret1 > 0 ? 1 : 0);
-  assert(normalized_ret == E);
+  assert(ret1 == E);
 
   // check signatures
   ASSERT_NOEXCEPT(p1.compare(p2));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23322: [OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2

2016-08-12 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Do you think testing the declaration to be available without/with an error 
after the extension is enabled/disabled might be useful too?


https://reviews.llvm.org/D23322



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Doesn't libgcc_s contain bits of gcc's unwinder?


https://reviews.llvm.org/D23420



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


Re: [PATCH] D23322: [OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2

2016-08-12 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D23322#513792, @Anastasia wrote:

> Do you think testing the declaration to be available without/with an error 
> after the extension is enabled/disabled might be useful too?


I feel it is not so useful for a specific extension.

When the feature which diagnoses functions disabled by extension is 
implemented, tests will be added as a generic case.


https://reviews.llvm.org/D23322



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Adhemerval Zanella via cfe-commits
zatrazz added a comment.

Yes, but my understaning is the proposed link order will force libc++ to link 
against _Unwind* symbols from libunwind (this is what I am observing also).


https://reviews.llvm.org/D23420



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

This breaks the ODR... the behavior under those circumstances is undefined.


https://reviews.llvm.org/D23420



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


Re: [PATCH] D23361: [OpenCL] AMDGCN: Fix size_t type

2016-08-12 Thread Joey Gouly via cfe-commits
joey added a subscriber: joey.


Comment at: lib/CodeGen/CodeGenModule.cpp:101
@@ -100,3 +100,3 @@
   DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
   PointerWidthInBits = C.getTargetInfo().getPointerWidth(0);
   PointerAlignInBytes =

What if you create a new function in TargetInfo called 
getMaxPointerWidth(unsigned AddrSpace), and call that here? That would by 
default just call 'getPointerWidth', but in your AMDGPU TargetInfo you can 
override that.
That feels more generic.


https://reviews.llvm.org/D23361



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Adhemerval Zanella via cfe-commits
zatrazz added a comment.

Yes, although in pratice for shared libraries this is not an issue (at least on 
Linux with current linker strategies). And I open for suggestion on how to 
proceed in this case since we have some other options:

1. Add the required soft-sp implementations when building for Linux (this might 
happen not only on aarch64, but any other ABI that defines long double using 
fallback soft-fp)
2. Remove the possible soft-fp usages on all the tests. However this will lead 
to possible remove *all* the FP cases if libcxx should be used in a pure 
soft-fp platform
3. Only allows the libcxx + linunwind to be built against compiler-rt


https://reviews.llvm.org/D23420



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D23420#513820, @zatrazz wrote:

> Yes, although in pratice for shared libraries this is not an issue (at least 
> on Linux with current linker strategies). And I open for suggestion on how to 
> proceed in this case since we have some other options:
>
> 1. Add the required soft-sp implementations when building for Linux (this 
> might happen not only on aarch64, but any other ABI that defines long double 
> using fallback soft-fp)


Are the softfp symbols you need not contained in libgcc.a?

> 2. Remove the possible soft-fp usages on all the tests. However this will 
> lead to possible remove *all* the FP cases if libcxx should be used in a pure 
> soft-fp platform

> 3. Only allows the libcxx + linunwind to be built against compiler-rt





https://reviews.llvm.org/D23420



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


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

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

The patch LG.

In https://reviews.llvm.org/D23434#513533, @djasper wrote:

> I think we should entirely drop this implementation of the check and let it 
> just check #includes with clang-format. clang-format's implementation isn't a 
> strict superset, e.g. won't sort between multiple blocks, but that's 
> intentional for now.


Since sorting across blocks is frequently needed to make include order 
consistent with the LLVM coding standards, it makes sense to keep this check 
until clang-format is able to sort across blocks. Especially, since Zachary is 
specifically interested in this functionality.


https://reviews.llvm.org/D23434



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Adhemerval Zanella via cfe-commits
zatrazz added a comment.

In https://reviews.llvm.org/D23420#513824, @jroelofs wrote:

> In https://reviews.llvm.org/D23420#513820, @zatrazz wrote:
>
> > Yes, although in pratice for shared libraries this is not an issue (at 
> > least on Linux with current linker strategies). And I open for suggestion 
> > on how to proceed in this case since we have some other options:
> >
> > 1. Add the required soft-sp implementations when building for Linux (this 
> > might happen not only on aarch64, but any other ABI that defines long 
> > double using fallback soft-fp)
>
>
> Are the softfp symbols you need not contained in libgcc.a?


Good call, I think just using 'lgcc' should be suffice. I will change the patch.


https://reviews.llvm.org/D23420



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


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Zachary Turner via cfe-commits
You and daniel both imply that clang-tidy can sort across blocks. Am I
missing this somewhere?

My intention was to add an option for this in a followup patch because it
doesn't seem to be able to currently.
On Fri, Aug 12, 2016 at 8:21 AM Alexander Kornienko 
wrote:

> alexfh accepted this revision.
> alexfh added a comment.
> This revision is now accepted and ready to land.
>
> The patch LG.
>
> In https://reviews.llvm.org/D23434#513533, @djasper wrote:
>
> > I think we should entirely drop this implementation of the check and let
> it just check #includes with clang-format. clang-format's implementation
> isn't a strict superset, e.g. won't sort between multiple blocks, but
> that's intentional for now.
>
>
> Since sorting across blocks is frequently needed to make include order
> consistent with the LLVM coding standards, it makes sense to keep this
> check until clang-format is able to sort across blocks. Especially, since
> Zachary is specifically interested in this functionality.
>
>
> https://reviews.llvm.org/D23434
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I think we got confused. We once had tried to write an experimental separate 
check to comply with Google's style guide. If you want to fiddle around with 
that, contact me, I can send you pointers. But as I mentioned we moved away 
from that. And I think it makes more sense to re-create the sort-across-blocks 
functionality in clang-format and not in clang-tidy.


https://reviews.llvm.org/D23434



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


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Zachary Turner via cfe-commits
one disadvantage to clang format is that you have less control over how and
whether to apply fixits. Reordering across blocks has a higher risk of
breaking code, and you can't tell clang format to only apply fixits which
don't break code, or to not apply any fixits but just warn.

Code duplication is always bad, but maybe we could find a way to share code
between the two so that they share the same algorithm.

I'm not opposed to trying to add cross block reordering to clang format,
but killing the clang tidy check entirely breaks my use case, and since the
current patch is strictly a bugfix should be fine to commit it right?



On Fri, Aug 12, 2016 at 8:50 AM Daniel Jasper  wrote:

> djasper added a comment.
>
> I think we got confused. We once had tried to write an experimental
> separate check to comply with Google's style guide. If you want to fiddle
> around with that, contact me, I can send you pointers. But as I mentioned
> we moved away from that. And I think it makes more sense to re-create the
> sort-across-blocks functionality in clang-format and not in clang-tidy.
>
>
> https://reviews.llvm.org/D23434
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D23434#513839, @djasper wrote:

> I think we got confused. We once had tried to write an experimental separate 
> check to comply with Google's style guide. If you want to fiddle around with 
> that, contact me, I can send you pointers. But as I mentioned we moved away 
> from that. And I think it makes more sense to re-create the 
> sort-across-blocks functionality in clang-format and not in clang-tidy.


Yep, we definitely got confused. That experimental check actually implemented 
cross-block sorting, but this caused a bunch of issues. Which makes me think 
that proper implementation of cross-block include sorting is challenging be it 
in clang-format or clang-tidy. Clang-format probably makes it even more 
complex, since a higher safety of transformations is expected from it.


https://reviews.llvm.org/D23434



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


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Zachary Turner via cfe-commits
That's actually the reason I think it makes more sense in clang tidy. It
can be a configuration option, off by default, and since there is more
control over whether to apply fixits, and it doesn't apply fixits by
default, it would be easier to iterate on the experimental nature of it
without messing up code


On Fri, Aug 12, 2016 at 9:14 AM Alexander Kornienko 
wrote:

> alexfh added a comment.
>
> In https://reviews.llvm.org/D23434#513839, @djasper wrote:
>
> > I think we got confused. We once had tried to write an experimental
> separate check to comply with Google's style guide. If you want to fiddle
> around with that, contact me, I can send you pointers. But as I mentioned
> we moved away from that. And I think it makes more sense to re-create the
> sort-across-blocks functionality in clang-format and not in clang-tidy.
>
>
> Yep, we definitely got confused. That experimental check actually
> implemented cross-block sorting, but this caused a bunch of issues. Which
> makes me think that proper implementation of cross-block include sorting is
> challenging be it in clang-format or clang-tidy. Clang-format probably
> makes it even more complex, since a higher safety of transformations is
> expected from it.
>
>
> https://reviews.llvm.org/D23434
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23452: [OpenCL] Release 3.9 notes

2016-08-12 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: hans.
Anastasia added subscribers: yaxunl, bader, cfe-commits.

Release notes for OpenCL in Clang

https://reviews.llvm.org/D23452

Files:
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -191,7 +191,47 @@
 OpenCL C Language Changes in Clang
 --
 
-...
+Clang now has support for all OpenCL 2.0 features.  In particular, the 
following
+features have been completed since the previous release:
+
+- Pipe builtin functions (s6.13.16.2-4).
+- Address space conversion functions ``to_{global/local/private}``.
+- ``nosvm`` attribute support.
+- Improved diagnostic and generation of Clang Blocks used in OpenCL kernel 
code.
+- ``opencl_unroll_hint`` pragma.
+
+Several miscellaneous improvements have been made:
+
+- Supported extensions are now part of the target representation to give 
correct
+  diagnostics  for unsupported target features during compilation. For example,
+  when compiling for a target that does not support the double precision
+  floating point extension, Clang will give an error when encountering the
+  ``cl_khr_fp64 pragma``. Several missing extensions were added covering up to
+  and including OpenCL 2.0.
+- Clang now comes with the OpenCL standard headers declaring builtin types and
+  functions up to and including OpenCL 2.0 in ``lib/Headers/opencl-c.h``. By
+  default, Clang will not include this header. It can be included either using
+  the regular ``-I`` directive or (if the default one
+  from installation is to be used) using the ``-finclude-default-header``
+  frontend flag.
+  Example:
+``echo "bool is_wg_uniform(int i){return 
get_enqueued_local_size(i)==get_local_size(i);}" > test.cl``
+``clang -cc1 -finclude-default-header -cl-std=CL2.0 test.cl``
+  All builtin function declarations from OpenCL 2.0 will be automatically
+  visible in test.cl.
+- Image types have been improved with better diagnostics for access qualifiers.
+  Images with one access qualifier type cannot be used in declarations for
+  another. Also qualifiers are now propagated from the frontend down to
+  libraries and backends.
+- Diagnostic improvements for OpenCL types, address spaces and vectors.
+- Half type literal support has been added. For example, ``1.0h`` represents a
+  floating point literal in half precision, i.e., the value ``0xH3C00``.
+- The Clang driver now accepts OpenCL compiler options ``-cl-*`` (following the
+  OpenCL Spec v1.1-1.2 s5.8). For example, the ``-cl-std=CL1.2`` option from 
the
+  spec enables compilation for OpenCL 1.2, or ``-cl-mad-enable`` will enable
+  fusing multiply-and-add operations.
+- Clang now uses function metadata instead of module metadata to propagate
+  information related to OpenCL kernels e.g. kernel argument information.
 
 OpenMP Support in Clang
 --


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -191,7 +191,47 @@
 OpenCL C Language Changes in Clang
 --
 
-...
+Clang now has support for all OpenCL 2.0 features.  In particular, the following
+features have been completed since the previous release:
+
+- Pipe builtin functions (s6.13.16.2-4).
+- Address space conversion functions ``to_{global/local/private}``.
+- ``nosvm`` attribute support.
+- Improved diagnostic and generation of Clang Blocks used in OpenCL kernel code.
+- ``opencl_unroll_hint`` pragma.
+
+Several miscellaneous improvements have been made:
+
+- Supported extensions are now part of the target representation to give correct
+  diagnostics  for unsupported target features during compilation. For example,
+  when compiling for a target that does not support the double precision
+  floating point extension, Clang will give an error when encountering the
+  ``cl_khr_fp64 pragma``. Several missing extensions were added covering up to
+  and including OpenCL 2.0.
+- Clang now comes with the OpenCL standard headers declaring builtin types and
+  functions up to and including OpenCL 2.0 in ``lib/Headers/opencl-c.h``. By
+  default, Clang will not include this header. It can be included either using
+  the regular ``-I`` directive or (if the default one
+  from installation is to be used) using the ``-finclude-default-header``
+  frontend flag.
+  Example:
+``echo "bool is_wg_uniform(int i){return get_enqueued_local_size(i)==get_local_size(i);}" > test.cl``
+``clang -cc1 -finclude-default-header -cl-std=CL2.0 test.cl``
+  All builtin function declarations from OpenCL 2.0 will be automatically
+  visible in test.cl.
+- Image types have been improved with better diagnostics for access qualifiers.
+  Images with one access qualifier type cannot be used in declarations for
+  another. Also qualifiers are now 

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:10388-10390
@@ -10387,2 +10387,5 @@
 
+  // Cache the result of checking for constant initialization.
+  Optional HasConstInit;
+
   if (var->getTLSKind() == VarDecl::TLS_Static) {

You could use a lambda to abstract away the "check if it's cached, if not 
query" logic.


Comment at: lib/Sema/SemaDecl.cpp:10485
@@ +10484,3 @@
+  if (var->hasAttr() && !Init)
+ Diag(var->getLocation(), diag::err_require_constant_init_failed);
+

Any reason not to use the already existing `err_init_element_not_constant`?


https://reviews.llvm.org/D23385



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


Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

2016-08-12 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A few initial comments.



Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:492
@@ +491,3 @@
+  DeclRefs->clear();
+  for (CFGBlock::const_iterator I = Block->begin(), E = Block->end(); I != E;
+   ++I) {

Any reason to avoid range-based for loops here?


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:505
@@ +504,3 @@
+for (const auto &Match : Matches) {
+  const DeclRefExpr *DeclRef = Match.getNodeAs("declref");
+  if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {

The type is specified verbatim in the initializer, so it's better to use `const 
auto *` here.


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:506
@@ +505,3 @@
+  const DeclRefExpr *DeclRef = Match.getNodeAs("declref");
+  if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
+DeclRefs->insert(DeclRef);

It's uncommon to use braces for single-line `if`/`for`/... bodies in LLVM/Clang 
code.


Comment at: docs/clang-tidy/checks/misc-use-after-move.rst:51
@@ +50,3 @@
+In some cases, the check may not be able to detect that two branches are
+mutually exclusive. For example (assuming that ``i`` is an int):
+

Eugene.Zelenko wrote:
> i is not language construct, please use `.
It's an inline code snippet, isn't it? I'd format it as code (double 
backquotes).


Comment at: docs/clang-tidy/checks/misc-use-after-move.rst:190
@@ +189,3 @@
+
+The check will not consider ``s`` to be reinitialized after the last line;
+instead, the line that assigns to ``s.str`` will be flagged as a 
use-after-move.

Eugene.Zelenko wrote:
> s, s.str and S are not language construct. Please use `.
Seems fine to format these as code as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D23353



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


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Daniel Jasper via cfe-commits
The check's implementation will be replaced by a simple call to clang tidy.
It will remain a check in clang tidy to continue to cater to both use cases.

On Aug 12, 2016 6:19 PM, "Zachary Turner"  wrote:

> That's actually the reason I think it makes more sense in clang tidy. It
> can be a configuration option, off by default, and since there is more
> control over whether to apply fixits, and it doesn't apply fixits by
> default, it would be easier to iterate on the experimental nature of it
> without messing up code
>
>
> On Fri, Aug 12, 2016 at 9:14 AM Alexander Kornienko 
> wrote:
>
>> alexfh added a comment.
>>
>> In https://reviews.llvm.org/D23434#513839, @djasper wrote:
>>
>> > I think we got confused. We once had tried to write an experimental
>> separate check to comply with Google's style guide. If you want to fiddle
>> around with that, contact me, I can send you pointers. But as I mentioned
>> we moved away from that. And I think it makes more sense to re-create the
>> sort-across-blocks functionality in clang-format and not in clang-tidy.
>>
>>
>> Yep, we definitely got confused. That experimental check actually
>> implemented cross-block sorting, but this caused a bunch of issues. Which
>> makes me think that proper implementation of cross-block include sorting is
>> challenging be it in clang-format or clang-tidy. Clang-format probably
>> makes it even more complex, since a higher safety of transformations is
>> expected from it.
>>
>>
>> https://reviews.llvm.org/D23434
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Zachary Turner via cfe-commits
Ahh, I see.  Just to be clear, is there an LGTM to get this path in?  I
know alexfh@ lgtm'ed it, want to make sure you're ok with this too.

On Fri, Aug 12, 2016 at 9:40 AM Daniel Jasper  wrote:

> The check's implementation will be replaced by a simple call to clang
> tidy. It will remain a check in clang tidy to continue to cater to both use
> cases.
>
> On Aug 12, 2016 6:19 PM, "Zachary Turner"  wrote:
>
>> That's actually the reason I think it makes more sense in clang tidy. It
>> can be a configuration option, off by default, and since there is more
>> control over whether to apply fixits, and it doesn't apply fixits by
>> default, it would be easier to iterate on the experimental nature of it
>> without messing up code
>>
>>
>> On Fri, Aug 12, 2016 at 9:14 AM Alexander Kornienko 
>> wrote:
>>
>>> alexfh added a comment.
>>>
>>> In https://reviews.llvm.org/D23434#513839, @djasper wrote:
>>>
>>> > I think we got confused. We once had tried to write an experimental
>>> separate check to comply with Google's style guide. If you want to fiddle
>>> around with that, contact me, I can send you pointers. But as I mentioned
>>> we moved away from that. And I think it makes more sense to re-create the
>>> sort-across-blocks functionality in clang-format and not in clang-tidy.
>>>
>>>
>>> Yep, we definitely got confused. That experimental check actually
>>> implemented cross-block sorting, but this caused a bunch of issues. Which
>>> makes me think that proper implementation of cross-block include sorting is
>>> challenging be it in clang-format or clang-tidy. Clang-format probably
>>> makes it even more complex, since a higher safety of transformations is
>>> expected from it.
>>>
>>>
>>> https://reviews.llvm.org/D23434
>>>
>>>
>>>
>>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23453: Add a c2x language mode

2016-08-12 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, doug.gregor.
aaron.ballman added a subscriber: cfe-commits.

This patch adds support for a "c2x" language standard mode for the eventual new 
C language standard, expected to come out in 202x. The spelling and 
capitalization is pulled from the C2x charter 
(http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2021.htm).

I added a pretty simple driver test for this language mode because we do not 
currently have any C2x language features. However, I have a WIP patch that will 
require this functionality and figured that this part should be split off from 
it. If there is a better way to test this, or if it should wait for the WIP, 
please let me know.

https://reviews.llvm.org/D23453

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/LangStandard.h
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/clang_std_c.c

Index: test/Driver/clang_std_c.c
===
--- test/Driver/clang_std_c.c
+++ test/Driver/clang_std_c.c
@@ -0,0 +1,7 @@
+/* Test various -std driver options for C. */
+// RUN: %clang -std=c11 -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -std=c2x -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK-NOT: invalid value 'c11' in '-std=c11'
+// CHECK-NOT: invalid value 'c2x' in '-std=c2x'
+
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1535,6 +1535,7 @@
   Opts.LineComment = Std.hasLineComments();
   Opts.C99 = Std.isC99();
   Opts.C11 = Std.isC11();
+  Opts.C2x = Std.isC2x();
   Opts.CPlusPlus = Std.isCPlusPlus();
   Opts.CPlusPlus11 = Std.isCPlusPlus11();
   Opts.CPlusPlus14 = Std.isCPlusPlus14();
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -91,6 +91,11 @@
  "ISO C 2011 with GNU extensions",
  LineComment | C99 | C11 | Digraphs | GNUMode | HexFloat)
 
+// C2X modes
+LANGSTANDARD(c2x, "c2x",
+ "Working draft for ISO C 202x",
+ LineComment | C99 | C11 | C2x | Digraphs | HexFloat)
+
 // C++ modes
 LANGSTANDARD(cxx98, "c++98",
  "ISO C++ 1998 with amendments",
Index: include/clang/Frontend/LangStandard.h
===
--- include/clang/Frontend/LangStandard.h
+++ include/clang/Frontend/LangStandard.h
@@ -22,14 +22,15 @@
   C89 = (1 << 1),
   C99 = (1 << 2),
   C11 = (1 << 3),
-  CPlusPlus = (1 << 4),
-  CPlusPlus11 = (1 << 5),
-  CPlusPlus14 = (1 << 6),
-  CPlusPlus1z = (1 << 7),
-  Digraphs = (1 << 8),
-  GNUMode = (1 << 9),
-  HexFloat = (1 << 10),
-  ImplicitInt = (1 << 11)
+  C2x = (1 << 4),
+  CPlusPlus = (1 << 5),
+  CPlusPlus11 = (1 << 6),
+  CPlusPlus14 = (1 << 7),
+  CPlusPlus1z = (1 << 8),
+  Digraphs = (1 << 9),
+  GNUMode = (1 << 10),
+  HexFloat = (1 << 11),
+  ImplicitInt = (1 << 12)
 };
 
 }
@@ -67,6 +68,9 @@
   /// isC11 - Language is a superset of C11.
   bool isC11() const { return Flags & frontend::C11; }
 
+  /// isC2x - Language is a superset of C2x.
+  bool isC2x() const { return Flags & frontend::C2x; }
+
   /// isCPlusPlus - Language is a C++ variant.
   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
 
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -82,6 +82,7 @@
 // FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead.
 LANGOPT(C99   , 1, 0, "C99")
 LANGOPT(C11   , 1, 0, "C11")
+LANGOPT(C2x   , 1, 0, "C2x")
 LANGOPT(MSVCCompat, 1, 0, "Microsoft Visual C++ full compatibility 
mode")
 LANGOPT(MicrosoftExt  , 1, 0, "Microsoft C++ extensions")
 LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")


Index: test/Driver/clang_std_c.c
===
--- test/Driver/clang_std_c.c
+++ test/Driver/clang_std_c.c
@@ -0,0 +1,7 @@
+/* Test various -std driver options for C. */
+// RUN: %clang -std=c11 -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -std=c2x -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK-NOT: invalid value 'c11' in '-std=c11'
+// CHECK-NOT: invalid value 'c2x' in '-std=c2x'
+
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1535,6 +1535,7 @@
   Opts.LineComment = Std.hasLineComments();
   Opts.C99 = Std.isC99();
   Opts.C11 = Std.isC11();
+  Opts.C2x = Std.isC2x();
   Opts.CPlusPlus = Std.isCPlusPlus();
   Opts.CPlusPlus11 = Std.

Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-08-12 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:95-98
@@ +94,6 @@
+const QualType T = VD->getType();
+if (T->isPointerType() && !T->getPointeeType().isConstQualified())
+  markCanNotBeConst(VD->getInit(), true);
+else if (T->isArrayType())
+  markCanNotBeConst(VD->getInit(), true);
+  }

This looks like it could be in the same if.


https://reviews.llvm.org/D15332



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


r278525 - BugReporter: Use ilist_half_embedded_sentinel_traits, NFC

2016-08-12 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Fri Aug 12 11:46:25 2016
New Revision: 278525

URL: http://llvm.org/viewvc/llvm-project?rev=278525&view=rev
Log:
BugReporter: Use ilist_half_embedded_sentinel_traits, NFC

This avoids duplicated code with llvm/ADT/ilist.h.  No functionality
change.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=278525&r1=278524&r2=278525&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Fri 
Aug 12 11:46:25 2016
@@ -315,22 +315,9 @@ public:
 } // end clang namespace
 
 namespace llvm {
-  template<> struct ilist_traits
-: public ilist_default_traits {
-clang::ento::BugReport *createSentinel() const {
-  return static_cast(&Sentinel);
-}
-void destroySentinel(clang::ento::BugReport *) const {}
-
-clang::ento::BugReport *provideInitialHead() const {
-  return createSentinel();
-}
-clang::ento::BugReport *ensureHead(clang::ento::BugReport *) const {
-  return createSentinel();
-}
-  private:
-mutable ilist_half_node Sentinel;
-  };
+template <>
+struct ilist_sentinel_traits
+: public ilist_half_embedded_sentinel_traits {};
 }
 
 namespace clang {


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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-12 Thread Adhemerval Zanella via cfe-commits
zatrazz updated this revision to Diff 67850.
zatrazz added a comment.

I think patch should be safe now.


https://reviews.llvm.org/D23420

Files:
  test/libcxx/test/target_info.py

Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -180,7 +180,8 @@
 if llvm_unwinder:
 flags += ['-lunwind', '-ldl']
 else:
-flags += ['-lgcc_s', '-lgcc']
+flags += ['-lgcc_s']
+flags += ['-lgcc']
 use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
 if use_libatomic:
 flags += ['-latomic']


Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -180,7 +180,8 @@
 if llvm_unwinder:
 flags += ['-lunwind', '-ldl']
 else:
-flags += ['-lgcc_s', '-lgcc']
+flags += ['-lgcc_s']
+flags += ['-lgcc']
 use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
 if use_libatomic:
 flags += ['-latomic']
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23453: Add a c2x language mode

2016-08-12 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: include/clang/Frontend/LangStandards.def:94
@@ -93,1 +93,3 @@
 
+// C2X modes
+LANGSTANDARD(c2x, "c2x",

Should this be C2x instead of C2X?


https://reviews.llvm.org/D23453



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


Re: [PATCH] D23387: [Analyzer] Report found fields order in PaddingChecker.

2016-08-12 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:217
@@ +216,3 @@
+// then large field indices to small field indices
+return std::make_tuple(Align, -Size,
+   Field ? 
-static_cast(Field->getFieldIndex())

bcraig wrote:
> Nit:
> I think std::tie is the more idiomatic way to do this (not that I had it 
> right before either).  You get less copying of values, though that doesn't 
> matter much for the types we are using here.
std::tie expects an l-value for 2nd argument,
so it doesn't compile (if i switch to std::tie):

/Users/alexshap/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:217:16:
 error:
  no matching function for call to 'tie'
return std::tie(Align, -Size,
   ^~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/tuple:814:1:
 note:
  candidate function [with _Tp = ] not viable: expects an l-value for 2nd argument
tie(_Tp&... __t) _NOEXCEPT



https://reviews.llvm.org/D23387



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


Re: [PATCH] D23429: [CUDA] Place GPU binary into .nv_fatbin section and align it by 8.

2016-08-12 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 67851.
tra added a comment.

Reverted argument type to std::string


https://reviews.llvm.org/D23429

Files:
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -45,10 +45,12 @@
 // * constant unnamed string with the kernel name
 // CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
-// CHECK: private unnamed_addr constant{{.*}}\00"
+// CHECK: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
+// CHECK-SAME: section ".nv_fatbin", align 8
 // * constant struct that wraps GPU binary
 // CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } 
-// CHECK:   { i32 1180844977, i32 1, {{.*}}, i8* null }
+// CHECK-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
+// CHECK-SAME: section ".nvFatBinSegment"
 // * variable to save GPU binary handle after initialization
 // CHECK: @__cuda_gpubin_handle = internal global i8** null
 // * Make sure our constructor/destructor was added to global ctor/dtor list.
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -55,10 +55,18 @@
   /// where the C code specifies const char*.
   llvm::Constant *makeConstantString(const std::string &Str,
  const std::string &Name = "",
+ const std::string &SectionName = "",
  unsigned Alignment = 0) {
 llvm::Constant *Zeros[] = {llvm::ConstantInt::get(SizeTy, 0),
llvm::ConstantInt::get(SizeTy, 0)};
 auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
+llvm::GlobalVariable *GV =
+cast(ConstStr.getPointer());
+if (!SectionName.empty())
+  GV->setSection(SectionName);
+if (Alignment)
+  GV->setAlignment(Alignment);
+
 return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),
 ConstStr.getPointer(), Zeros);
  }
@@ -285,7 +293,8 @@
 llvm::Constant *Values[] = {
 llvm::ConstantInt::get(IntTy, 0x466243b1), // Fatbin wrapper magic.
 llvm::ConstantInt::get(IntTy, 1),  // Fatbin version.
-makeConstantString(GpuBinaryOrErr.get()->getBuffer(), "", 16), // Data.
+makeConstantString(GpuBinaryOrErr.get()->getBuffer(), // Data.
+   "", ".nv_fatbin", 8),  //
 llvm::ConstantPointerNull::get(VoidPtrTy)}; // Unused in fatbin v1.
 llvm::GlobalVariable *FatbinWrapper = new llvm::GlobalVariable(
 TheModule, FatbinWrapperTy, true, llvm::GlobalValue::InternalLinkage,


Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -45,10 +45,12 @@
 // * constant unnamed string with the kernel name
 // CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
-// CHECK: private unnamed_addr constant{{.*}}\00"
+// CHECK: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
+// CHECK-SAME: section ".nv_fatbin", align 8
 // * constant struct that wraps GPU binary
 // CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } 
-// CHECK:   { i32 1180844977, i32 1, {{.*}}, i8* null }
+// CHECK-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
+// CHECK-SAME: section ".nvFatBinSegment"
 // * variable to save GPU binary handle after initialization
 // CHECK: @__cuda_gpubin_handle = internal global i8** null
 // * Make sure our constructor/destructor was added to global ctor/dtor list.
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -55,10 +55,18 @@
   /// where the C code specifies const char*.
   llvm::Constant *makeConstantString(const std::string &Str,
  const std::string &Name = "",
+ const std::string &SectionName = "",
  unsigned Alignment = 0) {
 llvm::Constant *Zeros[] = {llvm::ConstantInt::get(SizeTy, 0),
llvm::ConstantInt::get(SizeTy, 0)};
 auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
+llvm::GlobalVariable *GV =
+cast(ConstStr.getPointer());
+if (!SectionName.empty())
+  GV->setSection(SectionName);
+if (Alignment)
+  GV->setAlignment(Alignment);
+
 return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),
 ConstStr.getPointer(), 

Re: [PATCH] D23409: Make clang-tidy work with clang-cl

2016-08-12 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

The changes in Driver LGTM (though I'd prefer someone who knows Driver to look).

Could you move lib/Tooling/JSONCompilationDatabase.cpp to a separate patch? It 
seems like an orthogonal change.

As for a clang-cl-mode test for clang-tidy, clang-tidy-run-with-database.cpp is 
only tangentially related. We probably need two tests: one with a JSON 
compilation database and the other with a fixed compilation database (passing 
compiler arguments after `--`). In both cases I'd use flags like `/D` to verify 
correct parsing of the command line. Something along the lines of:

  // RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- clang-cl /DTEST1 
/DFOO=foo /DBAR#bar | FileCheck -implicit-check-not="{{warning|error}}:" %s
  int *a = 0;
  // CHECK: :[[@LINE-1]]:10: warning: use nullptr
  #ifdef TEST1
  int *b = 0;
  // CHECK: :[[@LINE-1]]:10: warning: use nullptr
  #endif
  #define foo 1
  #define bar 1
  #if FOO
  int *c = 0;
  // CHECK: :[[@LINE-1]]:10: warning: use nullptr
  #endif
  #if BAR
  int *d = 0;
  // CHECK: :[[@LINE-1]]:10: warning: use nullptr
  #endif

Maybe some other aspects of clang-cl mode options parsing can be tested this 
way as well.


https://reviews.llvm.org/D23409



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


Re: [PATCH] D23429: [CUDA] Place GPU binary into .nv_fatbin section and align it by 8.

2016-08-12 Thread Artem Belevich via cfe-commits
tra marked an inline comment as done.


Comment at: lib/CodeGen/CGCUDANV.cpp:62-69
@@ -60,3 +61,10 @@
llvm::ConstantInt::get(SizeTy, 0)};
 auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
+llvm::GlobalVariable *GV =
+cast(ConstStr.getPointer());
+if (!SectionName.empty())
+  GV->setSection(SectionName);
+if (Alignment)
+  GV->setAlignment(Alignment);
+
 return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),

Good point. I've reverted argument types to std::string.


https://reviews.llvm.org/D23429



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


Re: [PATCH] D23453: Add a c2x language mode

2016-08-12 Thread Aaron Ballman via cfe-commits
aaron.ballman marked an inline comment as done.


Comment at: include/clang/Frontend/LangStandards.def:94
@@ -93,1 +93,3 @@
 
+// C2X modes
+LANGSTANDARD(c2x, "c2x",

majnemer wrote:
> Should this be C2x instead of C2X?
Probably. :-D


https://reviews.llvm.org/D23453



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


Re: [PATCH] D23409: Make clang-tidy work with clang-cl

2016-08-12 Thread Zachary Turner via cfe-commits
zturner abandoned this revision.
zturner added a comment.

Once I split the JSONCompilationDatabase patch out, then the rest is strictly a 
driver-only patch, and the other one is strictly a tooling patch.  So I will 
abandon this one and upload two new patches with a more targeted set of 
reviewers.


https://reviews.llvm.org/D23409



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


[PATCH] D23454: [Driver] Set the default clang driver mode based on the executable

2016-08-12 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added a reviewer: rnk.
zturner added a subscriber: cfe-commits.

If `--driver-mode` is passed in one or more times, it will overwrite the 
default by this patch.  This patch only makes it so that if NO `--driver-mode` 
is passed in, we try to do better than saying "must be GCC".

This is one of two steps necessary to get clang-tidy working on Windows.  
However, despite that, this change seems correct even in the general sense.  If 
a `--driver-mode` option is not passed in, we should make the most informed 
possible decision we can.

https://reviews.llvm.org/D23454

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  unittests/Driver/ToolChainTest.cpp

Index: unittests/Driver/ToolChainTest.cpp
===
--- unittests/Driver/ToolChainTest.cpp
+++ unittests/Driver/ToolChainTest.cpp
@@ -117,4 +117,29 @@
 S);
 }
 
+TEST(ToolChainTest, DefaultDriverMode) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  InMemoryFileSystem);
+  Driver CXXDriver("/home/test/bin/clang++", "arm-linux-gnueabi", Diags,
+   InMemoryFileSystem);
+  Driver CLDriver("/home/test/bin/clang-cl", "arm-linux-gnueabi", Diags,
+  InMemoryFileSystem);
+
+  std::unique_ptr CC(CCDriver.BuildCompilation({"foo.cpp"}));
+  std::unique_ptr CXX(CXXDriver.BuildCompilation({"foo.cpp"}));
+  std::unique_ptr CL(CLDriver.BuildCompilation({"foo.cpp"}));
+
+  EXPECT_TRUE(CCDriver.CCCIsCC());
+  EXPECT_TRUE(CXXDriver.CCCIsCXX());
+  EXPECT_TRUE(CLDriver.IsCLMode());
+}
+
 } // end anonymous namespace
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -88,31 +88,39 @@
   llvm::DeleteContainerSeconds(ToolChains);
 }
 
-void Driver::ParseDriverMode(ArrayRef Args) {
-  const std::string OptName =
-  getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
+void Driver::ParseDriverMode(StringRef ProgramName,
+ ArrayRef Args) {
+  auto Default = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  StringRef DefaultMode(Default.second);
+  setDriverModeFromOption(DefaultMode);
 
   for (const char *ArgPtr : Args) {
 // Ingore nullptrs, they are response file's EOL markers
 if (ArgPtr == nullptr)
   continue;
 const StringRef Arg = ArgPtr;
-if (!Arg.startswith(OptName))
-  continue;
+setDriverModeFromOption(Arg);
+  }
+}
+
+void Driver::setDriverModeFromOption(StringRef Opt) {
+  const std::string OptName =
+  getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
+  if (!Opt.startswith(OptName))
+return;
+  StringRef Value = Opt.drop_front(OptName.size());
 
-const StringRef Value = Arg.drop_front(OptName.size());
-const unsigned M = llvm::StringSwitch(Value)
-   .Case("gcc", GCCMode)
-   .Case("g++", GXXMode)
-   .Case("cpp", CPPMode)
-   .Case("cl", CLMode)
-   .Default(~0U);
+  const unsigned M = llvm::StringSwitch(Value)
+ .Case("gcc", GCCMode)
+ .Case("g++", GXXMode)
+ .Case("cpp", CPPMode)
+ .Case("cl", CLMode)
+ .Default(~0U);
 
-if (M != ~0U)
-  Mode = static_cast(M);
-else
-  Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
-  }
+  if (M != ~0U)
+Mode = static_cast(M);
+  else
+Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
 }
 
 InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings) {
@@ -468,7 +476,7 @@
 
   // We look for the driver mode option early, because the mode can affect
   // how other options are parsed.
-  ParseDriverMode(ArgList.slice(1));
+  ParseDriverMode(ClangExecutable, ArgList.slice(1));
 
   // FIXME: What are we going to do with -V and -b?
 
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -155,6 +155,9 @@
   /// Whether the driver is just the preprocessor.
   bool CCCIsCPP() const { return Mode == CPPMode; }
 
+  /// Whether the driver should follow gcc like behavior.
+  bool CCCIsCC() const { return Mode == GCCMode; }
+
   /// Whether the driver should follow cl.exe like behavior.
   bool IsCLMode() const { return Mode == CLMode; }
 
@@ -291,7 +294,7 @@
   /// @{
 
   /// ParseDriverMode 

[PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-12 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added reviewers: alexfh, djasper.
zturner added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

When a compilation database is used on Windows, the command lines cannot be 
parsed using the standard GNU style syntax.  LLVM provides functions for 
parsing Windows style command lines, so use them.

This is a break-off from D23409.  Just uploading this here for now as a 
placeholder, will try to work on a test for this in the meantime.

https://reviews.llvm.org/D23455

Files:
  lib/Tooling/JSONCompilationDatabase.cpp

Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,7 +16,10 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
 #include 
 
 namespace clang {
@@ -113,8 +116,17 @@
 
 std::vector unescapeCommandLine(
 StringRef EscapedCommandLine) {
+#if defined(LLVM_ON_WIN32)
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Saver(Alloc);
+  llvm::SmallVector T;
+  llvm::cl::TokenizeWindowsCommandLine(EscapedCommandLine, Saver, T);
+  std::vector Result(T.begin(), T.end());
+  return Result;
+#else
   CommandLineArgumentParser parser(EscapedCommandLine);
   return parser.parse();
+#endif
 }
 
 class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {


Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,7 +16,10 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
 #include 
 
 namespace clang {
@@ -113,8 +116,17 @@
 
 std::vector unescapeCommandLine(
 StringRef EscapedCommandLine) {
+#if defined(LLVM_ON_WIN32)
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Saver(Alloc);
+  llvm::SmallVector T;
+  llvm::cl::TokenizeWindowsCommandLine(EscapedCommandLine, Saver, T);
+  std::vector Result(T.begin(), T.end());
+  return Result;
+#else
   CommandLineArgumentParser parser(EscapedCommandLine);
   return parser.parse();
+#endif
 }
 
 class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23454: [Driver] Set the default clang driver mode based on the executable

2016-08-12 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D23454



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


r278533 - Test commit - first LLVM repo commit

2016-08-12 Thread Alexander Droste via cfe-commits
Author: alexander_droste
Date: Fri Aug 12 12:43:58 2016
New Revision: 278533

URL: http://llvm.org/viewvc/llvm-project?rev=278533&view=rev
Log:
Test commit - first LLVM repo commit

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h?rev=278533&r1=278532&r2=278533&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h Fri Aug 12 
12:43:58 2016
@@ -65,3 +65,4 @@ struct ProgramStateTraithttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23045: [Include-fixer] Install executables and support scripts

2016-08-12 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

Ping. I could not proceed until my question answered.


Repository:
  rL LLVM

https://reviews.llvm.org/D23045



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-12 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk added a comment.

We should convince cmake to emit "arguments" instead of "command" so that we 
don't have this ambiguity.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23375: Add kfree( ) to MallocChecker.cpp

2016-08-12 Thread Devin Coughlin via cfe-commits
dcoughlin commandeered this revision.
dcoughlin edited reviewers, added: andrewmw94; removed: dcoughlin.
dcoughlin added a comment.

Thanks for the patches! I've commandeered this revision to be able to update 
the diff to merge the two patch files into one. You should commandeer it back 
by using the 'Commandeer Revision' action.

By the way, there are instructions for how to create and upload diffs using 
Phabricator at 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface


Repository:
  rL LLVM

https://reviews.llvm.org/D23375



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-12 Thread Zachary Turner via cfe-commits
zturner added a comment.

I mentioned offline that we could detect CRLF or LF and heuristically decide 
whether it's a windows compilation database.  That seems like a horrible hack, 
so failing that, yes having CMake do it for us would be better.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23375: Add kfree( ) to MallocChecker.cpp

2016-08-12 Thread Devin Coughlin via cfe-commits
dcoughlin removed rL LLVM as the repository for this revision.
dcoughlin updated this revision to Diff 67862.
dcoughlin added a comment.

Merge the two patches into one diff.


https://reviews.llvm.org/D23375

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/kmalloc-linux.c

Index: test/Analysis/kmalloc-linux.c
===
--- test/Analysis/kmalloc-linux.c
+++ test/Analysis/kmalloc-linux.c
@@ -6,6 +6,7 @@
 #define NULL ((void *)0)
 
 void *kmalloc(size_t, int);
+void *kfree(size_t);
 
 struct test {
 };
@@ -24,7 +25,7 @@
 t = list[i];
 foo(t);
   }
-  free(list); // no-warning
+  kfree(list); // no-warning
 }
 
 void test_nonzero() {
@@ -39,7 +40,7 @@
 t = list[i]; // expected-warning{{undefined}}
 foo(t);
   }
-  free(list);
+  kfree(list);
 }
 
 void test_indeterminate(int flags) {
@@ -54,5 +55,5 @@
 t = list[i]; // expected-warning{{undefined}}
 foo(t);
   }
-  free(list);
+  kfree(list);
 }
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -44,6 +44,7 @@
   AF_CXXNew,
   AF_CXXNewArray,
   AF_IfNameIndex,
+  AF_KMalloc,
   AF_Alloca
 };
 
@@ -173,8 +174,9 @@
 II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
 II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
 II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
-II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
-II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
+II_kfree(nullptr), II_if_nameindex(nullptr),
+II_if_freenameindex(nullptr), II_wcsdup(nullptr),
+II_win_wcsdup(nullptr) {}
 
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -235,8 +237,8 @@
   mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc, *II_free,
  *II_realloc, *II_calloc, *II_valloc, *II_reallocf,
  *II_strndup, *II_strdup, *II_win_strdup, *II_kmalloc,
- *II_if_nameindex, *II_if_freenameindex, *II_wcsdup,
- *II_win_wcsdup;
+ *II_kfree, *II_if_nameindex, *II_if_freenameindex,
+ *II_wcsdup, *II_win_wcsdup;
   mutable Optional KernelZeroFlagVal;
 
   void initIdentifierInfo(ASTContext &C) const;
@@ -287,7 +289,7 @@
   ProgramStateRef State,
   AllocationFamily Family = AF_Malloc);
 
-  // Check if this malloc() for special flags. At present that means M_ZERO or
+  // Check this malloc() for special flags. At present that means M_ZERO or
   // __GFP_ZERO (in which case, treat it like calloc).
   llvm::Optional
   performKernelMalloc(const CallExpr *CE, CheckerContext &C,
@@ -544,6 +546,7 @@
   II_strndup = &Ctx.Idents.get("strndup");
   II_wcsdup = &Ctx.Idents.get("wcsdup");
   II_kmalloc = &Ctx.Idents.get("kmalloc");
+  II_kfree = &Ctx.Idents.get("kfree");
   II_if_nameindex = &Ctx.Idents.get("if_nameindex");
   II_if_freenameindex = &Ctx.Idents.get("if_freenameindex");
 
@@ -586,7 +589,8 @@
 initIdentifierInfo(C);
 
 if (Family == AF_Malloc && CheckFree) {
-  if (FunI == II_free || FunI == II_realloc || FunI == II_reallocf)
+  if (FunI == II_free || FunI == II_realloc ||
+	  FunI == II_reallocf || FunI == II_kfree)
 return true;
 }
 
@@ -796,7 +800,7 @@
   State = CallocMem(C, CE, State);
   State = ProcessZeroAllocation(C, CE, 0, State);
   State = ProcessZeroAllocation(C, CE, 1, State);
-} else if (FunI == II_free) {
+} else if (FunI == II_free || FunI == II_kfree) {
   State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory);
 } else if (FunI == II_strdup || FunI == II_win_strdup ||
FunI == II_wcsdup || FunI == II_win_wcsdup) {
@@ -943,7 +947,7 @@
   const CXXConstructorDecl *CtorD = ConstructE->getConstructor();
 
   // Iterate over the constructor parameters.
-  for (const auto *CtorParam : CtorD->parameters()) {
+  for (const auto *CtorParam : CtorD->params()) {
 
 QualType CtorParamPointeeT = CtorParam->getType()->getPointeeType();
 if (CtorParamPointeeT.isNull())
@@ -1289,6 +1293,7 @@
 case AF_CXXNew: os << "'new'"; return;
 case AF_CXXNewArray: os << "'new[]'"; return;
 case AF_IfNameIndex: os << "'if_nameindex()'"; return;
+case AF_KMalloc: os <<"kmalloc()"; return;
 case AF_Alloca:
 case AF_None: llvm_unreachable("not a deallocation expression");
   }
@@ -1301,6 +1306,7 @@
 case AF_CXXNew: os << "'delete'"; return;
 case AF_CXXNewArray: os << "'delete[]'"; return;
 case AF_IfNameIndex: os << "'if_freenameindex()'"; return;
+case AF_KMalloc: os << "kfree()"; return;
 case AF_Alloca:
 

Re: [PATCH] D23454: [Driver] Set the default clang driver mode based on the executable

2016-08-12 Thread Zachary Turner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278535: [Driver] Set the default driver mode based on the 
executable. (authored by zturner).

Changed prior to commit:
  https://reviews.llvm.org/D23454?vs=67853&id=67861#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23454

Files:
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/unittests/Driver/ToolChainTest.cpp

Index: cfe/trunk/include/clang/Driver/Driver.h
===
--- cfe/trunk/include/clang/Driver/Driver.h
+++ cfe/trunk/include/clang/Driver/Driver.h
@@ -155,6 +155,9 @@
   /// Whether the driver is just the preprocessor.
   bool CCCIsCPP() const { return Mode == CPPMode; }
 
+  /// Whether the driver should follow gcc like behavior.
+  bool CCCIsCC() const { return Mode == GCCMode; }
+
   /// Whether the driver should follow cl.exe like behavior.
   bool IsCLMode() const { return Mode == CLMode; }
 
@@ -291,7 +294,7 @@
   /// @{
 
   /// ParseDriverMode - Look for and handle the driver mode option in Args.
-  void ParseDriverMode(ArrayRef Args);
+  void ParseDriverMode(StringRef ProgramName, ArrayRef Args);
 
   /// ParseArgStrings - Parse the given list of strings into an
   /// ArgList.
@@ -440,6 +443,10 @@
   LTOKind getLTOMode() const { return LTOMode; }
 
 private:
+  /// Set the driver mode (cl, gcc, etc) from an option string of the form
+  /// --driver-mode=.
+  void setDriverModeFromOption(StringRef Opt);
+
   /// Parse the \p Args list for LTO options and record the type of LTO
   /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
   void setLTOMode(const llvm::opt::ArgList &Args);
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -88,31 +88,39 @@
   llvm::DeleteContainerSeconds(ToolChains);
 }
 
-void Driver::ParseDriverMode(ArrayRef Args) {
-  const std::string OptName =
-  getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
+void Driver::ParseDriverMode(StringRef ProgramName,
+ ArrayRef Args) {
+  auto Default = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  StringRef DefaultMode(Default.second);
+  setDriverModeFromOption(DefaultMode);
 
   for (const char *ArgPtr : Args) {
 // Ingore nullptrs, they are response file's EOL markers
 if (ArgPtr == nullptr)
   continue;
 const StringRef Arg = ArgPtr;
-if (!Arg.startswith(OptName))
-  continue;
+setDriverModeFromOption(Arg);
+  }
+}
+
+void Driver::setDriverModeFromOption(StringRef Opt) {
+  const std::string OptName =
+  getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
+  if (!Opt.startswith(OptName))
+return;
+  StringRef Value = Opt.drop_front(OptName.size());
 
-const StringRef Value = Arg.drop_front(OptName.size());
-const unsigned M = llvm::StringSwitch(Value)
-   .Case("gcc", GCCMode)
-   .Case("g++", GXXMode)
-   .Case("cpp", CPPMode)
-   .Case("cl", CLMode)
-   .Default(~0U);
+  const unsigned M = llvm::StringSwitch(Value)
+ .Case("gcc", GCCMode)
+ .Case("g++", GXXMode)
+ .Case("cpp", CPPMode)
+ .Case("cl", CLMode)
+ .Default(~0U);
 
-if (M != ~0U)
-  Mode = static_cast(M);
-else
-  Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
-  }
+  if (M != ~0U)
+Mode = static_cast(M);
+  else
+Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
 }
 
 InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings) {
@@ -468,7 +476,7 @@
 
   // We look for the driver mode option early, because the mode can affect
   // how other options are parsed.
-  ParseDriverMode(ArgList.slice(1));
+  ParseDriverMode(ClangExecutable, ArgList.slice(1));
 
   // FIXME: What are we going to do with -V and -b?
 
Index: cfe/trunk/unittests/Driver/ToolChainTest.cpp
===
--- cfe/trunk/unittests/Driver/ToolChainTest.cpp
+++ cfe/trunk/unittests/Driver/ToolChainTest.cpp
@@ -117,4 +117,29 @@
 S);
 }
 
+TEST(ToolChainTest, DefaultDriverMode) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  InMemoryFileSystem);
+  Driver CXXDriver("/home/test/bin/clang++", "arm-linux-gnueabi", D

r278534 - Revert test commit

2016-08-12 Thread Alexander Droste via cfe-commits
Author: alexander_droste
Date: Fri Aug 12 12:46:23 2016
New Revision: 278534

URL: http://llvm.org/viewvc/llvm-project?rev=278534&view=rev
Log:
Revert test commit

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h?rev=278534&r1=278533&r2=278534&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h Fri Aug 12 
12:46:23 2016
@@ -65,4 +65,3 @@ struct ProgramStateTraithttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278535 - [Driver] Set the default driver mode based on the executable.

2016-08-12 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Fri Aug 12 12:47:52 2016
New Revision: 278535

URL: http://llvm.org/viewvc/llvm-project?rev=278535&view=rev
Log:
[Driver] Set the default driver mode based on the executable.

Currently, if --driver-mode is not passed at all, it will default
to GCC style driver.  This is never an issue for clang because
it manually constructs a --driver-mode option and passes it.

However, we should still try to do as good as we can even if no
--driver-mode is passed.  LibTooling, for example, does not pass
a --driver-mode option and while it could, it seems like we should
still fallback to the best possible default we can.

This is one of two steps necessary to get clang-tidy working on Windows.

Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D23454

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/unittests/Driver/ToolChainTest.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=278535&r1=278534&r2=278535&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Aug 12 12:47:52 2016
@@ -155,6 +155,9 @@ public:
   /// Whether the driver is just the preprocessor.
   bool CCCIsCPP() const { return Mode == CPPMode; }
 
+  /// Whether the driver should follow gcc like behavior.
+  bool CCCIsCC() const { return Mode == GCCMode; }
+
   /// Whether the driver should follow cl.exe like behavior.
   bool IsCLMode() const { return Mode == CLMode; }
 
@@ -291,7 +294,7 @@ public:
   /// @{
 
   /// ParseDriverMode - Look for and handle the driver mode option in Args.
-  void ParseDriverMode(ArrayRef Args);
+  void ParseDriverMode(StringRef ProgramName, ArrayRef Args);
 
   /// ParseArgStrings - Parse the given list of strings into an
   /// ArgList.
@@ -440,6 +443,10 @@ public:
   LTOKind getLTOMode() const { return LTOMode; }
 
 private:
+  /// Set the driver mode (cl, gcc, etc) from an option string of the form
+  /// --driver-mode=.
+  void setDriverModeFromOption(StringRef Opt);
+
   /// Parse the \p Args list for LTO options and record the type of LTO
   /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
   void setLTOMode(const llvm::opt::ArgList &Args);

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=278535&r1=278534&r2=278535&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Aug 12 12:47:52 2016
@@ -88,33 +88,41 @@ Driver::~Driver() {
   llvm::DeleteContainerSeconds(ToolChains);
 }
 
-void Driver::ParseDriverMode(ArrayRef Args) {
-  const std::string OptName =
-  getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
+void Driver::ParseDriverMode(StringRef ProgramName,
+ ArrayRef Args) {
+  auto Default = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  StringRef DefaultMode(Default.second);
+  setDriverModeFromOption(DefaultMode);
 
   for (const char *ArgPtr : Args) {
 // Ingore nullptrs, they are response file's EOL markers
 if (ArgPtr == nullptr)
   continue;
 const StringRef Arg = ArgPtr;
-if (!Arg.startswith(OptName))
-  continue;
-
-const StringRef Value = Arg.drop_front(OptName.size());
-const unsigned M = llvm::StringSwitch(Value)
-   .Case("gcc", GCCMode)
-   .Case("g++", GXXMode)
-   .Case("cpp", CPPMode)
-   .Case("cl", CLMode)
-   .Default(~0U);
-
-if (M != ~0U)
-  Mode = static_cast(M);
-else
-  Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
+setDriverModeFromOption(Arg);
   }
 }
 
+void Driver::setDriverModeFromOption(StringRef Opt) {
+  const std::string OptName =
+  getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
+  if (!Opt.startswith(OptName))
+return;
+  StringRef Value = Opt.drop_front(OptName.size());
+
+  const unsigned M = llvm::StringSwitch(Value)
+ .Case("gcc", GCCMode)
+ .Case("g++", GXXMode)
+ .Case("cpp", CPPMode)
+ .Case("cl", CLMode)
+ .Default(~0U);
+
+  if (M != ~0U)
+Mode = static_cast(M);
+  else
+Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
+}
+
 InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings) {
   llvm::PrettyStackTraceString CrashInfo("Command line argument parsing");
 
@@ -468,7 +476,7 @@ Compilation *Driver::BuildCompilation(Ar
 
   // We look for the driver mode option early, because the mode can affect
   // how other options are pars

[libcxx] r278538 - Merging r278357:

2016-08-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Aug 12 12:59:24 2016
New Revision: 278538

URL: http://llvm.org/viewvc/llvm-project?rev=278538&view=rev
Log:
Merging r278357:

r278357 | compnerd | 2016-08-11 09:58:12 -0700 (Thu, 11 Aug 2016) | 6 lines

test: relax the FS test a slight bit to be more reliable

Some filesystems track atime always.  This relaxes the test to accept either a
filesystem which does not accurately track atime or does track the atime
accurately.  This allows the test to pass on filesystems mounted with
`strictatime` on Linux or on macOS.


Modified:
libcxx/branches/release_39/   (props changed)

libcxx/branches/release_39/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Propchange: libcxx/branches/release_39/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 12 12:59:24 2016
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:278282,278387
+/libcxx/trunk:278282,278357,278387

Modified: 
libcxx/branches/release_39/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_39/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=278538&r1=278537&r2=278538&view=diff
==
--- 
libcxx/branches/release_39/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/branches/release_39/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Fri Aug 12 12:59:24 2016
@@ -158,7 +158,8 @@ TEST_CASE(get_last_write_time_dynamic_en
 
 TEST_CHECK(ftime2 > ftime);
 TEST_CHECK(dtime2 > dtime);
-TEST_CHECK(LastAccessTime(file) == file_access_time);
+TEST_CHECK(LastAccessTime(file) == file_access_time ||
+   LastAccessTime(file) == Clock::to_time_t(ftime2));
 TEST_CHECK(LastAccessTime(dir) == dir_access_time);
 }
 


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


Re: [libcxx] r278357 - test: relax the FS test a slight bit to be more reliable

2016-08-12 Thread Hans Wennborg via cfe-commits
On Thu, Aug 11, 2016 at 8:50 PM, Saleem Abdulrasool
 wrote:
> On Thu, Aug 11, 2016 at 9:58 AM, Saleem Abdulrasool via cfe-commits
>  wrote:
>>
>> Author: compnerd
>> Date: Thu Aug 11 11:58:12 2016
>> New Revision: 278357
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=278357&view=rev
>> Log:
>> test: relax the FS test a slight bit to be more reliable
>>
>> Some filesystems track atime always.  This relaxes the test to accept
>> either a
>> filesystem which does not accurately track atime or does track the atime
>> accurately.  This allows the test to pass on filesystems mounted with
>> `strictatime` on Linux or on macOS.
>
>
> Thoughts on merging this to 3.9?  It fixes tests on Linux.

Sounds good to me. r278538.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23452: [OpenCL] Release 3.9 notes

2016-08-12 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm!

Please commit to https://llvm.org/svn/llvm-project/cfe/branches/release_39 or 
let me know if you'd prefer me to do it.



Comment at: docs/ReleaseNotes.rst:206
@@ +205,3 @@
+- Supported extensions are now part of the target representation to give 
correct
+  diagnostics  for unsupported target features during compilation. For example,
+  when compiling for a target that does not support the double precision

very minor nit: there are two spaces after "diagnostics"


https://reviews.llvm.org/D23452



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


r278541 - CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-08-12 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri Aug 12 13:12:08 2016
New Revision: 278541

URL: http://llvm.org/viewvc/llvm-project?rev=278541&view=rev
Log:
CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

Summary:
This changes clang to use the llvm::lto::thinBackend function instead of
its own less comprehensive ThinLTO backend implementation.

Patch by Peter Collingbourne

Reviewers: tejohnson, mehdi_amini

Subscribers: cfe-commits, mehdi_amini

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=278541&r1=278540&r2=278541&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Aug 12 13:12:08 2016
@@ -29,9 +29,11 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/Timer.h"
@@ -74,8 +76,7 @@ private:
   /// Set LLVM command line options passed through -backend-option.
   void setCommandLineOpts();
 
-  void CreatePasses(legacy::PassManager &MPM, legacy::FunctionPassManager &FPM,
-ModuleSummaryIndex *ModuleSummary);
+  void CreatePasses(legacy::PassManager &MPM, legacy::FunctionPassManager 
&FPM);
 
   /// Generates the TargetMachine.
   /// Leaves TM unchanged if it is unable to create the target machine.
@@ -284,8 +285,7 @@ static void addSymbolRewriterPass(const
 }
 
 void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
-  legacy::FunctionPassManager &FPM,
-  ModuleSummaryIndex *ModuleSummary) {
+  legacy::FunctionPassManager &FPM) {
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
@@ -336,14 +336,6 @@ void EmitAssemblyHelper::CreatePasses(le
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
-  // If we are performing a ThinLTO importing compile, invoke the LTO
-  // pipeline and pass down the in-memory module summary index.
-  if (ModuleSummary) {
-PMBuilder.ModuleSummary = ModuleSummary;
-PMBuilder.populateThinLTOPassManager(MPM);
-return;
-  }
-
   // Add target-specific passes that need to run as early as possible.
   if (TM)
 PMBuilder.addExtension(
@@ -670,26 +662,6 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  // If we are performing a ThinLTO importing compile, load the function
-  // index into memory and pass it into CreatePasses, which will add it
-  // to the PassManagerBuilder and invoke LTO passes.
-  std::unique_ptr ModuleSummary;
-  if (!CodeGenOpts.ThinLTOIndexFile.empty()) {
-ErrorOr> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(
-CodeGenOpts.ThinLTOIndexFile, [&](const DiagnosticInfo &DI) {
-  TheModule->getContext().diagnose(DI);
-});
-if (std::error_code EC = IndexOrErr.getError()) {
-  std::string Error = EC.message();
-  errs() << "Error loading index file '" << CodeGenOpts.ThinLTOIndexFile
- << "': " << Error << "\n";
-  return;
-}
-ModuleSummary = std::move(IndexOrErr.get());
-assert(ModuleSummary && "Expected non-empty module summary index");
-  }
-
   legacy::PassManager PerModulePasses;
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
@@ -698,7 +670,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   PerFunctionPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
-  CreatePasses(PerModulePasses, PerFunctionPasses, ModuleSummary.get());
+  CreatePasses(PerModulePasses, PerFunctionPasses);
 
   legacy::PassManager CodeGenPasses;
   CodeGenPasses.add(
@@ -751,12 +723,71 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   }
 }
 
+static void runThinLTOBackend(const CodeGenOptions &CGOpts, Module *M,
+  std::unique_ptr OS) {
+  // If we are performing a ThinLTO importing compile, load the function index
+  // into memory and pass it into thinBackend, which will run the function
+  // importer and invoke LTO passes.
+  ErrorOr> IndexOrErr =
+  llvm::getModuleSummaryIndexForFile(
+  CGOpts.ThinLTOIndexFile,
+  [&](const DiagnosticInfo &DI) { M->getContext().diagnose(DI); });
+  if (std::error_code EC = IndexOrErr.getError()) {
+std::string Error = EC.message();
+  

Re: [PATCH] D21545: CodeGen: Replace ThinLTO backend implementation with a client of LTO/Resolution.

2016-08-12 Thread Teresa Johnson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278541: CodeGen: Replace ThinLTO backend implementation with 
a client of LTO/Resolution. (authored by tejohnson).

Changed prior to commit:
  https://reviews.llvm.org/D21545?vs=64043&id=67868#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21545

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CMakeLists.txt

Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -29,9 +29,11 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/Timer.h"
@@ -74,8 +76,7 @@
   /// Set LLVM command line options passed through -backend-option.
   void setCommandLineOpts();
 
-  void CreatePasses(legacy::PassManager &MPM, legacy::FunctionPassManager &FPM,
-ModuleSummaryIndex *ModuleSummary);
+  void CreatePasses(legacy::PassManager &MPM, legacy::FunctionPassManager &FPM);
 
   /// Generates the TargetMachine.
   /// Leaves TM unchanged if it is unable to create the target machine.
@@ -284,8 +285,7 @@
 }
 
 void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
-  legacy::FunctionPassManager &FPM,
-  ModuleSummaryIndex *ModuleSummary) {
+  legacy::FunctionPassManager &FPM) {
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
@@ -336,14 +336,6 @@
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
-  // If we are performing a ThinLTO importing compile, invoke the LTO
-  // pipeline and pass down the in-memory module summary index.
-  if (ModuleSummary) {
-PMBuilder.ModuleSummary = ModuleSummary;
-PMBuilder.populateThinLTOPassManager(MPM);
-return;
-  }
-
   // Add target-specific passes that need to run as early as possible.
   if (TM)
 PMBuilder.addExtension(
@@ -670,35 +662,15 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  // If we are performing a ThinLTO importing compile, load the function
-  // index into memory and pass it into CreatePasses, which will add it
-  // to the PassManagerBuilder and invoke LTO passes.
-  std::unique_ptr ModuleSummary;
-  if (!CodeGenOpts.ThinLTOIndexFile.empty()) {
-ErrorOr> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(
-CodeGenOpts.ThinLTOIndexFile, [&](const DiagnosticInfo &DI) {
-  TheModule->getContext().diagnose(DI);
-});
-if (std::error_code EC = IndexOrErr.getError()) {
-  std::string Error = EC.message();
-  errs() << "Error loading index file '" << CodeGenOpts.ThinLTOIndexFile
- << "': " << Error << "\n";
-  return;
-}
-ModuleSummary = std::move(IndexOrErr.get());
-assert(ModuleSummary && "Expected non-empty module summary index");
-  }
-
   legacy::PassManager PerModulePasses;
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
   legacy::FunctionPassManager PerFunctionPasses(TheModule);
   PerFunctionPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
-  CreatePasses(PerModulePasses, PerFunctionPasses, ModuleSummary.get());
+  CreatePasses(PerModulePasses, PerFunctionPasses);
 
   legacy::PassManager CodeGenPasses;
   CodeGenPasses.add(
@@ -751,12 +723,71 @@
   }
 }
 
+static void runThinLTOBackend(const CodeGenOptions &CGOpts, Module *M,
+  std::unique_ptr OS) {
+  // If we are performing a ThinLTO importing compile, load the function index
+  // into memory and pass it into thinBackend, which will run the function
+  // importer and invoke LTO passes.
+  ErrorOr> IndexOrErr =
+  llvm::getModuleSummaryIndexForFile(
+  CGOpts.ThinLTOIndexFile,
+  [&](const DiagnosticInfo &DI) { M->getContext().diagnose(DI); });
+  if (std::error_code EC = IndexOrErr.getError()) {
+std::string Error = EC.message();
+errs() << "Error loading index file '" << CGOpts.ThinLTOIndexFile
+   << "': " << Error << "\n";
+return;
+  }
+  std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
+
+  auto AddStream = [&](size_t Task) { return std::move(OS); };
+
+  StringMap>
+  ModuleToDefinedGVSummaries;
+  CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
+
+  // FIXME: We could simply import the modules mentioned in the combined index
+  // here.
+  FunctionImporter::ImportMapTy ImportList;

Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Zachary Turner via cfe-commits
Sounds good.  Just to be clear, you plan to delete the code from
clang-tidy, then take the code from clang-format and move it to clang-tidy,
and have clang-format call clang-tidy (or otherwise share the code somehow
so they both use the same implementation)?

I may still try to implement cross-block reordering in clang-tidy because
it's the only way to do it in such a way that it just warns you but doesn't
apply fixits, or applies them only if it doesn't break the compile, which
is what I need at the moment.  But since this is just experimental anyway,
it probably shouldn't matter much.  And if I end up getting something that
works reasonably well, we can always move that code over to clang-format if
we want to support cross-block reordering there.

On Fri, Aug 12, 2016 at 11:17 AM Daniel Jasper  wrote:

> I haven't read the patch, but if Alex is ok, so am I.. just wanted to make
> sure that we don't spend much more time on this, as we are likely going to
> remove most of the code..
>
> On Aug 12, 2016 6:42 PM, "Zachary Turner"  wrote:
>
>> Ahh, I see.  Just to be clear, is there an LGTM to get this path in?  I
>> know alexfh@ lgtm'ed it, want to make sure you're ok with this too.
>>
>> On Fri, Aug 12, 2016 at 9:40 AM Daniel Jasper  wrote:
>>
>>> The check's implementation will be replaced by a simple call to clang
>>> tidy. It will remain a check in clang tidy to continue to cater to both use
>>> cases.
>>>
>>> On Aug 12, 2016 6:19 PM, "Zachary Turner"  wrote:
>>>
 That's actually the reason I think it makes more sense in clang tidy.
 It can be a configuration option, off by default, and since there is more
 control over whether to apply fixits, and it doesn't apply fixits by
 default, it would be easier to iterate on the experimental nature of it
 without messing up code


 On Fri, Aug 12, 2016 at 9:14 AM Alexander Kornienko 
 wrote:

> alexfh added a comment.
>
> In https://reviews.llvm.org/D23434#513839, @djasper wrote:
>
> > I think we got confused. We once had tried to write an experimental
> separate check to comply with Google's style guide. If you want to fiddle
> around with that, contact me, I can send you pointers. But as I mentioned
> we moved away from that. And I think it makes more sense to re-create the
> sort-across-blocks functionality in clang-format and not in clang-tidy.
>
>
> Yep, we definitely got confused. That experimental check actually
> implemented cross-block sorting, but this caused a bunch of issues. Which
> makes me think that proper implementation of cross-block include sorting 
> is
> challenging be it in clang-format or clang-tidy. Clang-format probably
> makes it even more complex, since a higher safety of transformations is
> expected from it.
>
>
> https://reviews.llvm.org/D23434
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Daniel Jasper via cfe-commits
I haven't read the patch, but if Alex is ok, so am I.. just wanted to make
sure that we don't spend much more time on this, as we are likely going to
remove most of the code..

On Aug 12, 2016 6:42 PM, "Zachary Turner"  wrote:

> Ahh, I see.  Just to be clear, is there an LGTM to get this path in?  I
> know alexfh@ lgtm'ed it, want to make sure you're ok with this too.
>
> On Fri, Aug 12, 2016 at 9:40 AM Daniel Jasper  wrote:
>
>> The check's implementation will be replaced by a simple call to clang
>> tidy. It will remain a check in clang tidy to continue to cater to both use
>> cases.
>>
>> On Aug 12, 2016 6:19 PM, "Zachary Turner"  wrote:
>>
>>> That's actually the reason I think it makes more sense in clang tidy. It
>>> can be a configuration option, off by default, and since there is more
>>> control over whether to apply fixits, and it doesn't apply fixits by
>>> default, it would be easier to iterate on the experimental nature of it
>>> without messing up code
>>>
>>>
>>> On Fri, Aug 12, 2016 at 9:14 AM Alexander Kornienko 
>>> wrote:
>>>
 alexfh added a comment.

 In https://reviews.llvm.org/D23434#513839, @djasper wrote:

 > I think we got confused. We once had tried to write an experimental
 separate check to comply with Google's style guide. If you want to fiddle
 around with that, contact me, I can send you pointers. But as I mentioned
 we moved away from that. And I think it makes more sense to re-create the
 sort-across-blocks functionality in clang-format and not in clang-tidy.


 Yep, we definitely got confused. That experimental check actually
 implemented cross-block sorting, but this caused a bunch of issues. Which
 makes me think that proper implementation of cross-block include sorting is
 challenging be it in clang-format or clang-tidy. Clang-format probably
 makes it even more complex, since a higher safety of transformations is
 expected from it.


 https://reviews.llvm.org/D23434




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


r278543 - Reapply [VFS] Skip non existent files from the VFS tree

2016-08-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Aug 12 13:18:24 2016
New Revision: 278543

URL: http://llvm.org/viewvc/llvm-project?rev=278543&view=rev
Log:
Reapply [VFS] Skip non existent files from the VFS tree

Reapply r278457 with test fixed to not abouse fs case sensitivity.

When the VFS uses a YAML file, the real file path for a
virtual file is described in the "external-contents" field. Example:

  ...
  {
 'type': 'file',
 'name': 'a.h',
 'external-contents': '/a/b/c/a.h'
  }

Currently, when parsing umbrella directories, we use
vfs::recursive_directory_iterator to gather the header files to generate the
equivalent modules for. If the external contents for a header does not exist,
we currently are unable to build a module, since the VFS
vfs::recursive_directory_iterator will fail when it finds an entry without a
reliable real path.

Since the YAML file could be prepared ahead of time and shared among
different compiler invocations, an entry might not yet have a reliable
path in 'external-contents', breaking the iteration.

Give the VFS the capability to skip such entries whenever
'ignore-non-existent-contents' property is set in the YAML file.

rdar://problem/27531549

Added:
cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/A.h
cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/B.h
cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/C.h
cfe/trunk/test/VFS/Inputs/Bar.framework/Modules/module.modulemap
cfe/trunk/test/VFS/Inputs/bar-headers.yaml
cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m
Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=278543&r1=278542&r2=278543&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Aug 12 13:18:24 2016
@@ -1778,29 +1778,47 @@ VFSFromYamlDirIterImpl::VFSFromYamlDirIt
 RedirectingDirectoryEntry::iterator Begin,
 RedirectingDirectoryEntry::iterator End, std::error_code &EC)
 : Dir(_Path.str()), FS(FS), Current(Begin), End(End) {
-  if (Current != End) {
+  while (Current != End) {
 SmallString<128> PathStr(Dir);
 llvm::sys::path::append(PathStr, (*Current)->getName());
 llvm::ErrorOr S = FS.status(PathStr);
-if (S)
+if (S) {
   CurrentEntry = *S;
-else
+  return;
+}
+// Skip entries which do not map to a reliable external content.
+if (FS.ignoreNonExistentContents() &&
+S.getError() == llvm::errc::no_such_file_or_directory) {
+  ++Current;
+  continue;
+} else {
   EC = S.getError();
+  break;
+}
   }
 }
 
 std::error_code VFSFromYamlDirIterImpl::increment() {
   assert(Current != End && "cannot iterate past end");
-  if (++Current != End) {
+  while (++Current != End) {
 SmallString<128> PathStr(Dir);
 llvm::sys::path::append(PathStr, (*Current)->getName());
 llvm::ErrorOr S = FS.status(PathStr);
-if (!S)
-  return S.getError();
+if (!S) {
+  // Skip entries which do not map to a reliable external content.
+  if (FS.ignoreNonExistentContents() &&
+  S.getError() == llvm::errc::no_such_file_or_directory) {
+continue;
+  } else {
+return S.getError();
+  }
+}
 CurrentEntry = *S;
-  } else {
-CurrentEntry = Status();
+break;
   }
+
+  if (Current == End)
+CurrentEntry = Status();
   return std::error_code();
 }
 

Added: cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/A.h?rev=278543&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/A.h (added)
+++ cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/A.h Fri Aug 12 13:18:24 2016
@@ -0,0 +1 @@
+// A.h

Added: cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/B.h?rev=278543&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/B.h (added)
+++ cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/B.h Fri Aug 12 13:18:24 2016
@@ -0,0 +1 @@
+// B.h

Added: cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/C.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/C.h?rev=278543&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/C.h (added)
+++ cfe/trunk/test/VFS/Inputs/Bar.framework/Headers/C.h Fri Aug 12 13:18:24 2016
@@ -0,0 +1 @@
+// C.h

Added: cfe/trunk/test/VFS/Inputs/Bar.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Bar.fram

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread Richard Smith via cfe-commits
rsmith added a comment.

Attributes are specified in include/clang/Basic/Attr.td with a (hopefully) 
fairly self-explanatory declarative syntax. You'll then need to add code to 
lib/Sema/SemaDeclAttr.cpp to create a corresponding attribute object and attach 
it to the declaration.

Two implementation approaches seem feasible: either check that the VarDecl has 
constant initialization at the point when the attribute is attached in 
SemaDeclAttr.cpp, or attach the attribute without checking and instead perform 
the check from `Sema::CheckCompleteVariableDeclaration`, around where we 
currently call `isConstantInitializer` to produce a warning on non-constant 
initialization -- the effect of the attribute would then be to promote that 
warning to an error.


https://reviews.llvm.org/D23385



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


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-08-12 Thread Vedant Kumar via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D21695#513723, @filcab wrote:

> In https://reviews.llvm.org/D21695#510788, @vsk wrote:
>
> > After reading through the discussion in https://reviews.llvm.org/D19668, I 
> > don't think I understood the pros/cons of using a single ABI check (like 
> > asan does) versus adding version numbers to each handler routine. With the 
> > latter approach, wouldn't users only be able to link old object files with 
> > new runtimes if we never delete old checks? If that's the case, and 
> > assuming that we'd like to delete old checks, a single version symbol check 
> > would accomplish the same thing.
>
>
> With ASan it's very easy to add a single symbol for all of it, since it's a 
> single pass, and when it runs, instrumentation is added. For UBSan it depends 
> on it being enabled and you hitting a place where it checks for it. We can 
> emit the version check symbol in emitCheckHandlerCall, though.


Ah, yeah, I can see how this might be cumbersome.

> With split versioning, as long as the checks you enable don't get different 
> versions (it's rare that we change checks, too), they'll still work (arguably 
> this is not as valuable as I think it is, but things like Android frameworks 
> enabling UBSan checks in production might make it more valuable).


Running sanitized programs in production sounds strange to me. But, if there 
isn't really a cost to supporting this, I suppose it's fine.



Comment at: lib/CodeGen/CGExpr.cpp:2473
@@ +2472,3 @@
+  ("__ubsan_handle_" + CheckName +
+   (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "") +
+   (NeedsAbortSuffix ? "_abort" : ""))

filcab wrote:
> vsk wrote:
> > Wdyt of dropping the "_vN" component if the version is 0? That's one less 
> > compiler-rt change that we'd need.
> That's what it's doing:
>   (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "")
> 
Of course! My mistake.


https://reviews.llvm.org/D21695



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


Re: [PATCH] D22834: Added 'inline' attribute to basic_string's destructor

2016-08-12 Thread Aditya Kumar via cfe-commits
hiraditya added a comment.

In https://reviews.llvm.org/D22834#504425, @EricWF wrote:

> LGTM.
>
> However I would like to see a small benchmark that demonstrates the 
> performance change. Please try and write the benchmark using Google Benchmark.
>  Some helpful links:
>
> http://libcxx.llvm.org/docs/TestingLibcxx.html#building-benchmarks
>  http://github.com/google/benchmark
>
> Let me know if I can help.


Hi Eric,
Is this also good to merge.

Thanks,
-Aditya


https://reviews.llvm.org/D22834



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


Re: [PATCH] D23375: Add kfree( ) to MallocChecker.cpp

2016-08-12 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:593
@@ -590,1 +592,3 @@
+  if (FunI == II_free || FunI == II_realloc ||
+ FunI == II_reallocf || FunI == II_kfree)
 return true;

It looks like you are using tabs here. The LLVM style guide calls for spaces. 
http://llvm.org/docs/CodingStandards.html#use-spaces-instead-of-tabs

If you haven't seen it, the clang-format tool can help automatically format 
code to conform to LLVM's expected style.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:950
@@ -945,3 +949,3 @@
   // Iterate over the constructor parameters.
-  for (const auto *CtorParam : CtorD->parameters()) {
+  for (const auto *CtorParam : CtorD->params()) {
 

It looks like this method has recently been renamed "parameters()" and so your 
patch doesn't compile. Are you using top of trunk from the llvm.org repo?


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1296
@@ -1291,2 +1295,3 @@
 case AF_IfNameIndex: os << "'if_nameindex()'"; return;
+case AF_KMalloc: os <<"kmalloc()"; return;
 case AF_Alloca:

I think it would good to add a test that covers this code. There are analogous 
tests in test/Analysis/free.c -- that would be a good place for this added test.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1309
@@ -1303,2 +1308,3 @@
 case AF_IfNameIndex: os << "'if_freenameindex()'"; return;
+case AF_KMalloc: os << "kfree()"; return;
 case AF_Alloca:

Should there be a test for this case, as well? This would be exercised if code 
is allocated with kmalloc() and then freed in some way other than kfree (such 
as free() or delete). There are analogous tests in the MismatchedDeallocator 
test files.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2206
@@ -2198,2 +2205,3 @@
  isCMemFunction(FD, Ctx, AF_IfNameIndex,
-MemoryOperationKind::MOK_Free)))
+   MemoryOperationKind::MOK_Free) ||
+isCMemFunction(FD, Ctx, AF_KMalloc, MemoryOperationKind::MOK_Free)))

There are tabs on these two lines, as well.


https://reviews.llvm.org/D23375



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


Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-12 Thread Richard Smith via cfe-commits
rsmith added a comment.

Sorry about the redundant previous comment, the thread got forked by the change 
of subject and I missed the updated patch.



Comment at: lib/Sema/SemaDecl.cpp:10484-10485
@@ -10478,1 +10483,4 @@
 
+  if (var->hasAttr() && !Init)
+ Diag(var->getLocation(), diag::err_require_constant_init_failed);
+

I think this check is incorrect: we perform constant initialization (to zero) 
for globals with no initializer.


Comment at: lib/Sema/SemaDecl.cpp:10500
@@ +10499,3 @@
+if (!*HasConstInit)
+  Diag(var->getLocation(), diag::warn_global_constructor)
+<< Init->getSourceRange();

Instead of diagnosing the condition separately (and getting both a warning and 
an error for the same situation), it would seem preferable to change this to 
produce either `diag::warn_global_constructor` or your new error depending on 
whether the attribute is present. This would also remove the duplicate error 
messages if the attribute is specified on an object that is also marked 
`constexpr`.


https://reviews.llvm.org/D23385



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


Re: [PATCH] D23452: [OpenCL] Release 3.9 notes

2016-08-12 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Thanks! Is there a way to check the doc before committing? I am not sure how to 
make the html generated out of this.


https://reviews.llvm.org/D23452



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


Re: [PATCH] D23322: [OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2

2016-08-12 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D23322



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


Re: [PATCH] D23434: Don't allow llvm-include-order to intermingle includes from different files.

2016-08-12 Thread Zachary Turner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278546: Analyze include order on a per-file basis. (authored 
by zturner).

Changed prior to commit:
  https://reviews.llvm.org/D23434?vs=6&id=67876#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23434

Files:
  clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/cross-file-a.h
  clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/cross-file-b.h
  clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/cross-file-c.h
  clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
  clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp

Index: clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -12,6 +12,8 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 
+#include 
+
 namespace clang {
 namespace tidy {
 namespace llvm {
@@ -37,7 +39,9 @@
 bool IsAngled; ///< true if this was an include with angle brackets
 bool IsMainModule; ///< true if this was the first include in a file
   };
-  std::vector IncludeDirectives;
+
+  typedef std::vector FileIncludes;
+  std::map IncludeDirectives;
   bool LookForMainModule;
 
   ClangTidyCheck &Check;
@@ -80,7 +84,9 @@
 ID.IsMainModule = true;
 LookForMainModule = false;
   }
-  IncludeDirectives.push_back(std::move(ID));
+
+  // Bucket the include directives by the id of the file they were declared in.
+  IncludeDirectives[SM.getFileID(HashLoc)].push_back(std::move(ID));
 }
 
 void IncludeOrderPPCallbacks::EndOfMainFile() {
@@ -95,69 +101,73 @@
   // FIXME: We should be more careful about sorting below comments as we don't
   // know if the comment refers to the next include or the whole block that
   // follows.
-  std::vector Blocks(1, 0);
-  for (unsigned I = 1, E = IncludeDirectives.size(); I != E; ++I)
-if (SM.getExpansionLineNumber(IncludeDirectives[I].Loc) !=
-SM.getExpansionLineNumber(IncludeDirectives[I - 1].Loc) + 1)
-  Blocks.push_back(I);
-  Blocks.push_back(IncludeDirectives.size()); // Sentinel value.
-
-  // Get a vector of indices.
-  std::vector IncludeIndices;
-  for (unsigned I = 0, E = IncludeDirectives.size(); I != E; ++I)
-IncludeIndices.push_back(I);
-
-  // Sort the includes. We first sort by priority, then lexicographically.
-  for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI)
-std::sort(IncludeIndices.begin() + Blocks[BI],
-  IncludeIndices.begin() + Blocks[BI + 1],
-  [this](unsigned LHSI, unsigned RHSI) {
-  IncludeDirective &LHS = IncludeDirectives[LHSI];
-  IncludeDirective &RHS = IncludeDirectives[RHSI];
-
-  int PriorityLHS =
-  getPriority(LHS.Filename, LHS.IsAngled, LHS.IsMainModule);
-  int PriorityRHS =
-  getPriority(RHS.Filename, RHS.IsAngled, RHS.IsMainModule);
-
-  return std::tie(PriorityLHS, LHS.Filename) <
- std::tie(PriorityRHS, RHS.Filename);
-});
-
-  // Emit a warning for each block and fixits for all changes within that block.
-  for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI) {
-// Find the first include that's not in the right position.
-unsigned I, E;
-for (I = Blocks[BI], E = Blocks[BI + 1]; I != E; ++I)
-  if (IncludeIndices[I] != I)
-break;
-
-if (I == E)
-  continue;
-
-// Emit a warning.
-auto D = Check.diag(IncludeDirectives[I].Loc,
-"#includes are not sorted properly");
-
-// Emit fix-its for all following includes in this block.
-for (; I != E; ++I) {
-  if (IncludeIndices[I] == I)
-continue;
-  const IncludeDirective &CopyFrom = IncludeDirectives[IncludeIndices[I]];
-
-  SourceLocation FromLoc = CopyFrom.Range.getBegin();
-  const char *FromData = SM.getCharacterData(FromLoc);
-  unsigned FromLen = std::strcspn(FromData, "\n");
+  for (auto &Bucket : IncludeDirectives) {
+auto &FileDirectives = Bucket.second;
+std::vector Blocks(1, 0);
+for (unsigned I = 1, E = FileDirectives.size(); I != E; ++I)
+  if (SM.getExpansionLineNumber(FileDirectives[I].Loc) !=
+  SM.getExpansionLineNumber(FileDirectives[I - 1].Loc) + 1)
+Blocks.push_back(I);
+Blocks.push_back(FileDirectives.size()); // Sentinel value.
+
+// Get a vector of indices.
+std::vector IncludeIndices;
+for (unsigned I = 0, E = FileDirectives.size(); I != E; ++I)
+  IncludeIndices.push_back(I);
+
+// Sort the includes. We first sort by priority, then lexicographically.
+for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI)
+  std::sort(IncludeIndices.begin() + Blocks[BI],
+IncludeIndices.begin() + Blocks[BI + 1

[clang-tools-extra] r278546 - Analyze include order on a per-file basis.

2016-08-12 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Fri Aug 12 13:38:26 2016
New Revision: 278546

URL: http://llvm.org/viewvc/llvm-project?rev=278546&view=rev
Log:
Analyze include order on a per-file basis.

The include order check would get notified of all include
directives in a depth-first manner.  This created the
possibility of an include directive from a header file
interfering with the sort order of a set of two distinct
blocks from the top level cpp file, if that include directive
was on just the right line.

With this patch we bucket the include directives by the file
in which they appear in and process one bucket at a time,
so that directives from different files do not get mixed
together into the same list.

Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D23434

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/cross-file-a.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/cross-file-b.h
clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/cross-file-c.h
clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp

Modified: clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp?rev=278546&r1=278545&r2=278546&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp Fri Aug 12 
13:38:26 2016
@@ -12,6 +12,8 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 
+#include 
+
 namespace clang {
 namespace tidy {
 namespace llvm {
@@ -37,7 +39,9 @@ private:
 bool IsAngled; ///< true if this was an include with angle brackets
 bool IsMainModule; ///< true if this was the first include in a file
   };
-  std::vector IncludeDirectives;
+
+  typedef std::vector FileIncludes;
+  std::map IncludeDirectives;
   bool LookForMainModule;
 
   ClangTidyCheck &Check;
@@ -80,7 +84,9 @@ void IncludeOrderPPCallbacks::InclusionD
 ID.IsMainModule = true;
 LookForMainModule = false;
   }
-  IncludeDirectives.push_back(std::move(ID));
+
+  // Bucket the include directives by the id of the file they were declared in.
+  IncludeDirectives[SM.getFileID(HashLoc)].push_back(std::move(ID));
 }
 
 void IncludeOrderPPCallbacks::EndOfMainFile() {
@@ -95,69 +101,73 @@ void IncludeOrderPPCallbacks::EndOfMainF
   // FIXME: We should be more careful about sorting below comments as we don't
   // know if the comment refers to the next include or the whole block that
   // follows.
-  std::vector Blocks(1, 0);
-  for (unsigned I = 1, E = IncludeDirectives.size(); I != E; ++I)
-if (SM.getExpansionLineNumber(IncludeDirectives[I].Loc) !=
-SM.getExpansionLineNumber(IncludeDirectives[I - 1].Loc) + 1)
-  Blocks.push_back(I);
-  Blocks.push_back(IncludeDirectives.size()); // Sentinel value.
-
-  // Get a vector of indices.
-  std::vector IncludeIndices;
-  for (unsigned I = 0, E = IncludeDirectives.size(); I != E; ++I)
-IncludeIndices.push_back(I);
-
-  // Sort the includes. We first sort by priority, then lexicographically.
-  for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI)
-std::sort(IncludeIndices.begin() + Blocks[BI],
-  IncludeIndices.begin() + Blocks[BI + 1],
-  [this](unsigned LHSI, unsigned RHSI) {
-  IncludeDirective &LHS = IncludeDirectives[LHSI];
-  IncludeDirective &RHS = IncludeDirectives[RHSI];
-
-  int PriorityLHS =
-  getPriority(LHS.Filename, LHS.IsAngled, LHS.IsMainModule);
-  int PriorityRHS =
-  getPriority(RHS.Filename, RHS.IsAngled, RHS.IsMainModule);
-
-  return std::tie(PriorityLHS, LHS.Filename) <
- std::tie(PriorityRHS, RHS.Filename);
-});
-
-  // Emit a warning for each block and fixits for all changes within that 
block.
-  for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI) {
-// Find the first include that's not in the right position.
-unsigned I, E;
-for (I = Blocks[BI], E = Blocks[BI + 1]; I != E; ++I)
-  if (IncludeIndices[I] != I)
-break;
-
-if (I == E)
-  continue;
-
-// Emit a warning.
-auto D = Check.diag(IncludeDirectives[I].Loc,
-"#includes are not sorted properly");
-
-// Emit fix-its for all following includes in this block.
-for (; I != E; ++I) {
-  if (IncludeIndices[I] == I)
-continue;
-  const IncludeDirective &CopyFrom = IncludeDirectives[IncludeIndices[I]];
-
-  SourceLocation FromLoc = CopyFrom.Range.getBegin();
-  const char *FromData = SM.getCharacterData(FromLoc);
-  unsigned FromLen = std::strcspn(FromData, "\n");
+  for (auto &Bucket : IncludeDirectives) {
+auto &Fil

[clang-tools-extra] r278547 - Remove accidentally committed file.

2016-08-12 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Fri Aug 12 13:39:05 2016
New Revision: 278547

URL: http://llvm.org/viewvc/llvm-project?rev=278547&view=rev
Log:
Remove accidentally committed file.

Removed:
clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp

Removed: clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp?rev=278546&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- clang-cl /DTEST1 
/DFOO=foo /DBAR=bar | FileCheck -implicit-check-not="{{warning|error}}:" %s
-int *a = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#ifdef TEST1
-int *b = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#endif
-#define foo 1
-#define bar 1
-#if FOO
-int *c = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#endif
-#if BAR
-int *d = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#endif
\ No newline at end of file


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


  1   2   >