[PATCH] D44878: libFuzzer OpenBSD support

2018-04-09 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

Thanks ! anybody who can land it for me I ll be grateful.


https://reviews.llvm.org/D44878



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


[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

2018-04-09 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329671: [ExprConstant] Use an AST node and a version number 
as a key to create (authored by ahatanak, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42776?vs=141788=141789#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42776

Files:
  cfe/trunk/include/clang/AST/APValue.h
  cfe/trunk/lib/AST/APValue.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
  cfe/trunk/test/SemaCXX/constexpr-default-arg.cpp

Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -452,8 +452,8 @@
 
 // Note that we intentionally use std::map here so that references to
 // values are stable.
-typedef std::map MapTy;
-typedef MapTy::const_iterator temp_iterator;
+typedef std::pair MapKeyTy;
+typedef std::map MapTy;
 /// Temporaries - Temporary lvalues materialized within this stack frame.
 MapTy Temporaries;
 
@@ -463,6 +463,20 @@
 /// Index - The call index of this call.
 unsigned Index;
 
+/// The stack of integers for tracking version numbers for temporaries.
+SmallVector TempVersionStack = {1};
+unsigned CurTempVersion = TempVersionStack.back();
+
+unsigned getTempVersion() const { return TempVersionStack.back(); }
+
+void pushTempVersion() {
+  TempVersionStack.push_back(++CurTempVersion);
+}
+
+void popTempVersion() {
+  TempVersionStack.pop_back();
+}
+
 // FIXME: Adding this to every 'CallStackFrame' may have a nontrivial impact
 // on the overall stack usage of deeply-recursing constexpr evaluataions.
 // (We should cache this map rather than recomputing it repeatedly.)
@@ -479,10 +493,36 @@
APValue *Arguments);
 ~CallStackFrame();
 
-APValue *getTemporary(const void *Key) {
-  MapTy::iterator I = Temporaries.find(Key);
-  return I == Temporaries.end() ? nullptr : >second;
+// Return the temporary for Key whose version number is Version.
+APValue *getTemporary(const void *Key, unsigned Version) {
+  MapKeyTy KV(Key, Version);
+  auto LB = Temporaries.lower_bound(KV);
+  if (LB != Temporaries.end() && LB->first == KV)
+return >second;
+  // Pair (Key,Version) wasn't found in the map. Check that no elements
+  // in the map have 'Key' as their key.
+  assert((LB == Temporaries.end() || LB->first.first != Key) &&
+ (LB == Temporaries.begin() || std::prev(LB)->first.first != Key) &&
+ "Element with key 'Key' found in map");
+  return nullptr;
 }
+
+// Return the current temporary for Key in the map.
+APValue *getCurrentTemporary(const void *Key) {
+  auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
+  if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
+return ::prev(UB)->second;
+  return nullptr;
+}
+
+// Return the version number of the current temporary for Key.
+unsigned getCurrentTemporaryVersion(const void *Key) const {
+  auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
+  if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
+return std::prev(UB)->first.second;
+  return 0;
+}
+
 APValue (const void *Key, bool IsLifetimeExtended);
   };
 
@@ -612,7 +652,8 @@
 
 /// EvaluatingObject - Pair of the AST node that an lvalue represents and
 /// the call index that that lvalue was allocated in.
-typedef std::pair EvaluatingObject;
+typedef std::pair>
+EvaluatingObject;
 
 /// EvaluatingConstructors - Set of objects that are currently being
 /// constructed.
@@ -631,8 +672,10 @@
   }
 };
 
-bool isEvaluatingConstructor(APValue::LValueBase Decl, unsigned CallIndex) {
-  return EvaluatingConstructors.count(EvaluatingObject(Decl, CallIndex));
+bool isEvaluatingConstructor(APValue::LValueBase Decl, unsigned CallIndex,
+ unsigned Version) {
+  return EvaluatingConstructors.count(
+  EvaluatingObject(Decl, {CallIndex, Version}));
 }
 
 /// The current array initialization index, if we're performing array
@@ -728,7 +771,7 @@
 void setEvaluatingDecl(APValue::LValueBase Base, APValue ) {
   EvaluatingDecl = Base;
   EvaluatingDeclValue = 
-  EvaluatingConstructors.insert({Base, 0});
+  EvaluatingConstructors.insert({Base, {0, 0}});
 }
 
 const LangOptions () const { return Ctx.getLangOpts(); }
@@ -1092,11 +1135,16 @@
 unsigned OldStackSize;
   public:
 ScopeRAII(EvalInfo )
-: Info(Info), OldStackSize(Info.CleanupStack.size()) 

r329671 - [ExprConstant] Use an AST node and a version number as a key to create

2018-04-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Apr  9 22:15:01 2018
New Revision: 329671

URL: http://llvm.org/viewvc/llvm-project?rev=329671=rev
Log:
[ExprConstant] Use an AST node and a version number as a key to create
an APValue and retrieve it from map Temporaries.

The version number is needed when a single AST node is visited multiple
times and is used to create APValues that are required to be distinct
from each other (for example, MaterializeTemporaryExprs in default
arguments and VarDecls in loops).

rdar://problem/36505742

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

Added:
cfe/trunk/test/SemaCXX/constexpr-default-arg.cpp
Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=329671=329670=329671=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Mon Apr  9 22:15:01 2018
@@ -53,7 +53,58 @@ public:
 MemberPointer,
 AddrLabelDiff
   };
-  typedef llvm::PointerUnion LValueBase;
+
+  class LValueBase {
+  public:
+typedef llvm::PointerUnion PtrTy;
+
+LValueBase() : CallIndex(0), Version(0) {}
+
+template 
+LValueBase(T P, unsigned I = 0, unsigned V = 0)
+: Ptr(P), CallIndex(I), Version(V) {}
+
+template 
+bool is() const { return Ptr.is(); }
+
+template 
+T get() const { return Ptr.get(); }
+
+template 
+T dyn_cast() const { return Ptr.dyn_cast(); }
+
+void *getOpaqueValue() const;
+
+bool isNull() const;
+
+explicit operator bool () const;
+
+PtrTy getPointer() const {
+  return Ptr;
+}
+
+unsigned getCallIndex() const {
+  return CallIndex;
+}
+
+void setCallIndex(unsigned Index) {
+  CallIndex = Index;
+}
+
+unsigned getVersion() const {
+  return Version;
+}
+
+bool operator==(const LValueBase ) const {
+  return Ptr == Other.Ptr && CallIndex == Other.CallIndex &&
+ Version == Other.Version;
+}
+
+  private:
+PtrTy Ptr;
+unsigned CallIndex, Version;
+  };
+
   typedef llvm::PointerIntPair BaseOrMemberType;
   union LValuePathEntry {
 /// BaseOrMember - The FieldDecl or CXXRecordDecl indicating the next item
@@ -135,15 +186,15 @@ public:
   }
   APValue(const APValue );
   APValue(APValue &) : Kind(Uninitialized) { swap(RHS); }
-  APValue(LValueBase B, const CharUnits , NoLValuePath N, unsigned CallIndex,
+  APValue(LValueBase B, const CharUnits , NoLValuePath N,
   bool IsNullPtr = false)
   : Kind(Uninitialized) {
-MakeLValue(); setLValue(B, O, N, CallIndex, IsNullPtr);
+MakeLValue(); setLValue(B, O, N, IsNullPtr);
   }
   APValue(LValueBase B, const CharUnits , ArrayRef Path,
-  bool OnePastTheEnd, unsigned CallIndex, bool IsNullPtr = false)
+  bool OnePastTheEnd, bool IsNullPtr = false)
   : Kind(Uninitialized) {
-MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex, IsNullPtr);
+MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, IsNullPtr);
   }
   APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(Uninitialized) 
{
 MakeArray(InitElts, Size);
@@ -255,6 +306,7 @@ public:
   bool hasLValuePath() const;
   ArrayRef getLValuePath() const;
   unsigned getLValueCallIndex() const;
+  unsigned getLValueVersion() const;
   bool isNullPointer() const;
 
   APValue (unsigned I) {
@@ -376,10 +428,10 @@ public:
 ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I);
   }
   void setLValue(LValueBase B, const CharUnits , NoLValuePath,
- unsigned CallIndex, bool IsNullPtr);
+ bool IsNullPtr);
   void setLValue(LValueBase B, const CharUnits ,
  ArrayRef Path, bool OnePastTheEnd,
- unsigned CallIndex, bool IsNullPtr);
+ bool IsNullPtr);
   void setUnion(const FieldDecl *Field, const APValue ) {
 assert(isUnion() && "Invalid accessor");
 ((UnionData*)(char*)Data.buffer)->Field = Field;
@@ -451,4 +503,14 @@ private:
 
 } // end namespace clang.
 
+namespace llvm {
+template<> struct DenseMapInfo {
+  static clang::APValue::LValueBase getEmptyKey();
+  static clang::APValue::LValueBase getTombstoneKey();
+  static unsigned getHashValue(const clang::APValue::LValueBase );
+  static bool isEqual(const clang::APValue::LValueBase ,
+  const clang::APValue::LValueBase );
+};
+}
+
 #endif

Modified: cfe/trunk/lib/AST/APValue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/APValue.cpp?rev=329671=329670=329671=diff
==
--- cfe/trunk/lib/AST/APValue.cpp (original)
+++ cfe/trunk/lib/AST/APValue.cpp Mon Apr  9 22:15:01 

[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

2018-04-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 141788.
ahatanak marked an inline comment as done.
ahatanak set the repository for this revision to rC Clang.
ahatanak added a comment.

Use pair as the key.


Repository:
  rC Clang

https://reviews.llvm.org/D42776

Files:
  clang/include/clang/AST/APValue.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp
  clang/test/SemaCXX/constexpr-default-arg.cpp

Index: clang/test/SemaCXX/constexpr-default-arg.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-default-arg.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++1y -S -o - -emit-llvm -verify %s
+
+namespace default_arg_temporary {
+
+constexpr bool equals(const float& arg = 1.0f) {
+  return arg == 1.0f;
+}
+
+constexpr const int (const int  = 0) {
+  return p;
+}
+
+struct S {
+  constexpr S(const int  = 0) {}
+};
+
+void test_default_arg2() {
+  // This piece of code used to cause an assertion failure in
+  // CallStackFrame::createTemporary because the same MTE is used to initilize
+  // both elements of the array (see PR33140).
+  constexpr S s[2] = {};
+
+  // This piece of code used to cause an assertion failure in
+  // CallStackFrame::createTemporary because multiple CXXDefaultArgExpr share
+  // the same MTE (see PR33140).
+  static_assert(equals() && equals(), "");
+
+  // Test that constant expression evaluation produces distinct lvalues for
+  // each call.
+  static_assert(() != (), "");
+}
+
+// Check that multiple CXXDefaultInitExprs don't cause an assertion failure.
+struct A { int & = 0; }; // expected-warning {{binding reference member}} // expected-note {{reference member declared here}}
+struct B { A x, y; };
+B b = {};
+
+}
Index: clang/test/SemaCXX/constant-expression-cxx1y.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -852,7 +852,6 @@
   static_assert(h(2) == 0, ""); // expected-error {{constant expression}} expected-note {{in call}}
   static_assert(h(3) == 0, ""); // expected-error {{constant expression}} expected-note {{in call}}
 
-  // FIXME: This function should be treated as non-constant.
   constexpr void lifetime_versus_loops() {
 int *p = 0;
 for (int i = 0; i != 2; ++i) {
@@ -862,10 +861,10 @@
   if (i)
 // This modifies the 'n' from the previous iteration of the loop outside
 // its lifetime.
-++*q;
+++*q; // expected-note {{increment of object outside its lifetime}}
 }
   }
-  static_assert((lifetime_versus_loops(), true), "");
+  static_assert((lifetime_versus_loops(), true), ""); // expected-error {{constant expression}} expected-note {{in call}}
 }
 
 namespace Bitfields {
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -452,8 +452,8 @@
 
 // Note that we intentionally use std::map here so that references to
 // values are stable.
-typedef std::map MapTy;
-typedef MapTy::const_iterator temp_iterator;
+typedef std::pair MapKeyTy;
+typedef std::map MapTy;
 /// Temporaries - Temporary lvalues materialized within this stack frame.
 MapTy Temporaries;
 
@@ -463,6 +463,20 @@
 /// Index - The call index of this call.
 unsigned Index;
 
+/// The stack of integers for tracking version numbers for temporaries.
+SmallVector TempVersionStack = {1};
+unsigned CurTempVersion = TempVersionStack.back();
+
+unsigned getTempVersion() const { return TempVersionStack.back(); }
+
+void pushTempVersion() {
+  TempVersionStack.push_back(++CurTempVersion);
+}
+
+void popTempVersion() {
+  TempVersionStack.pop_back();
+}
+
 // FIXME: Adding this to every 'CallStackFrame' may have a nontrivial impact
 // on the overall stack usage of deeply-recursing constexpr evaluataions.
 // (We should cache this map rather than recomputing it repeatedly.)
@@ -479,10 +493,36 @@
APValue *Arguments);
 ~CallStackFrame();
 
-APValue *getTemporary(const void *Key) {
-  MapTy::iterator I = Temporaries.find(Key);
-  return I == Temporaries.end() ? nullptr : >second;
+// Return the temporary for Key whose version number is Version.
+APValue *getTemporary(const void *Key, unsigned Version) {
+  MapKeyTy KV(Key, Version);
+  auto LB = Temporaries.lower_bound(KV);
+  if (LB != Temporaries.end() && LB->first == KV)
+return >second;
+  // Pair (Key,Version) wasn't found in the map. Check that no elements
+  // in the map have 'Key' as their key.
+  assert((LB == Temporaries.end() || LB->first.first != Key) &&
+ (LB == Temporaries.begin() || std::prev(LB)->first.first != Key) &&
+ 

[PATCH] D45016: [libcxx] [test] Avoid MSVC truncation warnings.

2018-04-09 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

Ping?


https://reviews.llvm.org/D45016



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


[libcxx] r329665 - [libcxx] [test] Use the correct type from strlen. Include correct header.

2018-04-09 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Mon Apr  9 20:04:07 2018
New Revision: 329665

URL: http://llvm.org/viewvc/llvm-project?rev=329665=rev
Log:
[libcxx] [test] Use the correct type from strlen. Include correct header.

Modified:

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp

libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp?rev=329665=329664=329665=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
 Mon Apr  9 20:04:07 2018
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
@@ -71,8 +72,8 @@ int main()
 }
 {
 char buf[10] = "abcd";
-int s = std::strlen(buf);
-std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+std::size_t s = std::strlen(buf);
+std::strstreambuf sb(buf, sizeof(buf) - s, buf + s);
 assert(sb.sgetc() == 'a');
 assert(sb.snextc() == 'b');
 assert(sb.snextc() == 'c');

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp?rev=329665=329664=329665=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
 Mon Apr  9 20:04:07 2018
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
@@ -71,8 +72,8 @@ int main()
 }
 {
 signed char buf[10] = "abcd";
-int s = std::strlen((char*)buf);
-std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+std::size_t s = std::strlen((char*)buf);
+std::strstreambuf sb(buf, sizeof(buf) - s, buf + s);
 assert(sb.sgetc() == 'a');
 assert(sb.snextc() == 'b');
 assert(sb.snextc() == 'c');

Modified: 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp?rev=329665=329664=329665=diff
==
--- 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
 Mon Apr  9 20:04:07 2018
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 int main()
 {
@@ -71,8 +72,8 @@ int main()
 }
 {
 unsigned char buf[10] = "abcd";
-int s = std::strlen((char*)buf);
-std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+std::size_t s = std::strlen((char*)buf);
+std::strstreambuf sb(buf, sizeof(buf) - s, buf + s);
 assert(sb.sgetc() == 'a');
 assert(sb.snextc() == 'b');
 assert(sb.snextc() == 'c');

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp?rev=329665=329664=329665=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
 Mon Apr  9 20:04:07 2018
@@ -45,7 +45,7 @@ protected:
 {
 if (ch != base::traits_type::eof())
 {
-int n = str_.size();
+std::size_t n = str_.size();
 str_.push_back(static_cast(ch));
 

[PATCH] D45449: [CUDA] Document recent changes

2018-04-09 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Overall LGTM. We could use specific instructions for what exactly one needs to 
do in order to use relocatable device code in practice. Could be a separate 
patch.


Repository:
  rC Clang

https://reviews.llvm.org/D45449



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


Re: r329652 - [AST] Attempt to fix buildbot warnings + appease MSVC; NFCI

2018-04-09 Thread Akira Hatanaka via cfe-commits
Thanks!

> On Apr 9, 2018, at 6:11 PM, George Burgess IV via cfe-commits 
>  wrote:
> 
> Author: gbiv
> Date: Mon Apr  9 18:11:26 2018
> New Revision: 329652
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=329652=rev
> Log:
> [AST] Attempt to fix buildbot warnings + appease MSVC; NFCI
> 
> GCC 4.8.4 on a bot was warning about `ArgPassingKind` not fitting in
> `ArgPassingRestrictions`, which appears to be incorrect, since
> `ArgPassingKind` only has three potential values:
> 
> "warning: 'clang::RecordDecl::ArgPassingRestrictions' is too small to
> hold all values of 'enum clang::RecordDecl::ArgPassingKind'"
> 
> Additionally, I remember hearing (though my knowledge may be outdated)
> that MSVC won't merge adjacent bitfields if their types are different.
> 
> Try to fix both issues by turning these into `uint8_t`s.
> 
> Modified:
>cfe/trunk/include/clang/AST/Decl.h
> 
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=329652=329651=329652=diff
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  9 18:11:26 2018
> @@ -3599,10 +3599,13 @@ private:
>   /// Indicates whether this struct is destroyed in the callee. This flag is
>   /// meaningless when Microsoft ABI is used since parameters are always
>   /// destroyed in the callee.
> -  bool ParamDestroyedInCallee : 1;
> +  ///
> +  /// Please note that MSVC won't merge adjacent bitfields if they don't have
> +  /// the same type.
> +  uint8_t ParamDestroyedInCallee : 1;
> 
>   /// Represents the way this type is passed to a function.
> -  ArgPassingKind ArgPassingRestrictions : 2;
> +  uint8_t ArgPassingRestrictions : 2;
> 
> protected:
>   RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
> @@ -3691,15 +3694,15 @@ public:
>   /// it must have at least one trivial, non-deleted copy or move constructor.
>   /// FIXME: This should be set as part of completeDefinition.
>   bool canPassInRegisters() const {
> -return ArgPassingRestrictions == APK_CanPassInRegs;
> +return getArgPassingRestrictions() == APK_CanPassInRegs;
>   }
> 
>   ArgPassingKind getArgPassingRestrictions() const {
> -return ArgPassingRestrictions;
> +return static_cast(ArgPassingRestrictions);
>   }
> 
>   void setArgPassingRestrictions(ArgPassingKind Kind) {
> -ArgPassingRestrictions = Kind;
> +ArgPassingRestrictions = static_cast(Kind);
>   }
> 
>   bool isParamDestroyedInCallee() const {
> 
> 
> ___
> 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] D45470: Emit an error when mixing and

2018-04-09 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In addition to the currently proposed approach

  #if ...
  #error ...
  #endif
  // header content

I also tried

  #if ...
  #error ...
  #else
  // header content
  #endif

It allows to have fewer error messages but can be more surprising. It can look 
like the only problem is a missing macro but after defining it you can discover 
that the situations is more complex. Also in some cases omitting a header 
content can lead to other errors which can be confusing too.


https://reviews.llvm.org/D45470



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


r329652 - [AST] Attempt to fix buildbot warnings + appease MSVC; NFCI

2018-04-09 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Apr  9 18:11:26 2018
New Revision: 329652

URL: http://llvm.org/viewvc/llvm-project?rev=329652=rev
Log:
[AST] Attempt to fix buildbot warnings + appease MSVC; NFCI

GCC 4.8.4 on a bot was warning about `ArgPassingKind` not fitting in
`ArgPassingRestrictions`, which appears to be incorrect, since
`ArgPassingKind` only has three potential values:

"warning: 'clang::RecordDecl::ArgPassingRestrictions' is too small to
hold all values of 'enum clang::RecordDecl::ArgPassingKind'"

Additionally, I remember hearing (though my knowledge may be outdated)
that MSVC won't merge adjacent bitfields if their types are different.

Try to fix both issues by turning these into `uint8_t`s.

Modified:
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=329652=329651=329652=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  9 18:11:26 2018
@@ -3599,10 +3599,13 @@ private:
   /// Indicates whether this struct is destroyed in the callee. This flag is
   /// meaningless when Microsoft ABI is used since parameters are always
   /// destroyed in the callee.
-  bool ParamDestroyedInCallee : 1;
+  ///
+  /// Please note that MSVC won't merge adjacent bitfields if they don't have
+  /// the same type.
+  uint8_t ParamDestroyedInCallee : 1;
 
   /// Represents the way this type is passed to a function.
-  ArgPassingKind ArgPassingRestrictions : 2;
+  uint8_t ArgPassingRestrictions : 2;
 
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
@@ -3691,15 +3694,15 @@ public:
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.
   bool canPassInRegisters() const {
-return ArgPassingRestrictions == APK_CanPassInRegs;
+return getArgPassingRestrictions() == APK_CanPassInRegs;
   }
 
   ArgPassingKind getArgPassingRestrictions() const {
-return ArgPassingRestrictions;
+return static_cast(ArgPassingRestrictions);
   }
 
   void setArgPassingRestrictions(ArgPassingKind Kind) {
-ArgPassingRestrictions = Kind;
+ArgPassingRestrictions = static_cast(Kind);
   }
 
   bool isParamDestroyedInCallee() const {


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


[PATCH] D45470: Emit an error when mixing and

2018-04-09 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rsmith, EricWF, mclow.lists.
Herald added subscribers: christof, jkorous-apple.

Atomics in C and C++ are incompatible at the moment and mixing the
headers can result in confusing error messages.

Emit an error explicitly telling about the incompatibility. Introduce
the macro `__ALLOW_STDC_ATOMICS_IN_CXX__` that allows to choose in C++
between C atomics and C++ atomics.

rdar://problem/27435938


https://reviews.llvm.org/D45470

Files:
  clang/lib/Headers/stdatomic.h
  clang/test/Headers/stdatomic.cpp
  libcxx/include/atomic
  libcxx/test/libcxx/atomics/c_compatibility.fail.cpp


Index: libcxx/test/libcxx/atomics/c_compatibility.fail.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/atomics/c_compatibility.fail.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// 
+
+// Test that including  fails to compile when we want to use C atomics
+// in C++ and have corresponding macro defined.
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
+// MODULES_DEFINES: __ALLOW_STDC_ATOMICS_IN_CXX__
+#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__
+#define __ALLOW_STDC_ATOMICS_IN_CXX__
+#endif
+
+#include 
+
+int main()
+{
+}
+
Index: libcxx/include/atomic
===
--- libcxx/include/atomic
+++ libcxx/include/atomic
@@ -555,6 +555,9 @@
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 #error  is not implemented
 #endif
+#ifdef __ALLOW_STDC_ATOMICS_IN_CXX__
+#error  is incompatible with the C++ standard library
+#endif
 
 #if _LIBCPP_STD_VER > 14
 # define __cpp_lib_atomic_is_always_lock_free 201603L
Index: clang/test/Headers/stdatomic.cpp
===
--- /dev/null
+++ clang/test/Headers/stdatomic.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 -D__ALLOW_STDC_ATOMICS_IN_CXX__ %s -verify
+
+#include 
+
+#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__
+// expected-error@stdatomic.h:* {{ is incompatible with the C++ 
standard library}}
+#else
+// expected-no-diagnostics
+#endif
Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -31,6 +31,10 @@
 # include_next 
 #else
 
+#if !defined(__ALLOW_STDC_ATOMICS_IN_CXX__) && defined(__cplusplus)
+#error " is incompatible with the C++ standard library; define 
__ALLOW_STDC_ATOMICS_IN_CXX__ to proceed."
+#endif
+
 #include 
 #include 
 


Index: libcxx/test/libcxx/atomics/c_compatibility.fail.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/atomics/c_compatibility.fail.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// 
+
+// Test that including  fails to compile when we want to use C atomics
+// in C++ and have corresponding macro defined.
+
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
+// MODULES_DEFINES: __ALLOW_STDC_ATOMICS_IN_CXX__
+#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__
+#define __ALLOW_STDC_ATOMICS_IN_CXX__
+#endif
+
+#include 
+
+int main()
+{
+}
+
Index: libcxx/include/atomic
===
--- libcxx/include/atomic
+++ libcxx/include/atomic
@@ -555,6 +555,9 @@
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 #error  is not implemented
 #endif
+#ifdef __ALLOW_STDC_ATOMICS_IN_CXX__
+#error  is incompatible with the C++ standard library
+#endif
 
 #if _LIBCPP_STD_VER > 14
 # define __cpp_lib_atomic_is_always_lock_free 201603L
Index: clang/test/Headers/stdatomic.cpp

[PATCH] D45468: [clang-tidy] Adding Fuchsia checker for human-readable logging

2018-04-09 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: aaron.ballman, hokein, ilya-biryukov.
juliehockett added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, mgorny.

Adds a checker to the Fuchsia module to flag instances of attempting to log the 
system's numerical representation of the status, instead of the more 
human-friendly string representation. Matches formatting functions (the printf 
family and a set of user-specified formatting-like ones) that have a 
zx_status_t parameter and suggests a fixit to replace the zx_status_t parameter 
with a call to zx_status_get_string(param).


https://reviews.llvm.org/D45468

Files:
  clang-tidy/zircon/CMakeLists.txt
  clang-tidy/zircon/HumanReadableStatusCheck.cpp
  clang-tidy/zircon/HumanReadableStatusCheck.h
  clang-tidy/zircon/ZirconTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/zircon-human-readable-status.rst
  test/clang-tidy/zircon-human-readable-status.cpp

Index: test/clang-tidy/zircon-human-readable-status.cpp
===
--- /dev/null
+++ test/clang-tidy/zircon-human-readable-status.cpp
@@ -0,0 +1,70 @@
+// RUN: %check_clang_tidy %s zircon-human-readable-status %t -- \
+// RUN:   -config="{CheckOptions: [{key: zircon-human-readable-status.FormatLikeFunctions, value: 'my_printer'}]}" \
+// RUN:   -header-filter=.* \
+// RUN: -- -std=c++11
+
+#include 
+
+#define PRINT(fmt...) printf(fmt);
+
+void my_printer(const char *fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  printf(fmt, args);
+  va_end(args);
+}
+
+#define WRAP(fmt...) wrapper(fmt);
+void wrapper(const char *fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  printf(fmt, args);
+  va_end(args);
+}
+
+typedef int zx_status_t;
+
+const char *zx_status_get_string(zx_status_t status) { return "status"; }
+
+int main() {
+  zx_status_t status = 0;
+  printf("%d", status);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: non-human-readable log message
+  // CHECK-FIXES: printf("%s", zx_status_get_string(status));
+  printf("%s", zx_status_get_string(status));
+  my_printer("%d", status);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: non-human-readable log message
+  // CHECK-FIXES: my_printer("%s", zx_status_get_string(status));
+  PRINT("%d", status);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: non-human-readable log message
+  // CHECK-FIXES: PRINT("%s", zx_status_get_string(status));
+  
+  WRAP("%d", status);
+  wrapper("%d", status);
+  
+  unsigned notstatus = 0;
+  printf("%d", notstatus);
+  printf("%s", zx_status_get_string(status));
+  my_printer("%d", notstatus);
+  PRINT("%d", notstatus);
+  WRAP("%d", notstatus);
+  wrapper("%d", notstatus);
+  
+  printf("%d, %d", status, notstatus);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: non-human-readable log message
+  // CHECK-FIXES: printf("%s, %d", zx_status_get_string(status), notstatus);
+  printf("%s, %d", zx_status_get_string(status), notstatus);
+  my_printer("%d, %d", status, notstatus);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: non-human-readable log message
+  // CHECK-FIXES: my_printer("%s, %d", zx_status_get_string(status), notstatus);
+  printf("%d, %d", notstatus, status);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: non-human-readable log message
+  // CHECK-FIXES: printf("%d, %s", notstatus, zx_status_get_string(status));
+  PRINT("%d, %d", status, notstatus);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: non-human-readable log message
+  // CHECK-FIXES: PRINT("%s, %d", zx_status_get_string(status), notstatus);
+  
+  WRAP("%d, %d", notstatus, status);
+  wrapper("%d, %d", notstatus, status);
+
+}
Index: docs/clang-tidy/checks/zircon-human-readable-status.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/zircon-human-readable-status.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - zircon-human-readable-status
+
+zircon-human-readable-status
+
+
+Suggests fix for printf-family functions with a zx_status_t argument to convert
+status argument to a human-readable string (zx_status_t is a Zircon kernel
+status message, and zx_status_get_string() is a function that retrieves the
+associated string value.
+
+For example:
+
+.. code-block:: c++
+
+  zx_status_t status;
+  printf("%d", status);   // Suggests printf("%s", zx_status_get_string(status))
+  
+  unsigned num;
+  printf("%d", num)   // No warning
+
+
+Options
+---
+
+.. option:: Names
+
+   A semi-colon-separated list of fully-qualified names of functions that 
+   are printf-like (i.e. are variadic, with the first argument being a
+   formatting string and subsequent argments being the printf replacements.).
+   Default is empty.
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ 

[libclc] r329647 - hypot: Port from amd builtins

2018-04-09 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Mon Apr  9 17:11:58 2018
New Revision: 329647

URL: http://llvm.org/viewvc/llvm-project?rev=329647=rev
Log:
hypot: Port from amd builtins

v2: Fix whitespace errors

Use only subnormal path.
Passes CTS on carrizo and turks.
Signed-off-by: Jan Vesely 
Reviewer: Aaron Watry 

Added:
libclc/trunk/generic/include/math/clc_hypot.h
libclc/trunk/generic/lib/math/clc_hypot.cl
Removed:
libclc/trunk/generic/lib/math/hypot.inc
Modified:
libclc/trunk/generic/lib/SOURCES
libclc/trunk/generic/lib/math/hypot.cl

Added: libclc/trunk/generic/include/math/clc_hypot.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/clc_hypot.h?rev=329647=auto
==
--- libclc/trunk/generic/include/math/clc_hypot.h (added)
+++ libclc/trunk/generic/include/math/clc_hypot.h Mon Apr  9 17:11:58 2018
@@ -0,0 +1,5 @@
+#define __CLC_FUNCTION __clc_hypot
+#define __CLC_BODY 
+#include 
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=329647=329646=329647=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Mon Apr  9 17:11:58 2018
@@ -120,6 +120,7 @@ math/half_rsqrt.cl
 math/half_sin.cl
 math/half_sqrt.cl
 math/half_tan.cl
+math/clc_hypot.cl
 math/hypot.cl
 math/ilogb.cl
 math/clc_ldexp.cl

Added: libclc/trunk/generic/lib/math/clc_hypot.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/clc_hypot.cl?rev=329647=auto
==
--- libclc/trunk/generic/lib/math/clc_hypot.cl (added)
+++ libclc/trunk/generic/lib/math/clc_hypot.cl Mon Apr  9 17:11:58 2018
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include 
+#include 
+
+#include "config.h"
+#include "math.h"
+#include "../clcmacro.h"
+
+// Returns sqrt(x*x + y*y) with no overflow or underflow unless the result 
warrants it
+_CLC_DEF _CLC_OVERLOAD float __clc_hypot(float x, float y)
+{
+uint ux = as_uint(x);
+uint aux = ux & EXSIGNBIT_SP32;
+uint uy = as_uint(y);
+uint auy = uy & EXSIGNBIT_SP32;
+float retval;
+int c = aux > auy;
+ux = c ? aux : auy;
+uy = c ? auy : aux;
+
+int xexp = clamp((int)(ux >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32, -126, 126);
+float fx_exp = as_float((xexp + EXPBIAS_SP32) << EXPSHIFTBITS_SP32);
+float fi_exp = as_float((-xexp + EXPBIAS_SP32) << EXPSHIFTBITS_SP32);
+float fx = as_float(ux) * fi_exp;
+float fy = as_float(uy) * fi_exp;
+retval = sqrt(mad(fx, fx, fy*fy)) * fx_exp;
+
+retval = ux > PINFBITPATT_SP32 | uy == 0 ? as_float(ux) : retval;
+retval = ux == PINFBITPATT_SP32 | uy == PINFBITPATT_SP32 ? 
as_float(PINFBITPATT_SP32) : retval;
+return retval;
+}
+_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_hypot, float, float)
+
+#ifdef cl_khr_fp64
+_CLC_DEF _CLC_OVERLOAD double __clc_hypot(double x, double y)
+{
+ulong ux = as_ulong(x) & ~SIGNBIT_DP64;
+int xexp = ux >> EXPSHIFTBITS_DP64;
+x = as_double(ux);
+
+ulong uy = as_ulong(y) & ~SIGNBIT_DP64;
+int yexp = uy >> EXPSHIFTBITS_DP64;
+y = as_double(uy);
+
+int c = xexp > EXPBIAS_DP64 + 500 | yexp > EXPBIAS_DP64 + 500;
+double preadjust = c ? 0x1.0p-600 : 1.0;
+double postadjust = c ? 0x1.0p+600 : 1.0;
+
+c = xexp < EXPBIAS_DP64 - 500 | yexp < EXPBIAS_DP64 - 500;
+preadjust = c ? 0x1.0p+600 : preadjust;
+postadjust = c ? 0x1.0p-600 : postadjust;
+
+double ax = x * preadjust;
+double ay = y * preadjust;
+
+// The post adjust may overflow, but this can't be avoided in any case
+

[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

2018-04-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv updated this revision to Diff 141768.
george.burgess.iv marked 2 inline comments as done.
george.burgess.iv added a comment.

Address feedback


https://reviews.llvm.org/D45059

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
  clang-tidy/android/ComparisonInTempFailureRetryCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-comparison-in-temp-failure-retry.c

Index: test/clang-tidy/android-comparison-in-temp-failure-retry.c
===
--- /dev/null
+++ test/clang-tidy/android-comparison-in-temp-failure-retry.c
@@ -0,0 +1,148 @@
+// RUN: %check_clang_tidy %s android-comparison-in-temp-failure-retry %t
+
+#define TEMP_FAILURE_RETRY(x)  \
+  ({   \
+typeof(x) __z; \
+do \
+  __z = (x);   \
+while (__z == -1); \
+__z;   \
+  })
+
+int foo();
+int bar(int a);
+
+void test() {
+  int i;
+  TEMP_FAILURE_RETRY((i = foo()));
+  TEMP_FAILURE_RETRY(foo());
+  TEMP_FAILURE_RETRY((foo()));
+
+  TEMP_FAILURE_RETRY(foo() == 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: top-level comparison in TEMP_FAILURE_RETRY [android-comparison-in-temp-failure-retry]
+  TEMP_FAILURE_RETRY((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TEMP_FAILURE_RETRY((int)(foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  TEMP_FAILURE_RETRY(bar(foo() == 1));
+  TEMP_FAILURE_RETRY((bar(foo() == 1)));
+  TEMP_FAILURE_RETRY((bar(foo() == 1)) == 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TEMP_FAILURE_RETRY(((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TEMP_FAILURE_RETRY((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define INDIRECT TEMP_FAILURE_RETRY
+  INDIRECT(foo());
+  INDIRECT((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: top-level comparison in TEMP_FAILURE_RETRY
+  INDIRECT(bar(foo() == 1));
+  INDIRECT((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define TFR(x) TEMP_FAILURE_RETRY(x)
+  TFR(foo());
+  TFR((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TFR(bar(foo() == 1));
+  TFR((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define ADD_TFR(x) (1 + TEMP_FAILURE_RETRY(x) + 1)
+  ADD_TFR(foo());
+  ADD_TFR(foo() == 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  ADD_TFR(bar(foo() == 1));
+  ADD_TFR((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define ADDP_TFR(x) (1 + TEMP_FAILURE_RETRY((x)) + 1)
+  ADDP_TFR(foo());
+  ADDP_TFR((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  ADDP_TFR(bar(foo() == 1));
+  ADDP_TFR((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define MACRO TEMP_FAILURE_RETRY(foo() == 1)
+  MACRO;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  // Be sure that being a macro arg doesn't mess with this.
+#define ID(x) (x)
+  ID(ADDP_TFR(bar(foo() == 1)));
+  ID(ADDP_TFR(bar(foo() == 1) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in TEMP_FAILURE_RETRY
+  ID(MACRO);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define CMP(x) x == 1
+  TEMP_FAILURE_RETRY(CMP(foo()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: top-level comparison in TEMP_FAILURE_RETRY
+}
+
+// Be sure that it works inside of things like loops, if statements, etc.
+void control_flow() {
+  do {
+if (TEMP_FAILURE_RETRY(foo())) {
+}
+
+if (TEMP_FAILURE_RETRY(foo() == 1)) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
+}
+
+if (TEMP_FAILURE_RETRY(bar(foo() == 1))) {
+}
+
+if (TEMP_FAILURE_RETRY(bar(foo() 

[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

2018-04-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks!

I plan to commit this tomorrow, to give time for any last-minute comments.

Thanks again to everyone for the review. :)


https://reviews.llvm.org/D45059



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


LLVM buildmaster will restarted tonight

2018-04-09 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be restarted after 6PM Pacific time today.

Thanks

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


[PATCH] D43779: [Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

2018-04-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added subscribers: lebedev.ri, dblaikie.
dblaikie added a comment.

FWIW - I had some thoughts on this a while back:
https://reviews.llvm.org/D4313


Repository:
  rL LLVM

https://reviews.llvm.org/D43779



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


Re: [PATCH] D43779: [Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

2018-04-09 Thread David Blaikie via cfe-commits
FWIW - I had some thoughts on this a while back:
https://reviews.llvm.org/D4313

On Mon, Apr 9, 2018 at 4:54 AM Roman Lebedev via Phabricator via
llvm-commits  wrote:

> lebedev.ri added a comment.
>
> In https://reviews.llvm.org/D43779#1061444, @alexfh wrote:
>
> > In https://reviews.llvm.org/D43779#1061043, @lebedev.ri wrote:
> >
> > > Hmm.
> > >  Got back to this issue.
> > >
> > > Not reproducible with gcc-4.8.5 and gcc-4.9.3 in ubuntu 16.04 chroot.
> > >  *Reproducible* with gcc-4.8.4 and gcc-4.9.2 in debian oldstable
> (Jessie) chroot.
> > >  So one might assume that it was fixed.
> > >
> > > I did try to creduce the crasher, but not not much success, since gcc
> takes 10+ sec to crash.
> >
> >
> > That's unfortunate, but it could be even worse. My experience with
> creducing crashes is that the process can take up to several days. In this
> case, however, we know what changes cause the crash and it should be
> possible to construct the test case manually instead of creducing it.
> >
> > > Should i simply try to re-commit and see if the buildbots got upgraded
> so this is no longer an issue?
>
>
>
>
> > I wouldn't expect buildbots to have been upgraded without someone doing
> this on purpose. If you have the list of buildbots that crashed, you could
> look at their recent logs to figure out which GCC version they are using
> now.
>
> Yes, it seems they weren't upgraded yet as of this time.
>
> > It *might* be fine to require a patched version of GCC, but in that case
> you would have to:
> >  0. Ask llvm-dev+cfe-dev whether anyone has concerns in raising the
> minimum required version of GCC
>
> Yep, did that right after posting that comment,
> http://lists.llvm.org/pipermail/llvm-dev/2018-April/122438.html
>
> > 1. Fix the documentation, in particular this list:
> https://llvm.org/docs/GettingStarted.html#software and these
> instructions:
> https://llvm.org/docs/GettingStarted.html#getting-a-modern-host-c-toolchain
> > 2. Get buildbot maintainers to upgrade their GCC to at least the new
> required version
> >
> >   An alternative would be to try working around the bug.
>
>
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D43779
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-09 Thread Paul Semel via Phabricator via cfe-commits
paulsemel updated this revision to Diff 141762.
paulsemel added a comment.

Added a good test for the `int (*)()` function prototype, as we decided to 
accept it as a valid function for the dumper


Repository:
  rC Clang

https://reviews.llvm.org/D44093

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/dump-struct-builtin.c
  test/Sema/builtin-dump-struct.c

Index: test/Sema/builtin-dump-struct.c
===
--- /dev/null
+++ test/Sema/builtin-dump-struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -verify %s
+
+void invalid_uses() {
+  struct A {
+  };
+  struct A a;
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);
+  int (*badfunc2)(int, ...);
+  void (*badfunc3)(const char *, ...);
+  int (*badfunc4)(char *, ...);
+  int (*badfunc5)(void);
+
+  __builtin_dump_struct(); // expected-error {{too few arguments to function call, expected 2, have 0}}
+  __builtin_dump_struct(1);// expected-error {{too few arguments to function call, expected 2, have 1}}
+  __builtin_dump_struct(1, 2); // expected-error {{passing 'int' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('int' vs structure pointer)}}
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(b, goodfunc); // expected-error {{passing 'void *' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('void *' vs structure pointer)}}
+  __builtin_dump_struct(, badfunc1); // expected-error {{passing 'int (*)(const char *)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc2); // expected-error {{passing 'int (*)(int, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(int, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc3); // expected-error {{passing 'void (*)(const char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('void (*)(const char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc4); // expected-error {{passing 'int (*)(char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc5); // expected-error {{passing 'int (*)(void)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(void)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(a, goodfunc);  // expected-error {{passing 'struct A' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('struct A' vs structure pointer)}}
+}
+
+void valid_uses() {
+  struct A {
+  };
+  union B {
+  };
+
+  int (*goodfunc)(const char *, ...);
+  int (*goodfunc2)();
+  struct A a;
+  union B b;
+
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc2);
+}
Index: test/CodeGen/dump-struct-builtin.c
===
--- /dev/null
+++ test/CodeGen/dump-struct-builtin.c
@@ -0,0 +1,387 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/stdio.h"
+
+void unit1() {
+  struct U1A {
+short a;
+  };
+
+  struct U1A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U1A, %struct.U1A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit2() {
+  struct U2A {
+unsigned short a;
+  };
+
+  struct U2A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U2A, %struct.U2A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit3() {
+  struct U3A {
+int a;
+  };
+
+  struct U3A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U3A, %struct.U3A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-09 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added inline comments.



Comment at: test/Sema/builtin-dump-struct.c:8
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);

aaron.ballman wrote:
> paulsemel wrote:
> > aaron.ballman wrote:
> > > paulsemel wrote:
> > > > aaron.ballman wrote:
> > > > > Can you also add a test for: `int (*badfunc4)(char *, ...);` and `int 
> > > > > (*badfunc5)();`
> > > > Isn't `int (*func)()` is a valid prototype for a printf like function 
> > > > in C ?
> > > > I instead added `int (*func)(void)` to the test cases.
> > > > Isn't int (*func)() is a valid prototype for a printf like function in 
> > > > C ?
> > > 
> > > No, because it's missing the `const char *` as the mandatory first 
> > > parameter. Do you want that to be allowed and hope the callee has it 
> > > correct on their side, or do you want it to diagnose as not being a valid 
> > > function?
> > Actually, from a kernel developer perspective, I would say it's better to 
> > let the user do its stuff on his side, because kernel is full of trick !
> > But if you think I'd rather check whether we have `int (*)(const char *, 
> > ...)` at any time, we can go for it !
> Okay, if you think it'd be beneficial to allow a function without a 
> prototype, I'm okay with it. Can you make it an explicit "good" test case?
Sure :)


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


Re: r329580 - [Tooling] A CompilationDatabase wrapper that infers header commands.

2018-04-09 Thread Galina Kistanova via cfe-commits
Hello Sam,

It looks like this commit added broken tests to one of our builders:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/8957/steps/test-check-all/logs/stdio

Failing Tests (5):
Clang-Unit :: Tooling/./ToolingTests.exe/InterpolateTest.Case
Clang-Unit :: Tooling/./ToolingTests.exe/InterpolateTest.Language
Clang-Unit :: Tooling/./ToolingTests.exe/InterpolateTest.Nearby
Clang-Unit :: Tooling/./ToolingTests.exe/InterpolateTest.Strip
. . .
Please have a look?

The builder was red and did not send notifications.

Thanks

Galina

On Mon, Apr 9, 2018 at 8:17 AM, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Mon Apr  9 08:17:39 2018
> New Revision: 329580
>
> URL: http://llvm.org/viewvc/llvm-project?rev=329580=rev
> Log:
> [Tooling] A CompilationDatabase wrapper that infers header commands.
>
> Summary:
> The wrapper finds the closest matching compile command using filename
> heuristics
> and makes minimal tweaks so it can be used with the header.
>
> Subscribers: klimek, mgorny, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D45006
>
> Added:
> cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
> Modified:
> cfe/trunk/include/clang/Tooling/CompilationDatabase.h
> cfe/trunk/lib/Tooling/CMakeLists.txt
> cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/
> CompilationDatabase.h?rev=329580=329579=329580=diff
> 
> ==
> --- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
> +++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Mon Apr  9
> 08:17:39 2018
> @@ -213,6 +213,13 @@ private:
>std::vector CompileCommands;
>  };
>
> +/// Returns a wrapped CompilationDatabase that defers to the provided one,
> +/// but getCompileCommands() will infer commands for unknown files.
> +/// The return value of getAllFiles() or getAllCompileCommands() is
> unchanged.
> +/// See InterpolatingCompilationDatabase.cpp for details on heuristics.
> +std::unique_ptr
> +inferMissingCompileCommands(std::unique_ptr);
> +
>  } // namespace tooling
>  } // namespace clang
>
>
> Modified: cfe/trunk/lib/Tooling/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
> CMakeLists.txt?rev=329580=329579=329580=diff
> 
> ==
> --- cfe/trunk/lib/Tooling/CMakeLists.txt (original)
> +++ cfe/trunk/lib/Tooling/CMakeLists.txt Mon Apr  9 08:17:39 2018
> @@ -15,6 +15,7 @@ add_clang_library(clangTooling
>Execution.cpp
>FileMatchTrie.cpp
>FixIt.cpp
> +  InterpolatingCompilationDatabase.cpp
>JSONCompilationDatabase.cpp
>Refactoring.cpp
>RefactoringCallbacks.cpp
>
> Added: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
> InterpolatingCompilationDatabase.cpp?rev=329580=auto
> 
> ==
> --- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp (added)
> +++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp Mon Apr  9
> 08:17:39 2018
> @@ -0,0 +1,458 @@
> +//===- InterpolatingCompilationDatabase.cpp -*- C++
> -*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--
> ===//
> +//
> +// InterpolatingCompilationDatabase wraps another CompilationDatabase and
> +// attempts to heuristically determine appropriate compile commands for
> files
> +// that are not included, such as headers or newly created files.
> +//
> +// Motivating cases include:
> +//   Header files that live next to their implementation files. These
> typically
> +// share a base filename. (libclang/CXString.h, libclang/CXString.cpp).
> +//   Some projects separate headers from includes. Filenames still
> typically
> +// match, maybe other path segments too. (include/llvm/IR/Use.h,
> lib/IR/Use.cc).
> +//   Matches are sometimes only approximate (Sema.h, SemaDecl.cpp). This
> goes
> +// for directories too (Support/Unix/Process.inc,
> lib/Support/Process.cpp).
> +//   Even if we can't find a "right" compile command, even a random one
> from
> +// the project will tend to get important flags like -I and -x right.
> +//
> +// We "borrow" the compile command for the closest available file:
> +//   - points are awarded if the filename matches (ignoring extension)
> +//   - points are awarded if the directory structure matches
> +//   - ties are broken by length of path prefix match
> +//
> 

Re: r329617 - [ObjC++] Never pass structs that transitively contain __weak fields in

2018-04-09 Thread Akira Hatanaka via cfe-commits
Sorry for the breakage, I reverted the patch in r329627 and reapplied it with a 
fix in r329635. Let me know if the tests are still failing.

> On Apr 9, 2018, at 3:47 PM, Galina Kistanova  wrote:
> 
> Hello Akira,
> 
> This commit added broken tests to one of our builders:
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/8964
>  
> 
> 
> Failing Tests (8):
> Clang :: CodeGenObjCXX/objc-struct-cxx-abi.mm 
> 
> Clang :: SemaObjCXX/attr-trivial-abi.mm 
> . . .
> Please have a look?
> 
> The builder was red and did not send notifications.
> 
> Thanks
> 
> Galina
> 
> On Mon, Apr 9, 2018 at 1:39 PM, Akira Hatanaka via cfe-commits 
> > wrote:
> Author: ahatanak
> Date: Mon Apr  9 13:39:47 2018
> New Revision: 329617
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=329617=rev 
> 
> Log:
> [ObjC++] Never pass structs that transitively contain __weak fields in
> registers.
> 
> This patch fixes a bug in r328731 that caused structs transitively
> containing __weak fields to be passed in registers. The patch replaces
> the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
> whether the struct or structs containing the struct are forced to be
> passed indirectly.
> 
> rdar://problem/39194693
> 
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/test/CodeGenObjCXX/objc-struct-cxx-abi.mm 
> 
> 
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=329617=329616=329617=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  9 13:39:47 2018
> @@ -3541,6 +3541,31 @@ public:
>  ///   union Y { int A, B; }; // Has body with members A and B 
> (FieldDecls).
>  /// This decl will be marked invalid if *any* members are invalid.
>  class RecordDecl : public TagDecl {
> +public:
> +  /// Enum that represents the different ways arguments are passed to and
> +  /// returned from function calls. This takes into account the 
> target-specific
> +  /// and version-specific rules along with the rules determined by the
> +  /// language.
> +  enum ArgPassingKind {
> +/// The argument of this type can be passed directly in registers.
> +APK_CanPassInRegs,
> +
> +/// The argument of this type cannot be passed directly in registers.
> +/// Records containing this type as a subobject are not forced to be 
> passed
> +/// indirectly. This value is used only in C++. This value is required by
> +/// C++ because, in uncommon situations, it is possible for a class to 
> have
> +/// only trivial copy/move constructors even when one of its subobjects 
> has
> +/// a non-trivial copy/move constructor (if e.g. the corresponding 
> copy/move
> +/// constructor in the derived class is deleted).
> +APK_CannotPassInRegs,
> +
> +/// The argument of this type cannot be passed directly in registers.
> +/// Records containing this type as a subobject are forced to be passed
> +/// indirectly.
> +APK_CanNeverPassInRegs
> +  };
> +
> +private:
>friend class DeclContext;
> 
>// FIXME: This can be packed into the bitfields in Decl.
> @@ -3571,17 +3596,14 @@ class RecordDecl : public TagDecl {
>bool NonTrivialToPrimitiveCopy : 1;
>bool NonTrivialToPrimitiveDestroy : 1;
> 
> -  /// True if this class can be passed in a non-address-preserving fashion
> -  /// (such as in registers).
> -  /// This does not imply anything about how the ABI in use will actually
> -  /// pass an object of this class.
> -  bool CanPassInRegisters : 1;
> -
>/// Indicates whether this struct is destroyed in the callee. This flag is
>/// meaningless when Microsoft ABI is used since parameters are always
>/// destroyed in the callee.
>bool ParamDestroyedInCallee : 1;
> 
> +  /// Represents the way this type is passed to a function.
> +  ArgPassingKind ArgPassingRestrictions : 2;
> +
>  protected:
>RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
>   SourceLocation StartLoc, SourceLocation IdLoc,

r329635 - [ObjC++] Never pass structs that transitively contain __weak fields in

2018-04-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Apr  9 15:48:22 2018
New Revision: 329635

URL: http://llvm.org/viewvc/llvm-project?rev=329635=rev
Log:
[ObjC++] Never pass structs that transitively contain __weak fields in
registers.

This patch fixes a bug in r328731 that caused structs transitively
containing __weak fields to be passed in registers. The patch replaces
the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
whether the struct or structs containing the struct are forced to be
passed indirectly.

This reapplies r329617. r329617 didn't specify the underlying type for
enum ArgPassingKind, which caused regression tests to fail on a windows
bot.

rdar://problem/39194693

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

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenObjCXX/objc-struct-cxx-abi.mm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=329635=329634=329635=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  9 15:48:22 2018
@@ -3541,6 +3541,31 @@ public:
 ///   union Y { int A, B; }; // Has body with members A and B (FieldDecls).
 /// This decl will be marked invalid if *any* members are invalid.
 class RecordDecl : public TagDecl {
+public:
+  /// Enum that represents the different ways arguments are passed to and
+  /// returned from function calls. This takes into account the target-specific
+  /// and version-specific rules along with the rules determined by the
+  /// language.
+  enum ArgPassingKind : unsigned {
+/// The argument of this type can be passed directly in registers.
+APK_CanPassInRegs,
+
+/// The argument of this type cannot be passed directly in registers.
+/// Records containing this type as a subobject are not forced to be passed
+/// indirectly. This value is used only in C++. This value is required by
+/// C++ because, in uncommon situations, it is possible for a class to have
+/// only trivial copy/move constructors even when one of its subobjects has
+/// a non-trivial copy/move constructor (if e.g. the corresponding 
copy/move
+/// constructor in the derived class is deleted).
+APK_CannotPassInRegs,
+
+/// The argument of this type cannot be passed directly in registers.
+/// Records containing this type as a subobject are forced to be passed
+/// indirectly.
+APK_CanNeverPassInRegs
+  };
+
+private:
   friend class DeclContext;
 
   // FIXME: This can be packed into the bitfields in Decl.
@@ -3571,17 +3596,14 @@ class RecordDecl : public TagDecl {
   bool NonTrivialToPrimitiveCopy : 1;
   bool NonTrivialToPrimitiveDestroy : 1;
 
-  /// True if this class can be passed in a non-address-preserving fashion
-  /// (such as in registers).
-  /// This does not imply anything about how the ABI in use will actually
-  /// pass an object of this class.
-  bool CanPassInRegisters : 1;
-
   /// Indicates whether this struct is destroyed in the callee. This flag is
   /// meaningless when Microsoft ABI is used since parameters are always
   /// destroyed in the callee.
   bool ParamDestroyedInCallee : 1;
 
+  /// Represents the way this type is passed to a function.
+  ArgPassingKind ArgPassingRestrictions : 2;
+
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
  SourceLocation StartLoc, SourceLocation IdLoc,
@@ -3669,12 +3691,15 @@ public:
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.
   bool canPassInRegisters() const {
-return CanPassInRegisters;
+return ArgPassingRestrictions == APK_CanPassInRegs;
+  }
+
+  ArgPassingKind getArgPassingRestrictions() const {
+return ArgPassingRestrictions;
   }
 
-  /// Set that we can pass this RecordDecl in registers.
-  void setCanPassInRegisters(bool CanPass) {
-CanPassInRegisters = CanPass;
+  void setArgPassingRestrictions(ArgPassingKind Kind) {
+ArgPassingRestrictions = Kind;
   }
 
   bool isParamDestroyedInCallee() const {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=329635=329634=329635=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr  9 15:48:22 2018
@@ -1149,8 +1149,6 @@ public:
   /// source object is placed 

Re: r329617 - [ObjC++] Never pass structs that transitively contain __weak fields in

2018-04-09 Thread Galina Kistanova via cfe-commits
Hello Akira,

This commit added broken tests to one of our builders:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/8964

Failing Tests (8):
Clang :: CodeGenObjCXX/objc-struct-cxx-abi.mm
Clang :: SemaObjCXX/attr-trivial-abi.mm
. . .
Please have a look?

The builder was red and did not send notifications.

Thanks

Galina

On Mon, Apr 9, 2018 at 1:39 PM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ahatanak
> Date: Mon Apr  9 13:39:47 2018
> New Revision: 329617
>
> URL: http://llvm.org/viewvc/llvm-project?rev=329617=rev
> Log:
> [ObjC++] Never pass structs that transitively contain __weak fields in
> registers.
>
> This patch fixes a bug in r328731 that caused structs transitively
> containing __weak fields to be passed in registers. The patch replaces
> the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
> whether the struct or structs containing the struct are forced to be
> passed indirectly.
>
> rdar://problem/39194693
>
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Decl.h?rev=329617=329616=329617=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  9 13:39:47 2018
> @@ -3541,6 +3541,31 @@ public:
>  ///   union Y { int A, B; }; // Has body with members A and B
> (FieldDecls).
>  /// This decl will be marked invalid if *any* members are invalid.
>  class RecordDecl : public TagDecl {
> +public:
> +  /// Enum that represents the different ways arguments are passed to and
> +  /// returned from function calls. This takes into account the
> target-specific
> +  /// and version-specific rules along with the rules determined by the
> +  /// language.
> +  enum ArgPassingKind {
> +/// The argument of this type can be passed directly in registers.
> +APK_CanPassInRegs,
> +
> +/// The argument of this type cannot be passed directly in registers.
> +/// Records containing this type as a subobject are not forced to be
> passed
> +/// indirectly. This value is used only in C++. This value is
> required by
> +/// C++ because, in uncommon situations, it is possible for a class
> to have
> +/// only trivial copy/move constructors even when one of its
> subobjects has
> +/// a non-trivial copy/move constructor (if e.g. the corresponding
> copy/move
> +/// constructor in the derived class is deleted).
> +APK_CannotPassInRegs,
> +
> +/// The argument of this type cannot be passed directly in registers.
> +/// Records containing this type as a subobject are forced to be
> passed
> +/// indirectly.
> +APK_CanNeverPassInRegs
> +  };
> +
> +private:
>friend class DeclContext;
>
>// FIXME: This can be packed into the bitfields in Decl.
> @@ -3571,17 +3596,14 @@ class RecordDecl : public TagDecl {
>bool NonTrivialToPrimitiveCopy : 1;
>bool NonTrivialToPrimitiveDestroy : 1;
>
> -  /// True if this class can be passed in a non-address-preserving fashion
> -  /// (such as in registers).
> -  /// This does not imply anything about how the ABI in use will actually
> -  /// pass an object of this class.
> -  bool CanPassInRegisters : 1;
> -
>/// Indicates whether this struct is destroyed in the callee. This flag
> is
>/// meaningless when Microsoft ABI is used since parameters are always
>/// destroyed in the callee.
>bool ParamDestroyedInCallee : 1;
>
> +  /// Represents the way this type is passed to a function.
> +  ArgPassingKind ArgPassingRestrictions : 2;
> +
>  protected:
>RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
>   SourceLocation StartLoc, SourceLocation IdLoc,
> @@ -3669,12 +3691,15 @@ public:
>/// it must have at least one trivial, non-deleted copy or move
> constructor.
>/// FIXME: This should be set as part of completeDefinition.
>bool canPassInRegisters() const {
> -return CanPassInRegisters;
> +return ArgPassingRestrictions == APK_CanPassInRegs;
> +  }
> +
> +  ArgPassingKind getArgPassingRestrictions() const {
> +return ArgPassingRestrictions;
>}
>
> -  /// Set that we can pass this RecordDecl in registers.
> -  void setCanPassInRegisters(bool CanPass) {
> -CanPassInRegisters = CanPass;
> +  void setArgPassingRestrictions(ArgPassingKind Kind) {
> +

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-04-09 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 141759.
aheejin added a comment.

- Add a test in which try-catches are nested within a catch
- Rebase


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Cleanup
+void test3() {
+  Cleanup c;
+  may_throw();
+}
+
+// CHECK-LABEL: @_Z5test3v()
+
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label {{.*}} unwind 

[PATCH] D45465: [AST] Fix printing tag decl groups in decl contexts

2018-04-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: rsmith, hfinkel.
jdenny added a dependency: D45463: [AST] Print correct tag decl for tag 
specifier.

For example, given:

  struct T1 {
struct T2 *p0;
  };

-ast-print produced:

  struct T1 {
struct T2; 
struct T2 *p0;
  };

Compiling that produces a warning that the first struct T2 declaration
does not declare anything.

Details:

A tag decl group is one or more decls that share a type specifier that
is a tag decl (that is, a struct/union/class/enum decl).  Within
functions, the parser builds such a tag decl group as part of a
DeclStmt.  However, in decl contexts, such as file scope or a member
list, the parser does not group together the members of a tag decl
group.  Previously, detection of tag decl groups during printing was 
implemented but only if the tag decl was unnamed.  Otherwise, as in
the above example, the members of the group did not print together and 
so sometimes introduced warnings.

This patch extends detection of tag decl groups in decl contexts to
any tag decl that is recorded in the AST as not free-standing.


https://reviews.llvm.org/D45465

Files:
  lib/AST/DeclPrinter.cpp
  test/Misc/ast-print-enum-decl.c
  test/Misc/ast-print-record-decl.c
  test/Sema/ast-print.c
  test/SemaCXX/ast-print.cpp

Index: test/SemaCXX/ast-print.cpp
===
--- test/SemaCXX/ast-print.cpp
+++ test/SemaCXX/ast-print.cpp
@@ -214,10 +214,13 @@
 struct [[gnu::visibility("hidden")]] S;
 }
 
-// CHECK: struct CXXFunctionalCastExprPrint fce = CXXFunctionalCastExprPrint{};
+// CHECK:  struct CXXFunctionalCastExprPrint {
+// CHECK-NEXT: } fce = CXXFunctionalCastExprPrint{};
 struct CXXFunctionalCastExprPrint {} fce = CXXFunctionalCastExprPrint{};
 
-// CHECK: struct CXXTemporaryObjectExprPrint toe = CXXTemporaryObjectExprPrint{};
+// CHECK:  struct CXXTemporaryObjectExprPrint {
+// CHECK-NEXT:   CXXTemporaryObjectExprPrint();
+// CHECK-NEXT: } toe = CXXTemporaryObjectExprPrint{};
 struct CXXTemporaryObjectExprPrint { CXXTemporaryObjectExprPrint(); } toe = CXXTemporaryObjectExprPrint{};
 
 namespace PR24872 {
Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -83,8 +83,7 @@
   EnumWithAttributesFoo __attribute__((deprecated)),
   // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
   EnumWithAttributesBar __attribute__((unavailable)) = 50
-  // CHECK-NEXT: };
-  // CHECK-NEXT: enum EnumWithAttributes *EnumWithAttributesPtr;
+  // CHECK-NEXT: } *EnumWithAttributesPtr;
 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note {{'EnumWithAttributes' has been explicitly marked deprecated here}}
 
 // FIXME: If enum is forward-declared at file scope, attributes are lost.
Index: test/Misc/ast-print-record-decl.c
===
--- test/Misc/ast-print-record-decl.c
+++ test/Misc/ast-print-record-decl.c
@@ -6,8 +6,8 @@
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES= %s > %t.c
-//   RUN: FileCheck --check-prefixes=CHECK,PRINT -DKW=struct -DBASES= %s \
-//   RUN:   --input-file %t.c
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-C -DKW=struct -DBASES= \
+//   RUN:   %s --input-file %t.c
 //
 //   Now check compiling and printing of the printed file.
 //
@@ -18,7 +18,8 @@
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.c \
-//   RUN: | FileCheck --check-prefixes=CHECK,PRINT -DKW=struct -DBASES= %s
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-C -DKW=struct \
+//   RUN: -DBASES= %s
 
 // Repeat for union:
 //
@@ -28,8 +29,8 @@
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=union -DBASES= %s > %t.c
-//   RUN: FileCheck --check-prefixes=CHECK,PRINT -DKW=union -DBASES= %s \
-//   RUN:   --input-file %t.c
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-C -DKW=union -DBASES= \
+//   RUN:   %s --input-file %t.c
 //
 //   Now check compiling and printing of the printed file.
 //
@@ -40,7 +41,8 @@
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
 //   RUN: %clang_cc1 -verify -ast-print %t.c \
-//   RUN: | FileCheck --check-prefixes=CHECK,PRINT -DKW=union -DBASES= %s
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-C -DKW=union \
+//   RUN: -DBASES= %s
 
 // Repeat for C++ (BASES helps ensure we're printing as C++ not as C):
 //
@@ -52,7 +54,7 @@
 //
 //   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
 //   RUN: > %t.cpp
-//   RUN: FileCheck --check-prefixes=CHECK,PRINT,CXX -DKW=struct \
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s 

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/Sema/builtin-dump-struct.c:8
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);

paulsemel wrote:
> aaron.ballman wrote:
> > paulsemel wrote:
> > > aaron.ballman wrote:
> > > > Can you also add a test for: `int (*badfunc4)(char *, ...);` and `int 
> > > > (*badfunc5)();`
> > > Isn't `int (*func)()` is a valid prototype for a printf like function in 
> > > C ?
> > > I instead added `int (*func)(void)` to the test cases.
> > > Isn't int (*func)() is a valid prototype for a printf like function in C ?
> > 
> > No, because it's missing the `const char *` as the mandatory first 
> > parameter. Do you want that to be allowed and hope the callee has it 
> > correct on their side, or do you want it to diagnose as not being a valid 
> > function?
> Actually, from a kernel developer perspective, I would say it's better to let 
> the user do its stuff on his side, because kernel is full of trick !
> But if you think I'd rather check whether we have `int (*)(const char *, 
> ...)` at any time, we can go for it !
Okay, if you think it'd be beneficial to allow a function without a prototype, 
I'm okay with it. Can you make it an explicit "good" test case?


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D45403: Make [[maybe_unused]] work with static data members

2018-04-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:2054
-  }
-
   // If this is spelled as the standard C++17 attribute, but not in C++17, warn

Quuxplusone wrote:
> @aaron.ballman writes:
> > I don't think we're currently diagnosing static data members of classes as 
> > being unused in the first place; are there plans to implement that 
> > functionality so that someone might want to write the attribute there?
> 
> FWIW, "plans to implement that functionality" (in Clang) is not the only 
> reason to accept the attribute. Someone might write the attribute in their 
> codebase that currently compiles with some //other// compiler which 
> implements the functionality (or at least does not reject it); it would be 
> mildly unfortunate if that made their codebase non-portable-to-Clang. (Only 
> "mildly" because the diagnostic being removed here is just a warning; the 
> user could suppress it if they really needed to.)
> 
> Here's an example of code that compiles cleanly with GCC but gives an 
> arguably "false positive" diagnostic when compiled with Clang.
> https://wandbox.org/permlink/UG4kG5XTBn12xfuu
> Now, admittedly, both GCC and Clang produce a "false negative" re the unused 
> private static member `y`; but that false negative might get fixed in the 
> future. The user writes their code //today// and it must compile //today//. :)
> 
Agreed; that's why the analysis isn't a requirement for accepting this patch. I 
was mostly just curious if there were plans to extend that functionality or not.



Comment at: test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp:5
   int I [[maybe_unused]];
-  static int SI [[maybe_unused]]; // expected-warning {{'maybe_unused' 
attribute only applies to variables, functions, methods, types, enumerations, 
enumerators, labels, and non-static data members}}
+  static int SI [[maybe_unused]];
 };

Quuxplusone wrote:
> aaron.ballman wrote:
> > cpplearner wrote:
> > > lebedev.ri wrote:
> > > > As the code comment noted, 
> > > > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf, page 
> > > > 199:
> > > > ```
> > > > 2 The attribute may be applied to the declaration of a class, a 
> > > > typedef-name, a variable, a **non-static** data
> > > > member, a function, an enumeration, or an enumerator.
> > > > ```
> > > That section says that [[maybe_unused]] can be applied to a non-static 
> > > data member, which doesn't mean it can't be applied to a static data 
> > > member.
> > > 
> > > And I'm arguing that since a static data member is a variable, 
> > > [dcl.attr.unused]p2 actually allows [[maybe_unused]] to be applied to a 
> > > static data member.
> > Yes -- through twisty standardese, a static data member of a class might be 
> > a variable. This test case, however, is only a declaration and not a 
> > definition (which means it's not an object, which means it's not a 
> > variable). Should the attribute still appertain in this case?
> The attribute does currently apply to declarations as well as definitions, 
> although you have to be a real language lawyer to observe it.
> https://wandbox.org/permlink/WBLWBdd42rv95UaS
Good point. Also, declaration vs definition doesn't really matter when I think 
about it -- the whole point is to tell you "hey, this is unused" and give the 
programmer a way to say "maybe it's unused, but shut up about it anyway." 
Definition vs declaration doesn't much matter in that case.


Repository:
  rC Clang

https://reviews.llvm.org/D45403



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


r329630 - [AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

2018-04-09 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Apr  9 15:14:10 2018
New Revision: 329630

URL: http://llvm.org/viewvc/llvm-project?rev=329630=rev
Log:
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h?rev=329630=329629=329630=diff
==
--- cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h (original)
+++ cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h Mon Apr  9 15:14:10 
2018
@@ -1,4 +1,4 @@
-//===--- ASTStructuralEquivalence.h - ---*- C++ 
-*-===//
+//===- ASTStructuralEquivalence.h ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -19,6 +19,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include 
+#include 
 
 namespace clang {
 
@@ -57,7 +58,7 @@ struct StructuralEquivalenceContext {
   bool Complain;
 
   /// \c true if the last diagnostic came from ToCtx.
-  bool LastDiagFromC2;
+  bool LastDiagFromC2 = false;
 
   StructuralEquivalenceContext(
   ASTContext , ASTContext ,
@@ -66,8 +67,7 @@ struct StructuralEquivalenceContext {
   bool ErrorOnTagTypeMismatch = false)
   : FromCtx(FromCtx), ToCtx(ToCtx), NonEquivalentDecls(NonEquivalentDecls),
 StrictTypeSpelling(StrictTypeSpelling),
-ErrorOnTagTypeMismatch(ErrorOnTagTypeMismatch), Complain(Complain),
-LastDiagFromC2(false) {}
+ErrorOnTagTypeMismatch(ErrorOnTagTypeMismatch), Complain(Complain) {}
 
   DiagnosticBuilder Diag1(SourceLocation Loc, unsigned DiagID);
   DiagnosticBuilder Diag2(SourceLocation Loc, unsigned DiagID);
@@ -98,6 +98,7 @@ private:
   /// \returns true if an error occurred, false otherwise.
   bool Finish();
 };
+
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_ASTSTRUCTURALEQUIVALENCE_H

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=329630=329629=329630=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Mon Apr  9 15:14:10 2018
@@ -1,4 +1,4 @@
-//===--- ASTStructuralEquivalence.cpp - -*- C++ 
-*-===//
+//===- ASTStructuralEquivalence.cpp 
---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -15,15 +15,28 @@
 #include "clang/AST/ASTStructuralEquivalence.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDiagnostic.h"
-#include "clang/AST/ASTImporter.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
-#include "clang/AST/DeclVisitor.h"
-#include "clang/AST/StmtVisitor.h"
-#include "clang/AST/TypeVisitor.h"
-#include "clang/Basic/SourceManager.h"
-
-namespace {
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/ExceptionSpecificationType.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+#include 
 
 using namespace clang;
 
@@ -144,6 +157,7 @@ static bool IsStructurallyEquivalent(Str
IsStructurallyEquivalent(Context, TS1->getReplacement(),
 TS2->getReplacement());
   }
+
   case TemplateName::SubstTemplateTemplateParmPack: {
 SubstTemplateTemplateParmPackStorage
 *P1 = N1.getAsSubstTemplateTemplateParmPack(),
@@ -298,8 +312,8 @@ static bool IsStructurallyEquivalent(Str
 
   case Type::LValueReference:
   case Type::RValueReference: {
-const ReferenceType *Ref1 = cast(T1);
-const ReferenceType *Ref2 = cast(T2);
+const auto *Ref1 = cast(T1);
+const auto *Ref2 = cast(T2);
 if (Ref1->isSpelledAsLValue() != Ref2->isSpelledAsLValue())
   return false;
 if (Ref1->isInnerRef() != Ref2->isInnerRef())
@@ -311,8 +325,8 @@ static bool IsStructurallyEquivalent(Str
   }
 
   case Type::MemberPointer: {
-const MemberPointerType *MemPtr1 = cast(T1);
-const MemberPointerType *MemPtr2 = cast(T2);
+const auto *MemPtr1 = cast(T1);
+const auto *MemPtr2 = cast(T2);
 if 

[PATCH] D45455: [CFI] Disable CFI checks for __cxa_decrement_exception_refcount

2018-04-09 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329629: [CFI] Disable CFI checks for 
__cxa_decrement_exception_refcount (authored by vlad.tsyrklevich, committed by 
).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45455

Files:
  libcxxabi/trunk/include/__cxxabi_config.h
  libcxxabi/trunk/src/cxa_exception.cpp


Index: libcxxabi/trunk/src/cxa_exception.cpp
===
--- libcxxabi/trunk/src/cxa_exception.cpp
+++ libcxxabi/trunk/src/cxa_exception.cpp
@@ -630,8 +630,8 @@
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = 
cxa_exception_from_thrown_object(thrown_object);
Index: libcxxabi/trunk/include/__cxxabi_config.h
===
--- libcxxabi/trunk/include/__cxxabi_config.h
+++ libcxxabi/trunk/include/__cxxabi_config.h
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H


Index: libcxxabi/trunk/src/cxa_exception.cpp
===
--- libcxxabi/trunk/src/cxa_exception.cpp
+++ libcxxabi/trunk/src/cxa_exception.cpp
@@ -630,8 +630,8 @@
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = cxa_exception_from_thrown_object(thrown_object);
Index: libcxxabi/trunk/include/__cxxabi_config.h
===
--- libcxxabi/trunk/include/__cxxabi_config.h
+++ libcxxabi/trunk/include/__cxxabi_config.h
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45463: [AST] Print correct tag decl for tag specifier

2018-04-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: rsmith, nik, jbcoe, aaron.ballman, hfinkel.

For example, given:

  void fn() {
struct T *p0;
struct T { int i; } *p1;
  }

-ast-print produced:

  void fn() {
struct T { int i; } *p0;
struct T { int i; } *p1;
  }

Compiling that fails with a redefinition error.

Details:

For a tag specifier (that is, struct/union/class/enum used as a type
specifier in a declaration) that was also a tag declaration (that is, 
first occurrence of the tag) or tag redeclaration (that is, later
occurrence that specifies attributes or a member list), clang printed
the tag specifier as either (1) the full tag definition if one 
existed, or (2) the first tag declaration otherwise.  As in the above
example, redefinition errors were sometimes introduced.  Even when
that was impossible because no member list was ever specified,
attributes were sometimes lost, thus changing semantics and 
diagnostics.

This patch fixes a major culprit for these problems.  It does so by
replacing PrintingPolicy's IncludeTagDefinition, which triggered
printing of the member list, attributes, etc. for a tag specifier by
using a tag (re)declaration selected as described above.  The 
replacement is TagSpecifierAs, which triggers the same thing except it
specifies the tag (re)declaration actually recorded by the parser for 
that tag specifier.

I have two concerns about this patch:

1. TagSpecifierAs expands sizeof(PrintingPolicy) from 8 to 16 bytes. My concern 
is the comments on PrintingPolicy about how PrintingPolicy is intended to be 
small.  My guess it that 16 bytes is still small enough, but perhaps Richard 
Smith, who wrote that comment, knows better.

2. This patch drops IncludeTagDefinition from CXPrintingPolicyProperty and does 
not attempt to replace it because TagSpecifierAs doesn't seem to fit that 
interface.  This bit of functionality seems internal to the printing design, 
but I don't have any experience with CXPrintingPolicyProperty, so I might be 
missing an important use case.  We could actually keep IncludeTagDefinition 
alongside TagSpecifierAs, but my naive guess is that IncludeTagDefinition is 
not reliable enough to be worthwhile.  Perhaps Nikolai Kosjar or Jonathan Coe, 
who wrote/reviewed CXPrintingPolicyProperty can comment.


https://reviews.llvm.org/D45463

Files:
  include/clang-c/Index.h
  include/clang/AST/PrettyPrinter.h
  lib/AST/DeclPrinter.cpp
  lib/AST/TypePrinter.cpp
  test/Misc/ast-print-enum-decl.c
  test/Misc/ast-print-record-decl.c
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -4739,8 +4739,6 @@
 return P->SuppressSpecifiers;
   case CXPrintingPolicy_SuppressTagKeyword:
 return P->SuppressTagKeyword;
-  case CXPrintingPolicy_IncludeTagDefinition:
-return P->IncludeTagDefinition;
   case CXPrintingPolicy_SuppressScope:
 return P->SuppressScope;
   case CXPrintingPolicy_SuppressUnwrittenScope:
@@ -4808,9 +4806,6 @@
   case CXPrintingPolicy_SuppressTagKeyword:
 P->SuppressTagKeyword = Value;
 return;
-  case CXPrintingPolicy_IncludeTagDefinition:
-P->IncludeTagDefinition = Value;
-return;
   case CXPrintingPolicy_SuppressScope:
 P->SuppressScope = Value;
 return;
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -97,8 +97,6 @@
CXPrintingPolicy_SuppressSpecifiers},
   {"CINDEXTEST_PRINTINGPOLICY_SUPPRESSTAGKEYWORD",
CXPrintingPolicy_SuppressTagKeyword},
-  {"CINDEXTEST_PRINTINGPOLICY_INCLUDETAGDEFINITION",
-   CXPrintingPolicy_IncludeTagDefinition},
   {"CINDEXTEST_PRINTINGPOLICY_SUPPRESSSCOPE",
CXPrintingPolicy_SuppressScope},
   {"CINDEXTEST_PRINTINGPOLICY_SUPPRESSUNWRITTENSCOPE",
Index: test/Misc/ast-print-record-decl.c
===
--- /dev/null
+++ test/Misc/ast-print-record-decl.c
@@ -0,0 +1,251 @@
+// Check struct:
+//
+//   First check compiling and printing of this file.
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES= -o - %s \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES= %s > %t.c
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT -DKW=struct -DBASES= %s \
+//   RUN:   --input-file %t.c
+//
+//   Now check compiling and printing of the printed file.
+//
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.c
+//
+//   RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \
+//   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
+//
+//   RUN: %clang_cc1 -verify 

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Will be good idea to add HICPP alias.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


[PATCH] D45455: [CFI] Disable CFI checks for __cxa_decrement_exception_refcount

2018-04-09 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXXA329629: [CFI] Disable CFI checks for 
__cxa_decrement_exception_refcount (authored by vlad.tsyrklevich, committed by 
).

Changed prior to commit:
  https://reviews.llvm.org/D45455?vs=141733=141752#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45455

Files:
  include/__cxxabi_config.h
  src/cxa_exception.cpp


Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -630,8 +630,8 @@
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = 
cxa_exception_from_thrown_object(thrown_object);
Index: include/__cxxabi_config.h
===
--- include/__cxxabi_config.h
+++ include/__cxxabi_config.h
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H


Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -630,8 +630,8 @@
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = cxa_exception_from_thrown_object(thrown_object);
Index: include/__cxxabi_config.h
===
--- include/__cxxabi_config.h
+++ include/__cxxabi_config.h
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r329629 - [CFI] Disable CFI checks for __cxa_decrement_exception_refcount

2018-04-09 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Apr  9 15:11:28 2018
New Revision: 329629

URL: http://llvm.org/viewvc/llvm-project?rev=329629=rev
Log:
[CFI] Disable CFI checks for __cxa_decrement_exception_refcount

Summary:
exception_header->exceptionDestructor is a void(*)(void*) function
pointer; however, it can point to destructors like std::
exception::~exception that don't match that type signature.

Reviewers: pcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: kcc, christof, cfe-commits

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

Modified:
libcxxabi/trunk/include/__cxxabi_config.h
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=329629=329628=329629=diff
==
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Mon Apr  9 15:11:28 2018
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=329629=329628=329629=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Mon Apr  9 15:11:28 2018
@@ -630,8 +630,8 @@ __cxa_increment_exception_refcount(void
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = 
cxa_exception_from_thrown_object(thrown_object);


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


r329628 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-04-09 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Apr  9 14:54:38 2018
New Revision: 329628

URL: http://llvm.org/viewvc/llvm-project?rev=329628=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/ASTImporter.h
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/include/clang/AST/ASTImporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=329628=329627=329628=diff
==
--- cfe/trunk/include/clang/AST/ASTImporter.h (original)
+++ cfe/trunk/include/clang/AST/ASTImporter.h Mon Apr  9 14:54:38 2018
@@ -1,4 +1,4 @@
-//===--- ASTImporter.h - Importing ASTs from other Contexts -*- C++ 
-*-===//
+//===- ASTImporter.h - Importing ASTs from other Contexts ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -11,37 +11,44 @@
 //  context into another context.
 //
 
//===--===//
+
 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
 #define LLVM_CLANG_AST_ASTIMPORTER_H
 
 #include "clang/AST/DeclarationName.h"
+#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include 
 
 namespace clang {
-  class ASTContext;
-  class CXXCtorInitializer;
-  class CXXBaseSpecifier;
-  class Decl;
-  class DeclContext;
-  class DiagnosticsEngine;
-  class Expr;
-  class FileManager;
-  class IdentifierInfo;
-  class NestedNameSpecifier;
-  class Stmt;
-  class TypeSourceInfo;
-  
+
+class ASTContext;
+class CXXBaseSpecifier;
+class CXXCtorInitializer;
+class Decl;
+class DeclContext;
+class Expr;
+class FileManager;
+class NamedDecl;
+class Stmt;
+class TagDecl;
+class TypeSourceInfo;
+
   /// \brief Imports selected nodes from one AST context into another context,
   /// merging AST nodes where appropriate.
   class ASTImporter {
   public:
-typedef llvm::DenseSet NonEquivalentDeclSet;
-typedef llvm::DenseMap
-ImportedCXXBaseSpecifierMap;
+using NonEquivalentDeclSet = llvm::DenseSet;
+using ImportedCXXBaseSpecifierMap =
+llvm::DenseMap;
 
   private:
 /// \brief The contexts we're importing to and from.
@@ -54,7 +61,7 @@ namespace clang {
 bool Minimal;
 
 /// \brief Whether the last diagnostic came from the "from" context.
-bool LastDiagFromFrom;
+bool LastDiagFromFrom = false;
 
 /// \brief Mapping from the already-imported types in the "from" context
 /// to the corresponding types in the "to" context.
@@ -312,6 +319,7 @@ namespace clang {
 bool IsStructurallyEquivalent(QualType From, QualType To,
   bool Complain = true);
   };
-}
+
+} // namespace clang
 
 #endif // LLVM_CLANG_AST_ASTIMPORTER_H

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=329628=329627=329628=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr  9 14:54:38 2018
@@ -1,4 +1,4 @@
-//===--- ASTImporter.cpp - Importing ASTs from other Contexts ---*- C++ 
-*-===//
+//===- ASTImporter.cpp - Importing ASTs from other Contexts 
---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -11,27 +11,73 @@
 //  context into another context.
 //
 
//===--===//
+
 #include "clang/AST/ASTImporter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/ASTStructuralEquivalence.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclAccessPair.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclFriend.h"
+#include "clang/AST/DeclGroup.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclVisitor.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprObjC.h"
+#include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/LambdaCapture.h"
+#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OperationKinds.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/StmtCXX.h"
+#include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/TemplateBase.h"
+#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeVisitor.h"
+#include 

[PATCH] D45403: Make [[maybe_unused]] work with static data members

2018-04-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:2054
-  }
-
   // If this is spelled as the standard C++17 attribute, but not in C++17, warn

@aaron.ballman writes:
> I don't think we're currently diagnosing static data members of classes as 
> being unused in the first place; are there plans to implement that 
> functionality so that someone might want to write the attribute there?

FWIW, "plans to implement that functionality" (in Clang) is not the only reason 
to accept the attribute. Someone might write the attribute in their codebase 
that currently compiles with some //other// compiler which implements the 
functionality (or at least does not reject it); it would be mildly unfortunate 
if that made their codebase non-portable-to-Clang. (Only "mildly" because the 
diagnostic being removed here is just a warning; the user could suppress it if 
they really needed to.)

Here's an example of code that compiles cleanly with GCC but gives an arguably 
"false positive" diagnostic when compiled with Clang.
https://wandbox.org/permlink/UG4kG5XTBn12xfuu
Now, admittedly, both GCC and Clang produce a "false negative" re the unused 
private static member `y`; but that false negative might get fixed in the 
future. The user writes their code //today// and it must compile //today//. :)




Comment at: test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp:5
   int I [[maybe_unused]];
-  static int SI [[maybe_unused]]; // expected-warning {{'maybe_unused' 
attribute only applies to variables, functions, methods, types, enumerations, 
enumerators, labels, and non-static data members}}
+  static int SI [[maybe_unused]];
 };

aaron.ballman wrote:
> cpplearner wrote:
> > lebedev.ri wrote:
> > > As the code comment noted, 
> > > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf, page 
> > > 199:
> > > ```
> > > 2 The attribute may be applied to the declaration of a class, a 
> > > typedef-name, a variable, a **non-static** data
> > > member, a function, an enumeration, or an enumerator.
> > > ```
> > That section says that [[maybe_unused]] can be applied to a non-static data 
> > member, which doesn't mean it can't be applied to a static data member.
> > 
> > And I'm arguing that since a static data member is a variable, 
> > [dcl.attr.unused]p2 actually allows [[maybe_unused]] to be applied to a 
> > static data member.
> Yes -- through twisty standardese, a static data member of a class might be a 
> variable. This test case, however, is only a declaration and not a definition 
> (which means it's not an object, which means it's not a variable). Should the 
> attribute still appertain in this case?
The attribute does currently apply to declarations as well as definitions, 
although you have to be a real language lawyer to observe it.
https://wandbox.org/permlink/WBLWBdd42rv95UaS


Repository:
  rC Clang

https://reviews.llvm.org/D45403



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


r329627 - Revert "[ObjC++] Never pass structs that transitively contain __weak fields in"

2018-04-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Apr  9 14:47:58 2018
New Revision: 329627

URL: http://llvm.org/viewvc/llvm-project?rev=329627=rev
Log:
Revert "[ObjC++] Never pass structs that transitively contain __weak fields in"

This reverts commit r329617. It broke a windows bot.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16372/steps/test/logs/stdio

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenObjCXX/objc-struct-cxx-abi.mm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=329627=329626=329627=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  9 14:47:58 2018
@@ -3541,31 +3541,6 @@ public:
 ///   union Y { int A, B; }; // Has body with members A and B (FieldDecls).
 /// This decl will be marked invalid if *any* members are invalid.
 class RecordDecl : public TagDecl {
-public:
-  /// Enum that represents the different ways arguments are passed to and
-  /// returned from function calls. This takes into account the target-specific
-  /// and version-specific rules along with the rules determined by the
-  /// language.
-  enum ArgPassingKind {
-/// The argument of this type can be passed directly in registers.
-APK_CanPassInRegs,
-
-/// The argument of this type cannot be passed directly in registers.
-/// Records containing this type as a subobject are not forced to be passed
-/// indirectly. This value is used only in C++. This value is required by
-/// C++ because, in uncommon situations, it is possible for a class to have
-/// only trivial copy/move constructors even when one of its subobjects has
-/// a non-trivial copy/move constructor (if e.g. the corresponding 
copy/move
-/// constructor in the derived class is deleted).
-APK_CannotPassInRegs,
-
-/// The argument of this type cannot be passed directly in registers.
-/// Records containing this type as a subobject are forced to be passed
-/// indirectly.
-APK_CanNeverPassInRegs
-  };
-
-private:
   friend class DeclContext;
 
   // FIXME: This can be packed into the bitfields in Decl.
@@ -3596,14 +3571,17 @@ private:
   bool NonTrivialToPrimitiveCopy : 1;
   bool NonTrivialToPrimitiveDestroy : 1;
 
+  /// True if this class can be passed in a non-address-preserving fashion
+  /// (such as in registers).
+  /// This does not imply anything about how the ABI in use will actually
+  /// pass an object of this class.
+  bool CanPassInRegisters : 1;
+
   /// Indicates whether this struct is destroyed in the callee. This flag is
   /// meaningless when Microsoft ABI is used since parameters are always
   /// destroyed in the callee.
   bool ParamDestroyedInCallee : 1;
 
-  /// Represents the way this type is passed to a function.
-  ArgPassingKind ArgPassingRestrictions : 2;
-
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
  SourceLocation StartLoc, SourceLocation IdLoc,
@@ -3691,15 +3669,12 @@ public:
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.
   bool canPassInRegisters() const {
-return ArgPassingRestrictions == APK_CanPassInRegs;
-  }
-
-  ArgPassingKind getArgPassingRestrictions() const {
-return ArgPassingRestrictions;
+return CanPassInRegisters;
   }
 
-  void setArgPassingRestrictions(ArgPassingKind Kind) {
-ArgPassingRestrictions = Kind;
+  /// Set that we can pass this RecordDecl in registers.
+  void setCanPassInRegisters(bool CanPass) {
+CanPassInRegisters = CanPass;
   }
 
   bool isParamDestroyedInCallee() const {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=329627=329626=329627=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr  9 14:47:58 2018
@@ -1149,6 +1149,8 @@ public:
   /// source object is placed in an uninitialized state.
   PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const;
 
+  bool canPassInRegisters() const;
+
   enum DestructionKind {
 DK_none,
 DK_cxx_destructor,

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=329627=329626=329627=diff

[PATCH] D45458: MallocChecker refactoring of calls checkers

2018-04-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a reviewer: xazax.hun.
NoQ added a subscriber: xazax.hun.
NoQ added a comment.
Herald added a subscriber: rnkovacs.

@xazax.hun: do you think the approach you took in the `Valist` checker is 
applicable here? Did you like how it ended up working? Cause i'd love to see 
`CallDescription` and initializer lists used for readability here. And i'd love 
to see branches replaced with map lookups. And i'm not sure if anybody has 
written code that has all the stuff that i'd love to see.


Repository:
  rC Clang

https://reviews.llvm.org/D45458



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-09 Thread Paul Semel via Phabricator via cfe-commits
paulsemel updated this revision to Diff 141745.
paulsemel marked an inline comment as done.
paulsemel added a comment.

Updated the amperstamp in the Sema test to be consistent with the remaining 
part of it.


Repository:
  rC Clang

https://reviews.llvm.org/D44093

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/dump-struct-builtin.c
  test/Sema/builtin-dump-struct.c

Index: test/Sema/builtin-dump-struct.c
===
--- /dev/null
+++ test/Sema/builtin-dump-struct.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -verify %s
+
+void invalid_uses() {
+  struct A {
+  };
+  struct A a;
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);
+  int (*badfunc2)(int, ...);
+  void (*badfunc3)(const char *, ...);
+  int (*badfunc4)(char *, ...);
+  int (*badfunc5)(void);
+
+  __builtin_dump_struct(); // expected-error {{too few arguments to function call, expected 2, have 0}}
+  __builtin_dump_struct(1);// expected-error {{too few arguments to function call, expected 2, have 1}}
+  __builtin_dump_struct(1, 2); // expected-error {{passing 'int' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('int' vs structure pointer)}}
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(b, goodfunc); // expected-error {{passing 'void *' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('void *' vs structure pointer)}}
+  __builtin_dump_struct(, badfunc1); // expected-error {{passing 'int (*)(const char *)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc2); // expected-error {{passing 'int (*)(int, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(int, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc3); // expected-error {{passing 'void (*)(const char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('void (*)(const char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc4); // expected-error {{passing 'int (*)(char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc5); // expected-error {{passing 'int (*)(void)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(void)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(a, goodfunc);  // expected-error {{passing 'struct A' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('struct A' vs structure pointer)}}
+}
+
+void valid_uses() {
+  struct A {
+  };
+  union B {
+  };
+
+  int (*goodfunc)(const char *, ...);
+  struct A a;
+  union B b;
+
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc);
+}
Index: test/CodeGen/dump-struct-builtin.c
===
--- /dev/null
+++ test/CodeGen/dump-struct-builtin.c
@@ -0,0 +1,387 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/stdio.h"
+
+void unit1() {
+  struct U1A {
+short a;
+  };
+
+  struct U1A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U1A, %struct.U1A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit2() {
+  struct U2A {
+unsigned short a;
+  };
+
+  struct U2A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U2A, %struct.U2A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit3() {
+  struct U3A {
+int a;
+  };
+
+  struct U3A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U3A, %struct.U3A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i32, i32* 

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-09 Thread Paul Semel via Phabricator via cfe-commits
paulsemel marked an inline comment as done.
paulsemel added a comment.

No problem, thanks for getting back on this ! I was busy because of my midterms 
anyway :)




Comment at: test/Sema/builtin-dump-struct.c:8
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);

aaron.ballman wrote:
> paulsemel wrote:
> > aaron.ballman wrote:
> > > Can you also add a test for: `int (*badfunc4)(char *, ...);` and `int 
> > > (*badfunc5)();`
> > Isn't `int (*func)()` is a valid prototype for a printf like function in C ?
> > I instead added `int (*func)(void)` to the test cases.
> > Isn't int (*func)() is a valid prototype for a printf like function in C ?
> 
> No, because it's missing the `const char *` as the mandatory first parameter. 
> Do you want that to be allowed and hope the callee has it correct on their 
> side, or do you want it to diagnose as not being a valid function?
Actually, from a kernel developer perspective, I would say it's better to let 
the user do its stuff on his side, because kernel is full of trick !
But if you think I'd rather check whether we have `int (*)(const char *, ...)` 
at any time, we can go for it !



Comment at: test/Sema/builtin-dump-struct.c:17
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to 
parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 
2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(b, ); // expected-error {{passing 'void *' to 
parameter of incompatible type 'structure pointer type': type mismatch at 1st 
parameter ('void *' vs 'structure pointer type')}}
+  __builtin_dump_struct(, badfunc1); // expected-error {{passing 'int 
(*)(const char *)' to parameter of incompatible type 'int (*)(const char *, 
...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int 
(*)(const char *, ...)')}}

aaron.ballman wrote:
> paulsemel wrote:
> > aaron.ballman wrote:
> > > Why ``?
> > Yes, we already have a test like this anyway :)
> It was more a question of why the ampersand on the second argument -- I think 
> that can be dropped and it'll be consistent with the rest of the tests.
Sure, sorry, I missed this. Totally agree with you, I am going to make the 
changes.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Thanks!

Eww. Weird AST.

I wonder how this should work:

  // RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection 
-fheinous-gnu-extensions -w %s -verify
  
  int clang_analyzer_eval(int);
  
  int global;
  void testRValueOutput() {
int  = global;
ref = 1;
__asm__("" : "=r"((int)ref));
clang_analyzer_eval(ref == 1); // currently says UNKNOWN
clang_analyzer_eval(global == 1); // currently says TRUE
  }

The ultimate solution would probably be to add a fake cloned asm statement to 
the CFG (instead of the real asm statement) that would point to the correct 
output child-expression(s) that are untouched themselves but simply have their 
noop casts removed.

Or we could try


Repository:
  rC Clang

https://reviews.llvm.org/D45416



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


[PATCH] D45458: MallocChecker refactoring of calls checkers

2018-04-09 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

Splitting from https://reviews.llvm.org/D45149 as requested.


Repository:
  rC Clang

https://reviews.llvm.org/D45458



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


[PATCH] D45458: MallocChecker refactoring of calls checkers

2018-04-09 Thread David CARLIER via Phabricator via cfe-commits
devnexen created this revision.
devnexen added reviewers: NoQ, thakis.
Herald added a subscriber: cfe-commits.

- Splitting some by family to reduce the list of function identifiers.


Repository:
  rC Clang

https://reviews.llvm.org/D45458

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -171,18 +171,14 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
-II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
-II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
-II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
-II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
-II_wcsdup(nullptr), II_win_wcsdup(nullptr), II_g_malloc(nullptr),
-II_g_malloc0(nullptr), II_g_realloc(nullptr), II_g_try_malloc(nullptr), 
-II_g_try_malloc0(nullptr), II_g_try_realloc(nullptr), 
-II_g_free(nullptr), II_g_memdup(nullptr), II_g_malloc_n(nullptr), 
-II_g_malloc0_n(nullptr), II_g_realloc_n(nullptr), 
-II_g_try_malloc_n(nullptr), II_g_try_malloc0_n(nullptr), 
-II_g_try_realloc_n(nullptr) {}
+  : II_kmalloc(nullptr), II_if_nameindex(nullptr),
+II_if_freenameindex(nullptr), II_valloc(nullptr),
+II_realloc(nullptr), II_calloc(nullptr),
+II_reallocarray(nullptr), II_recallocarray(nullptr),
+II_strndup(nullptr), II_g_memdup(nullptr),
+II_g_malloc0(nullptr), II_g_try_malloc0(nullptr),
+II_g_malloc0_n(nullptr), II_g_try_malloc0_n(nullptr),
+II_reallocf(nullptr), II_malloc(nullptr) {}
 
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -242,18 +238,27 @@
   mutable std::unique_ptr BT_MismatchedDealloc;
   mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
-  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc, *II_free,
- *II_realloc, *II_calloc, *II_valloc, *II_reallocf,
- *II_strndup, *II_strdup, *II_win_strdup, *II_kmalloc,
- *II_if_nameindex, *II_if_freenameindex, *II_wcsdup,
- *II_win_wcsdup, *II_g_malloc, *II_g_malloc0, 
- *II_g_realloc, *II_g_try_malloc, *II_g_try_malloc0, 
- *II_g_try_realloc, *II_g_free, *II_g_memdup, 
- *II_g_malloc_n, *II_g_malloc0_n, *II_g_realloc_n, 
- *II_g_try_malloc_n, *II_g_try_malloc0_n, 
- *II_g_try_realloc_n;
   mutable Optional KernelZeroFlagVal;
 
+  mutable llvm::SmallSet AllocFunctions;
+  mutable llvm::SmallSet FreeFunctions;
+
+  mutable llvm::SmallSet AllocaFunctions;
+  mutable llvm::SmallSet SimpleMallocFunctions;
+
+  mutable llvm::SmallSet NZeroMallocFunctions;
+
+  mutable llvm::SmallSet NReallocFunctions;
+  mutable llvm::SmallSet ReallocFunctions;
+
+  mutable llvm::SmallSet StrdupFunctions;
+
+  mutable IdentifierInfo *II_kmalloc, *II_if_nameindex, *II_if_freenameindex,
+ *II_valloc, *II_realloc, *II_calloc, *II_reallocarray,
+ *II_recallocarray, *II_strndup, *II_g_memdup,
+ *II_g_malloc0, *II_g_try_malloc0, *II_g_malloc0_n,
+ *II_g_try_malloc0_n, *II_reallocf, *II_malloc;
+
   void initIdentifierInfo(ASTContext ) const;
 
   /// \brief Determine family of a deallocation expression.
@@ -345,7 +350,8 @@
   ProgramStateRef ReallocMemAux(CheckerContext , const CallExpr *CE,
 bool FreesMemOnFailure,
 ProgramStateRef State, 
-bool SuffixWithN = false) const;
+bool SuffixWithN = false,
+bool ZeroVal = false) const;
   static SVal evalMulForBufferSize(CheckerContext , const Expr *Blocks,
const Expr *BlockBytes);
   static ProgramStateRef CallocMem(CheckerContext , const CallExpr *CE,
@@ -575,42 +581,86 @@
 } // end anonymous namespace
 
 void MallocChecker::initIdentifierInfo(ASTContext ) const {
-  if (II_malloc)
+  if (!AllocFunctions.empty())
 return;
-  II_alloca = ("alloca");
-  II_malloc = ("malloc");
-  II_free = ("free");
-  II_realloc = ("realloc");
-  II_reallocf = ("reallocf");
-  II_calloc = ("calloc");
-  II_valloc = ("valloc");
-  II_strdup = ("strdup");
-  II_strndup = ("strndup");
-  II_wcsdup = ("wcsdup");
-  II_kmalloc = ("kmalloc");
-  II_if_nameindex = ("if_nameindex");
-  II_if_freenameindex = ("if_freenameindex");
+  AllocFunctions.insert(("malloc"));
+  

[PATCH] D44878: libFuzzer OpenBSD support

2018-04-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D44878



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


[PATCH] D45456: [Attr] Print enum attributes at correct position

2018-04-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: aaron.ballman, hfinkel.

In enum declarations, enum attributes were always printed after the
tag and any member list.  When no member list was present but the enum
was a type specifier in a variable declaration, the attribute then
applied to the variable not the enum, changing the semantics.

This patch fixes that by always printing attributes between the enum's
keyword and tag, as clang already does for structs, unions, and
classes.


https://reviews.llvm.org/D45456

Files:
  lib/AST/DeclPrinter.cpp
  test/Sema/ast-print.c


Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//
+// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
+// RUN: %clang_cc1 -fsyntax-only %t.c -verify
 
 typedef void func_typedef();
 func_typedef xxx;
@@ -58,7 +65,7 @@
 };
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
-struct pair_t p = {a: 3, .b = 4};
+struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style 
field designator extension}}
 
 void initializers() {
   // CHECK: int *x = ((void *)0), *y = ((void *)0);
@@ -70,11 +77,30 @@
   } z = {(struct Z){}};
 }
 
-// CHECK-LABEL: enum EnumWithAttributes {
-enum EnumWithAttributes {
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {
+enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is 
deprecated}}
   // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),
   EnumWithAttributesFoo __attribute__((deprecated)),
   // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 50
   EnumWithAttributesBar __attribute__((unavailable)) = 50
-  // CHECK-NEXT: } __attribute__((deprecated("")))
-} __attribute__((deprecated));
+  // CHECK-NEXT: };
+  // CHECK-NEXT: enum EnumWithAttributes *EnumWithAttributesPtr;
+} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
+
+// FIXME: If enum is forward-declared at file scope, attributes are lost.
+// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
+// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
+enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
+
+// CHECK-LABEL: EnumWithAttributes3Fn
+void EnumWithAttributes3Fn() {
+  // CHECK-NEXT: enum __attribute__((deprecated(""))) EnumWithAttributes3 
*EnumWithAttributes3Ptr;
+  // expected-warning@+2 {{'EnumWithAttributes3' is deprecated}}
+  // expected-note@+1 {{'EnumWithAttributes3' has been explicitly marked 
deprecated here}}
+  enum __attribute__((deprecated)) EnumWithAttributes3 *EnumWithAttributes3Ptr;
+  // Printing must not put the attribute after the tag where it would apply to
+  // the variable instead of the type, and then our deprecation warning would
+  // move to this use of the variable.
+  void *p = EnumWithAttributes3Ptr;
+}
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -496,14 +496,17 @@
 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
-  Out << "enum ";
+  Out << "enum";
   if (D->isScoped()) {
 if (D->isScopedUsingClassTag())
-  Out << "class ";
+  Out << " class";
 else
-  Out << "struct ";
+  Out << " struct";
   }
-  Out << *D;
+
+  prettyPrintAttributes(D);
+
+  Out << ' ' << *D;
 
   if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
 Out << " : " << D->getIntegerType().stream(Policy);
@@ -513,7 +516,6 @@
 VisitDeclContext(D);
 Indent() << "}";
   }
-  prettyPrintAttributes(D);
 }
 
 void DeclPrinter::VisitRecordDecl(RecordDecl *D) {


Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -1,5 +1,12 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-// RUN: %clang_cc1 %s -ast-print | %clang_cc1 -fsyntax-only -
+// RUN: %clang_cc1 %s -ast-print -verify > %t.c
+// RUN: FileCheck %s --input-file %t.c
+//

[PATCH] D45403: Make [[maybe_unused]] work with static data members

2018-04-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I don't think we're currently diagnosing static data members of classes as 
being unused in the first place; are there plans to implement that 
functionality so that someone might want to write the attribute there?




Comment at: lib/Sema/SemaDeclAttr.cpp:2050
-  S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
-  << AL.getName() << ExpectedForMaybeUnused;
-  return;

`ExpectedForMaybeUnused` can be removed from AttributeList.h and the 
`warn_attribute_wrong_decl_type` table definition can have the entry for 
`ExpectedForMaybeUnused` removed as well.



Comment at: test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp:5
   int I [[maybe_unused]];
-  static int SI [[maybe_unused]]; // expected-warning {{'maybe_unused' 
attribute only applies to variables, functions, methods, types, enumerations, 
enumerators, labels, and non-static data members}}
+  static int SI [[maybe_unused]];
 };

cpplearner wrote:
> lebedev.ri wrote:
> > As the code comment noted, 
> > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf, page 199:
> > ```
> > 2 The attribute may be applied to the declaration of a class, a 
> > typedef-name, a variable, a **non-static** data
> > member, a function, an enumeration, or an enumerator.
> > ```
> That section says that [[maybe_unused]] can be applied to a non-static data 
> member, which doesn't mean it can't be applied to a static data member.
> 
> And I'm arguing that since a static data member is a variable, 
> [dcl.attr.unused]p2 actually allows [[maybe_unused]] to be applied to a 
> static data member.
Yes -- through twisty standardese, a static data member of a class might be a 
variable. This test case, however, is only a declaration and not a definition 
(which means it's not an object, which means it's not a variable). Should the 
attribute still appertain in this case?


Repository:
  rC Clang

https://reviews.llvm.org/D45403



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


[PATCH] D45149: MallocChecker, adding specific BSD calls

2018-04-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Hi David.  While I did make some superficial changes here recently, I'm no 
authority on what belongs here.  However, I would suggest that the refactoring 
patch be split from the original patch.  Thanks.


https://reviews.llvm.org/D45149



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


[PATCH] D45109: Remove -cc1 option "-backend-option"

2018-04-09 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Uh sure. :)

Though I'd almost do it the other way around. That said, -mllvm probably has 
more uptake.


Repository:
  rC Clang

https://reviews.llvm.org/D45109



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


[PATCH] D45196: [libc++abi] Replace __sync_* functions with __libcpp_atomic_* functions.

2018-04-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Ping.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D45196



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


[PATCH] D45109: Remove -cc1 option "-backend-option"

2018-04-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added reviewers: pcc, echristo, rsmith.
efriedma added a comment.

Not sure who to add as reviewers here.


Repository:
  rC Clang

https://reviews.llvm.org/D45109



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


[PATCH] D44984: [HIP] Add hip file type and codegen for kernel launching

2018-04-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping. Any further changes need to be done for this patch? Thanks.


https://reviews.llvm.org/D44984



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


[PATCH] D45417: [analyzer] Don't crash on printing ConcreteInt of size >64 bits

2018-04-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/egraph-dump-int128.c:3
+// RUN: mkdir -p %t.dir
+// RUN: env TMPDIR=%t.dir TEMP=%t.dir TMP=%t.dir %clang_analyze_cc1 
-analyzer-checker=debug.ViewExplodedGraph %s
+

george.karpenkov wrote:
> At least on a mac, `ViewExplodedGraph` launches `GraphViz.app`.
> Can we have a less invasive check? Wouldn't just dumping a value be 
> sufficient?
Yeah, it just runs `xdg-open` on linux and `open` on mac, which often opens up 
a GUI viewer. That's not the behavior we want from automated tests.

I think you should use `ExprInspection` instead, and either dump the whole 
state with `clang_analyzer_printState()` or, even better, dump only the 
particular value with `clang_analyzer_dump(...)` - that way you'll be also 
capable of verifying the output.

Note that we actually don't have much tests for our dumps.


Repository:
  rC Clang

https://reviews.llvm.org/D45417



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


[PATCH] D45455: [CFI] Disable CFI checks for __cxa_decrement_exception_refcount

2018-04-09 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich created this revision.
Herald added subscribers: cfe-commits, christof.

exception_header->exceptionDestructor is a void(*)(void*) function
pointer; however, it can point to destructors like std::
exception::~exception that don't match that type signature.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D45455

Files:
  include/__cxxabi_config.h
  src/cxa_exception.cpp


Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -630,8 +630,8 @@
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = 
cxa_exception_from_thrown_object(thrown_object);
Index: include/__cxxabi_config.h
===
--- include/__cxxabi_config.h
+++ include/__cxxabi_config.h
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H


Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -630,8 +630,8 @@
 
 Requires:  If thrown_object is not NULL, it is a native exception.
 */
-void
-__cxa_decrement_exception_refcount(void *thrown_object) throw() {
+_LIBCXXABI_NO_CFI
+void __cxa_decrement_exception_refcount(void *thrown_object) throw() {
 if (thrown_object != NULL )
 {
 __cxa_exception* exception_header = cxa_exception_from_thrown_object(thrown_object);
Index: include/__cxxabi_config.h
===
--- include/__cxxabi_config.h
+++ include/__cxxabi_config.h
@@ -60,4 +60,14 @@
 #define _LIBCXXABI_WEAK __attribute__((__weak__))
 #endif
 
+#if defined(__clang__)
+#define _LIBCXXABI_COMPILER_CLANG
+#endif
+
+#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
+#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCXXABI_NO_CFI
+#endif
+
 #endif // CXXABI_CONFIG_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak closed this revision.
ahatanak added a comment.

Committed in r329617.


Repository:
  rC Clang

https://reviews.llvm.org/D45384



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


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-09 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh created this revision.
chh added reviewers: sylvestre.ledru, davidxl, rnk, void.

__gcov_flush is not called from other functions in GCDAProfiling.c,
but have been used by Android, which needs an interface function
to flush profile data of multiple .so files.

See https://bugs.llvm.org/show_bug.cgi?id=27224#c5


https://reviews.llvm.org/D45454

Files:
  lib/profile/GCDAProfiling.c
  test/profile/Inputs/instrprof-dlopen-dlclose-main.c


Index: test/profile/Inputs/instrprof-dlopen-dlclose-main.c
===
--- test/profile/Inputs/instrprof-dlopen-dlclose-main.c
+++ test/profile/Inputs/instrprof-dlopen-dlclose-main.c
@@ -16,6 +16,25 @@
 return EXIT_FAILURE;
   }
 
+  void (*f1_flush)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
+  if (f1_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func.shared'\n");
+return EXIT_FAILURE;
+  }
+  f1_flush();
+
+  void (*f2_flush)() = (void (*)())dlsym(f2_handle, "__gcov_flush");
+  if (f2_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func2.shared'\n");
+return EXIT_FAILURE;
+  }
+  f2_flush();
+
+  if (f1_flush == f2_flush) {
+fprintf(stderr, "Same __gcov_flush found in func.shared and 
func2.shared\n");
+return EXIT_FAILURE;
+  }
+
   if (dlclose(f2_handle) != 0) {
 fprintf(stderr, "unable to close 'func2.shared': %s\n", dlerror());
 return EXIT_FAILURE;
Index: lib/profile/GCDAProfiling.c
===
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -527,7 +527,7 @@
   }
 }
 
-COMPILER_RT_VISIBILITY
+// Keep __gcov_flush visible for special use cases.
 void __gcov_flush() {
   struct flush_fn_node *curr = flush_fn_head;
 


Index: test/profile/Inputs/instrprof-dlopen-dlclose-main.c
===
--- test/profile/Inputs/instrprof-dlopen-dlclose-main.c
+++ test/profile/Inputs/instrprof-dlopen-dlclose-main.c
@@ -16,6 +16,25 @@
 return EXIT_FAILURE;
   }
 
+  void (*f1_flush)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
+  if (f1_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func.shared'\n");
+return EXIT_FAILURE;
+  }
+  f1_flush();
+
+  void (*f2_flush)() = (void (*)())dlsym(f2_handle, "__gcov_flush");
+  if (f2_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func2.shared'\n");
+return EXIT_FAILURE;
+  }
+  f2_flush();
+
+  if (f1_flush == f2_flush) {
+fprintf(stderr, "Same __gcov_flush found in func.shared and func2.shared\n");
+return EXIT_FAILURE;
+  }
+
   if (dlclose(f2_handle) != 0) {
 fprintf(stderr, "unable to close 'func2.shared': %s\n", dlerror());
 return EXIT_FAILURE;
Index: lib/profile/GCDAProfiling.c
===
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -527,7 +527,7 @@
   }
 }
 
-COMPILER_RT_VISIBILITY
+// Keep __gcov_flush visible for special use cases.
 void __gcov_flush() {
   struct flush_fn_node *curr = flush_fn_head;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r329618 - [test] [NFC] cleanup aligned_storage test

2018-04-09 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Mon Apr  9 13:41:45 2018
New Revision: 329618

URL: http://llvm.org/viewvc/llvm-project?rev=329618=rev
Log:
[test] [NFC] cleanup aligned_storage test

* `s/"" )/"")/g`
* Don't redundantly test triviality for `TEST_STD_VER > 17`

Modified:

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp?rev=329618=329617=329618=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
 Mon Apr  9 13:41:45 2018
@@ -23,13 +23,10 @@ int main()
 {
 typedef std::aligned_storage<10, 1 >::type T1;
 #if TEST_STD_VER > 11
-static_assert(std::is_same, T1>::value, "" );
+static_assert(std::is_same, T1>::value, "");
 #endif
-#if TEST_STD_VER > 17
-//  P0767
-static_assert(std::is_trivial::value, "" );
-#else
-static_assert(std::is_pod::value, "" );
+#if TEST_STD_VER <= 17
+static_assert(std::is_pod::value, "");
 #endif
 static_assert(std::is_trivial::value, "");
 static_assert(std::is_standard_layout::value, "");
@@ -39,13 +36,10 @@ int main()
 {
 typedef std::aligned_storage<10, 2 >::type T1;
 #if TEST_STD_VER > 11
-static_assert(std::is_same, T1>::value, "" );
+static_assert(std::is_same, T1>::value, "");
 #endif
-#if TEST_STD_VER > 17
-//  P0767
-static_assert(std::is_trivial::value, "" );
-#else
-static_assert(std::is_pod::value, "" );
+#if TEST_STD_VER <= 17
+static_assert(std::is_pod::value, "");
 #endif
 static_assert(std::is_trivial::value, "");
 static_assert(std::is_standard_layout::value, "");
@@ -55,13 +49,10 @@ int main()
 {
 typedef std::aligned_storage<10, 4 >::type T1;
 #if TEST_STD_VER > 11
-static_assert(std::is_same, T1>::value, "" );
+static_assert(std::is_same, T1>::value, "");
 #endif
-#if TEST_STD_VER > 17
-//  P0767
-static_assert(std::is_trivial::value, "" );
-#else
-static_assert(std::is_pod::value, "" );
+#if TEST_STD_VER <= 17
+static_assert(std::is_pod::value, "");
 #endif
 static_assert(std::is_trivial::value, "");
 static_assert(std::is_standard_layout::value, "");
@@ -71,13 +62,10 @@ int main()
 {
 typedef std::aligned_storage<10, 8 >::type T1;
 #if TEST_STD_VER > 11
-static_assert(std::is_same, T1>::value, "" );
+static_assert(std::is_same, T1>::value, "");
 #endif
-#if TEST_STD_VER > 17
-//  P0767
-static_assert(std::is_trivial::value, "" );
-#else
-static_assert(std::is_pod::value, "" );
+#if TEST_STD_VER <= 17
+static_assert(std::is_pod::value, "");
 #endif
 static_assert(std::is_trivial::value, "");
 static_assert(std::is_standard_layout::value, "");
@@ -87,13 +75,10 @@ int main()
 {
 typedef std::aligned_storage<10, 16 >::type T1;
 #if TEST_STD_VER > 11
-static_assert(std::is_same, T1>::value, "" 
);
+static_assert(std::is_same, T1>::value, "");
 #endif
-#if TEST_STD_VER > 17
-//  P0767
-static_assert(std::is_trivial::value, "" );
-#else
-static_assert(std::is_pod::value, "" );
+#if TEST_STD_VER <= 17
+static_assert(std::is_pod::value, "");
 #endif
 static_assert(std::is_trivial::value, "");
 static_assert(std::is_standard_layout::value, "");
@@ -103,13 +88,10 @@ int main()
 {
 typedef std::aligned_storage<10, 32 >::type T1;
 #if TEST_STD_VER > 11
-static_assert(std::is_same, T1>::value, "" 
);
+static_assert(std::is_same, T1>::value, "");
 #endif
-#if TEST_STD_VER > 17
-//  P0767
-static_assert(std::is_trivial::value, "" );
-#else
-static_assert(std::is_pod::value, "" );
+#if TEST_STD_VER <= 17
+static_assert(std::is_pod::value, "");
 #endif
 static_assert(std::is_trivial::value, "");
 static_assert(std::is_standard_layout::value, "");
@@ -119,13 +101,10 @@ int main()
 {
 typedef std::aligned_storage<20, 32 >::type T1;
 #if TEST_STD_VER > 11
-static_assert(std::is_same, T1>::value, "" 
);
+static_assert(std::is_same, T1>::value, "");
 #endif
-#if TEST_STD_VER > 17
-//  P0767
-static_assert(std::is_trivial::value, "" );
-#else
-static_assert(std::is_pod::value, "" );
+#if TEST_STD_VER <= 17
+

r329617 - [ObjC++] Never pass structs that transitively contain __weak fields in

2018-04-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Apr  9 13:39:47 2018
New Revision: 329617

URL: http://llvm.org/viewvc/llvm-project?rev=329617=rev
Log:
[ObjC++] Never pass structs that transitively contain __weak fields in
registers.

This patch fixes a bug in r328731 that caused structs transitively
containing __weak fields to be passed in registers. The patch replaces
the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates
whether the struct or structs containing the struct are forced to be
passed indirectly.

rdar://problem/39194693

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenObjCXX/objc-struct-cxx-abi.mm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=329617=329616=329617=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Apr  9 13:39:47 2018
@@ -3541,6 +3541,31 @@ public:
 ///   union Y { int A, B; }; // Has body with members A and B (FieldDecls).
 /// This decl will be marked invalid if *any* members are invalid.
 class RecordDecl : public TagDecl {
+public:
+  /// Enum that represents the different ways arguments are passed to and
+  /// returned from function calls. This takes into account the target-specific
+  /// and version-specific rules along with the rules determined by the
+  /// language.
+  enum ArgPassingKind {
+/// The argument of this type can be passed directly in registers.
+APK_CanPassInRegs,
+
+/// The argument of this type cannot be passed directly in registers.
+/// Records containing this type as a subobject are not forced to be passed
+/// indirectly. This value is used only in C++. This value is required by
+/// C++ because, in uncommon situations, it is possible for a class to have
+/// only trivial copy/move constructors even when one of its subobjects has
+/// a non-trivial copy/move constructor (if e.g. the corresponding 
copy/move
+/// constructor in the derived class is deleted).
+APK_CannotPassInRegs,
+
+/// The argument of this type cannot be passed directly in registers.
+/// Records containing this type as a subobject are forced to be passed
+/// indirectly.
+APK_CanNeverPassInRegs
+  };
+
+private:
   friend class DeclContext;
 
   // FIXME: This can be packed into the bitfields in Decl.
@@ -3571,17 +3596,14 @@ class RecordDecl : public TagDecl {
   bool NonTrivialToPrimitiveCopy : 1;
   bool NonTrivialToPrimitiveDestroy : 1;
 
-  /// True if this class can be passed in a non-address-preserving fashion
-  /// (such as in registers).
-  /// This does not imply anything about how the ABI in use will actually
-  /// pass an object of this class.
-  bool CanPassInRegisters : 1;
-
   /// Indicates whether this struct is destroyed in the callee. This flag is
   /// meaningless when Microsoft ABI is used since parameters are always
   /// destroyed in the callee.
   bool ParamDestroyedInCallee : 1;
 
+  /// Represents the way this type is passed to a function.
+  ArgPassingKind ArgPassingRestrictions : 2;
+
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
  SourceLocation StartLoc, SourceLocation IdLoc,
@@ -3669,12 +3691,15 @@ public:
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.
   bool canPassInRegisters() const {
-return CanPassInRegisters;
+return ArgPassingRestrictions == APK_CanPassInRegs;
+  }
+
+  ArgPassingKind getArgPassingRestrictions() const {
+return ArgPassingRestrictions;
   }
 
-  /// Set that we can pass this RecordDecl in registers.
-  void setCanPassInRegisters(bool CanPass) {
-CanPassInRegisters = CanPass;
+  void setArgPassingRestrictions(ArgPassingKind Kind) {
+ArgPassingRestrictions = Kind;
   }
 
   bool isParamDestroyedInCallee() const {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=329617=329616=329617=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr  9 13:39:47 2018
@@ -1149,8 +1149,6 @@ public:
   /// source object is placed in an uninitialized state.
   PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const;
 
-  bool canPassInRegisters() const;
-
   enum DestructionKind {
 DK_none,
 DK_cxx_destructor,

Modified: 

[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

2018-04-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 141730.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D45384

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm

Index: clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
===
--- clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
+++ clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
@@ -8,6 +8,8 @@
 // pointer fields are passed directly.
 
 // CHECK: %[[STRUCT_STRONGWEAK:.*]] = type { i8*, i8* }
+// CHECK: %[[STRUCT_CONTAINSSTRONGWEAK:.*]] = type { %[[STRUCT_STRONGWEAK]] }
+// CHECK: %[[STRUCT_DERIVEDSTRONGWEAK:.*]] = type { %[[STRUCT_STRONGWEAK]] }
 // CHECK: %[[STRUCT_STRONG:.*]] = type { i8* }
 // CHECK: %[[STRUCT_S:.*]] = type { i8* }
 // CHECK: %[[STRUCT_CONTAINSNONTRIVIAL:.*]] = type { %{{.*}}, i8* }
@@ -21,6 +23,21 @@
   __weak id fweak;
 };
 
+#ifdef TRIVIALABI
+struct __attribute__((trivial_abi)) ContainsStrongWeak {
+#else
+struct ContainsStrongWeak {
+#endif
+  StrongWeak sw;
+};
+
+#ifdef TRIVIALABI
+struct __attribute__((trivial_abi)) DerivedStrongWeak : StrongWeak {
+#else
+struct DerivedStrongWeak : StrongWeak {
+#endif
+};
+
 #ifdef TRIVIALABI
 struct __attribute__((trivial_abi)) Strong {
 #else
@@ -84,6 +101,18 @@
   return *a;
 }
 
+// CHECK: define void @_Z27testParamContainsStrongWeak18ContainsStrongWeak(%[[STRUCT_CONTAINSSTRONGWEAK]]* %[[A:.*]])
+// CHECK: call %[[STRUCT_CONTAINSSTRONGWEAK]]* @_ZN18ContainsStrongWeakD1Ev(%[[STRUCT_CONTAINSSTRONGWEAK]]* %[[A]])
+
+void testParamContainsStrongWeak(ContainsStrongWeak a) {
+}
+
+// CHECK: define void @_Z26testParamDerivedStrongWeak17DerivedStrongWeak(%[[STRUCT_DERIVEDSTRONGWEAK]]* %[[A:.*]])
+// CHECK: call %[[STRUCT_DERIVEDSTRONGWEAK]]* @_ZN17DerivedStrongWeakD1Ev(%[[STRUCT_DERIVEDSTRONGWEAK]]* %[[A]])
+
+void testParamDerivedStrongWeak(DerivedStrongWeak a) {
+}
+
 // CHECK: define void @_Z15testParamStrong6Strong(i64 %[[A_COERCE:.*]])
 // CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONG]], align 8
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[A]], i32 0, i32 0
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -469,8 +469,8 @@
   Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize());
   Record.push_back(D->isNonTrivialToPrimitiveCopy());
   Record.push_back(D->isNonTrivialToPrimitiveDestroy());
-  Record.push_back(D->canPassInRegisters());
   Record.push_back(D->isParamDestroyedInCallee());
+  Record.push_back(D->getArgPassingRestrictions());
 
   if (D->getDeclContext() == D->getLexicalDeclContext() &&
   !D->hasAttrs() &&
@@ -1913,9 +1913,10 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
   // isNonTrivialToPrimitiveDestroy
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // canPassInRegisters
   // isParamDestroyedInCallee
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
+  // getArgPassingRestrictions
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));
 
   // DC
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));   // LexicalOffset
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -5193,8 +5193,8 @@
   case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
 auto *RD = cast(D);
 UpdatedDeclContexts.insert(RD->getPrimaryContext());
-Record.push_back(RD->canPassInRegisters());
 Record.push_back(RD->isParamDestroyedInCallee());
+Record.push_back(RD->getArgPassingRestrictions());
 Record.AddCXXDefinitionData(RD);
 Record.AddOffset(WriteDeclContextLexicalBlock(
 *Context, const_cast(RD)));
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -742,8 +742,8 @@
   RD->setNonTrivialToPrimitiveDefaultInitialize(Record.readInt());
   RD->setNonTrivialToPrimitiveCopy(Record.readInt());
   RD->setNonTrivialToPrimitiveDestroy(Record.readInt());
-  RD->setCanPassInRegisters(Record.readInt());
   RD->setParamDestroyedInCallee(Record.readInt());
+  RD->setArgPassingRestrictions((RecordDecl::ArgPassingKind)Record.readInt());
   return Redecl;
 }
 

[PATCH] D44878: libFuzzer OpenBSD support

2018-04-09 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

the sanitizer part had been accepted https://reviews.llvm.org/D44877


https://reviews.llvm.org/D44878



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


r329612 - asan: kernel: make no_sanitize("address") attribute work with -fsanitize=kernel-address

2018-04-09 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Apr  9 13:10:29 2018
New Revision: 329612

URL: http://llvm.org/viewvc/llvm-project?rev=329612=rev
Log:
asan: kernel: make no_sanitize("address") attribute work with 
-fsanitize=kernel-address

Summary:
Right now to disable -fsanitize=kernel-address instrumentation, one needs to 
use no_sanitize("kernel-address"). Make either no_sanitize("address") or 
no_sanitize("kernel-address")  disable both ASan and KASan instrumentation. 
Also remove redundant test.

Patch by Andrey Konovalov

Reviewers: eugenis, kcc, glider, dvyukov, vitalybuka

Reviewed By: eugenis, vitalybuka

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

Added:
cfe/trunk/test/CodeGen/address-safety-attr-flavors.cpp
Removed:
cfe/trunk/test/CodeGen/address-safety-attr-kasan-hwasan.cpp
cfe/trunk/test/CodeGen/address-safety-attr-kasan.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=329612=329611=329612=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Apr  9 13:10:29 2018
@@ -846,8 +846,14 @@ void CodeGenFunction::StartFunction(Glob
 
   if (D) {
 // Apply the no_sanitize* attributes to SanOpts.
-for (auto Attr : D->specific_attrs())
-  SanOpts.Mask &= ~Attr->getMask();
+for (auto Attr : D->specific_attrs()) {
+  SanitizerMask mask = Attr->getMask();
+  SanOpts.Mask &= ~mask;
+  if (mask & SanitizerKind::Address)
+SanOpts.set(SanitizerKind::KernelAddress, false);
+  if (mask & SanitizerKind::KernelAddress)
+SanOpts.set(SanitizerKind::Address, false);
+}
   }
 
   // Apply sanitizer attributes to the function.

Added: cfe/trunk/test/CodeGen/address-safety-attr-flavors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-safety-attr-flavors.cpp?rev=329612=auto
==
--- cfe/trunk/test/CodeGen/address-safety-attr-flavors.cpp (added)
+++ cfe/trunk/test/CodeGen/address-safety-attr-flavors.cpp Mon Apr  9 13:10:29 
2018
@@ -0,0 +1,55 @@
+// Make sure the sanitize_address attribute is emitted when using ASan, KASan 
or
+// HWASan. Either __attribute__((no_sanitize("address")) or
+// __attribute__((no_sanitize("kernel-address")) disables both ASan and KASan
+// instrumentation.
+
+// RUN: %clang_cc1 -triple i386-unknown-linux -disable-O0-optnone \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NOASAN %s
+
+// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=address \
+// RUN:   -disable-O0-optnone -emit-llvm -o - %s | \
+// RUN:   FileCheck -check-prefix=CHECK-ASAN %s
+
+// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=kernel-address \
+// RUN:   -disable-O0-optnone -emit-llvm -o - %s | \
+// RUN:   FileCheck -check-prefix=CHECK-KASAN %s
+
+// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=hwaddress \
+// RUN:   -disable-O0-optnone -emit-llvm -o - %s | \
+// RUN:   FileCheck -check-prefix=CHECK-HWASAN %s
+
+int HasSanitizeAddress() { return 1; }
+// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-ASAN: Function Attrs: noinline nounwind sanitize_address
+// CHECK-KASAN: Function Attrs: noinline nounwind sanitize_address
+// CHECK-HWASAN: Function Attrs: noinline nounwind sanitize_hwaddress
+
+__attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() {
+  return 0;
+}
+// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-ASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-KASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
+
+__attribute__((no_sanitize_address)) int NoSanitizeAddress() { return 0; }
+// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-ASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-KASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
+
+__attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() {
+  return 0;
+}
+// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-ASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-KASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
+
+__attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() {
+  return 0;
+}
+// CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
+// CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}}
+// CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}}
+// CHECK-HWASAN: {{Function Attrs: noinline nounwind$}}

Removed: cfe/trunk/test/CodeGen/address-safety-attr-kasan-hwasan.cpp
URL: 

[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2018-04-09 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Are there more thoughts on this change?


https://reviews.llvm.org/D34331



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


[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-09 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 141719.
zinovy.nis marked 9 inline comments as done.
zinovy.nis added a comment.

- Default value is **5**.
- Switched to 'tooling::fixit::getText'.
- Updated rst docs.


https://reviews.llvm.org/D45405

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-cast.cpp
  test/clang-tidy/modernize-use-auto-min-type-name-length.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.MinTypeNameLength, value: '0'}]}" \
+// RUN:   -- -std=c++11 -frtti
 
 class MyType {};
 
Index: test/clang-tidy/modernize-use-auto-min-type-name-length.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-min-type-name-length.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.MinTypeNameLength, value: '5'}]}" \
+// RUN:   -- -std=c++11 -frtti
+
+extern int foo();
+
+using VeryVeryVeryLongTypeName = int;
+
+int bar() {
+  int a = static_cast(foo());
+  // strlen('int') = 4 <  5, so skip it,
+  // even strlen('VeryVeryVeryLongTypeName') > 5.
+
+  unsigned b = static_cast(foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
+  // CHECK-FIXES: auto b = static_cast(foo());
+
+  bool c = static_cast(foo());
+  // strlen('bool') = 4 <  5, so skip it.
+
+  const bool c1 = static_cast(foo());
+  // strlen('bool') = 4 <  5, so skip it, even there's a 'const'.
+
+  unsigned long long ull = static_cast(foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
+  // CHECK-FIXES: auto ull = static_cast(foo());
+
+  return 1;
+}
+
Index: test/clang-tidy/modernize-use-auto-cast.cpp
===
--- test/clang-tidy/modernize-use-auto-cast.cpp
+++ test/clang-tidy/modernize-use-auto-cast.cpp
@@ -1,5 +1,6 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t -- -- \
-// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto -frtti
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.MinTypeNameLength, value: '0'}]}" \
+// RUN:   -- -std=c++11 -I %S/Inputs/modernize-use-auto -frtti
 
 struct A {
   virtual ~A() {}
Index: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
===
--- test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
+++ test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s modernize-use-auto %t -- \
-// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'} , {key: modernize-use-auto.MinTypeNameLength, value: '0'}]}" \
 // RUN:   -- -std=c++11 -frtti
 
 struct A {
Index: docs/clang-tidy/checks/modernize-use-auto.rst
===
--- docs/clang-tidy/checks/modernize-use-auto.rst
+++ docs/clang-tidy/checks/modernize-use-auto.rst
@@ -194,3 +194,23 @@
   // RemoveStars = 1
 
   auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;
+
+.. option:: MinTypeNameLength
+
+   If the option is set to non-zero (default '5'), the check will ignore
+   type names having a length less than the option value.
+   The option affects expressions only, not iterators.
+
+.. code-block:: c++
+
+  // MinTypeNameLength = 0
+
+  int a = static_cast(foo());// ---> auto a = ...
+  bool b = new bool;  // ---> auto b = ...
+  unsigned c = static_cast(foo());  // ---> auto c = ...
+
+  // MinTypeNameLength = 8
+
+  int a = static_cast(foo());// ---> int  a = ...
+  bool b = new bool;  // ---> bool b = ...
+  unsigned c = static_cast(foo());  // ---> auto c = ...
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New option `MinTypeNameLength` for `modernize-use-auto` to limit the minimal
+  length of type names to be replaced with 'auto'. 

[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

2018-04-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with a few minor nits to be fixed.




Comment at: 
docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst:4
+android-comparison-in-temp-failure-retry
+=
+

Underlining is off here.



Comment at: 
docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst:25
+
+Since TEMP_FAILURE_RETRY will check for whether the result *of the comparison*
+is ``-1``, and retry if so.

s/Since/Because


https://reviews.llvm.org/D45059



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


Re: r328680 - [ObjC] Make C++ triviality type traits available to non-trivial C

2018-04-09 Thread Akira Hatanaka via cfe-commits

> On Apr 5, 2018, at 1:25 PM, John McCall  wrote:
> 
> 
> 
>> On Apr 5, 2018, at 3:54 PM, Akira Hatanaka > > wrote:
>> 
>> 
>>> On Apr 5, 2018, at 12:39 PM, John McCall >> > wrote:
>>> 
>>> 
>>> 
 On Apr 4, 2018, at 7:37 PM, Akira Hatanaka > wrote:
 
 
 
> On Apr 4, 2018, at 4:24 PM, Akira Hatanaka via cfe-commits 
> > wrote:
> 
>> 
>> On Apr 4, 2018, at 3:38 PM, Richard Smith > > wrote:
>> 
>> Hi Akira,
>> 
>> This change has broken the C++ versions of these type traits for classes 
>> with volatile members. Such classes are required to claim to be trivial 
>> per C++ DR 2094 
>> (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 
>> ) but 
>> return false from isNonTrivialToPrimitiveCopy().
>> 
> 
> Oh that’s right. The function returns false when 
> isNonTrivialToPrimitiveCopy() returns PCK_VolatileTrivial. That is wrong.
> 
>> Also, exposing these __has_* traits more widely seems like a backwards 
>> step to me: these traits are deprecated, near-useless, and we're trying 
>> to remove them. No code should be using them under any circumstances; 
>> the __is_* traits should be used instead.
>> 
> 
> The __is_* traits (is_trivially_copy_constructible, etc.) are templates 
> defined in libcxx, so it seems that we can’t use them when compiling in C 
> mode. Is it OK to add their definitions to TokenKinds.def as non-C++ 
> keywords?
> 
 
 Or perhaps redefine the six __has_* traits used here as non-C++ (KEYNOCXX 
 or ‘KEYC99 | KEYC11') keywords?
>>> 
>>> I think Richard is talking about e.g. the __is_trivially_destructible 
>>> intrinsic type trait function rather than std::is_trivially_destructible.
>>> 
>>> Do we have a concrete need to expose these type traits to C?
>>> 
>> 
>> No, no one has asked any of these type traits to be exposed to C yet. Do you 
>> think we should just revert the patch and wait until someone asks for those 
>> type traits to be available in C?
> 
> I think that would be fine.  Although it would be nice if we could save the 
> part of the patch that makes the trait logic sensitive to the type queries 
> instead of needing to include duplicated checks for __strong, __weak, and 
> whatever other non-trivial C features we eventually add.
> 

Reverted r329289 in r329608. I wasn’t sure which part of the patch should be 
saved. I don’t think we need to check the properties of the types calling the 
QualType::isNonTrivialTo* functions since we aren’t exposing the type traits to 
C anymore?

> John.
> 
>> 
>>> John.
>>> 
 
>> On 27 March 2018 at 17:12, Akira Hatanaka via cfe-commits 
>> > wrote:
>> Author: ahatanak
>> Date: Tue Mar 27 17:12:08 2018
>> New Revision: 328680
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=328680=rev 
>> 
>> Log:
>> [ObjC] Make C++ triviality type traits available to non-trivial C
>> structs.
>> 
>> r326307 and r327870 made changes that allowed using non-trivial C
>> structs with fields qualified with __strong or __weak. This commit makes
>> the following C++ triviality type traits available to non-trivial C
>> structs:
>> 
>> __has_trivial_assign
>> __has_trivial_move_assign
>> __has_trivial_copy
>> __has_trivial_move_constructor
>> __has_trivial_constructor
>> __has_trivial_destructor
>> 
>> rdar://problem/33599681 
>> 
>> Differential Revision: https://reviews.llvm.org/D44913 
>> 
>> 
>> Added:
>> cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
>> Modified:
>> cfe/trunk/include/clang/Basic/TokenKinds.def
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> 
>> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=328680=328679=328680=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
>> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Mar 27 17:12:08 2018
>> @@ -433,12 +433,12 @@ TYPE_TRAIT_1(__has_nothrow_assign, HasNo
>>  TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, 

[PATCH] D45284: [RISCV] More validations on the input value of -march=

2018-04-09 Thread Ana Pazos via Phabricator via cfe-commits
apazos updated this revision to Diff 141717.
apazos edited the summary of this revision.
apazos added a comment.
Herald added a subscriber: zzheng.

Updated code according to the ISA string rules that have been clarified.


https://reviews.llvm.org/D45284

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/RISCV.cpp
  test/Driver/riscv-arch.c

Index: test/Driver/riscv-arch.c
===
--- test/Driver/riscv-arch.c
+++ test/Driver/riscv-arch.c
@@ -1,89 +1,243 @@
-// RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ima -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ic -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ia -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32g -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32gc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64im -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64ima -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64ic -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64ia -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64g -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64gc -### %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ima -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imaf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imafd -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ic -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imc -### %s \
+// RUN: -fsyntax-only 2>&1 | 

r329608 - Revert "[ObjC] Make C++ triviality type traits available to non-trivial C"

2018-04-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Apr  9 12:39:27 2018
New Revision: 329608

URL: http://llvm.org/viewvc/llvm-project?rev=329608=rev
Log:
Revert "[ObjC] Make C++ triviality type traits available to non-trivial C"

This reverts commit r329289.

It was decided that we shouldn't expose the __has_* traits to C since
they are deprecated and useless.

See the discussion here:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180402/thread.html#223921

Removed:
cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=329608=329607=329608=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Mon Apr  9 12:39:27 2018
@@ -433,12 +433,12 @@ TYPE_TRAIT_1(__has_nothrow_assign, HasNo
 TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, KEYCXX)
 TYPE_TRAIT_1(__has_nothrow_copy, HasNothrowCopy, KEYCXX)
 TYPE_TRAIT_1(__has_nothrow_constructor, HasNothrowConstructor, KEYCXX)
-TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYALL)
-TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYALL)
-TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYALL)
-TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, KEYALL)
-TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, KEYALL)
-TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYALL)
+TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYCXX)
+TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYCXX)
+TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYCXX)
+TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, KEYCXX)
+TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, KEYCXX)
+TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYCXX)
 TYPE_TRAIT_1(__has_virtual_destructor, HasVirtualDestructor, KEYCXX)
 TYPE_TRAIT_1(__is_abstract, IsAbstract, KEYCXX)
 TYPE_TRAIT_1(__is_aggregate, IsAggregate, KEYCXX)

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=329608=329607=329608=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Apr  9 12:39:27 2018
@@ -4521,8 +4521,6 @@ static bool EvaluateUnaryTypeTrait(Sema
 // does not correctly compute triviality in the presence of multiple 
special
 // members of the same kind. Revisit this once the g++ bug is fixed.
   case UTT_HasTrivialDefaultConstructor:
-if (T.isNonTrivialToPrimitiveDefaultInitialize())
-  return false;
 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html:
 //   If __is_pod (type) is true then the trait is true, else if type is
 //   a cv class or union type (or array thereof) with a trivial default
@@ -4533,11 +4531,7 @@ static bool EvaluateUnaryTypeTrait(Sema
   return RD->hasTrivialDefaultConstructor() &&
  !RD->hasNonTrivialDefaultConstructor();
 return false;
-  case UTT_HasTrivialMoveConstructor: {
-QualType::PrimitiveCopyKind PCK =
-T.isNonTrivialToPrimitiveDestructiveMove();
-if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_VolatileTrivial)
-  return false;
+  case UTT_HasTrivialMoveConstructor:
 //  This trait is implemented by MSVC 2012 and needed to parse the
 //  standard library headers. Specifically this is used as the logic
 //  behind std::is_trivially_move_constructible (20.9.4.3).
@@ -4546,11 +4540,7 @@ static bool EvaluateUnaryTypeTrait(Sema
 if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
   return RD->hasTrivialMoveConstructor() && 
!RD->hasNonTrivialMoveConstructor();
 return false;
-  }
-  case UTT_HasTrivialCopy: {
-QualType::PrimitiveCopyKind PCK = T.isNonTrivialToPrimitiveCopy();
-if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_VolatileTrivial)
-  return false;
+  case UTT_HasTrivialCopy:
 // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html:
 //   If __is_pod (type) is true or type is a reference type then
 //   the trait is true, else if type is a cv class or union type
@@ -4562,12 +4552,7 @@ static bool EvaluateUnaryTypeTrait(Sema
   return RD->hasTrivialCopyConstructor() &&
  !RD->hasNonTrivialCopyConstructor();
 return false;
-  }
-  case UTT_HasTrivialMoveAssign: {
-QualType::PrimitiveCopyKind PCK =
-T.isNonTrivialToPrimitiveDestructiveMove();
-if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_VolatileTrivial)
-  return false;
+  case UTT_HasTrivialMoveAssign:
 //  This trait is 

[PATCH] D45093: [AST] Fix -ast-print for _Bool when have diagnostics

2018-04-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 141715.
jdenny added a comment.

Rebased onto a more recent master.


https://reviews.llvm.org/D45093

Files:
  include/clang/AST/ASTContext.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  test/Misc/ast-print-bool.c

Index: test/Misc/ast-print-bool.c
===
--- /dev/null
+++ test/Misc/ast-print-bool.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-CBOOL,CBOOL
+//
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL -DDIAG \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-CBOOL,CBOOL
+//
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_INT \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-INT,CBOOL
+//
+// RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_INT -DDIAG \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-INT,CBOOL
+//
+// RUN: %clang_cc1 -verify -ast-print %s -xc++ \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-BOOL
+//
+// RUN: %clang_cc1 -verify -ast-print %s -xc++ -DDIAG \
+// RUN: | FileCheck %s --check-prefixes=BOOL-AS-BOOL
+
+#if DEF_BOOL_CBOOL
+# define bool _Bool
+#elif DEF_BOOL_INT
+# define bool int
+#endif
+
+// BOOL-AS-CBOOL: _Bool i;
+// BOOL-AS-INT:   int i;
+// BOOL-AS-BOOL:  bool i;
+bool i;
+
+#ifndef __cplusplus
+// CBOOL: _Bool j;
+_Bool j;
+#endif
+
+// Induce a diagnostic (and verify we actually managed to do so), which used to
+// permanently alter the -ast-print printing policy for _Bool.  How bool is
+// defined by the preprocessor is examined only once per compilation, when the
+// diagnostic is emitted, and it used to affect the entirety of -ast-print, so
+// test only one definition of bool per compilation.
+#if DIAG
+void fn() { 1; } // expected-warning {{expression result unused}}
+#else
+// expected-no-diagnostics
+#endif
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -505,7 +505,7 @@
   llvm::raw_svector_ostream OS(TemplateArgsStr);
   Template->printName(OS);
   printTemplateArgumentList(OS, Active->template_arguments(),
-getPrintingPolicy());
+getDiagPrintingPolicy());
   Diags.Report(Active->PointOfInstantiation,
diag::note_default_arg_instantiation_here)
 << OS.str()
@@ -571,7 +571,7 @@
   llvm::raw_svector_ostream OS(TemplateArgsStr);
   FD->printName(OS);
   printTemplateArgumentList(OS, Active->template_arguments(),
-getPrintingPolicy());
+getDiagPrintingPolicy());
   Diags.Report(Active->PointOfInstantiation,
diag::note_default_function_arg_instantiation_here)
 << OS.str()
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -3012,7 +3012,7 @@
   std::string Description;
   {
 llvm::raw_string_ostream Out(Description);
-FailedCond->printPretty(Out, nullptr, getPrintingPolicy());
+FailedCond->printPretty(Out, nullptr, getDiagPrintingPolicy());
   }
   return { FailedCond, Description };
 }
@@ -9821,7 +9821,7 @@
 }
 
 Out << " = ";
-Args[I].print(getPrintingPolicy(), Out);
+Args[I].print(getDiagPrintingPolicy(), Out);
   }
 
   Out << ']';
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -5546,7 +5546,7 @@
 // conversion; use it.
 QualType ConvTy = Conversion->getConversionType().getNonReferenceType();
 std::string TypeStr;
-ConvTy.getAsStringInternal(TypeStr, SemaRef.getPrintingPolicy());
+ConvTy.getAsStringInternal(TypeStr, SemaRef.getDiagPrintingPolicy());
 
 Converter.diagnoseExplicitConv(SemaRef, Loc, T, ConvTy)
 << FixItHint::CreateInsertion(From->getLocStart(),
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -4202,7 +4202,7 @@
   std::string NewQualified = TC.getAsString(SemaRef.getLangOpts());
   std::string OldQualified;
   llvm::raw_string_ostream OldOStream(OldQualified);
-  SS->getScopeRep()->print(OldOStream, SemaRef.getPrintingPolicy());
+  SS->getScopeRep()->print(OldOStream, SemaRef.getDiagPrintingPolicy());
   OldOStream << 

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Sorry for the delayed review; I'm back from vacation now and am picking things 
up again.




Comment at: test/Sema/builtin-dump-struct.c:8
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);

paulsemel wrote:
> aaron.ballman wrote:
> > Can you also add a test for: `int (*badfunc4)(char *, ...);` and `int 
> > (*badfunc5)();`
> Isn't `int (*func)()` is a valid prototype for a printf like function in C ?
> I instead added `int (*func)(void)` to the test cases.
> Isn't int (*func)() is a valid prototype for a printf like function in C ?

No, because it's missing the `const char *` as the mandatory first parameter. 
Do you want that to be allowed and hope the callee has it correct on their 
side, or do you want it to diagnose as not being a valid function?



Comment at: test/Sema/builtin-dump-struct.c:15
+  __builtin_dump_struct(1);// expected-error {{too few arguments 
to function call, expected 2, have 1}}
+  __builtin_dump_struct(1, 2); // expected-error {{passing 'int' to 
parameter of incompatible type 'structure pointer type': type mismatch at 1st 
parameter ('int' vs 'structure pointer type')}}
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to 
parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 
2nd parameter ('int' vs 'int (*)(const char *, ...)')}}

paulsemel wrote:
> aaron.ballman wrote:
> > Hrm, the `'structure pointer type'` in this diagnostic is unfortunate 
> > because it's being quoted as though it were a real type -- you could drop 
> > the single quotes. If you think the resulting diagnostic reads too 
> > strangely, perhaps we will have to go back to a custom diagnostic after all.
> I think it will be better to just put something like `structure pointer`, so 
> that we understand the type we are talking about.
> But this diagnostic seems great, still, what do you think about sticking with 
> it ?
I think it's fine now; if it turns out to be horribly confusing to users, we 
can address it later.



Comment at: test/Sema/builtin-dump-struct.c:17
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to 
parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 
2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(b, ); // expected-error {{passing 'void *' to 
parameter of incompatible type 'structure pointer type': type mismatch at 1st 
parameter ('void *' vs 'structure pointer type')}}
+  __builtin_dump_struct(, badfunc1); // expected-error {{passing 'int 
(*)(const char *)' to parameter of incompatible type 'int (*)(const char *, 
...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int 
(*)(const char *, ...)')}}

paulsemel wrote:
> aaron.ballman wrote:
> > Why ``?
> Yes, we already have a test like this anyway :)
It was more a question of why the ampersand on the second argument -- I think 
that can be dropped and it'll be consistent with the rest of the tests.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D45451: [ItaniumMangle] Undeduced auto type doesn't belong in the substitution table

2018-04-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, majnemer, rjmccall.

Since "Da" and "Dc" (auto and decltype(auto)) are under  in the 
mangling grammer, they shouldn't have a substitution 
(https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression). I 
believe that a deduced AutoType shouldn't be able to reach mangleType(AutoType) 
because it's deduced type would have been canonicalized in mangleType(QualType) 
before, so I removed that branch and added an assert. FWIW, with this patch 
applied Clang and GCC agree on the manglings in the affected file.

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D45451

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp


Index: clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
@@ -52,10 +52,10 @@
   
   template auto foo() { return [](const T&) { return 42; }; }
 };
-//CHECK-LABEL: define linkonce_odr i32 
@_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES5_(%class.anon
+//CHECK-LABEL: define linkonce_odr i32 
@_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES4_(%class.anon
 int run2 = A{}.func()(3.14);
 
-//CHECK-LABEL: define linkonce_odr i32 
@_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES5_(%class.anon
+//CHECK-LABEL: define linkonce_odr i32 
@_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES4_(%class.anon
 int run3 = A{}.func()('a');
 } // end inline_member_function
 
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -2338,7 +2338,8 @@
 return true;
   if (Ty->isBuiltinType())
 return false;
-
+  if (isa(Ty))
+return false;
   return true;
 }
 
@@ -3250,14 +3251,13 @@
 }
 
 void CXXNameMangler::mangleType(const AutoType *T) {
-  QualType D = T->getDeducedType();
-  //  ::= Da  # dependent auto
-  if (D.isNull()) {
-assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
-   "shouldn't need to mangle __auto_type!");
-Out << (T->isDecltypeAuto() ? "Dc" : "Da");
-  } else
-mangleType(D);
+  assert(T->getDeducedType().isNull() &&
+ "Deduced AutoType shouldn't be handled here!");
+  assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
+ "shouldn't need to mangle __auto_type!");
+  //  ::= Da # auto
+  //::= Dc # decltype(auto)
+  Out << (T->isDecltypeAuto() ? "Dc" : "Da");
 }
 
 void CXXNameMangler::mangleType(const DeducedTemplateSpecializationType *T) {


Index: clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
@@ -52,10 +52,10 @@
   
   template auto foo() { return [](const T&) { return 42; }; }
 };
-//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES5_(%class.anon
+//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES4_(%class.anon
 int run2 = A{}.func()(3.14);
 
-//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES5_(%class.anon
+//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES4_(%class.anon
 int run3 = A{}.func()('a');
 } // end inline_member_function
 
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -2338,7 +2338,8 @@
 return true;
   if (Ty->isBuiltinType())
 return false;
-
+  if (isa(Ty))
+return false;
   return true;
 }
 
@@ -3250,14 +3251,13 @@
 }
 
 void CXXNameMangler::mangleType(const AutoType *T) {
-  QualType D = T->getDeducedType();
-  //  ::= Da  # dependent auto
-  if (D.isNull()) {
-assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
-   "shouldn't need to mangle __auto_type!");
-Out << (T->isDecltypeAuto() ? "Dc" : "Da");
-  } else
-mangleType(D);
+  assert(T->getDeducedType().isNull() &&
+ "Deduced AutoType shouldn't be handled here!");
+  assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
+ "shouldn't need to mangle __auto_type!");
+  //  ::= Da # auto
+  //::= Dc # decltype(auto)
+  Out << (T->isDecltypeAuto() ? "Dc" : "Da");
 }
 
 void CXXNameMangler::mangleType(const DeducedTemplateSpecializationType *T) {

[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D45383#1062099, @efriedma wrote:

> Basically, yes, although I was thinking you could be a bit more aggressive.  
> At least, anything marked "t" for custom typechecking is probably not 
> something which should be redeclared.


Ok, thank you very much for your help!  I'll see if I can accomplish soon!


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Basically, yes, although I was thinking you could be a bit more aggressive.  At 
least, anything marked "t" for custom typechecking is probably not something 
which should be redeclared.


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D45421: [X86] Emit native IR for pmuldq/pmuludq builtins.

2018-04-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329605: [X86] Emit native IR for pmuldq/pmuludq builtins. 
(authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45421?vs=141691=141707#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45421

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/avx2-builtins.c
  cfe/trunk/test/CodeGen/avx512f-builtins.c
  cfe/trunk/test/CodeGen/avx512vl-builtins.c
  cfe/trunk/test/CodeGen/sse2-builtins.c
  cfe/trunk/test/CodeGen/sse41-builtins.c

Index: cfe/trunk/test/CodeGen/sse41-builtins.c
===
--- cfe/trunk/test/CodeGen/sse41-builtins.c
+++ cfe/trunk/test/CodeGen/sse41-builtins.c
@@ -312,7 +312,11 @@
 
 __m128i test_mm_mul_epi32(__m128i x, __m128i y) {
   // CHECK-LABEL: test_mm_mul_epi32
-  // CHECK: call <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
+  // CHECK: shl <2 x i64> %{{.*}}, 
+  // CHECK: ashr <2 x i64> %{{.*}}, 
+  // CHECK: shl <2 x i64> %{{.*}}, 
+  // CHECK: ashr <2 x i64> %{{.*}}, 
+  // CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   return _mm_mul_epi32(x, y);
 }
 
Index: cfe/trunk/test/CodeGen/avx2-builtins.c
===
--- cfe/trunk/test/CodeGen/avx2-builtins.c
+++ cfe/trunk/test/CodeGen/avx2-builtins.c
@@ -835,13 +835,19 @@
 
 __m256i test_mm256_mul_epi32(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_mul_epi32
-  // CHECK: call <4 x i64> @llvm.x86.avx2.pmul.dq(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
+  // CHECK: shl <4 x i64> %{{.*}}, 
+  // CHECK: ashr <4 x i64> %{{.*}}, 
+  // CHECK: shl <4 x i64> %{{.*}}, 
+  // CHECK: ashr <4 x i64> %{{.*}}, 
+  // CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   return _mm256_mul_epi32(a, b);
 }
 
 __m256i test_mm256_mul_epu32(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_mul_epu32
-  // CHECK: call <4 x i64> @llvm.x86.avx2.pmulu.dq(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
+  // CHECK: and <4 x i64> %{{.*}}, 
+  // CHECK: and <4 x i64> %{{.*}}, 
+  // CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   return _mm256_mul_epu32(a, b);
 }
 
Index: cfe/trunk/test/CodeGen/avx512vl-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512vl-builtins.c
+++ cfe/trunk/test/CodeGen/avx512vl-builtins.c
@@ -727,60 +727,84 @@
 __m256i test_mm256_mask_mul_epi32 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y) {
   //CHECK-LABEL: @test_mm256_mask_mul_epi32
-  //CHECK: @llvm.x86.avx2.pmul.dq
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_mul_epi32(__W, __M, __X, __Y);
 }
 
 __m256i test_mm256_maskz_mul_epi32 (__mmask8 __M, __m256i __X, __m256i __Y) {
   //CHECK-LABEL: @test_mm256_maskz_mul_epi32
-  //CHECK: @llvm.x86.avx2.pmul.dq
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_maskz_mul_epi32(__M, __X, __Y);
 }
 
 
 __m128i test_mm_mask_mul_epi32 (__m128i __W, __mmask8 __M, __m128i __X,
 __m128i __Y) {
   //CHECK-LABEL: @test_mm_mask_mul_epi32
-  //CHECK: @llvm.x86.sse41.pmuldq
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_mul_epi32(__W, __M, __X, __Y);
 }
 
 __m128i test_mm_maskz_mul_epi32 (__mmask8 __M, __m128i __X, __m128i __Y) {
   //CHECK-LABEL: @test_mm_maskz_mul_epi32
-  //CHECK: @llvm.x86.sse41.pmuldq
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_maskz_mul_epi32(__M, __X, __Y);
 }
 
 __m256i test_mm256_mask_mul_epu32 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y) {
   //CHECK-LABEL: @test_mm256_mask_mul_epu32
-  //CHECK: @llvm.x86.avx2.pmulu.dq
+  //CHECK: and <4 x i64> %{{.*}}, 
+  //CHECK: and <4 x i64> %{{.*}}, 
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_mul_epu32(__W, __M, __X, __Y);
 }
 
 __m256i test_mm256_maskz_mul_epu32 (__mmask8 __M, __m256i __X, __m256i __Y) {
   //CHECK-LABEL: @test_mm256_maskz_mul_epu32
-  //CHECK: @llvm.x86.avx2.pmulu.dq
+  //CHECK: and <4 x i64> 

r329605 - [X86] Emit native IR for pmuldq/pmuludq builtins.

2018-04-09 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr  9 12:17:54 2018
New Revision: 329605

URL: http://llvm.org/viewvc/llvm-project?rev=329605=rev
Log:
[X86] Emit native IR for pmuldq/pmuludq builtins.

I believe all the pieces are now in place in the backend to make this work 
correctly. We can either mask the input to 32 bits for pmuludg or shl/ashr for 
pmuldq and use a regular mul instruction. The backend should combine this to 
PMULUDQ/PMULDQ and then SimplifyDemandedBits will remove the and/shifts.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/avx2-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c
cfe/trunk/test/CodeGen/sse41-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=329605=329604=329605=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Apr  9 12:17:54 2018
@@ -8264,6 +8264,32 @@ static Value *EmitX86MinMax(CodeGenFunct
   return EmitX86Select(CGF, Ops[3], Res, Ops[2]);
 }
 
+static Value *EmitX86Muldq(CodeGenFunction , bool IsSigned,
+   ArrayRef Ops) {
+  llvm::Type *Ty = Ops[0]->getType();
+  // Arguments have a vXi32 type so cast to vXi64.
+  Ty = llvm::VectorType::get(CGF.Int64Ty,
+ Ty->getPrimitiveSizeInBits() / 64);
+  Value *LHS = CGF.Builder.CreateBitCast(Ops[0], Ty);
+  Value *RHS = CGF.Builder.CreateBitCast(Ops[1], Ty);
+
+  if (IsSigned) {
+// Shift left then arithmetic shift right.
+Constant *ShiftAmt = ConstantInt::get(Ty, 32);
+LHS = CGF.Builder.CreateShl(LHS, ShiftAmt);
+LHS = CGF.Builder.CreateAShr(LHS, ShiftAmt);
+RHS = CGF.Builder.CreateShl(RHS, ShiftAmt);
+RHS = CGF.Builder.CreateAShr(RHS, ShiftAmt);
+  } else {
+// Clear the upper bits.
+Constant *Mask = ConstantInt::get(Ty, 0x);
+LHS = CGF.Builder.CreateAnd(LHS, Mask);
+RHS = CGF.Builder.CreateAnd(RHS, Mask);
+  }
+
+  return CGF.Builder.CreateMul(LHS, RHS);
+}
+
 static Value *EmitX86SExtMask(CodeGenFunction , Value *Op, 
   llvm::Type *DstTy) {
   unsigned NumberOfElements = DstTy->getVectorNumElements();
@@ -8968,6 +8994,16 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_pminuq512_mask:
 return EmitX86MinMax(*this, ICmpInst::ICMP_ULT, Ops);
 
+  case X86::BI__builtin_ia32_pmuludq128:
+  case X86::BI__builtin_ia32_pmuludq256:
+  case X86::BI__builtin_ia32_pmuludq512:
+return EmitX86Muldq(*this, /*IsSigned*/false, Ops);
+
+  case X86::BI__builtin_ia32_pmuldq128:
+  case X86::BI__builtin_ia32_pmuldq256:
+  case X86::BI__builtin_ia32_pmuldq512:
+return EmitX86Muldq(*this, /*IsSigned*/true, Ops);
+
   // 3DNow!
   case X86::BI__builtin_ia32_pswapdsf:
   case X86::BI__builtin_ia32_pswapdsi: {

Modified: cfe/trunk/test/CodeGen/avx2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=329605=329604=329605=diff
==
--- cfe/trunk/test/CodeGen/avx2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx2-builtins.c Mon Apr  9 12:17:54 2018
@@ -835,13 +835,19 @@ __m256i test_mm256_mpsadbw_epu8(__m256i
 
 __m256i test_mm256_mul_epi32(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_mul_epi32
-  // CHECK: call <4 x i64> @llvm.x86.avx2.pmul.dq(<8 x i32> %{{.*}}, <8 x i32> 
%{{.*}})
+  // CHECK: shl <4 x i64> %{{.*}}, 
+  // CHECK: ashr <4 x i64> %{{.*}}, 
+  // CHECK: shl <4 x i64> %{{.*}}, 
+  // CHECK: ashr <4 x i64> %{{.*}}, 
+  // CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   return _mm256_mul_epi32(a, b);
 }
 
 __m256i test_mm256_mul_epu32(__m256i a, __m256i b) {
   // CHECK-LABEL: test_mm256_mul_epu32
-  // CHECK: call <4 x i64> @llvm.x86.avx2.pmulu.dq(<8 x i32> %{{.*}}, <8 x 
i32> %{{.*}})
+  // CHECK: and <4 x i64> %{{.*}}, 
+  // CHECK: and <4 x i64> %{{.*}}, 
+  // CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   return _mm256_mul_epu32(a, b);
 }
 

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=329605=329604=329605=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon Apr  9 12:17:54 2018
@@ -1874,13 +1874,21 @@ __m512i test_mm512_add_epi64(__m512i __A
 
 __m512i test_mm512_mul_epi32(__m512i __A, __m512i __B) {
   //CHECK-LABEL: @test_mm512_mul_epi32
-  //CHECK: @llvm.x86.avx512.pmul.dq.512
+  //CHECK: shl <8 x i64> %{{.*}}, 
+  //CHECK: ashr <8 x i64> %{{.*}}, 
+  //CHECK: shl <8 x i64> %{{.*}}, 
+  //CHECK: ashr <8 x i64> %{{.*}}, 
+  //CHECK: mul 

[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D45383#1062078, @efriedma wrote:

> > I believe it is permissible to implement va_copy and va_end as a function, 
> > isn't it?
>
> I guess you could, in theory, but LLVM doesn't support any targets which do 
> that.


Ok, fair enough.  So is your guidance to identify these 7 builtins (4 builtins 
+ 3 lib builtins) and disallow redeclaring? Or am I missing a more subtle 
solution here?


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> I believe it is permissible to implement va_copy and va_end as a function, 
> isn't it?

I guess you could, in theory, but LLVM doesn't support any targets which do 
that.


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-09 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT updated this revision to Diff 141701.
DHowett-MSFT edited the summary of this revision.
DHowett-MSFT added a comment.

I've fixed the test to check the LLVM IR; I chose to use `CHECK-SAME` and use 
indentation to clarify what was going on. We're now checking that an empty 
protocol is emitted in full, and that all of its members match our expectations.


Repository:
  rC Clang

https://reviews.llvm.org/D45305

Files:
  lib/CodeGen/CGObjCGNU.cpp
  test/CodeGenObjC/gnu-empty-protocol-v3.m


Index: test/CodeGenObjC/gnu-empty-protocol-v3.m
===
--- /dev/null
+++ test/CodeGenObjC/gnu-empty-protocol-v3.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 
-emit-llvm -o - %s | FileCheck %s
+
+@protocol X;
+
+__attribute__((objc_root_class))
+@interface Z 
+@end
+
+@implementation Z
+@end
+
+// CHECK:  @.objc_protocol_list = internal global { i8*, i32, [0 x i8*] } 
zeroinitializer, align 4
+// CHECK:  @.objc_method_list = internal global { i32, [0 x { i8*, i8* }] 
} zeroinitializer, align 4
+// CHECK:  @.objc_protocol_name = private unnamed_addr constant [2 x i8] 
c"X\00", align 1
+// CHECK:  @.objc_protocol = internal global { i8*, i8*, { i8*, i32, [0 x 
i8*] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 
x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, i8*, i8* } {
+// CHECK-SAME: i8* inttoptr (i32 3 to i8*),
+// CHECK-SAME: i8* getelementptr inbounds ([2 x i8], [2 x i8]* 
@.objc_protocol_name, i32 0, i32 0),
+// CHECK-SAME: { i8*, i32, [0 x i8*] }* @.objc_protocol_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: i8* null,
+// CHECK-SAME: i8* null
+// CHECK-SAME: }, align 4
Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -1813,11 +1813,13 @@
   llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
 
   Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
-  Elements.add(ProtocolList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
+  Elements.add(ProtocolList); /* .protocol_list */
+  Elements.add(MethodList);   /* .instance_methods */
+  Elements.add(MethodList);   /* .class_methods */
+  Elements.add(MethodList);   /* .optional_instance_methods */
+  Elements.add(MethodList);   /* .optional_class_methods */
+  Elements.add(NULLPtr);  /* .properties */
+  Elements.add(NULLPtr);  /* .optional_properties */
   return Elements.finishAndCreateGlobal(".objc_protocol",
 CGM.getPointerAlign());
 }


Index: test/CodeGenObjC/gnu-empty-protocol-v3.m
===
--- /dev/null
+++ test/CodeGenObjC/gnu-empty-protocol-v3.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 -emit-llvm -o - %s | FileCheck %s
+
+@protocol X;
+
+__attribute__((objc_root_class))
+@interface Z 
+@end
+
+@implementation Z
+@end
+
+// CHECK:  @.objc_protocol_list = internal global { i8*, i32, [0 x i8*] } zeroinitializer, align 4
+// CHECK:  @.objc_method_list = internal global { i32, [0 x { i8*, i8* }] } zeroinitializer, align 4
+// CHECK:  @.objc_protocol_name = private unnamed_addr constant [2 x i8] c"X\00", align 1
+// CHECK:  @.objc_protocol = internal global { i8*, i8*, { i8*, i32, [0 x i8*] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, i8*, i8* } {
+// CHECK-SAME: i8* inttoptr (i32 3 to i8*),
+// CHECK-SAME: i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.objc_protocol_name, i32 0, i32 0),
+// CHECK-SAME: { i8*, i32, [0 x i8*] }* @.objc_protocol_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: i8* null,
+// CHECK-SAME: i8* null
+// CHECK-SAME: }, align 4
Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -1813,11 +1813,13 @@
   llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
 
   Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
-  Elements.add(ProtocolList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  

[PATCH] D45449: [CUDA] Document recent changes

2018-04-09 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: tra, jlebar, rsmith.
Herald added a subscriber: cfe-commits.
Hahnfeld added a dependency: D42922: [CUDA] Register relocatable GPU binaries.

- Finding installations via ptxas binary
- Relocatable device code


Repository:
  rC Clang

https://reviews.llvm.org/D45449

Files:
  docs/ReleaseNotes.rst
  include/clang/Driver/Options.td


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -569,7 +569,7 @@
 def fcuda_approx_transcendentals : Flag<["-"], "fcuda-approx-transcendentals">,
   Flags<[CC1Option]>, HelpText<"Use approximate transcendental functions">;
 def fno_cuda_approx_transcendentals : Flag<["-"], 
"fno-cuda-approx-transcendentals">;
-def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option, HelpHidden]>,
+def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option]>,
   HelpText<"Generate relocatable device code, also known as separate 
compilation mode.">;
 def fno_cuda_rdc : Flag<["-"], "fno-cuda-rdc">;
 def dA : Flag<["-"], "dA">, Group;
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -163,6 +163,18 @@
 
 - ...
 
+CUDA Support in Clang
+-
+
+- Clang will now try to locate the CUDA installation next to :program:`ptxas`
+  in the `PATH` environment variable. This behavior can be turned off by 
passing
+  the new flag `--cuda-path-ignore-env`.
+
+- Clang now supports generating object files with relocatable device code. This
+  feature needs to be enabled with `-fcuda-rdc` and my result in performance
+  penalties compared to whole program compilation. Please note that NVIDIA's
+  :program:`nvcc` must be used for linking.
+
 Internal API Changes
 
 


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -569,7 +569,7 @@
 def fcuda_approx_transcendentals : Flag<["-"], "fcuda-approx-transcendentals">,
   Flags<[CC1Option]>, HelpText<"Use approximate transcendental functions">;
 def fno_cuda_approx_transcendentals : Flag<["-"], "fno-cuda-approx-transcendentals">;
-def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option, HelpHidden]>,
+def fcuda_rdc : Flag<["-"], "fcuda-rdc">, Flags<[CC1Option]>,
   HelpText<"Generate relocatable device code, also known as separate compilation mode.">;
 def fno_cuda_rdc : Flag<["-"], "fno-cuda-rdc">;
 def dA : Flag<["-"], "dA">, Group;
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -163,6 +163,18 @@
 
 - ...
 
+CUDA Support in Clang
+-
+
+- Clang will now try to locate the CUDA installation next to :program:`ptxas`
+  in the `PATH` environment variable. This behavior can be turned off by passing
+  the new flag `--cuda-path-ignore-env`.
+
+- Clang now supports generating object files with relocatable device code. This
+  feature needs to be enabled with `-fcuda-rdc` and my result in performance
+  penalties compared to whole program compilation. Please note that NVIDIA's
+  :program:`nvcc` must be used for linking.
+
 Internal API Changes
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42922: [CUDA] Register relocatable GPU binaries

2018-04-09 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 141698.
Hahnfeld added a comment.

Correct test check prefix.


https://reviews.llvm.org/D42922

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

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,7 +1,10 @@
 // RUN: echo "GPU binary would be here" > %t
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s --check-prefixes=CHECK,DEFAULT
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
 // RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-rdc -fcuda-include-gpubinary %t -o - \
+// RUN:   | FileCheck %s --check-prefixes=CHECK,RDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
@@ -46,16 +49,24 @@
 // CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
 // CHECK: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
-// CHECK-SAME: section ".nv_fatbin", align 8
+// DEFAULT-SAME: section ".nv_fatbin", align 8
+// RDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
 // CHECK: @__cuda_fatbin_wrapper = internal constant { i32, i32, i8*, i8* } 
 // CHECK-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
 // CHECK-SAME: section ".nvFatBinSegment"
 // * variable to save GPU binary handle after initialization
-// CHECK: @__cuda_gpubin_handle = internal global i8** null
-// * Make sure our constructor/destructor was added to global ctor/dtor list.
+// DEFAULT: @__cuda_gpubin_handle = internal global i8** null
+// * constant unnamed string with NVModuleID
+// RDC: [[MODULE_ID_GLOBAL:@.*]] = private unnamed_addr constant
+// RDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32
+// * Make sure our constructor was added to global ctor list.
 // CHECK: @llvm.global_ctors = appending global {{.*}}@__cuda_module_ctor
-// CHECK: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor
+// * In separate mode we also register a destructor.
+// DEFAULT: @llvm.global_dtors = appending global {{.*}}@__cuda_module_dtor
+// * Alias to global symbol containing the NVModuleID.
+// RDC: @__fatbinwrap[[MODULE_ID]] = alias { i32, i32, i8*, i8* }
+// RDC-SAME: { i32, i32, i8*, i8* }* @__cuda_fatbin_wrapper
 
 // Test that we build the correct number of calls to cudaSetupArgument followed
 // by a call to cudaLaunch.
@@ -83,19 +94,25 @@
 // CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
 // CHECK: ret void
 
-// Test that we've built constructor..
+// Test that we've built a constructor.
 // CHECK: define internal void @__cuda_module_ctor
-//   .. that calls __cudaRegisterFatBinary(&__cuda_fatbin_wrapper)
-// CHECK: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
+
+// In separate mode it calls __cudaRegisterFatBinary(&__cuda_fatbin_wrapper)
+// DEFAULT: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
 //   .. stores return value in __cuda_gpubin_handle
-// CHECK-NEXT: store{{.*}}__cuda_gpubin_handle
+// DEFAULT-NEXT: store{{.*}}__cuda_gpubin_handle
 //   .. and then calls __cuda_register_globals
-// CHECK-NEXT: call void @__cuda_register_globals
+// DEFAULT-NEXT: call void @__cuda_register_globals
+
+// With relocatable device code we call __cudaRegisterLinkedBinary%NVModuleID%
+// RDC: call{{.*}}__cudaRegisterLinkedBinary[[MODULE_ID]](
+// RDC-SAME: __cuda_register_globals, {{.*}}__cuda_fatbin_wrapper
+// RDC-SAME: [[MODULE_ID_GLOBAL]]
 
 // Test that we've created destructor.
-// CHECK: define internal void @__cuda_module_dtor
-// CHECK: load{{.*}}__cuda_gpubin_handle
-// CHECK-NEXT: call void @__cudaUnregisterFatBinary
+// DEFAULT: define internal void @__cuda_module_dtor
+// DEFAULT: load{{.*}}__cuda_gpubin_handle
+// DEFAULT-NEXT: call void @__cudaUnregisterFatBinary
 
 // There should be no __cuda_register_globals if we have no
 // device-side globals, but we still need to register GPU binary.
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -15,12 +15,13 @@
 #include "CGCUDARuntime.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
-#include "clang/CodeGen/ConstantInitBuilder.h"
 #include "clang/AST/Decl.h"
+#include "clang/CodeGen/ConstantInitBuilder.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
+#include "llvm/Support/Format.h"
 
 using namespace clang;
 using 

[PATCH] D45421: [X86] Emit native IR for pmuldq/pmuludq builtins.

2018-04-09 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM (assuming the backend gets this right in all cases and we have tests for 
that).


https://reviews.llvm.org/D45421



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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D45383#1062014, @efriedma wrote:

> > I don't see redeclaring the latter 3 as being disallowed,
>
> It is in fact disallowed by the standard, in the section describing 
> va_start/va_arg/va_end/va_copy: "If a macro definition is suppressed in order 
> to access an actual function, or a program defines an external identifier 
> with the same name, the behavior is undefined."


The C spec seems to overload the usage of 'macro' a few times there.  I believe 
it is permissible to implement va_copy and va_end as a function, isn't it?  The 
first sentence of that section says va_start/va_arg must be implemented as 
"macros, not functions", but va_copy/va_end can be identifiers with external 
linkage.


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[libcxxabi] r329601 - [demangler] Support for fold expressions.

2018-04-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Apr  9 11:33:01 2018
New Revision: 329601

URL: http://llvm.org/viewvc/llvm-project?rev=329601=rev
Log:
[demangler] Support for fold expressions.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=329601=329600=329601=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Mon Apr  9 11:33:01 2018
@@ -10,7 +10,6 @@
 // FIXME: (possibly) incomplete list of features that clang mangles that this
 // file does not yet support:
 //   - C++ modules TS
-//   - All C++14 and C++17 features
 
 #define _LIBCPP_NO_EXCEPTIONS
 
@@ -1695,6 +1694,55 @@ public:
   }
 };
 
+struct FoldExpr : Expr {
+  Node *Pack, *Init;
+  StringView OperatorName;
+  bool IsLeftFold;
+
+  FoldExpr(bool IsLeftFold_, StringView OperatorName_, Node *Pack_, Node 
*Init_)
+  : Pack(Pack_), Init(Init_), OperatorName(OperatorName_),
+IsLeftFold(IsLeftFold_) {}
+
+  void printLeft(OutputStream ) const override {
+auto PrintPack = [&] {
+  S += '(';
+  ParameterPackExpansion(Pack).print(S);
+  S += ')';
+};
+
+S += '(';
+
+if (IsLeftFold) {
+  // init op ... op pack
+  if (Init != nullptr) {
+Init->print(S);
+S += ' ';
+S += OperatorName;
+S += ' ';
+  }
+  // ... op pack
+  S += "... ";
+  S += OperatorName;
+  S += ' ';
+  PrintPack();
+} else { // !IsLeftFold
+  // pack op ...
+  PrintPack();
+  S += ' ';
+  S += OperatorName;
+  S += " ...";
+  // pack op ... op init
+  if (Init != nullptr) {
+S += ' ';
+S += OperatorName;
+S += ' ';
+Init->print(S);
+  }
+}
+S += ')';
+  }
+};
+
 class ThrowExpr : public Expr {
   const Node *Op;
 
@@ -2063,6 +2111,7 @@ struct Db {
   Node *parseNewExpr();
   Node *parseConversionExpr();
   Node *parseBracedExpr();
+  Node *parseFoldExpr();
 
   /// Parse the  production.
   Node *parseType();
@@ -3807,6 +3856,76 @@ Node *Db::parseBracedExpr() {
   return parseExpr();
 }
 
+// (not yet in the spec)
+//  ::= fL   
+// ::= fR   
+// ::= fl  
+// ::= fr  
+Node *Db::parseFoldExpr() {
+  if (!consumeIf('f'))
+return nullptr;
+
+  char FoldKind = look();
+  bool IsLeftFold, HasInitializer;
+  HasInitializer = FoldKind == 'L' || FoldKind == 'R';
+  if (FoldKind == 'l' || FoldKind == 'L')
+IsLeftFold = true;
+  else if (FoldKind == 'r' || FoldKind == 'R')
+IsLeftFold = false;
+  else
+return nullptr;
+  ++First;
+
+  // FIXME: This map is duplicated in parseOperatorName and parseExpr.
+  StringView OperatorName;
+  if  (consumeIf("aa")) OperatorName = "&&";
+  else if (consumeIf("an")) OperatorName = "&";
+  else if (consumeIf("aN")) OperatorName = "&=";
+  else if (consumeIf("aS")) OperatorName = "=";
+  else if (consumeIf("cm")) OperatorName = ",";
+  else if (consumeIf("ds")) OperatorName = ".*";
+  else if (consumeIf("dv")) OperatorName = "/";
+  else if (consumeIf("dV")) OperatorName = "/=";
+  else if (consumeIf("eo")) OperatorName = "^";
+  else if (consumeIf("eO")) OperatorName = "^=";
+  else if (consumeIf("eq")) OperatorName = "==";
+  else if (consumeIf("ge")) OperatorName = ">=";
+  else if (consumeIf("gt")) OperatorName = ">";
+  else if (consumeIf("le")) OperatorName = "<=";
+  else if (consumeIf("ls")) OperatorName = "<<";
+  else if (consumeIf("lS")) OperatorName = "<<=";
+  else if (consumeIf("lt")) OperatorName = "<";
+  else if (consumeIf("mi")) OperatorName = "-";
+  else if (consumeIf("mI")) OperatorName = "-=";
+  else if (consumeIf("ml")) OperatorName = "*";
+  else if (consumeIf("mL")) OperatorName = "*=";
+  else if (consumeIf("ne")) OperatorName = "!=";
+  else if (consumeIf("oo")) OperatorName = "||";
+  else if (consumeIf("or")) OperatorName = "|";
+  else if (consumeIf("oR")) OperatorName = "|=";
+  else if (consumeIf("pl")) OperatorName = "+";
+  else if (consumeIf("pL")) OperatorName = "+=";
+  else if (consumeIf("rm")) OperatorName = "%";
+  else if (consumeIf("rM")) OperatorName = "%=";
+  else if (consumeIf("rs")) OperatorName = ">>";
+  else if (consumeIf("rS")) OperatorName = ">>=";
+  else return nullptr;
+
+  Node *Pack = parseExpr(), *Init = nullptr;
+  if (Pack == nullptr)
+return nullptr;
+  if (HasInitializer) {
+Init = parseExpr();
+if (Init == nullptr)
+  return nullptr;
+  }
+
+  if (IsLeftFold && Init)
+std::swap(Pack, Init);
+
+  return make(IsLeftFold, OperatorName, Pack, Init);
+}
+
 //  ::=  
 //  ::=   
 //  ::=

@@ -3861,8 +3980,12 @@ Node *Db::parseExpr() {
 return parseExprPrimary();
   case 'T':
 return parseTemplateParam();
-  case 'f':
-return 

[libcxxabi] r329600 - [demangler] Support for .

2018-04-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Apr  9 11:32:25 2018
New Revision: 329600

URL: http://llvm.org/viewvc/llvm-project?rev=329600=rev
Log:
[demangler] Support for .

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=329600=329599=329600=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Mon Apr  9 11:32:25 2018
@@ -2639,6 +2639,8 @@ Node *Db::parseCtorDtorName(Node *
 //  ::=  
 //  extension ::= L
 //
+//  :=  [] M
+//
 //  ::=  
 //   ::= 
 //   ::= 
@@ -2669,6 +2671,13 @@ Node *Db::parseNestedName(NameState *Sta
   while (!consumeIf('E')) {
 consumeIf('L'); // extension
 
+//  :=  [] M
+if (consumeIf('M')) {
+  if (SoFar == nullptr)
+return nullptr;
+  continue;
+}
+
 //  ::= 
 if (look() == 'T') {
   Node *TP = parseTemplateParam();

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=329600=329599=329600=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Mon Apr  9 11:32:25 2018
@@ -29740,6 +29740,9 @@ const char* cases[][2] =
 {"_ZN1Scv7MuncherIJDpPT_EEIJFivEA_iEEEv", "S::operator Muncher()"},
 
 {"_Z2f8IiJ8identityIiES0_IfEEEvRAsPiDpT0_T_DpNS3_4typeEE_i", "void f8(int (&) [sizeof... (int, identity, 
identity, int, identity::type, identity::type)])"},
+
+{"_ZNK13StaticMembersIfE1xMUlvE_clEv", 
"StaticMembers::x::'lambda'()::operator()() const"},
+{"_ZNK10inline_varMUlvE_clEv", "inline_var::'lambda'()::operator()() 
const"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);


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


[libcxxabi] r329599 - [demangler] Support for partially substituted sizeof....

2018-04-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Apr  9 11:31:50 2018
New Revision: 329599

URL: http://llvm.org/viewvc/llvm-project?rev=329599=rev
Log:
[demangler] Support for partially substituted sizeof

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=329599=329598=329599=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Mon Apr  9 11:31:50 2018
@@ -161,6 +161,7 @@ public:
 class Node {
 public:
   enum Kind : unsigned char {
+KNodeArrayNode,
 KDotSuffix,
 KVendorExtQualType,
 KQualType,
@@ -323,6 +324,14 @@ public:
   }
 };
 
+struct NodeArrayNode : Node {
+  NodeArray Array;
+  NodeArrayNode(NodeArray Array_) : Node(KNodeArrayNode), Array(Array_) {}
+  void printLeft(OutputStream ) const override {
+Array.printWithComma(S);
+  }
+};
+
 class DotSuffix final : public Node {
   const Node *Prefix;
   const StringView Suffix;
@@ -3821,6 +3830,7 @@ Node *Db::parseBracedExpr() {
 //  ::= ds   # 
expr.*expr
 //  ::= sZ   # 
size of a parameter pack
 //  ::= sZ   # 
size of a function parameter pack
+//  ::= sP * E # 
sizeof...(T), size of a captured template parameter pack from an alias template
 //  ::= sp   # 
pack expansion
 //  ::= tw   # 
throw expression
 //  ::= tr   # 
throw with no operand (rethrow)
@@ -4221,9 +4231,22 @@ Node *Db::parseExpr() {
 Node *FP = parseFunctionParam();
 if (FP == nullptr)
   return nullptr;
-return make("sizeof...", FP, ")");
+return make("sizeof... (", FP, ")");
   }
   return nullptr;
+case 'P': {
+  First += 2;
+  size_t ArgsBegin = Names.size();
+  while (!consumeIf('E')) {
+Node *Arg = parseTemplateArg();
+if (Arg == nullptr)
+  return nullptr;
+Names.push_back(Arg);
+  }
+  return make(
+  "sizeof... (", make(popTrailingNodeArray(ArgsBegin)),
+  ")");
+}
 }
 return nullptr;
   case 't':

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=329599=329598=329599=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Mon Apr  9 11:31:50 2018
@@ -29738,6 +29738,8 @@ const char* cases[][2] =
 {"_ZN5OuterI4MarpEcvT_I4MerpEEv", "Outer::operator Merp()"},
 {"_ZZN5OuterI4MarpEcv7MuncherIJT_T0_DpT1_EEI4MerpS0_JicfEEEvEN1ScvS9_Ev", 
"Outer::operator Muncher()::S::operator Merp()"},
 {"_ZN1Scv7MuncherIJDpPT_EEIJFivEA_iEEEv", "S::operator Muncher()"},
+
+{"_Z2f8IiJ8identityIiES0_IfEEEvRAsPiDpT0_T_DpNS3_4typeEE_i", "void f8(int (&) [sizeof... (int, identity, 
identity, int, identity::type, identity::type)])"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);


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


[PATCH] D45383: Strip reference from a va_list object in C when merging parameter types.

2018-04-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> I don't see redeclaring the latter 3 as being disallowed,

It is in fact disallowed by the standard, in the section describing 
va_start/va_arg/va_end/va_copy: "If a macro definition is suppressed in order 
to access an actual function, or a program defines an external identifier with 
the same name, the behavior is undefined."


Repository:
  rC Clang

https://reviews.llvm.org/D45383



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


[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Right, sorry. LGTM, but maybe Artem has something to add as well.
I don't have any suggestions, and trying to modifying lifetimes of expressions 
in environment for the sake of a GCC extensions seems suboptimal as well.


Repository:
  rC Clang

https://reviews.llvm.org/D45416



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


[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-09 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:3082
+if (X.isUnknown()) {
+  // The value being casted to rvalue can be garbage-collected after
+  // the cast is modeled. Try to recover the memory region being casted

george.karpenkov wrote:
> From my understanding, the code inside the if-block is not tested below
> 
It is tested: without this code, "TRUE" will be printed. The reason is that the 
lvalue of 'global' is removed from Environment after the cast happens so `X` 
becomes Unknown.  But the way of retrieving the value is definitely not the 
best so if you have any suggestions on improvement - they are welcome.


Repository:
  rC Clang

https://reviews.llvm.org/D45416



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


[PATCH] D44921: [PowerPC] Option for secure plt mode

2018-04-09 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a subscriber: chmeee.
nemanjai added a comment.

In https://reviews.llvm.org/D44921#1056672, @spetrovic wrote:

> -mbss-plt is currently default in LLVM, once secure plt support is finished 
> we can set secure plt as default in LLVM, but not for now.


I was thinking in case the override is needed to override something specified 
in make files, etc. of some build systems. In any case, this all looks fine to 
me. Perhaps @jhibbits/@chmeee or @joerg should give the final ACK for this. If 
not, I'll approve it next time you ping the patch.


https://reviews.llvm.org/D44921



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


[PATCH] D38479: Make -mgeneral-regs-only more like GCC's

2018-04-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv updated this revision to Diff 141693.
george.burgess.iv added a comment.

Rebased


https://reviews.llvm.org/D38479

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Sema/Sema.h
  lib/Driver/ToolChains/Arch/AArch64.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CodeGen/aarch64-mgeneral_regs_only.c
  test/Driver/aarch64-mgeneral_regs_only.c
  test/Sema/aarch64-mgeneral_regs_only.c
  test/SemaCXX/aarch64-mgeneral_regs_only.cpp

Index: test/SemaCXX/aarch64-mgeneral_regs_only.cpp
===
--- /dev/null
+++ test/SemaCXX/aarch64-mgeneral_regs_only.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -triple aarch64-linux-eabi -std=c++11 -general-regs-only %s -verify -DBANNED=float -Wno-unused-value
+// RUN: %clang_cc1 -triple aarch64-linux-eabi -std=c++11 -general-regs-only %s -verify -DBANNED=int '-DVECATTR=__attribute__((ext_vector_type(2)))' -Wno-unused-value
+// RUN: %clang_cc1 -triple aarch64-linux-eabi -std=c++11 -general-regs-only %s -verify -DBANNED=FloatTypedef -Wno-unused-value
+
+using FloatTypedef = float;
+
+#ifndef VECATTR
+#define VECATTR
+#define BannedToInt(x) (x)
+#else
+#define BannedToInt(x) ((x)[0])
+#endif
+
+typedef BANNED BannedTy VECATTR;
+
+namespace default_args {
+int foo(BannedTy = 0); // expected-error 2{{use of floating-point or vector values is disabled}}
+int bar(int = 1.0);
+
+void baz(int a = foo()); // expected-note{{from use of default argument here}}
+void bazz(int a = bar());
+
+void test() {
+  foo(); // expected-note{{from use of default argument here}}
+  bar();
+  baz(); // expected-note{{from use of default argument here}}
+  baz(4);
+  bazz();
+}
+}
+
+namespace conversions {
+struct ConvertToFloat { explicit operator BannedTy(); };
+struct ConvertToFloatImplicit { /* implicit */ operator BannedTy(); };
+struct ConvertFromFloat { ConvertFromFloat(BannedTy); };
+
+void takeFloat(BannedTy);
+void takeConvertFromFloat(ConvertFromFloat);
+void takeConvertFromFloatRef(const ConvertFromFloat &);
+
+void test() {
+  BannedTy(ConvertToFloat());
+
+  takeFloat(ConvertToFloatImplicit{}); // expected-error{{use of floating-point or vector values is disabled}}
+
+  ConvertFromFloat(0); // expected-error{{use of floating-point or vector values is disabled}}
+  ConvertFromFloat(ConvertToFloatImplicit{}); // expected-error{{use of floating-point or vector values is disabled}}
+
+  ConvertFromFloat{0}; // expected-error{{use of floating-point or vector values is disabled}}
+  ConvertFromFloat{ConvertToFloatImplicit{}}; // expected-error{{use of floating-point or vector values is disabled}}
+
+  takeConvertFromFloat(0); // expected-error{{use of floating-point or vector values is disabled}}
+  takeConvertFromFloatRef(0); // expected-error{{use of floating-point or vector values is disabled}}
+
+  takeConvertFromFloat(ConvertFromFloat(0)); // expected-error{{use of floating-point or vector values is disabled}}
+  takeConvertFromFloatRef(ConvertFromFloat(0)); // expected-error{{use of floating-point or vector values is disabled}}
+}
+
+
+void takeImplicitFloat(BannedTy = ConvertToFloatImplicit()); // expected-error{{use of floating-point or vector values is disabled}}
+void test2() {
+  takeImplicitFloat(); // expected-note{{from use of default argument here}}
+}
+}
+
+namespace refs {
+  struct BannedRef {
+const BannedTy 
+BannedRef(const BannedTy ): f(f) {}
+  };
+
+  BannedTy ();
+  BannedTy getBannedVal();
+
+  void foo() {
+BannedTy  = getBanned();
+BannedTy b = getBanned(); // expected-error{{use of floating-point or vector values is disabled}}
+const BannedTy  = getBanned();
+const BannedTy  = getBannedVal(); // expected-error{{use of floating-point or vector values is disabled}}
+
+const int  = 1.0;
+const int  = BannedToInt(getBannedVal()); // expected-error{{use of floating-point or vector values is disabled}}
+
+BannedRef{getBanned()};
+BannedRef{getBannedVal()}; // expected-error{{use of floating-point or vector values is disabled}}
+  }
+}
+
+namespace class_init {
+  struct Foo {
+float f = 1.0; // expected-error{{use of floating-point or vector values is disabled}}
+int i = 1.0;
+float j;
+
+Foo():
+  j(1) // expected-error{{use of floating-point or vector values is disabled}}
+{}
+  };
+}
+
+namespace copy_move_assign {
+  struct Foo { float f; }; // expected-error 2{{use of floating-point or vector values is disabled}}
+
+  void copyFoo(Foo ) {
+Foo a = f; // expected-error{{use of floating-point or vector values is disabled}}
+Foo b(static_cast(f)); // expected-error{{use of floating-point or vector values is disabled}}
+f = a; // expected-note{{in implicit copy assignment operator}}
+f = static_cast(b); // 

[PATCH] D38479: Make -mgeneral-regs-only more like GCC's

2018-04-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Hi! It fell off my radar, but I'm happy to put it back on my queue. :)

There's still a few aarch64-specific backend bits I need to fix before this 
patch should go in.


https://reviews.llvm.org/D38479



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


[PATCH] D45421: [X86] Emit native IR for pmuldq/pmuludq builtins.

2018-04-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 141691.
craig.topper added a comment.

Use shifts or and to match what InstCombine will do. This sidesteps the illegal 
type question.


https://reviews.llvm.org/D45421

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/sse2-builtins.c
  test/CodeGen/sse41-builtins.c

Index: test/CodeGen/sse41-builtins.c
===
--- test/CodeGen/sse41-builtins.c
+++ test/CodeGen/sse41-builtins.c
@@ -312,7 +312,11 @@
 
 __m128i test_mm_mul_epi32(__m128i x, __m128i y) {
   // CHECK-LABEL: test_mm_mul_epi32
-  // CHECK: call <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
+  // CHECK: shl <2 x i64> %{{.*}}, 
+  // CHECK: ashr <2 x i64> %{{.*}}, 
+  // CHECK: shl <2 x i64> %{{.*}}, 
+  // CHECK: ashr <2 x i64> %{{.*}}, 
+  // CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   return _mm_mul_epi32(x, y);
 }
 
Index: test/CodeGen/sse2-builtins.c
===
--- test/CodeGen/sse2-builtins.c
+++ test/CodeGen/sse2-builtins.c
@@ -816,7 +816,9 @@
 
 __m128i test_mm_mul_epu32(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_mul_epu32
-  // CHECK: call <2 x i64> @llvm.x86.sse2.pmulu.dq(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
+  // CHECK: and <2 x i64> %{{.*}}, 
+  // CHECK: and <2 x i64> %{{.*}}, 
+  // CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   return _mm_mul_epu32(A, B);
 }
 
Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -727,60 +727,84 @@
 __m256i test_mm256_mask_mul_epi32 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y) {
   //CHECK-LABEL: @test_mm256_mask_mul_epi32
-  //CHECK: @llvm.x86.avx2.pmul.dq
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_mul_epi32(__W, __M, __X, __Y);
 }
 
 __m256i test_mm256_maskz_mul_epi32 (__mmask8 __M, __m256i __X, __m256i __Y) {
   //CHECK-LABEL: @test_mm256_maskz_mul_epi32
-  //CHECK: @llvm.x86.avx2.pmul.dq
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: shl <4 x i64> %{{.*}}, 
+  //CHECK: ashr <4 x i64> %{{.*}}, 
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_maskz_mul_epi32(__M, __X, __Y);
 }
 
 
 __m128i test_mm_mask_mul_epi32 (__m128i __W, __mmask8 __M, __m128i __X,
 __m128i __Y) {
   //CHECK-LABEL: @test_mm_mask_mul_epi32
-  //CHECK: @llvm.x86.sse41.pmuldq
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_mul_epi32(__W, __M, __X, __Y);
 }
 
 __m128i test_mm_maskz_mul_epi32 (__mmask8 __M, __m128i __X, __m128i __Y) {
   //CHECK-LABEL: @test_mm_maskz_mul_epi32
-  //CHECK: @llvm.x86.sse41.pmuldq
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: shl <2 x i64> %{{.*}}, 
+  //CHECK: ashr <2 x i64> %{{.*}}, 
+  //CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_maskz_mul_epi32(__M, __X, __Y);
 }
 
 __m256i test_mm256_mask_mul_epu32 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y) {
   //CHECK-LABEL: @test_mm256_mask_mul_epu32
-  //CHECK: @llvm.x86.avx2.pmulu.dq
+  //CHECK: and <4 x i64> %{{.*}}, 
+  //CHECK: and <4 x i64> %{{.*}}, 
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_mul_epu32(__W, __M, __X, __Y);
 }
 
 __m256i test_mm256_maskz_mul_epu32 (__mmask8 __M, __m256i __X, __m256i __Y) {
   //CHECK-LABEL: @test_mm256_maskz_mul_epu32
-  //CHECK: @llvm.x86.avx2.pmulu.dq
+  //CHECK: and <4 x i64> %{{.*}}, 
+  //CHECK: and <4 x i64> %{{.*}}, 
+  //CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_maskz_mul_epu32(__M, __X, __Y);
 }
 
 __m128i test_mm_mask_mul_epu32 (__m128i __W, __mmask8 __M, __m128i __X,
 __m128i __Y) {
   //CHECK-LABEL: @test_mm_mask_mul_epu32
-  //CHECK: @llvm.x86.sse2.pmulu.dq
+  //CHECK: and <2 x i64> %{{.*}}, 
+  //CHECK: and <2 x i64> %{{.*}}, 
+  //CHECK: mul <2 x i64> %{{.*}}, %{{.*}}
   //CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_mul_epu32(__W, __M, __X, __Y);
 }
 
 __m128i test_mm_maskz_mul_epu32 (__mmask8 __M, __m128i 

Re: [clang-tools-extra] r329452 - [clang-tidy] Fix compilation for ParentVirtualCallCheck.cpp

2018-04-09 Thread Zinovy Nis via cfe-commits
I had compilation errors here on MVSV@PSP and for ARM:



FAILED: /usr/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools/clang/tools/extra/clang-tidy/bugprone
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/include
-Itools/clang/include -Iinclude
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/include
-fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall
-W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-fno-strict-aliasing -O3-UNDEBUG  -fno-exceptions -fno-rtti -MMD
-MT 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/clangTidyBugproneModule.dir/ParentVirtualCallCheck.cpp.o
-MF 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/clangTidyBugproneModule.dir/ParentVirtualCallCheck.cpp.o.d
-o 
tools/clang/tools/extra/clang-tidy/bugprone/CMakeFiles/clangTidyBugproneModule.dir/ParentVirtualCallCheck.cpp.o
-c 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:
In function 'bool clang::tidy::bugprone::isParentOf(const
clang::CXXRecordDecl&, const clang::CXXRecordDecl&)':
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:30:63:
error: use of 'auto' in lambda parameter declaration only available
with -std=c++14 or -std=gnu++14
   const auto ClassIter = llvm::find_if(ThisClass.bases(), [=](auto ) {
   ^
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:
In lambda function:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:31:27:
error: request for member 'getType' in 'Base', which is of non-class
type 'int'
 auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
   ^
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:
In function 'std::__cxx11::string
clang::tidy::bugprone::getExprAsString(const clang::Expr&,
clang::ASTContext&)':
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:77:48:
error: no matching function for call to
'remove_if(std::__cxx11::string&, )'
   Text.erase(llvm::remove_if(Text, std::isspace), Text.end());
^
In file included from
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/include/llvm/ADT/StringRef.h:13:0,
 from
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/include/llvm/ADT/StringMap.h:17,
 from
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/../ClangTidyOptions.h:14,
 from
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/../ClangTidyDiagnosticConsumer.h:13,
 from
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/../ClangTidy.h:13,
 from
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.h:13,
 from
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:10:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/include/llvm/ADT/STLExtras.h:886:6:
note: candidate: template decltype
(llvm::adl_begin(Range)) llvm::remove_if(R&&, UnaryPredicate)
 auto remove_if(R &, UnaryPredicate P) -> decltype(adl_begin(Range)) {
  ^
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/include/llvm/ADT/STLExtras.h:886:6:
note:   template argument deduction/substitution failed:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/tools/clang/tools/extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp:77:48:
note:   couldn't deduce template parameter 'UnaryPredicate'
   Text.erase(llvm::remove_if(Text, std::isspace), Text.end());
^
In file included from 

[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-09 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added a comment.

In https://reviews.llvm.org/D45392#1061433, @alexfh wrote:

> I wonder whether the readability-identifier-naming check could be extended to 
> support this use case instead of adding a new check specifically for 
> underscores in ivar names?


Hmm readability-identifier-naming is a C++ check but this one is only for ObjC. 
I prefer putting them in separate places unless they work for both languages.
Moreover, readability-identifier-naming always runs all matchers and apply the 
same checks on all identifiers. We have to change at least part of the 
structure to make it applicable for this check. And 
readability-identifier-naming is not in google default clang-tidy check list 
yet. We will even need more work to import it.
So I think creating a new simple ObjC-specific check is a better way here.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added inline comments.
This revision now requires changes to proceed.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:3082
+if (X.isUnknown()) {
+  // The value being casted to rvalue can be garbage-collected after
+  // the cast is modeled. Try to recover the memory region being casted

From my understanding, the code inside the if-block is not tested below



Repository:
  rC Clang

https://reviews.llvm.org/D45416



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


[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It'll be good idea to have option to apply this check for pointer/references 
only, or include built-in types/enums.




Comment at: clang-tidy/cppcoreguidelines/ConstCheck.cpp:13
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+#include 

Please remove empty line.



Comment at: docs/ReleaseNotes.rst:60
 
+- New :doc:`cppcoreguidelines-const
+  ` check

Please move into new checks list in alphabetical order.



Comment at: docs/ReleaseNotes.rst:63
+
+  FIXME: add release notes.
+

Please add short description here.



Comment at: docs/clang-tidy/checks/cppcoreguidelines-const.rst:6
+
+FIXME: Describe what patterns does the check detect and why. Give examples.

Preliminary documentation will be helpful.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


[PATCH] D45417: [analyzer] Don't crash on printing ConcreteInt of size >64 bits

2018-04-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Core/SVals.cpp:304
   const nonloc::ConcreteInt& C = castAs();
-  if (C.getValue().isUnsigned())
-os << C.getValue().getZExtValue();
-  else
-os << C.getValue().getSExtValue();
-  os << ' ' << (C.getValue().isUnsigned() ? 'U' : 'S')
- << C.getValue().getBitWidth() << 'b';
+  bool IsSigned = C.getValue().isSigned();
+  // FIXME: We can just call C.getValue().print() for all cases, but it has

Given that `getValue` is accessed 6 times now, I would put it into a variable



Comment at: lib/StaticAnalyzer/Core/SVals.cpp:305
+  bool IsSigned = C.getValue().isSigned();
+  // FIXME: We can just call C.getValue().print() for all cases, but it has
+  //rather slow performance (see implementation of toString()).

Makes sense, another option would be to add a fast path to `APInt::print`?



Comment at: test/Analysis/egraph-dump-int128.c:3
+// RUN: mkdir -p %t.dir
+// RUN: env TMPDIR=%t.dir TEMP=%t.dir TMP=%t.dir %clang_analyze_cc1 
-analyzer-checker=debug.ViewExplodedGraph %s
+

At least on a mac, `ViewExplodedGraph` launches `GraphViz.app`.
Can we have a less invasive check? Wouldn't just dumping a value be sufficient?


Repository:
  rC Clang

https://reviews.llvm.org/D45417



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


[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

2018-04-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv updated this revision to Diff 141687.
george.burgess.iv marked 2 inline comments as done.
george.burgess.iv added a comment.
Herald added a subscriber: srhines.

Addressed feedback


https://reviews.llvm.org/D45059

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
  clang-tidy/android/ComparisonInTempFailureRetryCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-comparison-in-temp-failure-retry.c

Index: test/clang-tidy/android-comparison-in-temp-failure-retry.c
===
--- /dev/null
+++ test/clang-tidy/android-comparison-in-temp-failure-retry.c
@@ -0,0 +1,148 @@
+// RUN: %check_clang_tidy %s android-comparison-in-temp-failure-retry %t
+
+#define TEMP_FAILURE_RETRY(x)  \
+  ({   \
+typeof(x) __z; \
+do \
+  __z = (x);   \
+while (__z == -1); \
+__z;   \
+  })
+
+int foo();
+int bar(int a);
+
+void test() {
+  int i;
+  TEMP_FAILURE_RETRY((i = foo()));
+  TEMP_FAILURE_RETRY(foo());
+  TEMP_FAILURE_RETRY((foo()));
+
+  TEMP_FAILURE_RETRY(foo() == 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: top-level comparison in TEMP_FAILURE_RETRY [android-comparison-in-temp-failure-retry]
+  TEMP_FAILURE_RETRY((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TEMP_FAILURE_RETRY((int)(foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  TEMP_FAILURE_RETRY(bar(foo() == 1));
+  TEMP_FAILURE_RETRY((bar(foo() == 1)));
+  TEMP_FAILURE_RETRY((bar(foo() == 1)) == 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TEMP_FAILURE_RETRY(((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TEMP_FAILURE_RETRY((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define INDIRECT TEMP_FAILURE_RETRY
+  INDIRECT(foo());
+  INDIRECT((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: top-level comparison in TEMP_FAILURE_RETRY
+  INDIRECT(bar(foo() == 1));
+  INDIRECT((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define TFR(x) TEMP_FAILURE_RETRY(x)
+  TFR(foo());
+  TFR((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: top-level comparison in TEMP_FAILURE_RETRY
+  TFR(bar(foo() == 1));
+  TFR((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define ADD_TFR(x) (1 + TEMP_FAILURE_RETRY(x) + 1)
+  ADD_TFR(foo());
+  ADD_TFR(foo() == 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  ADD_TFR(bar(foo() == 1));
+  ADD_TFR((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define ADDP_TFR(x) (1 + TEMP_FAILURE_RETRY((x)) + 1)
+  ADDP_TFR(foo());
+  ADDP_TFR((foo() == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  ADDP_TFR(bar(foo() == 1));
+  ADDP_TFR((int)((bar(foo() == 1)) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define MACRO TEMP_FAILURE_RETRY(foo() == 1)
+  MACRO;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+  // Be sure that being a macro arg doesn't mess with this.
+#define ID(x) (x)
+  ID(ADDP_TFR(bar(foo() == 1)));
+  ID(ADDP_TFR(bar(foo() == 1) == 1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in TEMP_FAILURE_RETRY
+  ID(MACRO);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: top-level comparison in TEMP_FAILURE_RETRY
+
+#define CMP(x) x == 1
+  TEMP_FAILURE_RETRY(CMP(foo()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: top-level comparison in TEMP_FAILURE_RETRY
+}
+
+// Be sure that it works inside of things like loops, if statements, etc.
+void control_flow() {
+  do {
+if (TEMP_FAILURE_RETRY(foo())) {
+}
+
+if (TEMP_FAILURE_RETRY(foo() == 1)) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
+}
+
+if (TEMP_FAILURE_RETRY(bar(foo() == 1))) {
+}
+
+ 

[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

2018-04-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for the feedback!

> and I suspect that your interest in this check is also related to android?

Yup :)

> Alternatively, if there are other checks specific to the GNU C library 
> planned, we could add a new module for it.

I have nothing planned, so I'm happy with this sitting under `android-`.




Comment at: 
docs/clang-tidy/checks/bugprone-comparison-in-temp-failure-retry.rst:7
+Diagnoses comparisons that appear to be incorrectly placed in the argument to
+the ``TEMP_FAILURE_RETRY`` macro. Having such a use is incorrect in the vast
+majority of cases, and will often silently defeat the purpose of the

alexfh wrote:
> The documentation should provide some context w.r.t what the 
> TEMP_FAILURE_RETRY macro is and where it comes from (maybe also link to its 
> documentation).
Added a paragraph after this one.


https://reviews.llvm.org/D45059



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


[PATCH] D45406: Document -std= values for different languages

2018-04-09 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

So, does this look good enough to commit?


Repository:
  rC Clang

https://reviews.llvm.org/D45406



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


[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-04-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.

LGTM. Sorry for the delay, I thought that a single acceptance was sufficient.


https://reviews.llvm.org/D41938



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-04-09 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

This seems like it would be nice to have in `bugprone-*` as well.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


  1   2   3   >