Re: [PATCH] D23530: Remove excessive padding from BarrierOp, PrefetchOp, PSBHintOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap updated this revision to Diff 68128.
alexshap added a comment.

Address code review comment


https://reviews.llvm.org/D23530

Files:
  lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -208,9 +208,9 @@
   };
 
   struct BarrierOp {
+const char *Data; 
+unsigned Length;
 unsigned Val; // Not the enum since not all values have names.
-const char *Data;
-unsigned Length;
   };
 
   struct SysRegOp {
@@ -226,15 +226,15 @@
   };
 
   struct PrefetchOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct PSBHintOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct ShiftExtendOp {


Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -208,9 +208,9 @@
   };
 
   struct BarrierOp {
+const char *Data; 
+unsigned Length;
 unsigned Val; // Not the enum since not all values have names.
-const char *Data;
-unsigned Length;
   };
 
   struct SysRegOp {
@@ -226,15 +226,15 @@
   };
 
   struct PrefetchOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct PSBHintOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct ShiftExtendOp {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r278773 - Default LIBCXXABI_LIBDIR_SUFFIX to LLVM_LIBDIR_SUFFIX

2016-08-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Aug 15 22:44:55 2016
New Revision: 278773

URL: http://llvm.org/viewvc/llvm-project?rev=278773=rev
Log:
Default LIBCXXABI_LIBDIR_SUFFIX to LLVM_LIBDIR_SUFFIX

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=278773=278772=278773=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Aug 15 22:44:55 2016
@@ -93,7 +93,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 set(LLVM_INCLUDE_TESTS OFF)
   endif()
 
-  set(LIBCXXABI_LIBDIR_SUFFIX "" CACHE STRING
+  set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
   "Define suffix of library directory name (32/64)")
 
   set(LIBCXXABI_BUILT_STANDALONE 1)


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


Re: [PATCH] D23485: [Branch 3.9] Remove any traces of partial constexpr lambda implementation (per Richard's request)

2016-08-15 Thread Faisal Vali via cfe-commits
faisalv closed this revision.
faisalv added a comment.

Closed by http://llvm.org/viewvc/llvm-project?view=revision=278771


https://reviews.llvm.org/D23485



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


Re: [clang-tools-extra] r278760 - [clang-rename] cleanup `auto` usages

2016-08-15 Thread Eric Fiselier via cfe-commits
On Mon, Aug 15, 2016 at 5:20 PM, Kirill Bobyrev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: omtcyfz
> Date: Mon Aug 15 18:20:05 2016
> New Revision: 278760
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278760=rev
> Log:
> [clang-rename] cleanup `auto` usages
>
> As Alexander pointed out, LLVM Coding Standards are more conservative about
> using auto, i.e. it should be used in the following situations:
>
> * When the type is obvious, i.e. explicitly mentioned in the same
> expression.
> For example `if (const clang::FieldDecl *FieldDecl =
> Initializer->getMember())`.
> * When the type is totally non-obvious and one iterates over something. For
> example
> `for (const auto  : Context.getTranslationUnitDecl()->decls())`.
>
> Otherwise the type should be explicitly stated.
>
> Reviewers: alexfh
>
> Differential Revision: https://reviews.llvm.org/D23397
>
> Modified:
> clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
> clang-tools-extra/trunk/clang-rename/USRFinder.cpp
> clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
> clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
>
> Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-rename/RenamingAction.cpp?rev=278760&
> r1=278759=278760=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
> +++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Mon Aug 15
> 18:20:05 2016
> @@ -52,7 +52,7 @@ public:
>void HandleOneRename(ASTContext , const std::string ,
> const std::string ,
> const std::vector ) {
> -const auto  = Context.getSourceManager();
> +const SourceManager  = Context.getSourceManager();
>  std::vector RenamingCandidates;
>  std::vector NewCandidates;
>
> @@ -61,7 +61,7 @@ public:
>  RenamingCandidates.insert(RenamingCandidates.end(),
> NewCandidates.begin(),
>NewCandidates.end());
>
> -auto PrevNameLen = PrevName.length();
> +unsigned PrevNameLen = PrevName.length();
>  for (const auto  : RenamingCandidates) {
>if (PrintLocations) {
>  FullSourceLoc FullLoc(Loc, SourceMgr);
> @@ -70,8 +70,8 @@ public:
> << FullLoc.getSpellingColumnNumber() << "\n";
>}
>// FIXME: better error handling.
> -  auto Replace = tooling::Replacement(SourceMgr, Loc, PrevNameLen,
> NewName);
> -  auto Err = FileToReplaces[Replace.getFilePath()].add(Replace);
> +  tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
> +  llvm::Error Err = FileToReplaces[Replace.
> getFilePath()].add(Replace);
>if (Err)
>  llvm::errs() << "Renaming failed in " << Replace.getFilePath() <<
> "! "
>   << llvm::toString(std::move(Err)) << "\n";
>
> Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-rename/USRFinder.cpp?rev=278760=278759=278760=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
> +++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Mon Aug 15
> 18:20:05 2016
> @@ -60,13 +60,13 @@ public:
>// Expression visitors:
>
>bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
> -const auto *Decl = Expr->getFoundDecl();
> +const NamedDecl *Decl = Expr->getFoundDecl();
>  return setResult(Decl, Expr->getLocation(),
>   Decl->getNameAsString().length());
>}
>
>bool VisitMemberExpr(const MemberExpr *Expr) {
> -const auto *Decl = Expr->getFoundDecl().getDecl();
> +const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
>  return setResult(Decl, Expr->getMemberLoc(),
>   Decl->getNameAsString().length());
>}
> @@ -74,9 +74,10 @@ public:
>// Other visitors:
>
>bool VisitTypeLoc(const TypeLoc Loc) {
> -const auto TypeBeginLoc = Loc.getBeginLoc();
> -const auto TypeEndLoc = Lexer::getLocForEndOfToken(
> -TypeBeginLoc, 0, Context.getSourceManager(),
> Context.getLangOpts());
> +const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
> +const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
> + TypeBeginLoc, 0, Context.getSourceManager(),
> + Context.getLangOpts());
>  if (const auto *TemplateTypeParm =
>  dyn_cast(Loc.getType())) {
>return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc,
> TypeEndLoc);
> @@ -117,7 +118,8 @@ public:
>// \returns false on success and sets Result.
>void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
>  while (NameLoc) {
> -  const auto *Decl = 

Re: [PATCH] D23530: Remove excessive padding from BarrierOp, PrefetchOp, PSBHintOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Yes: "Data, Length, Val" would work as well, i will update this diff


https://reviews.llvm.org/D23530



___
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-15 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 68121.
EricWF added a comment.

Do strict 'constant initializer' checking in C++11, but fall back to 
`isConstantInitializer()` in C++03. Add documentation about non-strict C++03 
checking.

This has weird results for POD types, for example:

  struct PODType { int x; int y; };
  __attribute__((require_constant_initialization)) PODType pod; // error in 
C++11, OK in C++03.


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,280 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_TWO \
+// RUN: -Wglobal-constructors -std=c++14 %s
+
+#if !__has_feature(cxx_static_assert)
+#define static_assert(b_, m_) _Static_assert(b_, m_)
+#endif
+
+#define ATTR __attribute__((require_constant_initialization)) // expected-note 0+ {{expanded from macro}}
+
+// 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}}
+ATTR int x = 42; // expected-error {{only applies to variables with static or thread}}
+ATTR extern int y;
+}
+struct ATTR class_mem { // expected-error {{only applies to variables with static or thread}}
+  ATTR int x; // expected-error {{only applies to variables with static or thread}}
+};
+
+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
+
+#if defined(TEST_ONE) // Test semantics of attribute
+
+// [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}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+ATTR static const int& global_init = glvalue_int;
+ATTR static const int& temp_init = 42;
+}
+
+ATTR const int& temp_ref = 42;
+ATTR const int& temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+ATTR const NonLit& nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+
+#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}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+
+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 

Re: [PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Thx, I don't have commit access, need smb to land this patch


https://reviews.llvm.org/D23536



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


Re: [PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a reviewer: arsenm.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D23536



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


Re: [PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Test plan: make -j8 check-llvm-unit

F2273124: Screen Shot 2016-08-15 at 5.14.59 PM.png 


F2273127: Screen Shot 2016-08-15 at 5.14.29 PM.png 



https://reviews.llvm.org/D23536



___
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-15 Thread Aaron Ballman via cfe-commits
On Mon, Aug 15, 2016 at 6:20 PM, Matthias Braun  wrote:
> MatzeB added a subscriber: MatzeB.
> MatzeB added a comment.
>
> The sanitizer code triggers this warning for code that looks conceptually 
> like this:
>
>   typedef struct Bla { char bar; int foo; } __attribute__((packed));
>
>   uintptr_t getu(struct Bla *b) { return (uintptr_t)>foo; }
>
> Resulting in:
>
>   taking address of packed member 'foo' of class or structure
> 'Bla' may result in an unaligned pointer value
> [-Waddress-of-packed-member]
>
> Of course the warning can be silenced with `return 
> (uintptr_t)(char*)>foo;` still casting to an int type seems like a benign 
> case for this warning so maybe we should exclude that?

I agree, it seems sensible to silence the warning in that case, yes.

~Aaron

>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D20561
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23530: Remove excessive padding from BarrierOp, PrefetchOp, PSBHintOp.

2016-08-15 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

The `Data` and `Length` fields are tied together.  Wouldn't it be possible to 
reorder this as `Val`, `Length`, `Data` and have it  achieve similar sizes and 
keep the `Data` and `Length` fields together?


https://reviews.llvm.org/D23530



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


Re: r278763 - PR28978: If we need overload resolution for the move constructor of an

2016-08-15 Thread Richard Smith via cfe-commits
Hi Hans, Eric Fiselier requested that we fix this bug for 3.9 (it affects
libc++'s std::optional implementation), so this would be a good candidate
for the branch.

On Mon, Aug 15, 2016 at 5:13 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Aug 15 19:13:47 2016
> New Revision: 278763
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278763=rev
> Log:
> PR28978: If we need overload resolution for the move constructor of an
> anonymous union member of a class, we need overload resolution for the move
> constructor of the class itself too; we can't rely on Sema to do the right
> thing for us for anonymous union types.
>
> Modified:
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
>
> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> DeclCXX.cpp?rev=278763=278762=278763=diff
> 
> ==
> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
> +++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 15 19:13:47 2016
> @@ -807,6 +807,17 @@ void CXXRecordDecl::addedMember(Decl *D)
>  data().DefaultedDestructorIsDeleted = true;
>  }
>
> +// For an anonymous union member, our overload resolution will
> perform
> +// overload resolution for its members.
> +if (Field->isAnonymousStructOrUnion()) {
> +  data().NeedOverloadResolutionForMoveConstructor |=
> +  FieldRec->data().NeedOverloadResolutionForMoveConstructor;
> +  data().NeedOverloadResolutionForMoveAssignment |=
> +  FieldRec->data().NeedOverloadResolutionForMoveAssignment;
> +  data().NeedOverloadResolutionForDestructor |=
> +  FieldRec->data().NeedOverloadResolutionForDestructor;
> +}
> +
>  // C++0x [class.ctor]p5:
>  //   A default constructor is trivial [...] if:
>  //-- for all the non-static data members of its class that
> are of
>
> Modified: cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/
> special/class.copy/p11.0x.move.cpp?rev=278763=278762&
> r2=278763=diff
> 
> ==
> --- cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp (original)
> +++ cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp Mon Aug 15
> 19:13:47 2016
> @@ -4,6 +4,9 @@ struct Trivial {};
>  struct NonTrivial {
>NonTrivial(NonTrivial&&); // expected-note{{copy constructor is
> implicitly deleted}}
>  };
> +struct DeletedCopy {
> +  DeletedCopy(const DeletedCopy&) = delete;
> +};
>
>  // A defaulted move constructor for a class X is defined as deleted if X
> has:
>
> @@ -22,6 +25,15 @@ struct DeletedNTVariant2 {
>  };
>  DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; //
> expected-error{{would delete}}
>
> +// Note, move constructor is not a candidate because it is deleted.
> +template struct DeletedNTVariant3 { // expected-note
> 2{{default}} expected-note 2{{copy}}
> +  union {
> +T NT;
> +  };
> +};
> +extern DeletedNTVariant3 dntv3a(0); // expected-error {{no
> matching}}
> +extern DeletedNTVariant3 dntv3a(0); // expected-error {{no
> matching}}
> +
>  // -- a non-static data member of class type M (or array thereof) that
> cannot be
>  //copied because overload resolution results in an ambiguity or a
> function
>  //that is deleted or inaccessible
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added a reviewer: tstellarAMD.
alexshap added a subscriber: cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".
Herald added subscribers: arsenm, aemerson.

The structs ImmOp and RegOp are in AArch64AsmParser.cpp (inside anonymous 
namespace).
This diff changes the order of fields and removes the excessive padding (8 
bytes).

https://reviews.llvm.org/D23536

Files:
  lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Index: lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
===
--- lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -136,18 +136,18 @@
   };
 
   struct ImmOp {
+int64_t Val;
+ImmTy Type;
 bool IsFPImm;
-ImmTy Type;
-int64_t Val;
 Modifiers Mods;
   };
 
   struct RegOp {
-unsigned RegNo;
-Modifiers Mods;
 const MCRegisterInfo *TRI;
 const MCSubtargetInfo *STI;
+unsigned RegNo;
 bool IsForcedVOP3;
+Modifiers Mods;
   };
 
   union {


Index: lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
===
--- lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -136,18 +136,18 @@
   };
 
   struct ImmOp {
+int64_t Val;
+ImmTy Type;
 bool IsFPImm;
-ImmTy Type;
-int64_t Val;
 Modifiers Mods;
   };
 
   struct RegOp {
-unsigned RegNo;
-Modifiers Mods;
 const MCRegisterInfo *TRI;
 const MCSubtargetInfo *STI;
+unsigned RegNo;
 bool IsForcedVOP3;
+Modifiers Mods;
   };
 
   union {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22794: [Sema] Propagate nullability when deducing type of auto

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

Is this really a good idea? If I write:

  int *_Nullable f();
  int n;
  int *_Nonnull g() {
auto *p = f();
if (!p) p = 
return p;
  }

... it would be wrong to produce a warning that I'm converting from a nullable 
pointer to a non-nullable pointer.


https://reviews.llvm.org/D22794



___
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-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

EricWF wrote:
> rsmith wrote:
> > In C++11 onwards, `checkInitIsICE` is the right thing to use in all cases. 
> > In C++98, `checkInitIsICE` is appropriate for globals of integral type; we 
> > do not have an implementation of strict constant expression checking for 
> > other types. Perhaps just documenting that (and maybe adding a FIXME here) 
> > is the best you can do for now, assuming you're not interested in 
> > implementing the C++98 rules.
> SGTM. I think I'll fall back to `isConstantInitializer()` in C++03. Do you 
> have an example of what `checkConstantInitializer()` gets wrong in C++03?
   struct A {
 ~A();
 int n;
   } a;
   int *p =  // constant initializer, but not a C++98 address constant 
expression


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] D22794: [Sema] Propagate nullability when deducing type of auto

2016-08-15 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.


Comment at: lib/Sema/SemaDecl.cpp:9739
@@ +9738,3 @@
+  DeducedType = DeducedType.setNullability(
+  Init->getType()->getNullability(Context), Context);
+

Do we propagate other attributes for deduced types?


https://reviews.llvm.org/D22794



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


Re: [PATCH] D22494: [analyzer] Explain why analyzer report is not generated (fix for PR12421).

2016-08-15 Thread Anton Yartsev via cfe-commits
ayartsev added a comment.

Ping.


https://reviews.llvm.org/D22494



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


r278763 - PR28978: If we need overload resolution for the move constructor of an

2016-08-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 15 19:13:47 2016
New Revision: 278763

URL: http://llvm.org/viewvc/llvm-project?rev=278763=rev
Log:
PR28978: If we need overload resolution for the move constructor of an
anonymous union member of a class, we need overload resolution for the move
constructor of the class itself too; we can't rely on Sema to do the right
thing for us for anonymous union types.

Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=278763=278762=278763=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 15 19:13:47 2016
@@ -807,6 +807,17 @@ void CXXRecordDecl::addedMember(Decl *D)
 data().DefaultedDestructorIsDeleted = true;
 }
 
+// For an anonymous union member, our overload resolution will perform
+// overload resolution for its members.
+if (Field->isAnonymousStructOrUnion()) {
+  data().NeedOverloadResolutionForMoveConstructor |=
+  FieldRec->data().NeedOverloadResolutionForMoveConstructor;
+  data().NeedOverloadResolutionForMoveAssignment |=
+  FieldRec->data().NeedOverloadResolutionForMoveAssignment;
+  data().NeedOverloadResolutionForDestructor |=
+  FieldRec->data().NeedOverloadResolutionForDestructor;
+}
+
 // C++0x [class.ctor]p5:
 //   A default constructor is trivial [...] if:
 //-- for all the non-static data members of its class that are of

Modified: cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp?rev=278763=278762=278763=diff
==
--- cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp (original)
+++ cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp Mon Aug 15 19:13:47 
2016
@@ -4,6 +4,9 @@ struct Trivial {};
 struct NonTrivial {
   NonTrivial(NonTrivial&&); // expected-note{{copy constructor is implicitly 
deleted}}
 };
+struct DeletedCopy {
+  DeletedCopy(const DeletedCopy&) = delete;
+};
 
 // A defaulted move constructor for a class X is defined as deleted if X has:
 
@@ -22,6 +25,15 @@ struct DeletedNTVariant2 {
 };
 DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; // 
expected-error{{would delete}}
 
+// Note, move constructor is not a candidate because it is deleted.
+template struct DeletedNTVariant3 { // expected-note 2{{default}} 
expected-note 2{{copy}}
+  union {
+T NT;
+  };
+};
+extern DeletedNTVariant3 dntv3a(0); // expected-error {{no 
matching}}
+extern DeletedNTVariant3 dntv3a(0); // expected-error {{no 
matching}}
+
 // -- a non-static data member of class type M (or array thereof) that cannot 
be
 //copied because overload resolution results in an ambiguity or a function
 //that is deleted or inaccessible


___
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-15 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

rsmith wrote:
> In C++11 onwards, `checkInitIsICE` is the right thing to use in all cases. In 
> C++98, `checkInitIsICE` is appropriate for globals of integral type; we do 
> not have an implementation of strict constant expression checking for other 
> types. Perhaps just documenting that (and maybe adding a FIXME here) is the 
> best you can do for now, assuming you're not interested in implementing the 
> C++98 rules.
SGTM. I think I'll fall back to `isConstantInitializer()` in C++03. Do you have 
an example of what `checkConstantInitializer()` gets wrong in C++03?


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] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-15 Thread Adrian McCarthy via cfe-commits
amccarth updated this revision to Diff 68114.
amccarth added a comment.

Added a test.


https://reviews.llvm.org/D23462

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-dllimport-base-class.cpp

Index: test/CodeGenCXX/debug-info-dllimport-base-class.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-dllimport-base-class.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -gcodeview 
-debug-info-kind=limited -fms-compatibility %s -x c++ -o - | FileCheck %s
+
+// Ensure we emit debug info for the full definition of base classes that will
+// be imported from a DLL.  Otherwise, the debugger wouldn't be able to show 
the
+// members.
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct __declspec(dllimport) ImportedBase {
+  ImportedBase();
+  virtual void Foo();
+};
+
+struct DerivedFromImported : public ImportedBase {};
+
+int main() {
+  DerivedFromImported d;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1685,7 +1685,8 @@
   if (!CXXDecl)
 return false;
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;


Index: test/CodeGenCXX/debug-info-dllimport-base-class.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-dllimport-base-class.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -gcodeview -debug-info-kind=limited -fms-compatibility %s -x c++ -o - | FileCheck %s
+
+// Ensure we emit debug info for the full definition of base classes that will
+// be imported from a DLL.  Otherwise, the debugger wouldn't be able to show the
+// members.
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct __declspec(dllimport) ImportedBase {
+  ImportedBase();
+  virtual void Foo();
+};
+
+struct DerivedFromImported : public ImportedBase {};
+
+int main() {
+  DerivedFromImported d;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1685,7 +1685,8 @@
   if (!CXXDecl)
 return false;
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-15 Thread Adrian McCarthy via cfe-commits
amccarth added a comment.

Thank, dblaikie, for correcting my terminology.


https://reviews.llvm.org/D23462



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


Re: [PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-08-15 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.
manmanren added a comment.

The fix looks reasonable to me.

Cheers,
Manman



Comment at: test/CodeGenObjCXX/encode.mm:231
@@ +230,3 @@
+struct S {
+  typedef T Ty;
+  Ty *t;

I wonder if we can further reduce the testing case. Is this necessary to cause 
the infinite recursion?


https://reviews.llvm.org/D22929



___
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-15 Thread Andrew Wells via cfe-commits
andrewmw94 added a comment.

I agree that more tests would be good.  Where should I put them? Should it be 
in a separate file or should I just have kmalloc/kfree tests next to the 
malloc/free ones?


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] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Art,

Thanks for the patch! That looks good.


https://reviews.llvm.org/D23526



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


Buildbot numbers for the last week of 8/07/2016 - 8/13/2016

2016-08-15 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 8/07/2016 - 8/13/2016.

Please see the same data in attached csv files:

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

Thanks

Galina


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

 buildername|  was_red
+---
 lldb-windows7-android  | 58:07:37
 clang-ppc64be-linux-lnt| 30:43:16
 clang-native-aarch64-full  | 26:00:07
 libcxx-libcxxabi-libunwind-arm-linux-noexceptions  | 24:33:36
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 24:14:15
 libcxx-libcxxabi-libunwind-arm-linux   | 23:14:43
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu | 22:38:52
 clang-cmake-armv7-a15-selfhost-neon| 18:00:25
 clang-cmake-thumbv7-a15-full-sh| 17:46:36
 clang-cmake-armv7-a15-selfhost | 16:41:55
 clang-ppc64le-linux-multistage | 15:50:57
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 14:17:49
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 14:14:15
 sanitizer-ppc64be-linux| 13:53:48
 sanitizer-ppc64le-linux| 13:14:27
 clang-ppc64be-linux-multistage | 13:04:22
 sanitizer-x86_64-linux | 13:00:15
 clang-native-arm-lnt   | 12:19:32
 clang-x86-win2008-selfhost | 10:05:12
 clang-x64-ninja-win7   | 10:00:44
 sanitizer-x86_64-linux-bootstrap   | 09:34:04
 sanitizer-windows  | 09:29:19
 clang-cmake-armv7-a15-full | 08:39:13
 clang-cmake-thumbv7-a15| 08:36:47
 clang-cmake-armv7-a15  | 08:36:08
 sanitizer-x86_64-linux-fast| 08:31:37
 clang-atom-d525-fedora-rel | 08:15:31
 clang-cmake-mips   | 07:15:00
 perf-x86_64-penryn-O3-polly| 06:24:47
 perf-x86_64-penryn-O3-polly-fast   | 06:03:32
 clang-ppc64le-linux| 05:28:22
 lldb-x86_64-ubuntu-14.04-android   | 05:17:18
 llvm-mips-linux| 05:10:10
 clang-ppc64be-linux| 04:49:44
 clang-cmake-aarch64-quick  | 04:22:23
 clang-ppc64le-linux-lnt| 04:17:03
 llvm-clang-lld-x86_64-debian-fast  | 04:11:50
 clang-cmake-aarch64-42vma  | 03:46:22
 polly-amd64-linux  | 03:27:00
 clang-cmake-aarch64-full   | 03:04:35
 lldb-x86_64-darwin-13.4| 02:55:02
 clang-x86_64-debian-fast   | 02:42:25
 lldb-x86_64-ubuntu-14.04-cmake | 02:31:13
 clang-bpf-build| 02:15:46
 clang-cuda-build   | 02:14:35
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 02:14:03
 llvm-sphinx-docs   | 02:08:21
 libomp-ompt-gcc-x86_64-linux-debian| 02:05:29
 libomp-gcc-x86_64-linux-debian | 02:05:24
 perf-x86_64-penryn-O3-polly-unprofitable   | 02:03:12
 lldb-x86_64-ubuntu-14.04-buildserver   | 01:49:26
 perf-x86_64-penryn-O3-polly-parallel-fast  | 01:44:41
 sanitizer-x86_64-linux-fuzzer  | 01:15:34
 clang-3stage-ubuntu| 01:10:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03 | 01:08:59
 sanitizer-x86_64-linux-autoconf| 01:02:47
 llvm-hexagon-elf   | 00:59:27
 clang-hexagon-elf  | 00:59:10
 clang-x86_64-linux-abi-test| 00:47:13
 lld-x86_64-win7

Buildbot numbers for the week of 7/31/2016 - 8/06/2016

2016-08-15 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 7/31/2016 - 8/06/2016.

Please see the same data in attached csv files:

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

Thanks

Galina


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

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


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

 buildername 

Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
omtcyfz marked an inline comment as done.
Closed by commit rL278760: [clang-rename] cleanup `auto` usages (authored by 
omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D23397?vs=68104=68107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23397

Files:
  clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRFinder.cpp
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Index: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp
@@ -60,23 +60,24 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 return setResult(Decl, Expr->getLocation(),
  Decl->getNameAsString().length());
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 return setResult(Decl, Expr->getMemberLoc(),
  Decl->getNameAsString().length());
   }
 
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
-const auto TypeBeginLoc = Loc.getBeginLoc();
-const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
+const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
+ TypeBeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());
 if (const auto *TemplateTypeParm =
 dyn_cast(Loc.getType())) {
   return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
@@ -117,7 +118,8 @@
   // \returns false on success and sets Result.
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
   NameLoc = NameLoc.getPrefix();
 }
@@ -173,14 +175,13 @@
 
 const NamedDecl *getNamedDeclAt(const ASTContext ,
 const SourceLocation Point) {
-  const auto SearchFile = Context.getSourceManager().getFilename(Point);
+  StringRef SearchFile = Context.getSourceManager().getFilename(Point);
   NamedDeclFindingASTVisitor Visitor(Point, Context);
 
   // We only want to search the decls that exist in the same file as the point.
-  auto Decls = Context.getTranslationUnitDecl()->decls();
-  for (auto  : Decls) {
-const auto FileLoc = CurrDecl->getLocStart();
-const auto FileName = Context.getSourceManager().getFilename(FileLoc);
+  for (const auto *CurrDecl : Context.getTranslationUnitDecl()->decls()) {
+const SourceLocation FileLoc = CurrDecl->getLocStart();
+StringRef FileName = Context.getSourceManager().getFilename(FileLoc);
 // FIXME: Add test.
 if (FileName == SearchFile) {
   Visitor.TraverseDecl(CurrDecl);
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -67,7 +67,7 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager  = Decl->getASTContext().getSourceManager();
@@ -79,7 +79,7 @@
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager  = Decl->getASTContext().getSourceManager();
   SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
@@ -116,7 +116,8 @@
   // Namespace traversal:
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   if (Decl && USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
 checkAndAddLocation(NameLoc.getLocalBeginLoc());
   }
@@ -126,8 +127,8 @@
 
 private:
   void checkAndAddLocation(SourceLocation Loc) {
-   

[clang-tools-extra] r278760 - [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Aug 15 18:20:05 2016
New Revision: 278760

URL: http://llvm.org/viewvc/llvm-project?rev=278760=rev
Log:
[clang-rename] cleanup `auto` usages

As Alexander pointed out, LLVM Coding Standards are more conservative about
using auto, i.e. it should be used in the following situations:

* When the type is obvious, i.e. explicitly mentioned in the same expression.
For example `if (const clang::FieldDecl *FieldDecl = Initializer->getMember())`.
* When the type is totally non-obvious and one iterates over something. For
example
`for (const auto  : Context.getTranslationUnitDecl()->decls())`.

Otherwise the type should be explicitly stated.

Reviewers: alexfh

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

Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
clang-tools-extra/trunk/clang-rename/USRFinder.cpp
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.cpp?rev=278760=278759=278760=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Mon Aug 15 18:20:05 
2016
@@ -52,7 +52,7 @@ public:
   void HandleOneRename(ASTContext , const std::string ,
const std::string ,
const std::vector ) {
-const auto  = Context.getSourceManager();
+const SourceManager  = Context.getSourceManager();
 std::vector RenamingCandidates;
 std::vector NewCandidates;
 
@@ -61,7 +61,7 @@ public:
 RenamingCandidates.insert(RenamingCandidates.end(), NewCandidates.begin(),
   NewCandidates.end());
 
-auto PrevNameLen = PrevName.length();
+unsigned PrevNameLen = PrevName.length();
 for (const auto  : RenamingCandidates) {
   if (PrintLocations) {
 FullSourceLoc FullLoc(Loc, SourceMgr);
@@ -70,8 +70,8 @@ public:
<< FullLoc.getSpellingColumnNumber() << "\n";
   }
   // FIXME: better error handling.
-  auto Replace = tooling::Replacement(SourceMgr, Loc, PrevNameLen, 
NewName);
-  auto Err = FileToReplaces[Replace.getFilePath()].add(Replace);
+  tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
+  llvm::Error Err = FileToReplaces[Replace.getFilePath()].add(Replace);
   if (Err)
 llvm::errs() << "Renaming failed in " << Replace.getFilePath() << "! "
  << llvm::toString(std::move(Err)) << "\n";

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=278760=278759=278760=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Mon Aug 15 18:20:05 2016
@@ -60,13 +60,13 @@ public:
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 return setResult(Decl, Expr->getLocation(),
  Decl->getNameAsString().length());
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 return setResult(Decl, Expr->getMemberLoc(),
  Decl->getNameAsString().length());
   }
@@ -74,9 +74,10 @@ public:
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
-const auto TypeBeginLoc = Loc.getBeginLoc();
-const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
+const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
+ TypeBeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());
 if (const auto *TemplateTypeParm =
 dyn_cast(Loc.getType())) {
   return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
@@ -117,7 +118,8 @@ public:
   // \returns false on success and sets Result.
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
   NameLoc = NameLoc.getPrefix();
 }
@@ -173,14 +175,13 @@ private:
 
 const NamedDecl *getNamedDeclAt(const ASTContext ,

[PATCH] D23533: [clang-tidy] Rewrite compilation database test to not require shell

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

This allows the test to run on windows, and also makes writing compilation 
database tests easier in general.  See D23532 for more information.

https://reviews.llvm.org/D23533

Files:
  test/clang-tidy/Inputs/compilation-database/a/a.cpp
  test/clang-tidy/Inputs/compilation-database/a/b.cpp
  test/clang-tidy/Inputs/compilation-database/b/b.cpp
  test/clang-tidy/Inputs/compilation-database/b/c.cpp
  test/clang-tidy/Inputs/compilation-database/b/d.cpp
  test/clang-tidy/Inputs/compilation-database/clang-tidy-database.json
  test/clang-tidy/Inputs/compilation-database/include/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- test/clang-tidy/clang-tidy-run-with-database.cpp
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -1,24 +1,35 @@
-// REQUIRES: shell
-// RUN: mkdir -p %T/compilation-database-test/include
-// RUN: mkdir -p %T/compilation-database-test/a
-// RUN: mkdir -p %T/compilation-database-test/b
-// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp
-// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp
-// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp
-// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp
-// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
-// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
-// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.*
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix
-// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
-// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
-// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3
-// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4
-// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %S/Inputs/compilation-database/clang-tidy-database.json \
+// RUN: -r %S/Inputs/compilation-database %S/Inputs/compilation-database/a/a.cpp %S/Inputs/compilation-database/a/b.cpp \
+// RUN: %S/Inputs/compilation-database/b/b.cpp %S/Inputs/compilation-database/b/c.cpp %S/Inputs/compilation-database/b/d.cpp \
+// RUN: -header-filter=.* -export-fixes=%t.yaml > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s
+// RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
 
-// CHECK-FIX1: int *AA = nullptr;
-// CHECK-FIX2: int *AB = nullptr;
-// CHECK-FIX3: int *BB = nullptr;
-// CHECK-FIX4: int *BC = nullptr;
-// CHECK-FIX5: int *HP = nullptr;
+// CHECK-MESSAGES: int *AA = 0;
+// CHECK-MESSAGES: int *AB = 0;
+// CHECK-MESSAGES: int *BB = 0;
+// CHECK-MESSAGES: int *BC = 0;
+// CHECK-MESSAGES: int *HP = 0;
+
+// CHECK-YAML: MainSourceFile:  ''
+// CHECK-YAML: Replacements:
+// CHECK-YAML:   - FilePath:a.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:b.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:b{{[/\\]}}b.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:..{{[/\\]}}b{{[/\\]}}c.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:'..{{[/\\]}}include{{[/\\]}}header.h'
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
\ No newline at end of file
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- test/clang-tidy/Inputs/compilation-database/template.json
+++ /dev/null
@@ -1,32 +0,0 @@
-[
-{
-  "directory": "test_dir/a",
-  "command": "clang++ -o test.o test_dir/a/a.cpp",
-  "file": "test_dir/a/a.cpp"
-},
-{
-  "directory": "test_dir/a",
-  "command": "clang++ -o test.o 

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

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:858
@@ +857,3 @@
+  };
+  SAFE_STATIC T x = {42}; // OK.
+  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer

Sure, if that's a conscious design decision for the attribute.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6842
@@ +6841,3 @@
+
+def err_require_constant_init_failed : Error<
+  "variable does not have a constant initializer as required by the "

A separate note pointed at the attribute would make it clearer how the 
attribute got involved (especially via the macro expansion backtrace).


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

In C++11 onwards, `checkInitIsICE` is the right thing to use in all cases. In 
C++98, `checkInitIsICE` is appropriate for globals of integral type; we do not 
have an implementation of strict constant expression checking for other types. 
Perhaps just documenting that (and maybe adding a FIXME here) is the best you 
can do for now, assuming you're not interested in implementing the C++98 rules.


https://reviews.llvm.org/D23385



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


[PATCH] D23532: [LibTooling] Allow compilation database to explicitly specify compilation database file and source root

2016-08-15 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added a reviewer: cfe-commits.
zturner added subscribers: klimek, alexfh, djasper.

Allow explicit specification of a compilation database file and source root.

While trying to create a compilation database test for D23455, I ran into the 
problem that compilation database tests require a command shell, evidenced by 
the fact that at the top of `clang-tidy-run-with-database-cpp` contains the 
line `REQUIRES: SHELL`.  This makes it impossible to write the test that was 
requested in D23455 (not to mention it means the existing test is not running 
on Windows either).

I solve this by introducing a new command line parameter and slightly enhancing 
the functionality of an existing one, detailed below:

1. There was no way to specify an arbitrary compilation database.  At best you 
could specify the directory of a compilation database, but it would still be 
forced to look for `compile_commands.json`.  This is an inflexible design when 
you want to have multiple tests which each use their own compilation database.  
You could put them in different folders and call each one 
`compile_commands.json`, but that leads to many different directories with only 
one file, which is kind of silly.

The `-p` option let you specify a build path, which would be the folder where a 
compilation database existed, but it did not let you specify a *specific file* 
to use as a compilation database.  I improved expanded this behavior of this 
option to check if the specified path is a regular file or a directory.  If it 
is a regular file it doesn't search for a compilation database, and instead 
just uses the file you specify.  The nice thing about this is that now we can 
put many compilation databases for various tests in the same directory, and 
have the run line of the test reference the exact compilation database needed 
for the test.

2. Instead of a "real" compilation database, the test consisted of a template.  
And the test used shell in order to invoke `sed` to modify the template so that 
the files and directories would be correct.  So the test would output the 
modified template into the CMake output directory, and then it had to use more 
shell commands to copy the source files over to the CMake output directory so 
that they would be in the right hierarchy in order to be found by the relative 
paths written to the compilation database.

In order to remove the dependency on shell, we need a way to reference the 
source files in their original location in the source tree, and not require 
them to be copied to the output tree.  To do this I introduced a new command 
line option `-r` that lets you specify the root at which relative paths are 
resolved against.  

These two things combined eliminate the need to modify the compilation database 
with `sed` and write it to the output folder because we can write *actual* 
source code on disk and check it in for the tests, and the compilation database 
can refer to these files using actual relative paths.  Then because of #1, the 
run line can point directly to the compilation database in question.

I re-wrote the compilation database test to use this new method, and it now no 
longer depends on shell.  I will upload the re-written test in a separate patch 
since I can't do cross-repo diffs.

https://reviews.llvm.org/D23532

Files:
  include/clang/Tooling/CompilationDatabase.h
  include/clang/Tooling/JSONCompilationDatabase.h
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/JSONCompilationDatabase.cpp
  lib/Tooling/Tooling.cpp

Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -407,10 +407,12 @@
   // difference for example on network filesystems, where symlinks might be
   // switched during runtime of the tool. Fixing this depends on having a
   // file system abstraction that allows openat() style interactions.
-  if (OverlayFileSystem->setCurrentWorkingDirectory(
-  CompileCommand.Directory))
-llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+  if (!CompileCommand.Directory.empty()) {
+if (OverlayFileSystem->setCurrentWorkingDirectory(
+CompileCommand.Directory))
+  llvm::report_fatal_error("Cannot chdir into \"" +
+   Twine(CompileCommand.Directory) + "\n!");
+  }
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,10 +16,12 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 

Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked 2 inline comments as done.


Comment at: clang-rename/USRFinder.cpp:182-184
@@ -179,6 +181,5 @@
   // We only want to search the decls that exist in the same file as the point.
-  auto Decls = Context.getTranslationUnitDecl()->decls();
-  for (auto  : Decls) {
-const auto FileLoc = CurrDecl->getLocStart();
-const auto FileName = Context.getSourceManager().getFilename(FileLoc);
+  for (const auto *CurrDecl : Context.getTranslationUnitDecl()->decls()) {
+const SourceLocation FileLoc = CurrDecl->getLocStart();
+StringRef FileName = Context.getSourceManager().getFilename(FileLoc);
 // FIXME: Add test.

Aww, sure. Thanks!


https://reviews.llvm.org/D23397



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


Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 68104.
omtcyfz added a comment.

Address comments.


https://reviews.llvm.org/D23397

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/USRFinder.cpp
  clang-rename/USRFindingAction.cpp
  clang-rename/USRLocFinder.cpp

Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -67,7 +67,7 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager  = Decl->getASTContext().getSourceManager();
@@ -79,7 +79,7 @@
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager  = Decl->getASTContext().getSourceManager();
   SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
@@ -116,7 +116,8 @@
   // Namespace traversal:
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   if (Decl && USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
 checkAndAddLocation(NameLoc.getLocalBeginLoc());
   }
@@ -126,8 +127,8 @@
 
 private:
   void checkAndAddLocation(SourceLocation Loc) {
-const auto BeginLoc = Loc;
-const auto EndLoc = Lexer::getLocForEndOfToken(
+const SourceLocation BeginLoc = Loc;
+const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
 BeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
 StringRef TokenName =
 Lexer::getSourceText(CharSourceRange::getTokenRange(BeginLoc, EndLoc),
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -116,14 +116,14 @@
 
   void addUSRsOfOverridenFunctions(const CXXMethodDecl *MethodDecl) {
 USRSet.insert(getUSRForDecl(MethodDecl));
-for (auto  : MethodDecl->overridden_methods()) {
+for (const auto  : MethodDecl->overridden_methods()) {
   // Recursively visit each OverridenMethod.
   addUSRsOfOverridenFunctions(OverriddenMethod);
 }
   }
 
   bool checkIfOverriddenFunctionAscends(const CXXMethodDecl *MethodDecl) {
-for (auto  : MethodDecl->overridden_methods()) {
+for (const auto  : MethodDecl->overridden_methods()) {
   if (USRSet.find(getUSRForDecl(OverriddenMethod)) != USRSet.end()) {
 return true;
   }
@@ -143,10 +143,11 @@
 
 struct NamedDeclFindingConsumer : public ASTConsumer {
   void HandleTranslationUnit(ASTContext ) override {
-const auto  = Context.getSourceManager();
+const SourceManager  = Context.getSourceManager();
 // The file we look for the USR in will always be the main source file.
-const auto Point = SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID())
-   .getLocWithOffset(SymbolOffset);
+const SourceLocation Point =
+SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID())
+.getLocWithOffset(SymbolOffset);
 if (!Point.isValid())
   return;
 const NamedDecl *FoundDecl = nullptr;
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -60,23 +60,24 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 return setResult(Decl, Expr->getLocation(),
  Decl->getNameAsString().length());
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 return setResult(Decl, Expr->getMemberLoc(),
  Decl->getNameAsString().length());
   }
 
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
-const auto TypeBeginLoc = Loc.getBeginLoc();
-const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
+const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
+ TypeBeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());
 if (const auto *TemplateTypeParm =
 dyn_cast(Loc.getType())) {
   return 

Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

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

LG with a couple of nits.



Comment at: clang-rename/USRFinder.cpp:182
@@ -179,5 +181,3 @@
   // We only want to search the decls that exist in the same file as the point.
-  auto Decls = Context.getTranslationUnitDecl()->decls();
-  for (auto  : Decls) {
-const auto FileLoc = CurrDecl->getLocStart();
-const auto FileName = Context.getSourceManager().getFilename(FileLoc);
+  for (const auto  : Context.getTranslationUnitDecl()->decls()) {
+const SourceLocation FileLoc = CurrDecl->getLocStart();

Should this be `const auto *` instead?


Comment at: clang-rename/USRLocFinder.cpp:132
@@ +131,3 @@
+const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+ BeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());

I suspect, clang-format will join the arguments to one line. Can you try? 
(maybe just `git clang-format`)


https://reviews.llvm.org/D23397



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


Re: [PATCH] D23242: [CUDA] Raise an error if a wrong-side call is codegen'ed.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278759: [CUDA] Raise an error if a wrong-side call is 
codegen'ed. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23242?vs=67378=68103#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23242

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CodeGenCUDA/host-device-calls-host.cu
  cfe/trunk/test/SemaCUDA/Inputs/cuda.h
  cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
  cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9186,6 +9186,18 @@
   void maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *FD,
const LookupResult );
 
+  /// Check whether we're allowed to call Callee from the current context.
+  ///
+  /// If the call is never allowed in a semantically-correct program
+  /// (CFP_Never), emits an error and returns false.
+  ///
+  /// If the call is allowed in semantically-correct programs, but only if it's
+  /// never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to be
+  /// emitted if and when the caller is codegen'ed, and returns true.
+  ///
+  /// Otherwise, returns true without emitting any diagnostics.
+  bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
+
   /// Finds a function in \p Matches with highest calling priority
   /// from \p Caller context and erases all functions with lower
   /// calling priority.
Index: cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
===
--- cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
+++ cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - -verify
+
+// Note: This test won't work with -fsyntax-only, because some of these errors
+// are emitted during codegen.
+
+#include "Inputs/cuda.h"
+
+extern "C" void host_fn() {}
+
+struct S {
+  S() {}
+  ~S() { host_fn(); }
+  int x;
+};
+
+struct T {
+  __host__ __device__ void hd() { host_fn(); }
+  // expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+
+  // No error; this is (implicitly) inline and is never called, so isn't
+  // codegen'ed.
+  __host__ __device__ void hd2() { host_fn(); }
+
+  __host__ __device__ void hd3();
+
+  void h() {}
+};
+
+__host__ __device__ void T::hd3() {
+  host_fn();
+  // expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+}
+
+template  __host__ __device__ void hd2() { host_fn(); }
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+__global__ void kernel() { hd2(); }
+
+__host__ __device__ void hd() { host_fn(); }
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+
+template  __host__ __device__ void hd3() { host_fn(); }
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+__device__ void device_fn() { hd3(); }
+
+// No error because this is never instantiated.
+template  __host__ __device__ void hd4() { host_fn(); }
+
+__host__ __device__ void local_var() {
+  S s;
+  // expected-error@-1 {{reference to __host__ function 'S' in __host__ __device__ function}}
+}
+
+__host__ __device__ void placement_new(char *ptr) {
+  ::new(ptr) S();
+  // expected-error@-1 {{reference to __host__ function 'S' in __host__ __device__ function}}
+}
+
+__host__ __device__ void explicit_destructor(S *s) {
+  s->~S();
+  // expected-error@-1 {{reference to __host__ function '~S' in __host__ __device__ function}}
+}
+
+__host__ __device__ void hd_member_fn() {
+  T t;
+  // Necessary to trigger an error on T::hd.  It's (implicitly) inline, so
+  // isn't codegen'ed until we call it.
+  t.hd();
+}
+
+__host__ __device__ void h_member_fn() {
+  T t;
+  t.h();
+  // expected-error@-1 {{reference to __host__ function 'h' in __host__ __device__ function}}
+}
+
+__host__ __device__ void fn_ptr() {
+  auto* ptr = _fn;
+  // expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+}
+
+template 
+__host__ __device__ void fn_ptr_template() {
+  auto* ptr = _fn;  // Not an error because the template isn't instantiated.
+}
Index: cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
===
--- cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
+++ cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple 

r278759 - [CUDA] Raise an error if a wrong-side call is codegen'ed.

2016-08-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Aug 15 18:00:49 2016
New Revision: 278759

URL: http://llvm.org/viewvc/llvm-project?rev=278759=rev
Log:
[CUDA] Raise an error if a wrong-side call is codegen'ed.

Summary:
Some function calls in CUDA are allowed to appear in
semantically-correct programs but are an error if they're ever
codegen'ed.  Specifically, a host+device function may call a host
function, but it's an error if such a function is ever codegen'ed in
device mode (and vice versa).

Previously, clang made no attempt to catch these errors.  For the most
part, they would be caught by ptxas, and reported as "call to unknown
function 'foo'".

Now we catch these errors and report them the same as we report other
illegal calls (e.g. a call from a host function to a device function).

This has a small change in error-message behavior for calls that were
previously disallowed (e.g. calls from a host to a device function).
Previously, we'd catch disallowed calls fairly early, before doing
additional semantic checking e.g. of the call's arguments.  Now we catch
these illegal calls at the very end of our semantic checks, so we'll
only emit a "illegal CUDA call" error if the call is otherwise
well-formed.

Reviewers: tra, rnk

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
Removed:
cfe/trunk/test/CodeGenCUDA/host-device-calls-host.cu
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCUDA/Inputs/cuda.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=278759=278758=278759=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Aug 15 18:00:49 2016
@@ -9186,6 +9186,18 @@ public:
   void maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *FD,
const LookupResult );
 
+  /// Check whether we're allowed to call Callee from the current context.
+  ///
+  /// If the call is never allowed in a semantically-correct program
+  /// (CFP_Never), emits an error and returns false.
+  ///
+  /// If the call is allowed in semantically-correct programs, but only if it's
+  /// never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to be
+  /// emitted if and when the caller is codegen'ed, and returns true.
+  ///
+  /// Otherwise, returns true without emitting any diagnostics.
+  bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
+
   /// Finds a function in \p Matches with highest calling priority
   /// from \p Caller context and erases all functions with lower
   /// calling priority.

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=278759=278758=278759=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Mon Aug 15 18:00:49 2016
@@ -480,3 +480,33 @@ void Sema::maybeAddCUDAHostDeviceAttrs(S
   NewD->addAttr(CUDAHostAttr::CreateImplicit(Context));
   NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context));
 }
+
+bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee) {
+  assert(getLangOpts().CUDA &&
+ "Should only be called during CUDA compilation.");
+  assert(Callee && "Callee may not be null.");
+  FunctionDecl *Caller = dyn_cast(CurContext);
+  if (!Caller)
+return true;
+
+  Sema::CUDAFunctionPreference Pref = IdentifyCUDAPreference(Caller, Callee);
+  if (Pref == Sema::CFP_Never) {
+Diag(Loc, diag::err_ref_bad_target) << IdentifyCUDATarget(Callee) << Callee
+<< IdentifyCUDATarget(Caller);
+Diag(Callee->getLocation(), diag::note_previous_decl) << Callee;
+return false;
+  }
+  if (Pref == Sema::CFP_WrongSide) {
+// We have to do this odd dance to create our PartialDiagnostic because we
+// want its storage to be allocated with operator new, not in an arena.
+PartialDiagnostic PD{PartialDiagnostic::NullDiagnostic()};
+PD.Reset(diag::err_ref_bad_target);
+PD << IdentifyCUDATarget(Callee) << Callee << IdentifyCUDATarget(Caller);
+Caller->addDeferredDiag({Loc, std::move(PD)});
+Diag(Callee->getLocation(), diag::note_previous_decl) << Callee;
+// This is not immediately an error, so return true.  The deferred errors
+// will be emitted if and when Caller is codegen'ed.
+return true;
+  }
+  return true;
+}

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=278759=278758=278759=diff

Re: [PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-15 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 68102.
beanz added a comment.
Herald added a subscriber: mehdi_amini.

Updating code comment and removing unneeded braces.

I'm going to sit on this for a bit before committing in case anyone comes up 
with a reason this is a bad idea.


https://reviews.llvm.org/D23531

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -472,21 +472,26 @@
 else if (isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.10.5");
 
-// For OS X, we thought we would only need a static runtime library when
-// targeting 10.4, to provide versions of the static functions which were
-// omitted from 10.4.dylib.
+// Originally for OS X, we thought we would only need a static runtime
+// library when targeting 10.4, to provide versions of the static functions
+// which were omitted from 10.4.dylib. This led to the creation of the 10.4
+// builtins library.
 //
 // Unfortunately, that turned out to not be true, because Darwin system
 // headers can still use eprintf on i386, and it is not exported from
 // libSystem. Therefore, we still must provide a runtime library just for
 // the tiny tiny handful of projects that *might* use that symbol.
-if (isMacosxVersionLT(10, 5)) {
+//
+// Then over time, we figured out it was useful to add more things to the
+// runtime so we created libclang_rt.osx.a to provide new functions when
+// deploying to old OS builds, and for a long time we had both eprintf and
+// osx builtin libraries. Which just seems excessive. So with PR 28855, we
+// are removing the eprintf library and expecting eprintf to be provided by
+// the OS X builtins library.
+if (isMacosxVersionLT(10, 5))
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
-} else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+else
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
-}
   }
 }
 


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -472,21 +472,26 @@
 else if (isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.10.5");
 
-// For OS X, we thought we would only need a static runtime library when
-// targeting 10.4, to provide versions of the static functions which were
-// omitted from 10.4.dylib.
+// Originally for OS X, we thought we would only need a static runtime
+// library when targeting 10.4, to provide versions of the static functions
+// which were omitted from 10.4.dylib. This led to the creation of the 10.4
+// builtins library.
 //
 // Unfortunately, that turned out to not be true, because Darwin system
 // headers can still use eprintf on i386, and it is not exported from
 // libSystem. Therefore, we still must provide a runtime library just for
 // the tiny tiny handful of projects that *might* use that symbol.
-if (isMacosxVersionLT(10, 5)) {
+//
+// Then over time, we figured out it was useful to add more things to the
+// runtime so we created libclang_rt.osx.a to provide new functions when
+// deploying to old OS builds, and for a long time we had both eprintf and
+// osx builtin libraries. Which just seems excessive. So with PR 28855, we
+// are removing the eprintf library and expecting eprintf to be provided by
+// the OS X builtins library.
+if (isMacosxVersionLT(10, 5))
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
-} else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+else
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
-}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Artem Belevich via cfe-commits
tra marked 2 inline comments as done.
tra added a comment.

https://reviews.llvm.org/D23526



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


Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

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

Addressed comments.


https://reviews.llvm.org/D23526

Files:
  lib/Driver/Driver.cpp
  test/Driver/cuda-bindings.cu

Index: test/Driver/cuda-bindings.cu
===
--- /dev/null
+++ test/Driver/cuda-bindings.cu
@@ -0,0 +1,137 @@
+// Tests the bindings generated for a CUDA offloading target for different
+// combinations of:
+// - Number of gpu architectures;
+// - Host/device-only compilation;
+// - User-requested final phase - binary or assembly.
+// It parallels cuda-phases.cu test, but verifies whether output file is temporary or not.
+
+// It's hard to check whether file name is temporary in a portable
+// way. Instead we check whether we've generated a permanent name on
+// device side, which appends '-device-cuda-' suffix.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Test single gpu architecture with complete compilation.
+// No intermediary device files should have "-device-cuda..." in the name.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN %s
+// BIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test single gpu architecture up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test two gpu architectures with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN2 %s
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test two gpu architectures up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM2 %s
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_35.s"
+// ASM2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test one or more gpu architecture with complete compilation in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// HBIN-NOT: cuda-bindings-device-cuda-nvptx64
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test one or more gpu architecture up to the assemble phase in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only -S 2>&1 \
+// RUN: | FileCheck -check-prefix=HASM %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only -S 2>&1 \
+// RUN: | FileCheck -check-prefix=HASM %s
+// HASM: # 

Re: [PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-15 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.

Might want to fix the braces while you're there.

-eric


https://reviews.llvm.org/D23531



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


[PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-15 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: ddunbar, bob.wilson.
beanz added a subscriber: cfe-commits.

The eprintf library was added before the general OS X builtins library existed 
as a place to store one builtin function. Since we have for several years had 
an actual mandated builtin library for OS X > 10.5, we should just merge 
eprintf into the main library.

This change will resolve PR28855.

As a follow up I'll also patch compiler-rt to not generate the eprintf library 
anymore.

https://reviews.llvm.org/D23531

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -483,8 +483,6 @@
 if (isMacosxVersionLT(10, 5)) {
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
 } else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
 }
   }


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -483,8 +483,6 @@
 if (isMacosxVersionLT(10, 5)) {
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
 } else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23242: [CUDA] Raise an error if a wrong-side call is codegen'ed.

2016-08-15 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm



Comment at: clang/include/clang/Sema/Sema.h:9162
@@ -9161,1 +9161,3 @@
 
+  /// Check whether we're allowed to call Callee from the current context.
+  ///

FWIW I never insert doxygen annotations. I figure if someone cares they can 
come insert them for me. =P


https://reviews.llvm.org/D23242



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


Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Wow, I have no idea if this is right.  I can try to figure it out, but if 
sfantao can review, that's easier.



Comment at: test/Driver/cuda-bindings.cu:10
@@ +9,3 @@
+// way. Instead we check whether we've generated a permanent name on
+// device side which appends '-device-cuda-' suffix.
+

Nonrestrictive subordinating clause, comma before "which".


Comment at: test/Driver/cuda-bindings.cu:60
@@ +59,3 @@
+//
+// Test two gpu architecturess up to the assemble phase.
+//

Spelling


https://reviews.llvm.org/D23526



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


Re: [PATCH] D23524: [libc++abi] Fix backtrace_test.pass.cpp failure seemingly caused by inlining differences.

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

I'm not sure that's guaranteed behavior either. That being said, I don't see a 
more robust way to write this test.


https://reviews.llvm.org/D23524



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


Re: [PATCH] D23003: [ObjC Availability] Warn upon unguarded use of partially available declaration

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



> This is done so containers, such as `vector` can be used 
> safely provided `partially_available` is safe at the point of instantiation. 
> I think the way to improve this is in `Sema::getVersionForDecl()`. There we 
> could look at function and template parameters to determine the best base 
> version, then diagnose against it.


Let's fix the diagnostics for dependent type in a follow-up patch. And your 
suggestion above sounds reasonable to me.

Thanks for the work!
Manman


https://reviews.llvm.org/D23003



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


Re: [PATCH] D23493: Fix PR28366: Teach the const-expression evaluator to be more fault tolerant with non-const enclosing local variables, or otherwise fold them if const.

2016-08-15 Thread Faisal Vali via cfe-commits
faisalv marked an inline comment as done.
faisalv added a comment.

https://reviews.llvm.org/D23493



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


Re: [PATCH] D23493: Fix PR28366: Teach the const-expression evaluator to be more fault tolerant with non-const enclosing local variables, or otherwise fold them if const.

2016-08-15 Thread Faisal Vali via cfe-commits
faisalv removed rL LLVM as the repository for this revision.
faisalv updated this revision to Diff 68091.
faisalv added a comment.

Updated the patch per Richard's direction (which helped clarify my thinking 
about this): Check only the current call frame - if the VarDecl is contained 
within the current callee - only then does it make sense to dig into the 
stack-variables of the frame.  No other scenario really makes sense (even for 
lambdas, we care about the parent decl-contexts (static binding), not variables 
within the call-frame stack (run-time binding).

Thanks Richard.


https://reviews.llvm.org/D23493

Files:
  lib/AST/ExprConstant.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/constant-expression-cxx11.cpp

Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -2066,3 +2066,33 @@
   constexpr Z z(1);
   static_assert(z.w == 1 && z.x == 2 && z.y == 3 && z.z == 4, "");
 }
+
+
+namespace PR28366 {
+namespace ns1 {
+
+void f(char c) { //expected-note2{{declared here}}
+  struct X {
+static constexpr char f() { //expected-error{{never produces a constant 
expression}}
+  return c; //expected-error{{reference to local}} 
expected-note{{non-const variable}}
+}
+  };
+  int I = X::f();
+}
+
+void g() {
+  const int c = 'c';
+  static const int d = 'd';
+  struct X {
+static constexpr int f() {
+  return c + d;
+}
+  };
+  constexpr int CD = X::f();
+}
+
+
+} // end ns1
+
+} //end ns PR28366
+
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -187,7 +187,7 @@
 
   SmallVector Diags;
   if (A->getCond()->isValueDependent() && !Cond->isValueDependent() &&
-  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(Tmpl),
+  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(New),
 Diags)) {
 S.Diag(A->getLocation(), diag::err_enable_if_never_constant_expr);
 for (int I = 0, N = Diags.size(); I != N; ++I)
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -4788,10 +4788,19 @@
   return Error(E);
 }
 
+
 bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
   CallStackFrame *Frame = nullptr;
-  if (VD->hasLocalStorage() && Info.CurrentCall->Index > 1)
-Frame = Info.CurrentCall;
+  if (VD->hasLocalStorage() && Info.CurrentCall->Index > 1) {
+// Only if the DeclContext of VD is the same as the called function do we
+// set the Frame to the Current CallStackFrame, so that we can find its
+// associated value from the variable-objects associated with that frame.
+if (Info.CurrentCall->Callee && isa(VD->getDeclContext()) &&
+cast(VD->getDeclContext()->getRedeclContext())
+->getFirstDecl() == Info.CurrentCall->Callee->getFirstDecl()) {
+  Frame = Info.CurrentCall;
+}
+  }
 
   if (!VD->getType()->isReferenceType()) {
 if (Frame) {


Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -2066,3 +2066,33 @@
   constexpr Z z(1);
   static_assert(z.w == 1 && z.x == 2 && z.y == 3 && z.z == 4, "");
 }
+
+
+namespace PR28366 {
+namespace ns1 {
+
+void f(char c) { //expected-note2{{declared here}}
+  struct X {
+static constexpr char f() { //expected-error{{never produces a constant expression}}
+  return c; //expected-error{{reference to local}} expected-note{{non-const variable}}
+}
+  };
+  int I = X::f();
+}
+
+void g() {
+  const int c = 'c';
+  static const int d = 'd';
+  struct X {
+static constexpr int f() {
+  return c + d;
+}
+  };
+  constexpr int CD = X::f();
+}
+
+
+} // end ns1
+
+} //end ns PR28366
+
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -187,7 +187,7 @@
 
   SmallVector Diags;
   if (A->getCond()->isValueDependent() && !Cond->isValueDependent() &&
-  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(Tmpl),
+  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(New),
 Diags)) {
 S.Diag(A->getLocation(), diag::err_enable_if_never_constant_expr);
 for (int I = 0, N = Diags.size(); I != N; ++I)
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ 

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

2016-08-15 Thread Matthias Braun via cfe-commits
MatzeB added a subscriber: MatzeB.
MatzeB added a comment.

The sanitizer code triggers this warning for code that looks conceptually like 
this:

  typedef struct Bla { char bar; int foo; } __attribute__((packed));
  
  uintptr_t getu(struct Bla *b) { return (uintptr_t)>foo; }

Resulting in:

  taking address of packed member 'foo' of class or structure
'Bla' may result in an unaligned pointer value
[-Waddress-of-packed-member]

Of course the warning can be silenced with `return (uintptr_t)(char*)>foo;` 
still casting to an int type seems like a benign case for this warning so maybe 
we should exclude that?


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



___
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-15 Thread Eric Fiselier via cfe-commits
EricWF marked 7 inline comments as done.


Comment at: include/clang/Basic/AttrDocs.td:844
@@ +843,3 @@
+the indeterminate order of dynamic initialization. They can also be safely
+used by other static constructors across translation units.
+

rsmith wrote:
> static constructors -> dynamic initializers?
Changed "by other static constructors" -> "during dynamic initialization"


Comment at: include/clang/Basic/AttrDocs.td:858
@@ +857,3 @@
+  };
+  SAFE_STATIC T x = {42}; // OK.
+  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer

rsmith wrote:
> OK even though T has a non-trivial destructor? This makes the variable unsafe 
> to use during program shutdown in the general case.
Right, but I want this attribute to be able to work with (A)  the union trick 
for "trivial" destructors and (B) variables not used during shutdown.
I was planning on following this up with an additional feature to aid in the 
shutdown case as well, but I think there is value in separating the features.

Currently -Wglobal-destructors will still warn on that declaration, so at least 
the unsafe shutdown is not silently missed.

Does this behavior make sense to you?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6842
@@ +6841,3 @@
+def err_require_constant_init_failed : Error<
+  "variable does not have a constant initializer">;
+

rsmith wrote:
> It may be useful for this diagnostic to say why we consider this to be an 
> error (that is, mention that there is a `require_constant_initialization` 
> attribute attached to the variable). The attribute will typically be hidden 
> behind a (perhaps unfamiliar to the reader) macro, so it may not be obvious 
> if we don't point it out.
"variable does not have a constant initializer as required by 
'require_constant_initializer' attribute"?

Or do we want the diagnostic to point to the attribute token in a "required 
from here"-like note?


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

rsmith wrote:
> Falling back to `checkConstInit` here will suppress the warning on some cases 
> that are not technically constant initializers (but that Clang can emit as 
> constants regardless). Is that what you want? If so, you should update the 
> documentation to say that instead of saying that we only check for a constant 
> initializer.
> Falling back to checkConstInit here will suppress the warning on some cases 
> that are not technically constant initializers (but that Clang can emit as 
> constants regardless). Is that what you want?

Not really. I would prefer this strictly conform to the standard so it can be 
used to portably detect possible dynamic initializers on other toolchains.

What would the correct fallback here be?


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:96-100
@@ +95,7 @@
+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
+}

rsmith wrote:
> Did you mean for this to still be here?
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] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 68089.
sfantao marked an inline comment as done.
sfantao added a comment.

- Remove redundant return statement.


https://reviews.llvm.org/D21851

Files:
  test/Driver/clang-offload-bundler.c
  test/Driver/clang-offload-bundler.c.o
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -72,20 +72,40 @@
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
 
+static cl::opt PrintExternalCommands(
+"###",
+cl::desc("Print any external commands that are to be executed "
+ "instead of actually executing them - for testing purposes.\n"),
+cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+static cl::opt DumpTemporaryFiles(
+"dump-temporary-files",
+cl::desc("Dumps any temporary files created - for testing purposes.\n"),
+cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
 
 /// The index of the host input in the list of inputs.
 static unsigned HostInputIndex = ~0u;
 
+/// Path to the current binary.
+static std::string BundlerExecutable;
+
 /// Obtain the offload kind and real machine triple out of the target
 /// information specified by the user.
 static void getOffloadKindAndTriple(StringRef Target, StringRef ,
 StringRef ) {
   auto KindTriplePair = Target.split('-');
   OffloadKind = KindTriplePair.first;
   Triple = KindTriplePair.second;
 }
+static StringRef getTriple(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return Triple;
+}
 static bool hasHostKind(StringRef Target) {
   StringRef OffloadKind;
   StringRef Triple;
@@ -116,8 +136,8 @@
   /// \a OS.
   virtual void WriteBundleStart(raw_fd_ostream , StringRef TargetTriple) = 0;
   /// Write the marker that closes a bundle for the triple \a TargetTriple to \a
-  /// OS.
-  virtual void WriteBundleEnd(raw_fd_ostream , StringRef TargetTriple) = 0;
+  /// OS. Return true if any error was found.
+  virtual bool WriteBundleEnd(raw_fd_ostream , StringRef TargetTriple) = 0;
   /// Write the bundle from \a Input into \a OS.
   virtual void WriteBundle(raw_fd_ostream , MemoryBuffer ) = 0;
 
@@ -303,15 +323,250 @@
 }
   }
   void WriteBundleStart(raw_fd_ostream , StringRef TargetTriple) {}
-  void WriteBundleEnd(raw_fd_ostream , StringRef TargetTriple) {}
+  bool WriteBundleEnd(raw_fd_ostream , StringRef TargetTriple) {
+return false;
+  }
   void WriteBundle(raw_fd_ostream , MemoryBuffer ) {
 OS.write(Input.getBufferStart(), Input.getBufferSize());
   }
 
   BinaryFileHandler() : FileHandler() {}
   ~BinaryFileHandler() {}
 };
 
+/// Handler for object files. The bundles are organized by sections with a
+/// designated name.
+///
+/// In order to bundle we create an IR file with the content of each section and
+/// use incremental linking to produce the resulting object. We also add section
+/// with a single byte to state the name of the component the main object file
+/// (the one we are bundling into) refers to.
+///
+/// To unbundle, we use just copy the contents of the designated section. If the
+/// requested bundle refer to the main object file, we just copy it with no
+/// changes.
+class ObjectFileHandler final : public FileHandler {
+
+  /// The object file we are currently dealing with.
+  ObjectFile 
+
+  /// Return the input file contents.
+  StringRef getInputFileContents() const { return Obj.getData(); }
+
+  /// Return true if the provided section is an offload section and return the
+  /// triple by reference.
+  static bool IsOffloadSection(SectionRef CurSection,
+   StringRef ) {
+StringRef SectionName;
+CurSection.getName(SectionName);
+
+if (SectionName.empty())
+  return false;
+
+// If it does not start with the reserved suffix, just skip this section.
+if (!SectionName.startswith(OFFLOAD_BUNDLER_MAGIC_STR))
+  return false;
+
+// Return the triple that is right after the reserved prefix.
+OffloadTriple = SectionName.substr(sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1);
+return true;
+  }
+
+  /// Total number of inputs.
+  unsigned NumberOfInputs = 0;
+
+  /// Total number of processed inputs, i.e, inputs that were already
+  /// read from the buffers.
+  unsigned NumberOfProcessedInputs = 0;
+
+  /// LLVM context used to to create the auxiliar modules.
+  LLVMContext VMContext;
+
+  /// LLVM module used to create an object with all the bundle
+  /// components.
+  std::unique_ptr AuxModule;
+
+  /// The 

[PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jlebar, sfantao.
tra added a subscriber: cfe-commits.

If they are, we end up with the last intermediary output preserved
in the current directory after compilation.

Added a test case to verify that we're using appropriate filenames
for outputs of different phases.


https://reviews.llvm.org/D23526

Files:
  lib/Driver/Driver.cpp
  test/Driver/cuda-bindings.cu

Index: test/Driver/cuda-bindings.cu
===
--- /dev/null
+++ test/Driver/cuda-bindings.cu
@@ -0,0 +1,137 @@
+// Tests the bindings generated for a CUDA offloading target for different
+// combinations of:
+// - Number of gpu architectures;
+// - Host/device-only compilation;
+// - User-requested final phase - binary or assembly.
+// It parallels cuda-phases.cu test, but verifies whether output file is temporary or not.
+
+// It's hard to check whether file name is temporary in a portable
+// way. Instead we check whether we've generated a permanent name on
+// device side which appends '-device-cuda-' suffix.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Test single gpu architecture with complete compilation.
+// No intermediary device files should have "-device-cuda..." in the name.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN %s
+// BIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test single gpu architecture up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test two gpu architectures with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN2 %s
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test two gpu architecturess up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM2 %s
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_35.s"
+// ASM2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test one or more gpu architecture with complete compilation in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// HBIN-NOT: cuda-bindings-device-cuda-nvptx64
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test one or more gpu architecture up to the assemble phase in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only -S 2>&1 \
+// RUN: | FileCheck -check-prefix=HASM %s
+// RUN: 

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

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Jonas,

Thanks for the review!



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
   )
   

Hahnfeld wrote:
> 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)
The bundler tool already depends on clang, so that would cause a circular 
dependency. I think that in general not building the bundler is fine - the user 
may not be interested in doing offloading, so if he attempts to do so, that 
would fail as, say, ld was not in the system.

I'm adding it only for testing because there are tests that will exercise the 
bundler that will fail if the driver does not detect the tool. 

Should we ask someone in specific for an opinion? Let me know your thoughts. 


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) {

Hahnfeld wrote:
> `to/from`?
Thanks for catching this! Fixed in the last diff, it should be `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 , uint64_t Val) {

Hahnfeld wrote:
> Duplicate `and write`? `to/from`?
Fixed in the last diff, it should be `to`.


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;

Hahnfeld wrote:
> Better say that we haven't found the bundle for the host?
Makes sense, I changed the message in the last diff.


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: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 68086.
sfantao marked 5 inline comments as done.
sfantao added a comment.

- Fix comments and diagnostics.


https://reviews.llvm.org/D13909

Files:
  test/CMakeLists.txt
  test/Driver/clang-offload-bundler.c
  tools/CMakeLists.txt
  tools/clang-offload-bundler/CMakeLists.txt
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- /dev/null
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -0,0 +1,681 @@
+//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a clang-offload-bundler that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadBundlerCategory("clang-offload-bundler options");
+
+static cl::list
+InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
+   cl::desc("[,...]"),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+TargetNames("targets", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[-,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+FilesType("type", cl::Required,
+  cl::desc("Type of the files to be bundled/unbundled.\n"
+   "Current supported types are:\n"
+   "  i   - cpp-output\n"
+   "  ii  - c++-cpp-output\n"
+   "  ll  - llvm\n"
+   "  bc  - llvm-bc\n"
+   "  s   - assembler\n"
+   "  o   - object\n"
+   "  gch - precompiled-header\n"
+   "  ast - clang AST file"),
+  cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+Unbundle("unbundle",
+ cl::desc("Unbundle bundled file into several output files.\n"),
+ cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+/// Magic string that marks the existence of offloading data.
+#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
+
+/// The index of the host input in the list of inputs.
+static unsigned HostInputIndex = ~0u;
+
+/// Obtain the offload kind and real machine triple out of the target
+/// information specified by the user.
+static void getOffloadKindAndTriple(StringRef Target, StringRef ,
+StringRef ) {
+  auto KindTriplePair = Target.split('-');
+  OffloadKind = KindTriplePair.first;
+  Triple = KindTriplePair.second;
+}
+static bool hasHostKind(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return OffloadKind == "host";
+}
+
+/// Generic file handler interface.
+class FileHandler {
+public:
+  /// Update the file handler with information from the header of the bundled
+  /// file
+  virtual void ReadHeader(MemoryBuffer ) = 0;
+  /// Read the marker of the next bundled to be read in the file. The triple of
+  /// the target associated with that bundle is returned. An empty string is
+  /// returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer ) = 0;
+  /// Read the marker that closes the current bundle.
+  virtual void ReadBundleEnd(MemoryBuffer ) = 0;
+  /// Read the current bundle and write the result into the stream \a OS.
+  virtual 

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

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

This seems premature; according to the charter, we are more than three years 
away from the C2x committee draft phase. Perhaps we should wait until we have 
either a new working draft or a paper approved by the WG14 for such a working 
draft.


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] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


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

Providing both seems fine, but regardless this should be a GNU spelling not a 
GCC spelling, because GCC doesn't support the attribute.


Comment at: include/clang/Basic/AttrDocs.td:836-840
@@ +835,7 @@
+  let Content = [{
+This attribute specifies expectations about the initialization of static and
+thread local variables. Specifically that the variable has a
+`constant initializer 
`_
+according to the rules of [basic.start.static]. Failure to meet this 
expectation
+will result in an error.
+

This reads a bit awkwardly, since you don't actually say what the attribute 
does until the second sentence. Maybe fold the first two sentences together:

"This attribute specifies that the variable to which it is attached is intended 
to have a constant initializer according to the rules of [basic.start.static]. 
The variable is required to have static or thread storage duration. If the 
initialization of the variable is not a constant initializer, an error will be 
produced."


Comment at: include/clang/Basic/AttrDocs.td:842
@@ +841,3 @@
+
+Static objects with constant initializers avoid hard-to-find bugs caused by
+the indeterminate order of dynamic initialization. They can also be safely

Static objects -> Static storage duration variables


Comment at: include/clang/Basic/AttrDocs.td:844
@@ +843,3 @@
+the indeterminate order of dynamic initialization. They can also be safely
+used by other static constructors across translation units.
+

static constructors -> dynamic initializers?


Comment at: include/clang/Basic/AttrDocs.td:858
@@ +857,3 @@
+  };
+  SAFE_STATIC T x = {42}; // OK.
+  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer

OK even though T has a non-trivial destructor? This makes the variable unsafe 
to use during program shutdown in the general case.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2575
@@ -2574,3 +2574,3 @@
   "functions, variables, classes, and Objective-C interfaces|"
-  "Objective-C protocols|"
+  "Objective-C protocols|variables with static or thread-local storage 
duration|"
   "functions and global variables|structs, unions, and typedefs|structs and 
typedefs|"

thread-local -> thread, per standard terminology


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6842
@@ +6841,3 @@
+def err_require_constant_init_failed : Error<
+  "variable does not have a constant initializer">;
+

It may be useful for this diagnostic to say why we consider this to be an error 
(that is, mention that there is a `require_constant_initialization` attribute 
attached to the variable). The attribute will typically be hidden behind a 
(perhaps unfamiliar to the reader) macro, so it may not be obvious if we don't 
point it out.


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

Falling back to `checkConstInit` here will suppress the warning on some cases 
that are not technically constant initializers (but that Clang can emit as 
constants regardless). Is that what you want? If so, you should update the 
documentation to say that instead of saying that we only check for a constant 
initializer.


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:7-15
@@ +6,11 @@
+
+#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
+

Just use `_Static_assert`.


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:96-100
@@ +95,7 @@
+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
+}

Did you mean for this to still be here?


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: r278710 - Replace an obsolete company name.

2016-08-15 Thread Robinson, Paul via cfe-commits
I had tried doing that in the Users.html page when I first added an entry 
there, and it caused problems.  So, I'd rather not embed a unicode character 
directly into the file, and I'd rather use a semi-intelligible substitution 
name than some raw hex value.  The intent is clearer.
--paulr

From: Sean Silva [mailto:chisophu...@gmail.com]
Sent: Monday, August 15, 2016 1:09 PM
To: Robinson, Paul
Cc: cfe-commits
Subject: Re: r278710 - Replace an obsolete company name.

You may also want to just try using the unicode character (not that it really 
matters that much though).

On Mon, Aug 15, 2016 at 11:45 AM, Paul Robinson via cfe-commits 
> wrote:
Author: probinson
Date: Mon Aug 15 13:45:52 2016
New Revision: 278710

URL: http://llvm.org/viewvc/llvm-project?rev=278710=rev
Log:
Replace an obsolete company name.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=278710=278709=278710=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Aug 15 13:45:52 2016
@@ -2,6 +2,8 @@
 Clang Compiler User's Manual
 

+.. include:: 
+
 .. contents::
:local:

@@ -1650,7 +1652,7 @@ features. You can "tune" the debug info

 .. option:: -ggdb, -glldb, -gsce

-  Tune the debug info for the ``gdb``, ``lldb``, or Sony Computer Entertainment
+  Tune the debug info for the ``gdb``, ``lldb``, or Sony PlayStation\ |reg|
   debugger, respectively. Each of these options implies **-g**. (Therefore, if
   you want both **-gline-tables-only** and debugger tuning, the tuning option
   must come first.)


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

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


Re: [PATCH] D23523: [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278746: [ADT] Change PostOrderIterator to use NodeRef. NFC. 
(authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23523?vs=68070=68082#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23523

Files:
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/Analysis/CallGraph.h

Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}


Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; }
   static inline 

r278746 - [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Aug 15 16:27:56 2016
New Revision: 278746

URL: http://llvm.org/viewvc/llvm-project?rev=278746=rev
Log:
[ADT] Change PostOrderIterator to use NodeRef. NFC.

Summary: Corresponding LLVM change: D23522

Reviewers: dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Analysis/CallGraph.h

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=278746=278745=278746=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Mon Aug 15 16:27:56 2016
@@ -999,6 +999,7 @@ template <> struct simplify_type< ::clan
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@ template <> struct GraphTraits< ::clang:
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@ template <> struct GraphTraits< const ::
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@ template <> struct GraphTraits struct GraphTraits {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=278746=278745=278746=diff
==
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Mon Aug 15 16:27:56 2016
@@ -172,6 +172,7 @@ public:
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@ template <> struct GraphTraits struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}


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


[libcxx] r278745 - libcxx: Fix path.compare.pass expected result

2016-08-15 Thread Adhemerval Zanella via cfe-commits
Author: azanella
Date: Mon Aug 15 16:24:50 2016
New Revision: 278745

URL: http://llvm.org/viewvc/llvm-project?rev=278745=rev
Log:
libcxx: Fix path.compare.pass expected result

The expected 'filesystem::path::compare' result states that for different
path only result sign contains the information about passed arguments
(not its integer value).  This is due it uses the output of other compare
functions (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.

Modified:

libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp?rev=278745=278744=278745=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
 Mon Aug 15 16:24:50 2016
@@ -73,6 +73,11 @@ const PathCompareTest CompareTestCases[]
 #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 @@ int main()
   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] D23096: [Sema] Pass CombineWithOuterScope = true to constructor of LocalInstantiationScope

2016-08-15 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 68078.
ahatanak added a comment.

Fix Sema::getTemplateInstantiationArgs to return the template instantiation 
args when variable templates are being instantiated.


https://reviews.llvm.org/D23096

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/vartemplate-lambda.cpp
  test/SemaTemplate/default-expr-arguments-3.cpp

Index: test/SemaTemplate/default-expr-arguments-3.cpp
===
--- /dev/null
+++ test/SemaTemplate/default-expr-arguments-3.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++14 -ast-dump %s 2>&1 | FileCheck %s
+
+namespace PR28795 {
+  // CHECK: FunctionDecl{{.*}}func 'void (void)'
+  // CHECK:  LambdaExpr
+  // CHECK:   CXXMethodDecl{{.*}}operator() 'enum foo (enum foo) const' inline
+  // CHECK:ParmVarDecl{{.*}}f 'enum foo' cinit
+  // CHECK: DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo'
+
+  template
+  void func() {
+enum class foo { a, b };
+auto bar = [](foo f = foo::a) { return f; };
+bar();
+  }
+
+  void foo() {
+func();
+  }
+}
+
+// Template struct case:
+
+// CHECK: ClassTemplateSpecializationDecl{{.*}}struct class2 definition
+// CHECK:  LambdaExpr
+// CHECK:   CXXMethodDecl{{.*}}used operator() 'enum foo (enum foo) const' inline
+// CHECK:ParmVarDecl{{.*}}f 'enum foo' cinit
+// CHECK: DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo'
+
+template  struct class2 {
+  void bar() {
+enum class foo { a, b };
+[](foo f = foo::a) { return f; }();
+  }
+};
+
+template struct class2;
+
+// CHECK: FunctionDecl{{.*}}f1 'void (void)'
+// CHECK:  CXXMethodDecl{{.*}}g1 'int (enum foo)'
+// CHECK:   ParmVarDecl{{.*}}n 'enum foo' cinit
+// CHECK:DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo'
+
+template
+void f1() {
+  enum class foo { a, b };
+  struct S {
+int g1(foo n = foo::a);
+  };
+}
+
+template void f1();
Index: test/SemaCXX/vartemplate-lambda.cpp
===
--- test/SemaCXX/vartemplate-lambda.cpp
+++ test/SemaCXX/vartemplate-lambda.cpp
@@ -1,15 +1,22 @@
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  auto fn0 = [] {};
 template  void foo0() { fn0(); }
 
 template auto fn1 = [](auto a) { return a + T(1); };
+template auto v1 = [](int a = T(1)) { return a; }();
+
+struct S {
+  template
+  static constexpr T t = [](int f = T(7)){return f;}(); // expected-error{{constexpr variable 't' must be initialized by a constant expression}} expected-error{{a lambda expression may not appear inside of a constant expression}} expected-note{{cannot be used in a constant expression}}
+};
 
 template 
 int foo2() {
   X a = 0x61;
   fn1(a);
+  (void)v1;
+  (void)S::t; // expected-note{{in instantiation of static data member 'S::t' requested here}}
   return 0;
 }
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3728,7 +3728,8 @@
   if (FromVar->isInvalidDecl())
 return nullptr;
 
-  InstantiatingTemplate Inst(*this, PointOfInstantiation, FromVar);
+  InstantiatingTemplate Inst(*this, PointOfInstantiation, FromVar,
+ SourceRange(), TemplateArgList.asArray());
   if (Inst.isInvalid())
 return nullptr;
 
@@ -4022,7 +4023,8 @@
 !Var->hasInit()) {
   // FIXME: Factor out the duplicated instantiation context setup/tear down
   // code here.
-  InstantiatingTemplate Inst(*this, PointOfInstantiation, Var);
+  InstantiatingTemplate Inst(*this, PointOfInstantiation, Var,
+ SourceRange(), TemplateArgs.getInnermost());
   if (Inst.isInvalid())
 return;
   PrettyDeclStackTraceEntry CrashInfo(*this, Var, SourceLocation(),
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -57,9 +57,16 @@
   // Accumulate the set of template argument lists in this structure.
   MultiLevelTemplateArgumentList Result;
 
+  ArrayRef VarTemplateArgs = varTemplateArguments();
+
+  if (!VarTemplateArgs.empty()) {
+Result.addOuterTemplateArguments(VarTemplateArgs);
+return Result;
+  }
+
   if (Innermost)
 Result.addOuterTemplateArguments(Innermost);
-  
+
   DeclContext *Ctx = dyn_cast(D);
   if (!Ctx) {
 Ctx = D->getDeclContext();
@@ -183,6 +190,19 @@
   return Result;
 }
 
+ArrayRef Sema::varTemplateArguments() const {
+  if (ActiveTemplateInstantiations.empty())
+return ArrayRef();
+
+  const auto  = ActiveTemplateInstantiations.back();
+
+  if (const auto *VD = dyn_cast_or_null(Inst.Entity))
+if 

[PATCH] D23524: [libc++abi] Fix backtrace_test.pass.cpp failure seemingly caused by inlining differences.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: danalbert, jroelofs, mclow.lists.
EricWF added a subscriber: cfe-commits.

The modified assertion fails when the test is compiled at various optimization 
levels.
The value of `nothrow_traced` and `throw_traced` at various optimization levels 
are:

* `-O0`: `nothrow_traced = 7`, `throw_traced = 7`
* `-O1`: `nothrow_traced = 4`, `throw_traced = 5`
* `-O2`: `nothrow_traced = 4`, `throw_traced = 4`
* `-O3`: `nothrow_traced = 4`, `throw_traced = 4`

I'm not sure exactly what this test is doing, so I would like somebody else to 
sign off on this change.


https://reviews.llvm.org/D23524

Files:
  test/backtrace_test.pass.cpp

Index: test/backtrace_test.pass.cpp
===
--- test/backtrace_test.pass.cpp
+++ test/backtrace_test.pass.cpp
@@ -60,6 +60,6 @@
   // Different platforms (and different runtimes) will unwind a different 
number
   // of times, so we can't make any better assumptions than this.
   assert(nothrow_ntraced > 1);
-  assert(throw_ntraced == nothrow_ntraced); // Make sure we unwind through 
catch
+  assert(throw_ntraced >= nothrow_ntraced); // Make sure we unwind through 
catch
   return 0;
 }


Index: test/backtrace_test.pass.cpp
===
--- test/backtrace_test.pass.cpp
+++ test/backtrace_test.pass.cpp
@@ -60,6 +60,6 @@
   // Different platforms (and different runtimes) will unwind a different number
   // of times, so we can't make any better assumptions than this.
   assert(nothrow_ntraced > 1);
-  assert(throw_ntraced == nothrow_ntraced); // Make sure we unwind through catch
+  assert(throw_ntraced >= nothrow_ntraced); // Make sure we unwind through catch
   return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278742 - Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.

2016-08-15 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Aug 15 16:05:00 2016
New Revision: 278742

URL: http://llvm.org/viewvc/llvm-project?rev=278742=rev
Log:
Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.

For the following example:
typedef __attribute__((NSObject)) CGColorRef ColorAttrRef;
@property (strong, nullable) ColorAttrRef color;
The property type should be ObjC NSObject type and the compiler should not emit
error: property with 'retain (or strong)' attribute must be of object type

rdar://problem/27747154

Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaObjC/nsobject-attribute.m

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=278742=278741=278742=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Aug 15 16:05:00 2016
@@ -3686,10 +3686,18 @@ bool Type::isObjCARCImplicitlyUnretained
 }
 
 bool Type::isObjCNSObjectType() const {
-  if (const TypedefType *typedefType = dyn_cast(this))
-return typedefType->getDecl()->hasAttr();
-  return false;
+  const Type *cur = this;
+  while (true) {
+if (const TypedefType *typedefType = dyn_cast(cur))
+  return typedefType->getDecl()->hasAttr();
+
+// Single-step desugar until we run out of sugar.
+QualType next = cur->getLocallyUnqualifiedSingleStepDesugaredType();
+if (next.getTypePtr() == cur) return false;
+cur = next.getTypePtr();
+  }
 }
+
 bool Type::isObjCIndependentClassType() const {
   if (const TypedefType *typedefType = dyn_cast(this))
 return typedefType->getDecl()->hasAttr();

Modified: cfe/trunk/test/SemaObjC/nsobject-attribute.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute.m?rev=278742=278741=278742=diff
==
--- cfe/trunk/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute.m Mon Aug 15 16:05:00 2016
@@ -21,6 +21,8 @@ typedef struct CGColor * __attribute__((
 @property (nonatomic, retain) CGColorRefNoNSObject color;
 // rdar://problem/12197822
 @property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning
+//rdar://problem/27747154
+@property (strong, nullable) CGColorRefNoNSObject color2; // no-warning
 @end
 
 void setProperty(id self, id value)  {


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


[libcxx] r278736 - Fix new ASAN failures

2016-08-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Aug 15 15:50:01 2016
New Revision: 278736

URL: http://llvm.org/viewvc/llvm-project?rev=278736=rev
Log:
Fix new ASAN failures

Modified:
libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp
libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp

Modified: libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp?rev=278736=278735=278736=diff
==
--- libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp Mon Aug 
15 15:50:01 2016
@@ -61,8 +61,8 @@ int main()
 C c(std::begin(t), std::end(t));
 c.reserve(2*c.size());
 assert(is_contiguous_container_asan_correct(c));
-assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 
1, c.data() + c.capacity()));
-T foo = c[c.size()];// should trigger ASAN
+assert(!__sanitizer_verify_contiguous_container( c.data(), c.data() + 
1, c.data() + c.capacity()));
+volatile T foo = c[c.size()]; // should trigger ASAN. Use volatile to 
prevent being optimized away.
 assert(false);  // if we got here, ASAN didn't trigger
 }
 }

Modified: 
libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp?rev=278736=278735=278736=diff
==
--- libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp 
(original)
+++ libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp Mon 
Aug 15 15:50:01 2016
@@ -25,4 +25,5 @@ struct B : A {};
 int main() {
 A* ptr = new B;
 (void)dynamic_cast(ptr);
+delete ptr;
 }


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


Re: [PATCH] D23241: Add the notion of deferred diagnostics.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278735: Add the notion of deferred diagnostics. (authored by 
jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23241?vs=68063=68073#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23241

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h

Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -3446,6 +3446,20 @@
   return 0;
 }
 
+void FunctionDecl::addDeferredDiag(PartialDiagnosticAt PD) {
+  getASTContext().getDeferredDiags()[this].push_back(std::move(PD));
+}
+
+std::vector FunctionDecl::takeDeferredDiags() const {
+  auto  = getASTContext().getDeferredDiags();
+  auto It = DD.find(this);
+  if (It == DD.end())
+return {};
+  auto Ret = std::move(It->second);
+  DD.erase(It);
+  return Ret;
+}
+
 //===--===//
 // FieldDecl Implementation
 //===--===//
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -497,6 +497,16 @@
   EmitVersionIdentMetadata();
 
   EmitTargetMetadata();
+
+  // Emit any deferred diagnostics gathered during codegen.  We didn't emit them
+  // when we first discovered them because that would have halted codegen,
+  // preventing us from gathering other deferred diags.
+  for (const PartialDiagnosticAt  : DeferredDiags) {
+SourceLocation Loc = DiagAt.first;
+const PartialDiagnostic  = DiagAt.second;
+DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
+PD.Emit(Builder);
+  }
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
@@ -2872,6 +2882,33 @@
  llvm::GlobalValue *GV) {
   const auto *D = cast(GD.getDecl());
 
+  // Emit this function's deferred diagnostics, if none of them are errors.  If
+  // any of them are errors, don't codegen the function, but also don't emit any
+  // of the diagnostics just yet.  Emitting an error during codegen stops
+  // further codegen, and we want to display as many deferred diags as possible.
+  // We'll emit the now twice-deferred diags at the very end of codegen.
+  //
+  // (If a function has both error and non-error diags, we don't emit the
+  // non-error diags here, because order can be significant, e.g. with notes
+  // that follow errors.)
+  auto Diags = D->takeDeferredDiags();
+  bool HasError = llvm::any_of(Diags, [this](const PartialDiagnosticAt ) {
+return getDiags().getDiagnosticLevel(PDAt.second.getDiagID(), PDAt.first) >=
+   DiagnosticsEngine::Error;
+  });
+  if (HasError) {
+DeferredDiags.insert(DeferredDiags.end(),
+ std::make_move_iterator(Diags.begin()),
+ std::make_move_iterator(Diags.end()));
+return;
+  }
+  for (PartialDiagnosticAt  : Diags) {
+const SourceLocation  = PDAt.first;
+const PartialDiagnostic  = PDAt.second;
+DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
+PD.Emit(Builder);
+  }
+
   // Compute the function info and LLVM type.
   const CGFunctionInfo  = getTypes().arrangeGlobalDeclaration(GD);
   llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -490,6 +490,10 @@
   /// MDNodes.
   llvm::DenseMap MetadataIdMap;
 
+  /// Diags gathered from FunctionDecl::takeDeferredDiags().  Emitted at the
+  /// very end of codegen.
+  std::vector> DeferredDiags;
+
 public:
   CodeGenModule(ASTContext , const HeaderSearchOptions ,
 const PreprocessorOptions ,
Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -2271,6 +2271,14 @@
   /// returns 0.
   unsigned getMemoryFunctionKind() const;
 
+  /// Add a diagnostic to be emitted if and when this function is codegen'ed.
+  void addDeferredDiag(PartialDiagnosticAt PD);
+
+  /// Gets this object's list of deferred diagnostics, if there are any.
+  ///
+  /// Although this is logically const, it clears our list of deferred diags.
+  std::vector takeDeferredDiags() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool 

Re: [PATCH] D23341: [CUDA] Include CUDA headers before anything else.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278734: [CUDA] Include CUDA headers before anything else. 
(authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23341?vs=67439=68072#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23341

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/cuda-detect.cu

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -410,6 +410,13 @@
 }
   }
 
+  // Add offload include arguments specific for CUDA.  This must happen before
+  // we -I or -include anything else, because we must pick up the CUDA headers
+  // from the particular CUDA installation, rather than from e.g.
+  // /usr/local/include.
+  if (JA.isOffloading(Action::OFK_Cuda))
+getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless
@@ -607,10 +614,6 @@
 // For IAMCU add special include arguments.
 getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
-
-  // Add offload include arguments specific for CUDA if that is required.
-  if (JA.isOffloading(Action::OFK_Cuda))
-getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.
Index: cfe/trunk/test/Driver/cuda-detect.cu
===
--- cfe/trunk/test/Driver/cuda-detect.cu
+++ cfe/trunk/test/Driver/cuda-detect.cu
@@ -96,6 +96,9 @@
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
+// -internal-externc-isystem flags must come *after* the cuda include flags,
+// because we must search the cuda include directory first.
+// CUDAINC-SAME: "-internal-externc-isystem"
 // COMMON-SAME: "-x" "cuda"
 // CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -410,6 +410,13 @@
 }
   }
 
+  // Add offload include arguments specific for CUDA.  This must happen before
+  // we -I or -include anything else, because we must pick up the CUDA headers
+  // from the particular CUDA installation, rather than from e.g.
+  // /usr/local/include.
+  if (JA.isOffloading(Action::OFK_Cuda))
+getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless
@@ -607,10 +614,6 @@
 // For IAMCU add special include arguments.
 getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
-
-  // Add offload include arguments specific for CUDA if that is required.
-  if (JA.isOffloading(Action::OFK_Cuda))
-getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.
Index: cfe/trunk/test/Driver/cuda-detect.cu
===
--- cfe/trunk/test/Driver/cuda-detect.cu
+++ cfe/trunk/test/Driver/cuda-detect.cu
@@ -96,6 +96,9 @@
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
+// -internal-externc-isystem flags must come *after* the cuda include flags,
+// because we must search the cuda include directory first.
+// CUDAINC-SAME: "-internal-externc-isystem"
 // COMMON-SAME: "-x" "cuda"
 // CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23340: [CUDA] Fix CUDA install version parsing.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278733: [CUDA] Fix CUDA install version parsing. (authored 
by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23340?vs=67438=68071#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23340

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1730,8 +1730,8 @@
   int Major = -1, Minor = -1;
   auto First = V.split('.');
   auto Second = First.second.split('.');
-  if (!First.first.getAsInteger(10, Major) ||
-  !Second.first.getAsInteger(10, Minor))
+  if (First.first.getAsInteger(10, Major) ||
+  Second.first.getAsInteger(10, Minor))
 return CudaVersion::UNKNOWN;
 
   if (Major == 7 && Minor == 0) {


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1730,8 +1730,8 @@
   int Major = -1, Minor = -1;
   auto First = V.split('.');
   auto Second = First.second.split('.');
-  if (!First.first.getAsInteger(10, Major) ||
-  !Second.first.getAsInteger(10, Minor))
+  if (First.first.getAsInteger(10, Major) ||
+  Second.first.getAsInteger(10, Minor))
 return CudaVersion::UNKNOWN;
 
   if (Major == 7 && Minor == 0) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278734 - [CUDA] Include CUDA headers before anything else.

2016-08-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Aug 15 15:38:52 2016
New Revision: 278734

URL: http://llvm.org/viewvc/llvm-project?rev=278734=rev
Log:
[CUDA] Include CUDA headers before anything else.

Summary:
There's no point to --cuda-path if we then go and include /usr/include
first.  And if you install the right packages, Ubuntu will install (very
old) CUDA headers there.

Reviewers: tra

Subscribers: cfe-commits, Prazek

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

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=278734=278733=278734=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Aug 15 15:38:52 2016
@@ -410,6 +410,13 @@ void Clang::AddPreprocessingOptions(Comp
 }
   }
 
+  // Add offload include arguments specific for CUDA.  This must happen before
+  // we -I or -include anything else, because we must pick up the CUDA headers
+  // from the particular CUDA installation, rather than from e.g.
+  // /usr/local/include.
+  if (JA.isOffloading(Action::OFK_Cuda))
+getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless
@@ -607,10 +614,6 @@ void Clang::AddPreprocessingOptions(Comp
 // For IAMCU add special include arguments.
 getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
-
-  // Add offload include arguments specific for CUDA if that is required.
-  if (JA.isOffloading(Action::OFK_Cuda))
-getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.

Modified: cfe/trunk/test/Driver/cuda-detect.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=278734=278733=278734=diff
==
--- cfe/trunk/test/Driver/cuda-detect.cu (original)
+++ cfe/trunk/test/Driver/cuda-detect.cu Mon Aug 15 15:38:52 2016
@@ -96,6 +96,9 @@
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
+// -internal-externc-isystem flags must come *after* the cuda include flags,
+// because we must search the cuda include directory first.
+// CUDAINC-SAME: "-internal-externc-isystem"
 // COMMON-SAME: "-x" "cuda"
 // CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"


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


r278735 - Add the notion of deferred diagnostics.

2016-08-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Aug 15 15:38:56 2016
New Revision: 278735

URL: http://llvm.org/viewvc/llvm-project?rev=278735=rev
Log:
Add the notion of deferred diagnostics.

Summary:
This patch lets you create diagnostics that are emitted if and only if a
particular FunctionDecl is codegen'ed.

This is necessary for CUDA, where some constructs -- e.g. calls from
host+device functions to host functions when compiling for device -- are
allowed to appear in semantically-correct programs, but only if they're
never codegen'ed.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=278735=278734=278735=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Aug 15 15:38:56 2016
@@ -324,6 +324,12 @@ class ASTContext : public RefCountedBase
   };
   llvm::DenseMap ModuleInitializers;
 
+  /// Diagnostics that are emitted if and only if the given function is
+  /// codegen'ed.  Access these through FunctionDecl::addDeferredDiag() and
+  /// FunctionDecl::takeDeferredDiags().
+  llvm::DenseMap>
+  DeferredDiags;
+
 public:
   /// \brief A type synonym for the TemplateOrInstantiation mapping.
   typedef llvm::PointerUnion
@@ -597,6 +603,11 @@ public:
 return DiagAllocator;
   }
 
+  decltype(DeferredDiags) () { return DeferredDiags; }
+  const decltype(DeferredDiags) () const {
+return DeferredDiags;
+  }
+
   const TargetInfo () const { return *Target; }
   const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
 

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=278735=278734=278735=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Aug 15 15:38:56 2016
@@ -2271,6 +2271,14 @@ public:
   /// returns 0.
   unsigned getMemoryFunctionKind() const;
 
+  /// Add a diagnostic to be emitted if and when this function is codegen'ed.
+  void addDeferredDiag(PartialDiagnosticAt PD);
+
+  /// Gets this object's list of deferred diagnostics, if there are any.
+  ///
+  /// Although this is logically const, it clears our list of deferred diags.
+  std::vector takeDeferredDiags() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=278735=278734=278735=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Aug 15 15:38:56 2016
@@ -3446,6 +3446,20 @@ unsigned FunctionDecl::getMemoryFunction
   return 0;
 }
 
+void FunctionDecl::addDeferredDiag(PartialDiagnosticAt PD) {
+  getASTContext().getDeferredDiags()[this].push_back(std::move(PD));
+}
+
+std::vector FunctionDecl::takeDeferredDiags() const {
+  auto  = getASTContext().getDeferredDiags();
+  auto It = DD.find(this);
+  if (It == DD.end())
+return {};
+  auto Ret = std::move(It->second);
+  DD.erase(It);
+  return Ret;
+}
+
 
//===--===//
 // FieldDecl Implementation
 
//===--===//

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=278735=278734=278735=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 15 15:38:56 2016
@@ -497,6 +497,16 @@ void CodeGenModule::Release() {
   EmitVersionIdentMetadata();
 
   EmitTargetMetadata();
+
+  // Emit any deferred diagnostics gathered during codegen.  We didn't emit 
them
+  // when we first discovered them because that would have halted codegen,
+  // preventing us from gathering other deferred diags.
+  for (const PartialDiagnosticAt  : DeferredDiags) {
+SourceLocation Loc = DiagAt.first;
+const PartialDiagnostic  = DiagAt.second;
+DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
+PD.Emit(Builder);
+  }
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
@@ -2872,6 +2882,33 @@ void CodeGenModule::EmitGlobalFunctionDe
  

r278733 - [CUDA] Fix CUDA install version parsing.

2016-08-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Aug 15 15:38:48 2016
New Revision: 278733

URL: http://llvm.org/viewvc/llvm-project?rev=278733=rev
Log:
[CUDA] Fix CUDA install version parsing.

Summary:
getAsInteger returns true on error.  Oops.

No test because the behavior at the moment is identical with or without
this change.

Reviewers: tra

Subscribers: cfe-commits, Prazek

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

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=278733=278732=278733=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Aug 15 15:38:48 2016
@@ -1730,8 +1730,8 @@ static CudaVersion ParseCudaVersionFile(
   int Major = -1, Minor = -1;
   auto First = V.split('.');
   auto Second = First.second.split('.');
-  if (!First.first.getAsInteger(10, Major) ||
-  !Second.first.getAsInteger(10, Minor))
+  if (First.first.getAsInteger(10, Major) ||
+  Second.first.getAsInteger(10, Minor))
 return CudaVersion::UNKNOWN;
 
   if (Major == 7 && Minor == 0) {


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


[PATCH] D23523: [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: dblaikie.
timshen added a subscriber: cfe-commits.

Corresponding LLVM change: D23522

https://reviews.llvm.org/D23523

Files:
  include/clang/Analysis/CFG.h
  include/clang/Analysis/CallGraph.h

Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}
Index: include/clang/Analysis/CFG.h
===
--- include/clang/Analysis/CFG.h
+++ include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)


Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; }
   static inline ChildIteratorType child_begin(NodeType *N) { return N->begin();}
Index: include/clang/Analysis/CFG.h
===
--- include/clang/Analysis/CFG.h
+++ include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
___
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-15 Thread Saleem Abdulrasool via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r278730


https://reviews.llvm.org/D23387



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


r278730 - StaticAnalyzer: Report found fields order in PaddingChecker

2016-08-15 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Aug 15 15:16:13 2016
New Revision: 278730

URL: http://llvm.org/viewvc/llvm-project?rev=278730=rev
Log:
StaticAnalyzer: Report found fields order in PaddingChecker

Report the found fields order in PaddingChecker.

Patch by Alexander Shaposhnikov!

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
cfe/trunk/test/Analysis/padding_message.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp?rev=278730=278729=278730=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp Mon Aug 15 
15:16:13 2016
@@ -82,7 +82,11 @@ public:
 CharUnits BaselinePad = calculateBaselinePad(RD, ASTContext, RL);
 if (BaselinePad.isZero())
   return;
-CharUnits OptimalPad = calculateOptimalPad(RD, ASTContext, RL);
+
+CharUnits OptimalPad;
+SmallVector OptimalFieldsOrder;
+std::tie(OptimalPad, OptimalFieldsOrder) =
+calculateOptimalPad(RD, ASTContext, RL);
 
 CharUnits DiffPad = PadMultiplier * (BaselinePad - OptimalPad);
 if (DiffPad.getQuantity() <= AllowedPad) {
@@ -90,7 +94,7 @@ public:
   // There is not enough excess padding to trigger a warning.
   return;
 }
-reportRecord(RD, BaselinePad, OptimalPad);
+reportRecord(RD, BaselinePad, OptimalPad, OptimalFieldsOrder);
   }
 
   /// \brief Look for arrays of overly padded types. If the padding of the
@@ -199,22 +203,30 @@ public:
   /// 7.  Add tail padding by rounding the current offset up to the structure
   /// alignment. Track the amount of padding added.
 
-  static CharUnits calculateOptimalPad(const RecordDecl *RD,
-   const ASTContext ,
-   const ASTRecordLayout ) {
-struct CharUnitPair {
+  static std::pair
+  calculateOptimalPad(const RecordDecl *RD, const ASTContext ,
+  const ASTRecordLayout ) {
+struct FieldInfo {
   CharUnits Align;
   CharUnits Size;
-  bool operator<(const CharUnitPair ) const {
+  const FieldDecl *Field;
+  bool operator<(const FieldInfo ) const {
 // Order from small alignments to large alignments,
 // then large sizes to small sizes.
-return std::make_pair(Align, -Size) <
-   std::make_pair(RHS.Align, -RHS.Size);
+// then large field indices to small field indices
+return std::make_tuple(Align, -Size,
+   Field ? 
-static_cast(Field->getFieldIndex())
+ : 0) <
+   std::make_tuple(
+   RHS.Align, -RHS.Size,
+   RHS.Field ? -static_cast(RHS.Field->getFieldIndex())
+ : 0);
   }
 };
-SmallVector Fields;
+SmallVector Fields;
 auto GatherSizesAndAlignments = [](const FieldDecl *FD) {
-  CharUnitPair RetVal;
+  FieldInfo RetVal;
+  RetVal.Field = FD;
   auto  = FD->getASTContext();
   std::tie(RetVal.Size, RetVal.Align) =
   Ctx.getTypeInfoInChars(FD->getType());
@@ -226,14 +238,13 @@ public:
 std::transform(RD->field_begin(), RD->field_end(),
std::back_inserter(Fields), GatherSizesAndAlignments);
 std::sort(Fields.begin(), Fields.end());
-
 // This lets us skip over vptrs and non-virtual bases,
 // so that we can just worry about the fields in our object.
 // Note that this does cause us to miss some cases where we
 // could pack more bytes in to a base class's tail padding.
 CharUnits NewOffset = ASTContext.toCharUnitsFromBits(RL.getFieldOffset(0));
 CharUnits NewPad;
-
+SmallVector OptimalFieldsOrder;
 while (!Fields.empty()) {
   unsigned TrailingZeros =
   llvm::countTrailingZeros((unsigned long 
long)NewOffset.getQuantity());
@@ -242,7 +253,7 @@ public:
   // our long long (and CharUnits internal type) negative. So shift 62.
   long long CurAlignmentBits = 1ull << (std::min)(TrailingZeros, 62u);
   CharUnits CurAlignment = CharUnits::fromQuantity(CurAlignmentBits);
-  CharUnitPair InsertPoint = {CurAlignment, CharUnits::Zero()};
+  FieldInfo InsertPoint = {CurAlignment, CharUnits::Zero(), nullptr};
   auto CurBegin = Fields.begin();
   auto CurEnd = Fields.end();
 
@@ -255,6 +266,7 @@ public:
 // We found a field that we can layout with the current alignment.
 --Iter;
 NewOffset += Iter->Size;
+OptimalFieldsOrder.push_back(Iter->Field);
 Fields.erase(Iter);
   } else {
 // We are poorly aligned, and we need to pad in order to layout another
@@ -268,18 +280,18 @@ public:
 // Calculate tail padding.
 

Re: r278655 - [CodeGen] Correctly implement the AVX512 psABI rules

2016-08-15 Thread Gerolf Hoflehner via cfe-commits
LGTM. But it would be great if someone with more exposure to CFE could double 
check.

-Gerolf


> On Aug 14, 2016, at 11:39 PM, David Majnemer via cfe-commits 
>  wrote:
> 
> Author: majnemer
> Date: Mon Aug 15 01:39:18 2016
> New Revision: 278655
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=278655=rev
> Log:
> [CodeGen] Correctly implement the AVX512 psABI rules
> 
> An __m512 vector type wrapped in a structure should be passed in a
> vector register.
> 
> Our prior implementation was based on a draft version of the psABI.
> 
> This fixes PR28975.
> 
> N.B. The update to the ABI was made here:
> https://github.com/hjl-tools/x86-psABI/commit/30f9c9
> 
> Modified:
>cfe/trunk/lib/CodeGen/TargetInfo.cpp
>cfe/trunk/test/CodeGen/x86_64-arguments.c
> 
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=278655=278654=278655=diff
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Aug 15 01:39:18 2016
> @@ -2492,8 +2492,8 @@ void X86_64ABIInfo::classify(QualType Ty
> uint64_t Size = getContext().getTypeSize(Ty);
> 
> // AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger
> -// than four eightbytes, ..., it has class MEMORY.
> -if (Size > 256)
> +// than eight eightbytes, ..., it has class MEMORY.
> +if (Size > 512)
>   return;
> 
> // AMD64-ABI 3.2.3p2: Rule 1. If ..., or it contains unaligned
> @@ -2512,7 +2512,9 @@ void X86_64ABIInfo::classify(QualType Ty
> // The only case a 256-bit wide vector could be used is when the array
> // contains a single 256-bit element. Since Lo and Hi logic isn't extended
> // to work for sizes wider than 128, early check and fallback to memory.
> -if (Size > 128 && EltSize != 256)
> +//
> +if (Size > 128 &&
> +(Size != EltSize || Size > getNativeVectorSizeForAVXABI(AVXLevel)))
>   return;
> 
> for (uint64_t i=0, Offset=OffsetBase; i EltSize) {
> @@ -2533,8 +2535,8 @@ void X86_64ABIInfo::classify(QualType Ty
> uint64_t Size = getContext().getTypeSize(Ty);
> 
> // AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger
> -// than four eightbytes, ..., it has class MEMORY.
> -if (Size > 256)
> +// than eight eightbytes, ..., it has class MEMORY.
> +if (Size > 512)
>   return;
> 
> // AMD64-ABI 3.2.3p2: Rule 2. If a C++ object has either a non-trivial
> @@ -2594,7 +2596,8 @@ void X86_64ABIInfo::classify(QualType Ty
>   // contains a single 256-bit element. Since Lo and Hi logic isn't 
> extended
>   // to work for sizes wider than 128, early check and fallback to memory.
>   //
> -  if (Size > 128 && getContext().getTypeSize(i->getType()) != 256) {
> +  if (Size > 128 && (Size != getContext().getTypeSize(i->getType()) ||
> + Size > getNativeVectorSizeForAVXABI(AVXLevel))) {
> Lo = Memory;
> postMerge(Size, Lo, Hi);
> return;
> @@ -2749,7 +2752,7 @@ llvm::Type *X86_64ABIInfo::GetByteVector
> 
>   // We couldn't find the preferred IR vector type for 'Ty'.
>   uint64_t Size = getContext().getTypeSize(Ty);
> -  assert((Size == 128 || Size == 256) && "Invalid type found!");
> +  assert((Size == 128 || Size == 256 || Size == 512) && "Invalid type 
> found!");
> 
>   // Return a LLVM IR vector type based on the size of 'Ty'.
>   return llvm::VectorType::get(llvm::Type::getDoubleTy(getVMContext()),
> 
> Modified: cfe/trunk/test/CodeGen/x86_64-arguments.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-arguments.c?rev=278655=278654=278655=diff
> ==
> --- cfe/trunk/test/CodeGen/x86_64-arguments.c (original)
> +++ cfe/trunk/test/CodeGen/x86_64-arguments.c Mon Aug 15 01:39:18 2016
> @@ -470,13 +470,14 @@ typedef struct {
> s512 x55;
> __m512 x56;
> 
> -// Even on AVX512, aggregates of size larger than four eightbytes have class
> -// MEMORY (AVX512 draft 0.3 3.2.3p2 Rule 1).
> +// On AVX512, aggregates which contain a __m512 type are classified as 
> SSE/SSEUP
> +// as per https://github.com/hjl-tools/x86-psABI/commit/30f9c9 3.2.3p2 Rule 1
> //
> -// CHECK: declare void @f55(%struct.s512* byval align 64)
> +// AVX512: declare void @f55(<16 x float>)
> +// NO-AVX512: declare void @f55(%struct.s512* byval align 64)
> void f55(s512 x);
> 
> -// However, __m512 has type SSE/SSEUP on AVX512.
> +// __m512 has type SSE/SSEUP on AVX512.
> //
> // AVX512: declare void @f56(<16 x float>)
> // NO-AVX512: declare void @f56(<16 x float>* byval align 64)
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278729 - [CMake] Apple stage1 doesn't need to set libcxx options

2016-08-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon Aug 15 15:15:22 2016
New Revision: 278729

URL: http://llvm.org/viewvc/llvm-project?rev=278729=rev
Log:
[CMake] Apple stage1 doesn't need to set libcxx options

LibCXX settings are configured in stage2 so we don't need them here.

Modified:
cfe/trunk/cmake/caches/Apple-stage1.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage1.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage1.cmake?rev=278729=278728=278729=diff
==
--- cfe/trunk/cmake/caches/Apple-stage1.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage1.cmake Mon Aug 15 15:15:22 2016
@@ -27,11 +27,6 @@ set(CLANG_BOOTSTRAP_PASSTHROUGH
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 
-# LIBCXX Settings
-set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
-set(LIBCXX_INSTALL_HEADERS ON CACHE BOOL "")
-set(LIBCXX_OVERRIDE_DARWIN_INSTALL ON CACHE BOOL "")
-
 set(CLANG_BOOTSTRAP_TARGETS
   generate-order-file
   check-all


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


Re: [PATCH] D23241: Add the notion of deferred diagnostics.

2016-08-15 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/D23241



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


Re: [PATCH] D23493: Fix PR28366: Teach the const-expression evaluator to be more fault tolerant with non-const enclosing local variables, or otherwise fold them if const.

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ExprConstant.cpp:4791-4802
@@ -4790,1 +4790,14 @@
 
+CallStackFrame *getNearestContainingCallFrame(CallStackFrame *CurFrame,
+  const VarDecl *VD) {
+  if (auto *FD =
+dyn_cast(VD->getDeclContext()->getRedeclContext())) {
+FD = FD->getFirstDecl();
+for (CallStackFrame *It = CurFrame; It; It = It->Caller) {
+  if (It->Callee && FD == It->Callee->getFirstDecl())
+return It;
+}
+  }
+  return nullptr;
+}
+

This doesn't seem right to me: in the case where the variable is not in the 
expected frame, there seems to be no reason to expect it would be in a caller's 
frame rather than in some unrelated place, nor to special-case that situation. 
(And this does the wrong thing for constexpr lambdas, where the captured 
variable need not be in the *innermost* call frame for the function in which 
the variable was declared.)

Instead, how about changing the `VD->hasLocalStorage() && ...` condition below 
to also check that the `DeclContext` of the `VarDecl` is the callee of the 
current call, and leave `Frame` null otherwise.


Repository:
  rL LLVM

https://reviews.llvm.org/D23493



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


Re: [PATCH] D23485: [Branch 3.9] Remove any traces of partial constexpr lambda implementation (per Richard's request)

2016-08-15 Thread Hans Wennborg via cfe-commits
hans added a comment.

Faisal: go ahead and commit directly to the branch, or let me know if you'd 
like me to do it.


https://reviews.llvm.org/D23485



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


Re: r278710 - Replace an obsolete company name.

2016-08-15 Thread Sean Silva via cfe-commits
You may also want to just try using the unicode character (not that it
really matters that much though).

On Mon, Aug 15, 2016 at 11:45 AM, Paul Robinson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: probinson
> Date: Mon Aug 15 13:45:52 2016
> New Revision: 278710
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278710=rev
> Log:
> Replace an obsolete company name.
>
> Modified:
> cfe/trunk/docs/UsersManual.rst
>
> Modified: cfe/trunk/docs/UsersManual.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> UsersManual.rst?rev=278710=278709=278710=diff
> 
> ==
> --- cfe/trunk/docs/UsersManual.rst (original)
> +++ cfe/trunk/docs/UsersManual.rst Mon Aug 15 13:45:52 2016
> @@ -2,6 +2,8 @@
>  Clang Compiler User's Manual
>  
>
> +.. include:: 
> +
>  .. contents::
> :local:
>
> @@ -1650,7 +1652,7 @@ features. You can "tune" the debug info
>
>  .. option:: -ggdb, -glldb, -gsce
>
> -  Tune the debug info for the ``gdb``, ``lldb``, or Sony Computer
> Entertainment
> +  Tune the debug info for the ``gdb``, ``lldb``, or Sony PlayStation\
> |reg|
>debugger, respectively. Each of these options implies **-g**.
> (Therefore, if
>you want both **-gline-tables-only** and debugger tuning, the tuning
> option
>must come first.)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23241: Add the notion of deferred diagnostics.

2016-08-15 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 68063.
jlebar added a comment.

Move deferred diags storage into ASTContext.


https://reviews.llvm.org/D23241

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h

Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -490,6 +490,10 @@
   /// MDNodes.
   llvm::DenseMap MetadataIdMap;
 
+  /// Diags gathered from FunctionDecl::takeDeferredDiags().  Emitted at the
+  /// very end of codegen.
+  std::vector> DeferredDiags;
+
 public:
   CodeGenModule(ASTContext , const HeaderSearchOptions ,
 const PreprocessorOptions ,
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -497,6 +497,16 @@
   EmitVersionIdentMetadata();
 
   EmitTargetMetadata();
+
+  // Emit any deferred diagnostics gathered during codegen.  We didn't emit them
+  // when we first discovered them because that would have halted codegen,
+  // preventing us from gathering other deferred diags.
+  for (const PartialDiagnosticAt  : DeferredDiags) {
+SourceLocation Loc = DiagAt.first;
+const PartialDiagnostic  = DiagAt.second;
+DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
+PD.Emit(Builder);
+  }
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
@@ -2872,6 +2882,33 @@
  llvm::GlobalValue *GV) {
   const auto *D = cast(GD.getDecl());
 
+  // Emit this function's deferred diagnostics, if none of them are errors.  If
+  // any of them are errors, don't codegen the function, but also don't emit any
+  // of the diagnostics just yet.  Emitting an error during codegen stops
+  // further codegen, and we want to display as many deferred diags as possible.
+  // We'll emit the now twice-deferred diags at the very end of codegen.
+  //
+  // (If a function has both error and non-error diags, we don't emit the
+  // non-error diags here, because order can be significant, e.g. with notes
+  // that follow errors.)
+  auto Diags = D->takeDeferredDiags();
+  bool HasError = llvm::any_of(Diags, [this](const PartialDiagnosticAt ) {
+return getDiags().getDiagnosticLevel(PDAt.second.getDiagID(), PDAt.first) >=
+   DiagnosticsEngine::Error;
+  });
+  if (HasError) {
+DeferredDiags.insert(DeferredDiags.end(),
+ std::make_move_iterator(Diags.begin()),
+ std::make_move_iterator(Diags.end()));
+return;
+  }
+  for (PartialDiagnosticAt  : Diags) {
+const SourceLocation  = PDAt.first;
+const PartialDiagnostic  = PDAt.second;
+DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
+PD.Emit(Builder);
+  }
+
   // Compute the function info and LLVM type.
   const CGFunctionInfo  = getTypes().arrangeGlobalDeclaration(GD);
   llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3446,6 +3446,20 @@
   return 0;
 }
 
+void FunctionDecl::addDeferredDiag(PartialDiagnosticAt PD) {
+  getASTContext().getDeferredDiags()[this].push_back(std::move(PD));
+}
+
+std::vector FunctionDecl::takeDeferredDiags() const {
+  auto  = getASTContext().getDeferredDiags();
+  auto It = DD.find(this);
+  if (It == DD.end())
+return {};
+  auto Ret = std::move(It->second);
+  DD.erase(It);
+  return Ret;
+}
+
 //===--===//
 // FieldDecl Implementation
 //===--===//
Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -2271,6 +2271,14 @@
   /// returns 0.
   unsigned getMemoryFunctionKind() const;
 
+  /// Add a diagnostic to be emitted if and when this function is codegen'ed.
+  void addDeferredDiag(PartialDiagnosticAt PD);
+
+  /// Gets this object's list of deferred diagnostics, if there are any.
+  ///
+  /// Although this is logically const, it clears our list of deferred diags.
+  std::vector takeDeferredDiags() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ 

[libcxx] r278722 - Use -O1 when testing with ASAN and MSAN to prevent Clang OOM errors.

2016-08-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Aug 15 14:37:20 2016
New Revision: 278722

URL: http://llvm.org/viewvc/llvm-project?rev=278722=rev
Log:
Use -O1 when testing with ASAN and MSAN to prevent Clang OOM errors.

Currently certain tests get killed when compiled with ASAN at -O0 because
they eat all of the systems memory. This doesn't happen at -O1, so enable that
to work around the issue.

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

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=278722=278721=278722=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Mon Aug 15 14:37:20 2016
@@ -617,6 +617,7 @@ class Configuration(object):
 self.env['ASAN_OPTIONS'] = 'detect_odr_violation=0'
 self.config.available_features.add('asan')
 self.config.available_features.add('sanitizer-new-delete')
+self.cxx.compile_flags += ['-O1']
 elif san == 'Memory' or san == 'MemoryWithOrigins':
 self.cxx.flags += ['-fsanitize=memory']
 if san == 'MemoryWithOrigins':
@@ -626,6 +627,7 @@ class Configuration(object):
 self.env['MSAN_SYMBOLIZER_PATH'] = llvm_symbolizer
 self.config.available_features.add('msan')
 self.config.available_features.add('sanitizer-new-delete')
+self.cxx.compile_flags += ['-O1']
 elif san == 'Undefined':
 self.cxx.flags += ['-fsanitize=undefined',

'-fno-sanitize=vptr,function,float-divide-by-zero',


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


Re: [clang-tools-extra] r278295 - [Documentation] Improve consistency.

2016-08-15 Thread Eugene Zelenko via cfe-commits
Hi, Miklos!

Sorry, I was not aware about documentation source.

But I think will be good idea to improve punctuation consistency in tool itself.

Eugene.

On Mon, Aug 15, 2016 at 12:24 PM, Miklos Vajna  wrote:
> Hi Eugene,
>
> On Wed, Aug 10, 2016 at 10:00:50PM -, Eugene Zelenko via cfe-commits 
>  wrote:
>> Modified: clang-tools-extra/trunk/docs/clang-rename.rst
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=278295=278294=278295=diff
>> ==
>> --- clang-tools-extra/trunk/docs/clang-rename.rst (original)
>> +++ clang-tools-extra/trunk/docs/clang-rename.rst Wed Aug 10 17:00:49 2016
>> @@ -70,7 +70,7 @@ Alternatively, old name / new name pairs
>>...
>>
>>
>> -That way you can avoid spelling out all the names as commandline arguments:
>> +That way you can avoid spelling out all the names as command line arguments:
>>
>>  .. code-block:: console
>>
>> @@ -122,12 +122,12 @@ The YAML file also supports offsets:
>>clang-rename rename-at options:
>>
>>  -export-fixes=   - YAML file to store suggested fixes in.
>> --extra-arg=- Additional argument to append to the 
>> compiler command line
>> --extra-arg-before= - Additional argument to prepend to the 
>> compiler command line
>> +-extra-arg=- Additional argument to append to the 
>> compiler command line.
>> +-extra-arg-before= - Additional argument to prepend to the 
>> compiler command line.
>>  -i - Overwrite edited s.
>>  -new-name= - The new name to change the symbol to.
>>  -offset= - Locates the symbol by offset as opposed to 
>> :.
>> --p=- Build path
>> +-p=- Build path.
>
> This is the output of the commandline tool. Is it wise to modify the
> documentation, even if the tool's output stays the same? I fear it'll be
> reverted implicitly next time we copy the output after a code
> change.
>
> Regards,
>
> Miklos
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t

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

In https://reviews.llvm.org/D23086#515506, @Anastasia wrote:

>




> Surely vendors can re-implement all OpenCL types with an implicit typedef. 
> For example this would just work:

> 

>   typedef int queue_t;

>   void bar(queue_t q);

>

> 

> I am afraid we will need to provide some implementation to ndrange_t in Clang 
> itself, otherwise I don't see how it could work. Also it would be good to 
> offer standard functionality without any extra includes just like it worked 
> up to now for all other features.


It will work if we have a way to identify whether a type is ndrange_t type. So 
far I have suggested to compare the canonical types. Basically when we see a 
declaration of typedef with name 'ndrange_t', we save its canonical type X to 
ASTContext. When we need to check if type Y is ndrange_t, we just need to check 
Y->getCanonicalType() == X.

On the other hand, pre-define ndrange_t in Clang does not solve the problem of 
how to decide if a type is ndrange_t, since user can define typedefs for 
ndrange_t, e.g.

  typedef ndrange_t my_ndrange_t;

In this case, we still need to check the canonical type.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086



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


Re: [clang-tools-extra] r278295 - [Documentation] Improve consistency.

2016-08-15 Thread Miklos Vajna via cfe-commits
Hi Eugene,

On Wed, Aug 10, 2016 at 10:00:50PM -, Eugene Zelenko via cfe-commits 
 wrote:
> Modified: clang-tools-extra/trunk/docs/clang-rename.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=278295=278294=278295=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-rename.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-rename.rst Wed Aug 10 17:00:49 2016
> @@ -70,7 +70,7 @@ Alternatively, old name / new name pairs
>...
>  
>  
> -That way you can avoid spelling out all the names as commandline arguments:
> +That way you can avoid spelling out all the names as command line arguments:
>  
>  .. code-block:: console
>  
> @@ -122,12 +122,12 @@ The YAML file also supports offsets:
>clang-rename rename-at options:
>  
>  -export-fixes=   - YAML file to store suggested fixes in.
> --extra-arg=- Additional argument to append to the 
> compiler command line
> --extra-arg-before= - Additional argument to prepend to the 
> compiler command line
> +-extra-arg=- Additional argument to append to the 
> compiler command line.
> +-extra-arg-before= - Additional argument to prepend to the 
> compiler command line.
>  -i - Overwrite edited s.
>  -new-name= - The new name to change the symbol to.
>  -offset= - Locates the symbol by offset as opposed to 
> :.
> --p=- Build path
> +-p=- Build path.

This is the output of the commandline tool. Is it wise to modify the
documentation, even if the tool's output stays the same? I fear it'll be
reverted implicitly next time we copy the output after a code
change.

Regards,

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


Re: [PATCH] D23507: [libcxx] include/math.h: Re-enable missing C++11 decls on SunOS

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r278716.


https://reviews.llvm.org/D23507



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


[libcxx] r278716 - Fix PR28506. Re-enable missing math.h C++11 decls on SunOS. Patch from Michal Gorny.

2016-08-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Aug 15 13:58:57 2016
New Revision: 278716

URL: http://llvm.org/viewvc/llvm-project?rev=278716=rev
Log:
Fix PR28506. Re-enable missing math.h C++11 decls on SunOS. Patch from Michal 
Gorny.

Modified:
libcxx/trunk/include/cmath
libcxx/trunk/include/math.h

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=278716=278715=278716=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Mon Aug 15 13:58:57 2016
@@ -331,7 +331,6 @@ using ::double_t;
 using ::abs;
 #endif
 
-#ifndef __sun__
 using ::acos;
 using ::acosf;
 using ::asin;
@@ -346,54 +345,44 @@ using ::cos;
 using ::cosf;
 using ::cosh;
 using ::coshf;
-#endif // __sun__
 
 using ::exp;
 using ::expf;
 
-#ifndef __sun__
 using ::fabs;
 using ::fabsf;
 using ::floor;
 using ::floorf;
-#endif //__sun__
 
 using ::fmod;
 using ::fmodf;
 
-#ifndef __sun__
 using ::frexp;
 using ::frexpf;
 using ::ldexp;
 using ::ldexpf;
-#endif // __sun__
 
 using ::log;
 using ::logf;
 
-#ifndef __sun__
 using ::log10;
 using ::log10f;
 using ::modf;
 using ::modff;
-#endif // __sun__ 
 
 using ::pow;
 using ::powf;
 
-#ifndef __sun__
 using ::sin;
 using ::sinf;
 using ::sinh;
 using ::sinhf;
-#endif // __sun__
 
 using ::sqrt;
 using ::sqrtf;
 using ::tan;
 using ::tanf;
 
-#ifndef __sun__
 using ::tanh;
 using ::tanhf;
 
@@ -449,14 +438,12 @@ using ::lrintf;
 using ::lround;
 using ::lroundf;
 #endif // _LIBCPP_MSVCRT
-#endif // __sun__
 
 #ifndef _LIBCPP_MSVCRT
 using ::nan;
 using ::nanf;
 #endif // _LIBCPP_MSVCRT
 
-#ifndef __sun__
 #ifndef _LIBCPP_MSVCRT
 using ::nearbyint;
 using ::nearbyintf;
@@ -547,11 +534,6 @@ using ::tgammal;
 using ::truncl;
 #endif // !_LIBCPP_MSVCRT
 
-#else 
-using ::lgamma;
-using ::lgammaf;
-#endif // __sun__
-
 #if _LIBCPP_STD_VER > 14
 inline _LIBCPP_INLINE_VISIBILITY float   hypot(   float x,   float 
y,   float z ) { return sqrt(x*x + y*y + z*z); }
 inline _LIBCPP_INLINE_VISIBILITY double  hypot(  double x,  double 
y,  double z ) { return sqrt(x*x + y*y + z*z); }

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=278716=278715=278716=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Mon Aug 15 13:58:57 2016
@@ -636,11 +636,9 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y)
 
 #endif  // isunordered
 
-#ifndef __sun__
-
 // abs
 
-#if !defined(_AIX)
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY
 float
 abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
@@ -652,11 +650,11 @@ abs(double __lcpp_x) _NOEXCEPT {return f
 inline _LIBCPP_INLINE_VISIBILITY
 long double
 abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
-#endif // !defined(_AIX)
+#endif // !(defined(_AIX) || defined(__sun__))
 
 // acos
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT
   {return acosf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) 
_NOEXCEPT {return acosl(__lcpp_x);}
 #endif
@@ -668,7 +666,7 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return aco
 
 // asin
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT
   {return asinf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) 
_NOEXCEPT {return asinl(__lcpp_x);}
 #endif
@@ -680,7 +678,7 @@ asin(_A1 __lcpp_x) _NOEXCEPT {return asi
 
 // atan
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   atan(float __lcpp_x) _NOEXCEPT
   {return atanf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) 
_NOEXCEPT {return atanl(__lcpp_x);}
 #endif
@@ -692,7 +690,7 @@ atan(_A1 __lcpp_x) _NOEXCEPT {return ata
 
 // atan2
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   atan2(float __lcpp_y, float 
__lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long 
double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
 #endif
@@ -715,7 +713,7 @@ atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXC
 
 // ceil
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   ceil(float __lcpp_x) _NOEXCEPT 

Re: [PATCH] D23507: [libcxx] include/math.h: Re-enable missing C++11 decls on SunOS

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.

Also LGTM.


https://reviews.llvm.org/D23507



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


r278710 - Replace an obsolete company name.

2016-08-15 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Aug 15 13:45:52 2016
New Revision: 278710

URL: http://llvm.org/viewvc/llvm-project?rev=278710=rev
Log:
Replace an obsolete company name.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=278710=278709=278710=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Aug 15 13:45:52 2016
@@ -2,6 +2,8 @@
 Clang Compiler User's Manual
 
 
+.. include:: 
+
 .. contents::
:local:
 
@@ -1650,7 +1652,7 @@ features. You can "tune" the debug info
 
 .. option:: -ggdb, -glldb, -gsce
 
-  Tune the debug info for the ``gdb``, ``lldb``, or Sony Computer Entertainment
+  Tune the debug info for the ``gdb``, ``lldb``, or Sony PlayStation\ |reg|
   debugger, respectively. Each of these options implies **-g**. (Therefore, if
   you want both **-gline-tables-only** and debugger tuning, the tuning option
   must come first.)


___
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-15 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D23455#515486, @brad.king wrote:

> > the feasibility of emitting 'arguments' instead of 'command' into the JSON 
> > compilation database.
>
>
> CMake constructs the command lines internally using string replacement on 
> templates.  We never actually know the exact arguments.  Therefore providing 
> arguments instead of the whole command would require parsing to be done on 
> the CMake side instead.  This is theoretically possible because we do know 
> the shell for which we are generating (Windows `cmd` versus MSYS `sh`).  
> However, it may also require a bunch of logic we don't have yet but that LLVM 
> does.
>
> Alternatively, the JSON could have an additional `command_shell="..."` field 
> that indicates the shell for which the command line is encoded.


Bummer. Given that this is hard to do in CMake, then I think we should just 
tokenize in Clang. Let's use llvm::sys::getProcessTriple() instead of 
LLVM_ON_WIN32 and check if that is an MSVC environment as a proxy for the shell 
type.


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] D23492: Make function local tags visible.

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaLookup.cpp:1546-1548
@@ -1545,5 +1549,5 @@
 // definition of it, because parameters aren't "within" the definition.
 if ((D->isTemplateParameter() || isa(D))
 ? isVisible(SemaRef, cast(DC))
 : SemaRef.hasVisibleDefinition(cast(DC))) {
   if (SemaRef.ActiveTemplateInstantiations.empty() &&

This check should already do the right thing for the case of a function-scope 
declaration.


Comment at: test/Modules/Inputs/PR28794/Subdir/LibBHeader.h:6-10
@@ +5,7 @@
+
+template 
+void *operator new(size_t, BumpPtrAllocatorImpl &) 
{
+  struct S {};
+  return (void*)0xdead;
+}
+

We should not be instantiating this template in the first place: the template 
definition should not be visible within pr28794.cpp because the LibBHeader.h 
submodule is never imported. I would guess the bug is that we're missing a 
visibility check for the template definition when we trigger the instantiation 
here.


Repository:
  rL LLVM

https://reviews.llvm.org/D23492



___
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-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

i don't have commit access, if you could land this patch i would be grateful


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] D23086: [OpenCL] Generate concrete struct type for ndrange_t

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

In https://reviews.llvm.org/D23086#515468, @yaxunl wrote:

> In https://reviews.llvm.org/D23086#515443, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D23086#514279, @yaxunl wrote:
> >
> > > How about we decide if a type is ndrange_t type based on their canonical 
> > > types. If the canonical type of type X is the same as the canonical type 
> > > of ndrange_t type, then type X is treated as ndrange_t type. Is this 
> > > reasonable?
> >
> >
> > I am not sure I understand entirely what you mean?
> >
> > Following the earlier suggestion from David, I think we can just create a 
> > struct type internally and then typedef it to ndrange_t, we can use 
> > buildImplicitRecord and addImplicitTypedef methods I believe. The latter 
> > one has already been used for other OpenCL types.
> >
> > We will have to switch to string comparisons to identify this type in 
> > SemaChecking.cpp and CGBuiltins.cpp for handling the enqueue_kernel call.
>
>
> This was not the approach we agreed upon.
>
> The approach we agreed upon was
>
> In https://reviews.llvm.org/D23086#507215, @majnemer wrote:
>
> > In https://reviews.llvm.org/D23086#507203, @yaxunl wrote:
> >
> > > How about assuming ndrange_t is a struct type defined by user and 
> > > identify it by struct type name in Clang? This gives user freedom of 
> > > implementing it differently than SPIR. In opencl-c.h define it as a 
> > > struct type as SPIR required.
> >
> >
> > That sounds fine to me.
>
>
> The issue of your approach is that vendors lose the freedom to define 
> ndrange_t the way they like.


Surely vendors can re-implement all OpenCL types with an implicit typedef. For 
example this would just work:

  typedef int queue_t;
  void bar(queue_t q);

I am afraid we will need to provide some implementation to ndrange_t in Clang 
itself, otherwise I don't see how it could work. Also it would be good to offer 
standard functionality without any extra includes just like it worked up to now 
for all other features.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086



___
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-15 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM



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())

alexshap wrote:
> 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 =  clang::CharUnits,
>   int>] not viable: expects an l-value for 2nd argument
> tie(_Tp&... __t) _NOEXCEPT
> 
Fair enough.  std::make_tuple it is.


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] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-15 Thread Brad King via cfe-commits
brad.king added a comment.

> the feasibility of emitting 'arguments' instead of 'command' into the JSON 
> compilation database.


CMake constructs the command lines internally using string replacement on 
templates.  We never actually know the exact arguments.  Therefore providing 
arguments instead of the whole command would require parsing to be done on the 
CMake side instead.  This is theoretically possible because we do know the 
shell for which we are generating (Windows `cmd` versus MSYS `sh`).  However, 
it may also require a bunch of logic we don't have yet but that LLVM does.

Alternatively, the JSON could have an additional `command_shell="..."` field 
that indicates the shell for which the command line is encoded.


https://reviews.llvm.org/D23455



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


[clang-tools-extra] r278686 - [Documentation] Improve checks groups descriptions in clang-tidy/index.rst

2016-08-15 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Aug 15 12:44:29 2016
New Revision: 278686

URL: http://llvm.org/viewvc/llvm-project?rev=278686=rev
Log:
[Documentation] Improve checks groups descriptions in clang-tidy/index.rst

Use table to avoid tautology. List all existing checks groups. Use alphabetical 
order.

Differential revision: https://reviews.llvm.org/D23471

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=278686=278685=278686=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Mon Aug 15 12:44:29 2016
@@ -50,25 +50,24 @@ enabled by this value.
 
 There are currently the following groups of checks:
 
-* Checks related to the LLVM coding conventions have names starting with
-  ``llvm-``.
+== 
=
+Name prefixDescription
+== 
=
+``boost-`` Checks related to Boost library.
+``cert-``  Checks related to CERT Secure Coding Guidelines.
+``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
+``clang-analyzer-``Clang Static Analyzer checks.
+``google-``Checks related to the Google coding conventions.
+``llvm-``  Checks related to the LLVM coding conventions.
+``misc-``  Checks that we didn't have a better category for.
+``modernize-`` Checks that advocate usage of modern (currently "modern"
+   means "C++11") language constructs.
+``mpi-``   Checks related to MPI (Message Passing Interface).
+``performance-``   Checks that target performance-related issues.
+``readability-``   Checks that target readability-related issues that don't
+   relate to any particular coding style.
+== 
=
 
-* Checks related to the Google coding conventions have names starting with
-  ``google-``.
-
-* Checks named ``modernize-*`` advocate the usage of modern (currently "modern"
-  means "C++11") language constructs.
-
-* The ``readability-`` checks target readability-related issues that don't
-  relate to any particular coding style.
-
-* Checks with names starting with ``misc-`` the checks that we didn't have a
-  better category for.
-
-* Clang static analyzer checks are named starting with ``clang-analyzer-``.
-
-* Checks related to Boost library starts with ``boost-``. 
-  
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
 diagnostics are displayed by clang-tidy and can be filtered out using
 ``-checks=`` option. However, the ``-checks=`` option does not affect


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


Re: [PATCH] D23471: [Documentation] Improve checks groups descriptions in clang-tidy/index.rst

2016-08-15 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278686: [Documentation] Improve checks groups descriptions 
in clang-tidy/index.rst (authored by eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D23471?vs=67926=68050#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23471

Files:
  clang-tools-extra/trunk/docs/clang-tidy/index.rst

Index: clang-tools-extra/trunk/docs/clang-tidy/index.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst
@@ -50,25 +50,24 @@
 
 There are currently the following groups of checks:
 
-* Checks related to the LLVM coding conventions have names starting with
-  ``llvm-``.
+== 
=
+Name prefixDescription
+== 
=
+``boost-`` Checks related to Boost library.
+``cert-``  Checks related to CERT Secure Coding Guidelines.
+``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
+``clang-analyzer-``Clang Static Analyzer checks.
+``google-``Checks related to the Google coding conventions.
+``llvm-``  Checks related to the LLVM coding conventions.
+``misc-``  Checks that we didn't have a better category for.
+``modernize-`` Checks that advocate usage of modern (currently "modern"
+   means "C++11") language constructs.
+``mpi-``   Checks related to MPI (Message Passing Interface).
+``performance-``   Checks that target performance-related issues.
+``readability-``   Checks that target readability-related issues that don't
+   relate to any particular coding style.
+== 
=
 
-* Checks related to the Google coding conventions have names starting with
-  ``google-``.
-
-* Checks named ``modernize-*`` advocate the usage of modern (currently "modern"
-  means "C++11") language constructs.
-
-* The ``readability-`` checks target readability-related issues that don't
-  relate to any particular coding style.
-
-* Checks with names starting with ``misc-`` the checks that we didn't have a
-  better category for.
-
-* Clang static analyzer checks are named starting with ``clang-analyzer-``.
-
-* Checks related to Boost library starts with ``boost-``. 
-  
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
 diagnostics are displayed by clang-tidy and can be filtered out using
 ``-checks=`` option. However, the ``-checks=`` option does not affect


Index: clang-tools-extra/trunk/docs/clang-tidy/index.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst
@@ -50,25 +50,24 @@
 
 There are currently the following groups of checks:
 
-* Checks related to the LLVM coding conventions have names starting with
-  ``llvm-``.
+== =
+Name prefixDescription
+== =
+``boost-`` Checks related to Boost library.
+``cert-``  Checks related to CERT Secure Coding Guidelines.
+``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
+``clang-analyzer-``Clang Static Analyzer checks.
+``google-``Checks related to the Google coding conventions.
+``llvm-``  Checks related to the LLVM coding conventions.
+``misc-``  Checks that we didn't have a better category for.
+``modernize-`` Checks that advocate usage of modern (currently "modern"
+   means "C++11") language constructs.
+``mpi-``   Checks related to MPI (Message Passing Interface).
+``performance-``   Checks that target performance-related issues.
+``readability-``   Checks that target readability-related issues that don't
+   relate to any particular coding style.
+== =
 
-* Checks related to the Google coding conventions have names starting with
-  ``google-``.
-
-* Checks named ``modernize-*`` advocate the usage of modern (currently "modern"
-  means "C++11") language constructs.
-
-* The ``readability-`` checks target readability-related issues that don't
-  relate to any particular coding style.
-
-* Checks with names starting with ``misc-`` the checks that we didn't have a
-  better category for.
-
-* Clang static analyzer checks are named starting with ``clang-analyzer-``.
-
-* Checks related to Boost library starts with ``boost-``. 
-  
 Clang diagnostics are treated in a similar way as 

Re: [PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t

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

In https://reviews.llvm.org/D23086#515443, @Anastasia wrote:

> In https://reviews.llvm.org/D23086#514279, @yaxunl wrote:
>
> > How about we decide if a type is ndrange_t type based on their canonical 
> > types. If the canonical type of type X is the same as the canonical type of 
> > ndrange_t type, then type X is treated as ndrange_t type. Is this 
> > reasonable?
>
>
> I am not sure I understand entirely what you mean?
>
> Following the earlier suggestion from David, I think we can just create a 
> struct type internally and then typedef it to ndrange_t, we can use 
> buildImplicitRecord and addImplicitTypedef methods I believe. The latter one 
> has already been used for other OpenCL types.
>
> We will have to switch to string comparisons to identify this type in 
> SemaChecking.cpp and CGBuiltins.cpp for handling the enqueue_kernel call.


This was not the approach we agreed upon.

The approach we agreed upon was

In https://reviews.llvm.org/D23086#507215, @majnemer wrote:

> In https://reviews.llvm.org/D23086#507203, @yaxunl wrote:
>
> > How about assuming ndrange_t is a struct type defined by user and identify 
> > it by struct type name in Clang? This gives user freedom of implementing it 
> > differently than SPIR. In opencl-c.h define it as a struct type as SPIR 
> > required.
>
>
> That sounds fine to me.


The issue of your approach is that vendors lose the freedom to define ndrange_t 
the way they like.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086



___
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-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap marked 2 inline comments as done.
alexshap added a comment.

ping


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] D23293: Some place that could using TargetParser in clang

2016-08-15 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

More trivial changes. LGTM. Thanks!


https://reviews.llvm.org/D23293



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


Re: [PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t

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

In https://reviews.llvm.org/D23086#514279, @yaxunl wrote:

> How about we decide if a type is ndrange_t type based on their canonical 
> types. If the canonical type of type X is the same as the canonical type of 
> ndrange_t type, then type X is treated as ndrange_t type. Is this reasonable?


I am not sure I understand entirely what you mean?

Following the earlier suggestion from David, I think we can just create a 
struct type internally and then typedef it to ndrange_t, we can use 
buildImplicitRecord and addImplicitTypedef methods I believe. The latter one 
has already been used for other OpenCL types.

We will have to switch to string comparisons to identify this type in 
SemaChecking.cpp and CGBuiltins.cpp for handling the enqueue_kernel call.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086



___
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-15 Thread Adhemerval Zanella via cfe-commits
zatrazz added a comment.

Ping.


https://reviews.llvm.org/D23420



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


  1   2   >