[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

2017-10-14 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

I don't think we should depend on LLVM for the locking stuff. This sort of 
infrastructure is in the same bucket as the demangler which we haven't really 
solved.

I *do* find it weird to do it this way though. I think you should have some 
mutex functions which include read/write unlock. This way you don't need the 
weird state.


https://reviews.llvm.org/D38704



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


r315845 - [Lex] Remove unused variables. No functionality change.

2017-10-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 14 21:27:37 2017
New Revision: 315845

URL: http://llvm.org/viewvc/llvm-project?rev=315845&view=rev
Log:
[Lex] Remove unused variables. No functionality change.

Modified:
cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
cfe/trunk/lib/Lex/TokenLexer.cpp

Modified: cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/VariadicMacroSupport.h?rev=315845&r1=315844&r2=315845&view=diff
==
--- cfe/trunk/include/clang/Lex/VariadicMacroSupport.h (original)
+++ cfe/trunk/include/clang/Lex/VariadicMacroSupport.h Sat Oct 14 21:27:37 2017
@@ -69,8 +69,6 @@ namespace clang {
   /// \brief A class for tracking whether we're inside a VA_OPT during a
   /// traversal of the tokens of a variadic macro definition.
   class VAOptDefinitionContext {
-Preprocessor &PP;
-
 /// Contains all the locations of so far unmatched lparens.
 SmallVector UnmatchedOpeningParens;
 
@@ -79,7 +77,7 @@ namespace clang {
 
   public:
 VAOptDefinitionContext(Preprocessor &PP)
-: PP(PP), Ident__VA_OPT__(PP.Ident__VA_OPT__) {}
+: Ident__VA_OPT__(PP.Ident__VA_OPT__) {}
 
 bool isVAOptToken(const Token &T) const {
   return Ident__VA_OPT__ && T.getIdentifierInfo() == Ident__VA_OPT__;

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=315845&r1=315844&r2=315845&view=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Sat Oct 14 21:27:37 2017
@@ -184,18 +184,12 @@ void TokenLexer::stringifyVAOPTContents(
   // Perform token pasting (concatenation) prior to stringization.
   for (unsigned int CurTokenIdx = 0; CurTokenIdx != NumVAOptTokens;
++CurTokenIdx) {
-const unsigned int PrevTokenIdx = CurTokenIdx;
-
 if (VAOPTTokens[CurTokenIdx].is(tok::hashhash)) {
   assert(CurTokenIdx != 0 &&
  "Can not have __VAOPT__ contents begin with a ##");
   Token &LHS = VAOPTTokens[CurTokenIdx - 1];
   pasteTokens(LHS, llvm::makeArrayRef(VAOPTTokens, NumVAOptTokens),
   CurTokenIdx);
-  // CurTokenIdx is either the same as NumTokens or one past the
-  // last token concatenated.
-  // PrevTokenIdx is the index of the hashhash
-  const unsigned NumTokensPastedTogether = CurTokenIdx - PrevTokenIdx + 1;
   // Replace the token prior to the first ## in this iteration.
   ConcatenatedVAOPTResultToks.back() = LHS;
   if (CurTokenIdx == NumVAOptTokens)


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


r315842 - [c++2a] Fix failing regression test related to not adding the extension warning to a diagnostic group (in r315840)

2017-10-14 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sat Oct 14 19:13:17 2017
New Revision: 315842

URL: http://llvm.org/viewvc/llvm-project?rev=315842&view=rev
Log:
[c++2a] Fix failing regression test related to not adding the extension warning 
to a diagnostic group (in r315840)

In passing also complete a comment that I left uncompleted.

For ease of reference, here's the parent commit: 
https://reviews.llvm.org/rL315840




Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Lex/TokenLexer.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=315842&r1=315841&r2=315842&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sat Oct 14 19:13:17 2017
@@ -347,8 +347,11 @@ def ext_pp_comma_expr : Extension<"comma
 def ext_pp_bad_vaargs_use : Extension<
   "__VA_ARGS__ can only appear in the expansion of a C99 variadic macro">;
 
-def ext_pp_bad_vaopt_use : Extension<
-  "__VA_OPT__ can only appear in the expansion of a variadic macro">;
+def ext_pp_bad_vaopt_use
+: ExtWarn<
+  "__VA_OPT__ can only appear in the expansion of a variadic macro">,
+  InGroup;
+
 def err_pp_missing_lparen_in_vaopt_use : Error<
   "missing '(' following __VA_OPT__">;
 def err_pp_vaopt_nested_use : Error<

Modified: cfe/trunk/include/clang/Lex/TokenLexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/TokenLexer.h?rev=315842&r1=315841&r2=315842&view=diff
==
--- cfe/trunk/include/clang/Lex/TokenLexer.h (original)
+++ cfe/trunk/include/clang/Lex/TokenLexer.h Sat Oct 14 19:13:17 2017
@@ -201,7 +201,9 @@ private:
   /// the tokens just expanded through __VA_OPT__ processing.  These (sub)
   /// sequence of tokens are folded into one stringified token.
   ///
-  /// \param[in] VCtx - contains information about the  
+  /// \param[in] VCtx - contains relevent contextual information about the
+  /// state of the tokens around and including the __VA_OPT__ token, necessary
+  /// for stringification.
 
   void stringifyVAOPTContents(SmallVectorImpl &ReplacementToks,
   const VAOptExpansionContext &VCtx,


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


r315840 - [c++2a] Implement P0306 __VA_OPT__ (Comma omission and comma deletion)

2017-10-14 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sat Oct 14 18:26:26 2017
New Revision: 315840

URL: http://llvm.org/viewvc/llvm-project?rev=315840&view=rev
Log:
[c++2a] Implement P0306 __VA_OPT__ (Comma omission and comma deletion)

This patch implements an extension to the preprocessor:

__VA_OPT__(contents) --> which expands into its contents if variadic arguments 
are supplied to the parent macro, or behaves as an empty token if none.

  - Currently this feature is only enabled for C++2a (this could be enabled, 
with some careful tweaks, for other dialects with the appropriate extension or 
compatibility warnings)

  - The patch was reviewed here: https://reviews.llvm.org/D35782 and asides 
from the above (and moving some of the definition and expansion recognition 
logic into the corresponding state machines), I believe I incorporated all of 
Richard's suggestions.

A few technicalities (most of which were clarified through private 
correspondence between rsmith, hubert and thomas) are worth mentioning.  Given:

#define F(a,...) a #__VA_OPT__(a ## a)  a ## __VA_OPT__(__VA_ARGS__)

- The call F(,) Does not supply any tokens for the variadic arguments and 
hence VA_OPT behaves as a placeholder.
- When expanding VA_OPT (for e.g. F(,1) token pasting occurs eagerly within 
its contents if the contents need to be stringified.
- A hash or a hashhash prior to VA_OPT does not inhibit expansion of 
arguments if they are the first token within VA_OPT.
- When a variadic argument is supplied, argument substitution occurs within 
the contents as does stringification - and these resulting tokens are inserted 
back into the macro expansions token stream just prior to the entire stream 
being rescanned and concatenated.

See wg21.link/P0306 for further details on the feature.


Acknowledgment: This patch would have been poorer if not for Richard Smith's 
usual thoughtful analysis and feedback.

Added:
cfe/trunk/test/Preprocessor/macro_vaopt_check.cpp
cfe/trunk/test/Preprocessor/macro_vaopt_expand.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Lex/MacroArgs.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Lex/TokenLexer.h
cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
cfe/trunk/lib/Lex/MacroArgs.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Lex/TokenLexer.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=315840&r1=315839&r2=315840&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sat Oct 14 18:26:26 2017
@@ -346,6 +346,20 @@ def ext_pp_extra_tokens_at_eol : ExtWarn
 def ext_pp_comma_expr : Extension<"comma operator in operand of #if">;
 def ext_pp_bad_vaargs_use : Extension<
   "__VA_ARGS__ can only appear in the expansion of a C99 variadic macro">;
+
+def ext_pp_bad_vaopt_use : Extension<
+  "__VA_OPT__ can only appear in the expansion of a variadic macro">;
+def err_pp_missing_lparen_in_vaopt_use : Error<
+  "missing '(' following __VA_OPT__">;
+def err_pp_vaopt_nested_use : Error<
+  "__VA_OPT__ cannot be nested within its own replacement tokens">;
+
+def err_vaopt_paste_at_start : Error<
+  "'##' cannot appear at start of __VA_OPT__ argument">;
+
+def err_vaopt_paste_at_end
+: Error<"'##' cannot appear at end of __VA_OPT__ argument">;
+
 def ext_pp_macro_redef : ExtWarn<"%0 macro redefined">, 
InGroup;
 def ext_variadic_macro : Extension<"variadic macros are a C99 feature">,
   InGroup;

Modified: cfe/trunk/include/clang/Lex/MacroArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroArgs.h?rev=315840&r1=315839&r2=315840&view=diff
==
--- cfe/trunk/include/clang/Lex/MacroArgs.h (original)
+++ cfe/trunk/include/clang/Lex/MacroArgs.h Sat Oct 14 18:26:26 2017
@@ -112,6 +112,20 @@ public:
   /// argument, this returns false.
   bool isVarargsElidedUse() const { return VarargsElided; }
 
+  /// Returns true if the macro was defined with a variadic (ellipsis) 
parameter
+  /// AND was invoked with at least one token supplied as a variadic argument.
+  ///
+  /// \code 
+  ///   #define F(a)  a
+  ///   #define V(a, ...) __VA_OPT__(a)
+  ///   F()<-- returns false on this invocation.
+  ///   V(,a)  <-- returns true on this invocation.
+  ///   V(,)   <-- returns false on this invocation.
+  /// \endcode
+  ///
+ 
+  bool invokedWithVariadicArgument(const MacroInfo *const MI) const;
+
   /// StringifyArgument - Implement C99 6.10.3.2p2, converting a sequence of
   /// tokens into the literal string token that should be produced by the C #
   /// preprocessor operator.  If Charify is true, then it sh

[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64

2017-10-14 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: include/unwind.h:125
   uintptr_t private_2; // holds sp that phase1 found for phase2 to use
-#ifndef __LP64__
+#if !defined(__LP64__) && !defined(_WIN64)
   // The implementation of _Unwind_Exception uses an attribute mode on the

I think I would prefer that we do this generically as:

#if __POINTER_WIDTH__ == 32



Comment at: src/AddressSpace.hpp:145
 public:
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
   typedef uint64_t pint_t;

I think I prefer the generic:

#if __POINTER_WIDTH__ == 64



Comment at: src/AddressSpace.hpp:197
 inline uintptr_t LocalAddressSpace::getP(pint_t addr) {
-#ifdef __LP64__
+#if defined(__LP64__) || defined(_WIN64)
   return get64(addr);

Same.



Comment at: src/UnwindRegistersRestore.S:68
 #
+#if defined(_WIN32)
+# On entry, thread_state pointer is in rcx

This is confusing.  Why is this `_WIN32`?  Shouldn't this be `_WIN64`?



Comment at: src/UnwindRegistersRestore.S:72
+  movq  56(%rcx), %rax # rax holds new stack pointer
+  subq  $16, %rax
+  movq  %rax, 56(%rcx)

Hmm, why is this `$16`?  The `$rsp` was adjusted by `$8` in the `setjmp`.



Comment at: src/UnwindRegistersSave.S:66
 DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+#if defined(_WIN32)
+  movq  %rax,   (%rcx)

Shouldn't this be `_WIN64`?


https://reviews.llvm.org/D38819



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


r315831 - Revert "Mark test as unsupported until r315808 is fixed"

2017-10-14 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Sat Oct 14 15:24:31 2017
New Revision: 315831

URL: http://llvm.org/viewvc/llvm-project?rev=315831&view=rev
Log:
Revert "Mark test as unsupported until r315808 is fixed"

Test is fixed in r315830

Modified:
cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl

Modified: cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl?rev=315831&r1=315830&r2=315831&view=diff
==
--- cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl (original)
+++ cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl Sat Oct 14 
15:24:31 2017
@@ -1,5 +1,4 @@
 // REQUIRES: amdgpu-registered-target
-// UNSUPPORTED: system-darwin
 // RUN: not %clang_cc1 -emit-codegen-only -triple=amdgcn-- %s 2>&1 | FileCheck 
%s
 
 // CHECK: error: local memory limit exceeded (48) in use_huge_lds


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


r315829 - Mark test as unsupported until r315808 is fixed

2017-10-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Sat Oct 14 15:14:23 2017
New Revision: 315829

URL: http://llvm.org/viewvc/llvm-project?rev=315829&view=rev
Log:
Mark test as unsupported until r315808 is fixed

This is causing:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/43381

Modified:
cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl

Modified: cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl?rev=315829&r1=315828&r2=315829&view=diff
==
--- cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl (original)
+++ cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl Sat Oct 14 
15:14:23 2017
@@ -1,4 +1,5 @@
 // REQUIRES: amdgpu-registered-target
+// UNSUPPORTED: system-darwin
 // RUN: not %clang_cc1 -emit-codegen-only -triple=amdgcn-- %s 2>&1 | FileCheck 
%s
 
 // CHECK: error: local memory limit exceeded (48) in use_huge_lds


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


[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

2017-10-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38704#892479, @zturner wrote:

> I'm a little nervous about re-inventing a poor man's version of a reader 
> writer lock.  Can we not just copy LLVM's?


I had a closer look at this, and noticed the following:

- The LLVM RWMutex class on windows tries to load the SRW functions 
dynamically, and falls back on a normal critical section otherwise. This init 
procedure doesn't seem to be threadsafe though, but as long as the first 
RWMutex object is initialized before any extra threads are started, we should 
be fine. For libunwind, it would probably be done in a constructor on CRT 
startup.
- Importing this implementation verbatim would require including one header, 3 
implementation files, and probably some CMake hookups.
- Until the LLVM relicensing is done, afaik we can't include code verbatim from 
LLVM into the runtime libs, or did I get this wrong?

If you prefer, it's pretty trivial to do a smaller but similar implementation 
for libunwind though. If we add a new RWMutex class instead of using the 
pthread API (and implementing the windows version behind that API), we can have 
separate unlock methods for read and write mode, getting rid of the ugly 
`lockedForWrite` variable I currently have. And one could have it either just 
use SRW, or try loading SRW dynamically if that's preferred (if one wants to 
spend extra effort on libunwind on pre-vista).

What do you think @zturner?


https://reviews.llvm.org/D38704



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


[PATCH] D37905: [libclang, bindings]: add spelling location

2017-10-14 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn added inline comments.



Comment at: bindings/python/clang/cindex.py:214
 
+class Location(object):
+"""A Location is a specific kind of source location.  A SourceLocation

Can you also add `Location` to `__all__`?


https://reviews.llvm.org/D37905



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


[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer

2017-10-14 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 119035.
Rakete added a comment.

Rebased and friendly ping :)


https://reviews.llvm.org/D38216

Files:
  lib/Sema/SemaDecl.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
  test/Parser/cxx1z-class-template-argument-deduction.cpp


Index: test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -52,7 +52,7 @@
 
   operator A(); // expected-error {{requires template arguments; argument 
deduction not allowed in conversion function type}}
 
-  static A x; // expected-error {{declaration of variable 'x' with deduced 
type 'A' requires an initializer}}
+  static A x;
   static constexpr A y = 0;
 };
 
@@ -114,7 +114,6 @@
 (void)A{n};
 (void)new A(n);
 (void)new A{n};
-// FIXME: We should diagnose the lack of an initializer here.
 (void)new A;
   }
 }
@@ -127,7 +126,7 @@
 
   auto k() -> A; // expected-error{{requires template arguments}}
 
-  A a; // expected-error {{declaration of variable 'a' with deduced type 'A' 
requires an initializer}}
+  A a;
   A b = 0;
   const A c = 0;
   A (parens) = 0; // expected-error {{cannot use parentheses when declaring 
variable with deduced class template specialization type}}
Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
@@ -5,8 +5,7 @@
 A(int) -> A;
 
 static constexpr inline const volatile A a = {}; // ok, specifiers are 
permitted
-// FIXME: There isn't really a good reason to reject this.
-A b; // expected-error {{requires an initializer}}
+A b;
 A c [[]] {};
 
 A d = {}, e = {};
@@ -13,6 +12,6 @@
 A f(0), g{}; // expected-error {{template arguments deduced as 'A' in 
declaration of 'f' and deduced as 'A' in declaration of 'g'}}
 
 struct B {
-  static A a; // expected-error {{requires an initializer}}
+  static A a;
 };
-extern A x; // expected-error {{requires an initializer}}
+extern A x;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10174,7 +10174,8 @@
   assert(Deduced && "deduceVarTypeFromInitializer for non-deduced type");
 
   // C++11 [dcl.spec.auto]p3
-  if (!Init) {
+  // Except for class argument deduction.
+  if (!Init && !isa(Deduced)) {
 assert(VDecl && "no init for init capture deduction?");
 Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
   << VDecl->getDeclName() << Type;
@@ -10193,7 +10194,10 @@
 InitializationKind Kind = InitializationKind::CreateForInit(
 VDecl->getLocation(), DirectInit, Init);
 // FIXME: Initialization should not be taking a mutable list of inits. 
-SmallVector InitsCopy(DeduceInits.begin(), DeduceInits.end());
+SmallVector InitsCopy;
+if (Init)
+  InitsCopy = {DeduceInits.begin(), DeduceInits.end()};
+
 return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
InitsCopy);
   }


Index: test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -52,7 +52,7 @@
 
   operator A(); // expected-error {{requires template arguments; argument deduction not allowed in conversion function type}}
 
-  static A x; // expected-error {{declaration of variable 'x' with deduced type 'A' requires an initializer}}
+  static A x;
   static constexpr A y = 0;
 };
 
@@ -114,7 +114,6 @@
 (void)A{n};
 (void)new A(n);
 (void)new A{n};
-// FIXME: We should diagnose the lack of an initializer here.
 (void)new A;
   }
 }
@@ -127,7 +126,7 @@
 
   auto k() -> A; // expected-error{{requires template arguments}}
 
-  A a; // expected-error {{declaration of variable 'a' with deduced type 'A' requires an initializer}}
+  A a;
   A b = 0;
   const A c = 0;
   A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}}
Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
@@ -5,8 +5,7 @@
 A(int) -> A;
 
 static constexpr inline const volatile A a = {}; // ok, specifiers are permitted
-// FIXME: There isn't really a good reason to reject this.
-A b; // expected-error {{requires an initializer}}
+A b;
 A c [[]] {};
 
 A d = {}, e = {};
@@ -13,6

[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state

2017-10-14 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 119032.
szepet added a comment.

Test file (running line) update.


https://reviews.llvm.org/D38675

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  test/Analysis/MisusedMovedObject.cpp


Index: test/Analysis/MisusedMovedObject.cpp
===
--- test/Analysis/MisusedMovedObject.cpp
+++ test/Analysis/MisusedMovedObject.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 -verify 
-analyzer-output=text %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.MisusedMovedObject 
-std=c++11 -verify -analyzer-output=text %s
 
 namespace std {
 
Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -272,6 +272,11 @@
   HelpText<"Checks C++ copy and move assignment operators for self 
assignment">,
   DescFile<"CXXSelfAssignmentChecker.cpp">;
 
+def MisusedMovedObjectChecker : Checker<"MisusedMovedObject">,
+  HelpText<"Method calls on a moved-from object and copying a moved-from "
+   "object will be reported">,
+  DescFile<"MisusedMovedObjectChecker.cpp">;
+
 } // end: "cplusplus"
 
 let ParentPackage = CplusplusOptIn in {
@@ -293,11 +298,6 @@
   HelpText<"Check for iterators used outside their valid ranges">,
   DescFile<"IteratorChecker.cpp">;
 
-def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">,
- HelpText<"Method calls on a moved-from object and copying a moved-from "
-  "object will be reported">,
- DescFile<"MisusedMovedObjectChecker.cpp">;
-
 } // end: "alpha.cplusplus"
 
 


Index: test/Analysis/MisusedMovedObject.cpp
===
--- test/Analysis/MisusedMovedObject.cpp
+++ test/Analysis/MisusedMovedObject.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 -verify -analyzer-output=text %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.MisusedMovedObject -std=c++11 -verify -analyzer-output=text %s
 
 namespace std {
 
Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -272,6 +272,11 @@
   HelpText<"Checks C++ copy and move assignment operators for self assignment">,
   DescFile<"CXXSelfAssignmentChecker.cpp">;
 
+def MisusedMovedObjectChecker : Checker<"MisusedMovedObject">,
+  HelpText<"Method calls on a moved-from object and copying a moved-from "
+   "object will be reported">,
+  DescFile<"MisusedMovedObjectChecker.cpp">;
+
 } // end: "cplusplus"
 
 let ParentPackage = CplusplusOptIn in {
@@ -293,11 +298,6 @@
   HelpText<"Check for iterators used outside their valid ranges">,
   DescFile<"IteratorChecker.cpp">;
 
-def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">,
- HelpText<"Method calls on a moved-from object and copying a moved-from "
-  "object will be reported">,
- DescFile<"MisusedMovedObjectChecker.cpp">;
-
 } // end: "alpha.cplusplus"
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38900: libunwind: document tested FreeBSD configs and sort OS list

2017-10-14 Thread Ed Maste via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315814: libunwind: document tested FreeBSD configs and sort 
OS list (authored by emaste).

Changed prior to commit:
  https://reviews.llvm.org/D38900?vs=118958&id=119031#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38900

Files:
  libunwind/trunk/docs/index.rst


Index: libunwind/trunk/docs/index.rst
===
--- libunwind/trunk/docs/index.rst
+++ libunwind/trunk/docs/index.rst
@@ -44,13 +44,14 @@
    
 OS   Arch CompilersUnwind Info
    
-Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
+Any  i386, x86_64, ARMClangSjLj
+Bare Metal   ARM  Clang, GCC   EHABI
+FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
 iOS  ARM  ClangSjLj
-Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
 LinuxARM  Clang, GCC   EHABI
-Bare Metal   ARM  Clang, GCC   EHABI
+Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
+Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
 NetBSD   x86_64   Clang, GCC   DWARF CFI
-Any  i386, x86_64, ARMClangSjLj
    
 
 The following minimum compiler versions are strongly recommended.


Index: libunwind/trunk/docs/index.rst
===
--- libunwind/trunk/docs/index.rst
+++ libunwind/trunk/docs/index.rst
@@ -44,13 +44,14 @@
    
 OS   Arch CompilersUnwind Info
    
-Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
+Any  i386, x86_64, ARMClangSjLj
+Bare Metal   ARM  Clang, GCC   EHABI
+FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
 iOS  ARM  ClangSjLj
-Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
 LinuxARM  Clang, GCC   EHABI
-Bare Metal   ARM  Clang, GCC   EHABI
+Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
+Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
 NetBSD   x86_64   Clang, GCC   DWARF CFI
-Any  i386, x86_64, ARMClangSjLj
    
 
 The following minimum compiler versions are strongly recommended.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r315814 - libunwind: document tested FreeBSD configs and sort OS list

2017-10-14 Thread Ed Maste via cfe-commits
Author: emaste
Date: Sat Oct 14 10:04:04 2017
New Revision: 315814

URL: http://llvm.org/viewvc/llvm-project?rev=315814&view=rev
Log:
libunwind: document tested FreeBSD configs and sort OS list

libunwind is known to work on FreeBSD i386, amd64 (x86_64) and arm64.
It is the unwinder provided by the base system on all of those
architectures.

While here sort the OS list.

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

Modified:
libunwind/trunk/docs/index.rst

Modified: libunwind/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/index.rst?rev=315814&r1=315813&r2=315814&view=diff
==
--- libunwind/trunk/docs/index.rst (original)
+++ libunwind/trunk/docs/index.rst Sat Oct 14 10:04:04 2017
@@ -44,13 +44,14 @@ libunwind is known to work on the follow
    
 OS   Arch CompilersUnwind Info
    
-Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
+Any  i386, x86_64, ARMClangSjLj
+Bare Metal   ARM  Clang, GCC   EHABI
+FreeBSD  i386, x86_64, ARM64  ClangDWARF CFI
 iOS  ARM  ClangSjLj
-Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
 LinuxARM  Clang, GCC   EHABI
-Bare Metal   ARM  Clang, GCC   EHABI
+Linuxi386, x86_64, ARM64  Clang, GCC   DWARF CFI
+Mac OS X i386, x86_64 Clang, GCC   DWARF CFI
 NetBSD   x86_64   Clang, GCC   DWARF CFI
-Any  i386, x86_64, ARMClangSjLj
    
 
 The following minimum compiler versions are strongly recommended.


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


[PATCH] D38900: libunwind: document tested FreeBSD configs and sort OS list

2017-10-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

Seems ok to me, with whatever other architectures it's verified on as well.


https://reviews.llvm.org/D38900



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


r315811 - Re-land r315787, "[Sema] Warn about unused variables if we can constant evaluate the initializer."

2017-10-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 14 08:59:34 2017
New Revision: 315811

URL: http://llvm.org/viewvc/llvm-project?rev=315811&view=rev
Log:
Re-land r315787, "[Sema] Warn about unused variables if we can constant 
evaluate the initializer."

The warnings in libc++ tests were fixed in the meantime.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315811&r1=315810&r2=315811&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Oct 14 08:59:34 2017
@@ -1723,7 +1723,8 @@ static bool ShouldDiagnoseUnusedDecl(con
 dyn_cast(Init);
   if (Construct && !Construct->isElidable()) {
 CXXConstructorDecl *CD = Construct->getConstructor();
-if (!CD->isTrivial() && !RD->hasAttr())
+if (!CD->isTrivial() && !RD->hasAttr() &&
+!VD->evaluateValue())
   return false;
   }
 }

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=315811&r1=315810&r2=315811&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Sat Oct 14 08:59:34 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify -std=c++11 %s
 template void f() {
   T t;
   t = 17;
@@ -194,3 +195,35 @@ void test() {
 }
 
 }
+
+#if __cplusplus >= 201103L
+namespace with_constexpr {
+template 
+struct Literal {
+  T i;
+  Literal() = default;
+  constexpr Literal(T i) : i(i) {}
+};
+
+struct NoLiteral {
+  int i;
+  NoLiteral() = default;
+  constexpr NoLiteral(int i) : i(i) {}
+  ~NoLiteral() {}
+};
+
+static Literal gl1;  // expected-warning {{unused variable 'gl1'}}
+static Literal gl2(1);   // expected-warning {{unused variable 'gl2'}}
+static const Literal gl3(0); // expected-warning {{unused variable 'gl3'}}
+
+template 
+void test(int i) {
+  Literal l1; // expected-warning {{unused variable 'l1'}}
+  Literal l2(42); // expected-warning {{unused variable 'l2'}}
+  Literal l3(i);  // no-warning
+  Literal l4(0);// no-warning
+  NoLiteral nl1;   // no-warning
+  NoLiteral nl2(42);   // no-warning
+}
+}
+#endif


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


[libcxx] r315809 - Placate unused variable warnings uncovered by improvements to clang's -Wunused-variable

2017-10-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Oct 14 08:52:38 2017
New Revision: 315809

URL: http://llvm.org/viewvc/llvm-project?rev=315809&view=rev
Log:
Placate unused variable warnings uncovered by improvements to clang's 
-Wunused-variable

Modified:
libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp
libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp
libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp
libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.syn/optional_includes_initializer_list.pass.cpp

libcxx/trunk/test/std/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp

libcxx/trunk/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp

libcxx/trunk/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
libcxx/trunk/test/std/numerics/c.math/ctgmath.pass.cpp
libcxx/trunk/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp

Modified: libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/depr/depr.c.headers/complex.h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -18,4 +18,5 @@
 int main()
 {
 std::complex d;
+(void)d;
 }

Modified: libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/depr/depr.c.headers/tgmath_h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -18,6 +18,7 @@
 int main()
 {
 std::complex cd;
+(void)cd;
 double x = sin(1.0);
 (void)x; // to placate scan-build
 }

Modified: 
libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/numerics/complex.number/ccmplx/ccomplex.pass.cpp 
Sat Oct 14 08:52:38 2017
@@ -18,4 +18,5 @@
 int main()
 {
 std::complex d;
+(void)d;
 }

Modified: libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/complex.h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -14,4 +14,5 @@
 int main()
 {
 std::complex d;
+(void)d;
 }

Modified: libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp?rev=315809&r1=315808&r2=315809&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/tgmath_h.pass.cpp Sat Oct 14 
08:52:38 2017
@@ -14,6 +14,7 @@
 int main()
 {
 std::complex cd;
+(void)cd;
 double x = sin(1.0);
 (void)x; // to placate scan-build
 }

Modified: 
libcxx/trunk/test/std/experim

[PATCH] D38678: [Sema] Warn about unused variables if we can constant evaluate the initializer.

2017-10-14 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added subscribers: EricWF, chapuni.
chapuni added a comment.

Excuse me, I have reverted it in https://reviews.llvm.org/rL315806. 
check-libcxx dislikes it.

See also; http://bb9.pgr.jp/#/builders/20/builds/111


Repository:
  rL LLVM

https://reviews.llvm.org/D38678



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


r315806 - Revert rL315787, "[Sema] Warn about unused variables if we can constant evaluate the initializer."

2017-10-14 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sat Oct 14 07:46:04 2017
New Revision: 315806

URL: http://llvm.org/viewvc/llvm-project?rev=315806&view=rev
Log:
Revert rL315787, "[Sema] Warn about unused variables if we can constant 
evaluate the initializer."

check-libcxx dislikes it.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315806&r1=315805&r2=315806&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Oct 14 07:46:04 2017
@@ -1723,8 +1723,7 @@ static bool ShouldDiagnoseUnusedDecl(con
 dyn_cast(Init);
   if (Construct && !Construct->isElidable()) {
 CXXConstructorDecl *CD = Construct->getConstructor();
-if (!CD->isTrivial() && !RD->hasAttr() &&
-!VD->evaluateValue())
+if (!CD->isTrivial() && !RD->hasAttr())
   return false;
   }
 }

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=315806&r1=315805&r2=315806&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Sat Oct 14 07:46:04 2017
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label 
-Wno-c++1y-extensions -verify -std=c++11 %s
 template void f() {
   T t;
   t = 17;
@@ -195,35 +194,3 @@ void test() {
 }
 
 }
-
-#if __cplusplus >= 201103L
-namespace with_constexpr {
-template 
-struct Literal {
-  T i;
-  Literal() = default;
-  constexpr Literal(T i) : i(i) {}
-};
-
-struct NoLiteral {
-  int i;
-  NoLiteral() = default;
-  constexpr NoLiteral(int i) : i(i) {}
-  ~NoLiteral() {}
-};
-
-static Literal gl1;  // expected-warning {{unused variable 'gl1'}}
-static Literal gl2(1);   // expected-warning {{unused variable 'gl2'}}
-static const Literal gl3(0); // expected-warning {{unused variable 'gl3'}}
-
-template 
-void test(int i) {
-  Literal l1; // expected-warning {{unused variable 'l1'}}
-  Literal l2(42); // expected-warning {{unused variable 'l2'}}
-  Literal l3(i);  // no-warning
-  Literal l4(0);// no-warning
-  NoLiteral nl1;   // no-warning
-  NoLiteral nl2(42);   // no-warning
-}
-}
-#endif


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


[PATCH] D38922: [analyzer] LoopUnrolling: check the bitwidth of the used numbers (pr34943)

2017-10-14 Thread Peter Szecsi via Phabricator via cfe-commits
szepet created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.

The loop unrolling feature aims to track the maximum possible steps a loop can 
make. In order to implement this, it investigates the initial value of the 
counter variable and the bound number. (There has to be known.) 
These numbers are used as llvm::APInts, however, it was not checked if their 
bitwidths are the same which lead to some crashes.
This revision solves this problem by extending the "shorter" one (to the length 
of the "longer" one).
For the detailed bug report, see: https://bugs.llvm.org/show_bug.cgi?id=34943


https://reviews.llvm.org/D38922

Files:
  lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  test/Analysis/loop-unrolling.cpp


Index: test/Analysis/loop-unrolling.cpp
===
--- test/Analysis/loop-unrolling.cpp
+++ test/Analysis/loop-unrolling.cpp
@@ -373,3 +373,9 @@
   return 0;
 }
 
+
+void pr34943() {
+  for (int i = 0; i < 6L; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{6}}
+  }
+}
Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -208,9 +208,16 @@
 return false;
 
   auto CounterVar = Matches[0].getNodeAs("initVarName");
-  auto BoundNum = Matches[0].getNodeAs("boundNum")->getValue();
-  auto InitNum = Matches[0].getNodeAs("initNum")->getValue();
+  llvm::APInt BoundNum =
+  Matches[0].getNodeAs("boundNum")->getValue();
+  llvm::APInt InitNum =
+  Matches[0].getNodeAs("initNum")->getValue();
   auto CondOp = Matches[0].getNodeAs("conditionOperator");
+  if (InitNum.getBitWidth() != BoundNum.getBitWidth()) {
+InitNum = InitNum.zextOrSelf(BoundNum.getBitWidth());
+BoundNum = BoundNum.zextOrSelf(InitNum.getBitWidth());
+  }
+
   if (CondOp->getOpcode() == BO_GE || CondOp->getOpcode() == BO_LE)
 maxStep = (BoundNum - InitNum + 1).abs().getZExtValue();
   else


Index: test/Analysis/loop-unrolling.cpp
===
--- test/Analysis/loop-unrolling.cpp
+++ test/Analysis/loop-unrolling.cpp
@@ -373,3 +373,9 @@
   return 0;
 }
 
+
+void pr34943() {
+  for (int i = 0; i < 6L; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{6}}
+  }
+}
Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -208,9 +208,16 @@
 return false;
 
   auto CounterVar = Matches[0].getNodeAs("initVarName");
-  auto BoundNum = Matches[0].getNodeAs("boundNum")->getValue();
-  auto InitNum = Matches[0].getNodeAs("initNum")->getValue();
+  llvm::APInt BoundNum =
+  Matches[0].getNodeAs("boundNum")->getValue();
+  llvm::APInt InitNum =
+  Matches[0].getNodeAs("initNum")->getValue();
   auto CondOp = Matches[0].getNodeAs("conditionOperator");
+  if (InitNum.getBitWidth() != BoundNum.getBitWidth()) {
+InitNum = InitNum.zextOrSelf(BoundNum.getBitWidth());
+BoundNum = BoundNum.zextOrSelf(InitNum.getBitWidth());
+  }
+
   if (CondOp->getOpcode() == BO_GE || CondOp->getOpcode() == BO_LE)
 maxStep = (BoundNum - InitNum + 1).abs().getZExtValue();
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315805 - Fix build failure on android due to missing std::to_string()

2017-10-14 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Sat Oct 14 05:51:52 2017
New Revision: 315805

URL: http://llvm.org/viewvc/llvm-project?rev=315805&view=rev
Log:
Fix build failure on android due to missing std::to_string()

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=315805&r1=315804&r2=315805&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Sat Oct 14 05:51:52 2017
@@ -25,6 +25,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Type.h"
 #include "llvm/Support/raw_ostream.h"
@@ -8994,7 +8995,7 @@ llvm::Function *AMDGPUTargetCodeGenInfo:
 ArgBaseTypeNames.push_back(llvm::MDString::get(C, "void*"));
 ArgTypeQuals.push_back(llvm::MDString::get(C, ""));
 ArgNames.push_back(
-llvm::MDString::get(C, std::string("local_arg") + std::to_string(I)));
+llvm::MDString::get(C, (Twine("local_arg") + Twine(I)).str()));
   }
   std::string Name = Invoke->getName().str() + "_kernel";
   auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(C), ArgTys, false);


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


[PATCH] D38921: [analyzer] LoopUnrolling: update the matched assignment operators

2017-10-14 Thread Peter Szecsi via Phabricator via cfe-commits
szepet created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.

Extended the matched assignment operators when checking for bound changes in a 
body of the loop. This updated list covers all the (current) possible 
assignments.


https://reviews.llvm.org/D38921

Files:
  lib/StaticAnalyzer/Core/LoopUnrolling.cpp


Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -99,7 +99,10 @@
 declRefExpr(to(varDecl(VarNodeMatcher)),
   binaryOperator(anyOf(hasOperatorName("="), hasOperatorName("+="),
hasOperatorName("/="), hasOperatorName("*="),
-   hasOperatorName("-=")),
+   hasOperatorName("-="), hasOperatorName("%="),
+   hasOperatorName("&="), hasOperatorName("|="),
+   hasOperatorName("^="), hasOperatorName("<<="),
+   hasOperatorName(">>=")),
  hasLHS(ignoringParenImpCasts(
  declRefExpr(to(varDecl(VarNodeMatcher)));
 }


Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -99,7 +99,10 @@
 declRefExpr(to(varDecl(VarNodeMatcher)),
   binaryOperator(anyOf(hasOperatorName("="), hasOperatorName("+="),
hasOperatorName("/="), hasOperatorName("*="),
-   hasOperatorName("-=")),
+   hasOperatorName("-="), hasOperatorName("%="),
+   hasOperatorName("&="), hasOperatorName("|="),
+   hasOperatorName("^="), hasOperatorName("<<="),
+   hasOperatorName(">>=")),
  hasLHS(ignoringParenImpCasts(
  declRefExpr(to(varDecl(VarNodeMatcher)));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-14 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315804: [OpenCL] Emit enqueued block as kernel (authored by 
yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D38134?vs=118795&id=119017#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38134

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenTypes.h
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.h
  cfe/trunk/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
  cfe/trunk/test/CodeGenOpenCL/blocks.cl
  cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple amdgcn | FileCheck %s --check-prefix=CHECK
+
+typedef struct {int a;} ndrange_t;
+
+// CHECK-LABEL: define amdgpu_kernel void @test
+kernel void test(global char *a, char b, global long *c, long d) {
+  queue_t default_queue;
+  unsigned flags = 0;
+  ndrange_t ndrange;
+
+  enqueue_kernel(default_queue, flags, ndrange,
+ ^(void) {
+ a[0] = b;
+ });
+
+  enqueue_kernel(default_queue, flags, ndrange,
+ ^(void) {
+ a[0] = b;
+ c[0] = d;
+ });
+}
+
+// CHECK-LABEL: define internal amdgpu_kernel void @__test_block_invoke_kernel(<{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i8 }>)
+// CHECK-SAME: #[[ATTR:[0-9]+]] !kernel_arg_addr_space !{{.*}} !kernel_arg_access_qual !{{.*}} !kernel_arg_type !{{.*}} !kernel_arg_base_type !{{.*}} !kernel_arg_type_qual !{{.*}}
+// CHECK: entry:
+// CHECK:  %1 = alloca <{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i8 }>, align 8
+// CHECK:  store <{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i8 }> %0, <{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i8 }>* %1, align 8
+// CHECK:  %2 = addrspacecast <{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i8 }>* %1 to i8 addrspace(4)*
+// CHECK:  call void @__test_block_invoke(i8 addrspace(4)* %2)
+// CHECK:  ret void
+// CHECK:}
+
+// CHECK-LABEL: define internal amdgpu_kernel void @__test_block_invoke_2_kernel(<{ i32, i32, i8 addrspace(4)*, i8 addrspace(1)*, i64 addrspace(1)*, i64, i8 }>)
+// CHECK-SAME: #[[ATTR]] !kernel_arg_addr_space !{{.*}} !kernel_arg_access_qual !{{.*}} !kernel_arg_type !{{.*}} !kernel_arg_base_type !{{.*}} !kernel_arg_type_qual !{{.*}}
+
+// CHECK: attributes #[[ATTR]] = { nounwind "enqueued-block" }
Index: cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -6,10 +6,30 @@
 typedef void (^bl_t)(local void *);
 typedef struct {int a;} ndrange_t;
 
-// N.B. The check here only exists to set BL_GLOBAL
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: %struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* }
+
+// For a block global variable, first emit the block literal as a global variable, then emit the block variable itself.
+// COMMON: [[BL_GLOBAL:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INV_G:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+
+// For anonymous blocks without captures, emit block literals as global variable.
+// COMMON: [[BLG1:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG2:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* {{@[^ ]+}} to i8*) to i8 addrspa

r315804 - [OpenCL] Emit enqueued block as kernel

2017-10-14 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Sat Oct 14 05:23:50 2017
New Revision: 315804

URL: http://llvm.org/viewvc/llvm-project?rev=315804&view=rev
Log:
[OpenCL] Emit enqueued block as kernel

In OpenCL the kernel function and non-kernel function has different calling 
conventions.
For certain targets they have different argument ABIs. Also kernels have 
special function
attributes and metadata for runtime to launch them.

The blocks passed to enqueue_kernel is supposed to be executed as kernels. As 
such,
the block invoke function should be emitted as kernel with proper calling 
convention and
argument ABI.

This patch emits enqueued block as kernel. If a block is both called directly 
and passed
to enqueue_kernel, separate functions will be generated.

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

Added:
cfe/trunk/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/test/CodeGenOpenCL/blocks.cl
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=315804&r1=315803&r2=315804&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Sat Oct 14 05:23:50 2017
@@ -738,16 +738,27 @@ void CodeGenFunction::destroyBlockInfos(
 }
 
 /// Emit a block literal expression in the current function.
-llvm::Value *CodeGenFunction::EmitBlockLiteral(const BlockExpr *blockExpr) {
+llvm::Value *CodeGenFunction::EmitBlockLiteral(const BlockExpr *blockExpr,
+   llvm::Function **InvokeF) {
   // If the block has no captures, we won't have a pre-computed
   // layout for it.
   if (!blockExpr->getBlockDecl()->hasCaptures()) {
-if (llvm::Constant *Block = CGM.getAddrOfGlobalBlockIfEmitted(blockExpr))
+// The block literal is emitted as a global variable, and the block invoke
+// function has to be extracted from its initializer.
+if (llvm::Constant *Block = CGM.getAddrOfGlobalBlockIfEmitted(blockExpr)) {
+  if (InvokeF) {
+auto *GV = cast(
+cast(Block)->stripPointerCasts());
+auto *BlockInit = cast(GV->getInitializer());
+*InvokeF = cast(
+BlockInit->getAggregateElement(2)->stripPointerCasts());
+  }
   return Block;
+}
 CGBlockInfo blockInfo(blockExpr->getBlockDecl(), CurFn->getName());
 computeBlockInfo(CGM, this, blockInfo);
 blockInfo.BlockExpression = blockExpr;
-return EmitBlockLiteral(blockInfo);
+return EmitBlockLiteral(blockInfo, InvokeF);
   }
 
   // Find the block info for this block and take ownership of it.
@@ -756,10 +767,11 @@ llvm::Value *CodeGenFunction::EmitBlockL
  blockExpr->getBlockDecl()));
 
   blockInfo->BlockExpression = blockExpr;
-  return EmitBlockLiteral(*blockInfo);
+  return EmitBlockLiteral(*blockInfo, InvokeF);
 }
 
-llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
+llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo,
+   llvm::Function **InvokeF) {
   bool IsOpenCL = CGM.getContext().getLangOpts().OpenCL;
   auto GenVoidPtrTy =
   IsOpenCL ? CGM.getOpenCLRuntime().getGenericVoidPointerType() : 
VoidPtrTy;
@@ -768,9 +780,11 @@ llvm::Value *CodeGenFunction::EmitBlockL
   CGM.getTarget().getPointerWidth(GenVoidPtrAddr) / 8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  llvm::Constant *blockFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
-  blockFn = llvm::ConstantExpr::getPointerCast(blockFn, GenVoidPtrTy);
+  if (InvokeF)
+*InvokeF = InvokeFn;
+  auto *blockFn = llvm::ConstantExpr::getPointerCast(InvokeFn, GenVoidPtrTy);
 
   // If there is nothing to capture, we can emit this as a global block.
   if (blockInfo.CanBeGlobal)

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=315804&r1=315803&r2=315804&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Oct 14 05:23:50 2017
@@ -2779,12 +2779,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   // The most basic form 

[PATCH] D38816: Convert clang::LangAS to a strongly typed enum

2017-10-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks! Great work!


https://reviews.llvm.org/D38816



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


[PATCH] D38919: [libcxx] Implemented from Library Fundamentals V2

2017-10-14 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.

This patch implements make_array and to_array from the Library Fundamentals V2 
TS.


https://reviews.llvm.org/D38919

Files:
  include/experimental/array
  test/std/experimental/container/array/creation/make_array.fail.cpp
  test/std/experimental/container/array/creation/make_array.pass.cpp
  test/std/experimental/container/array/creation/to_array.pass.cpp

Index: test/std/experimental/container/array/creation/to_array.pass.cpp
===
--- test/std/experimental/container/array/creation/to_array.pass.cpp
+++ test/std/experimental/container/array/creation/to_array.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// 
+#include 
+#include 
+
+int main() {
+  using std::experimental::to_array;
+
+  {
+constexpr int raw[4] = {0, 1, 2, 3};
+constexpr auto a = to_array(raw);
+
+static_assert(std::is_same>::value,
+  "Incorrect type");
+static_assert(a[0] == 0 && a[1] == 1 && a[2] == 2 && a[3] == 3,
+  "Incorrect values");
+  }
+
+  {
+struct S { char c; };
+
+constexpr S raw[6] = { {'a'}, {'b'}, {'c'}, {'d'}, {'e'}, {'f'}, };
+constexpr auto a = to_array(raw);
+
+static_assert(std::is_same>::value,
+  "Incorrect type");
+static_assert(a[0].c == 'a' &&
+  a[1].c == 'b' &&
+  a[2].c == 'c' &&
+  a[3].c == 'd' &&
+  a[4].c == 'e' &&
+  a[5].c == 'f',
+  "Incorrect values");
+  }
+}
Index: test/std/experimental/container/array/creation/make_array.pass.cpp
===
--- test/std/experimental/container/array/creation/make_array.pass.cpp
+++ test/std/experimental/container/array/creation/make_array.pass.cpp
@@ -0,0 +1,61 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// 
+#include 
+#include 
+#include 
+#include 
+
+#define CHECK_ARRAY(a, Ty, ...)   \
+do {  \
+  static_assert(std::is_same::value, \
+#a"'s type is incorrect");\
+  if (a != Ty{{__VA_ARGS__}}) \
+assert(false && #a"'s values are incorrect"); \
+} while(0)
+
+#define STD_ARRAY(T, N) ::std::array
+
+int main() {
+  using std::experimental::make_array;
+
+  // This is the example given in the specification.
+  {
+int i = 1; int &ri = i;
+auto a1 = make_array(i, ri);
+auto a2 = make_array(i, ri, 42L);
+auto a3 = make_array(i, ri);
+auto a4 = make_array();
+
+CHECK_ARRAY(a1, STD_ARRAY(int,  2), 1,  1);
+CHECK_ARRAY(a2, STD_ARRAY(long, 3), 1L, 1L, 42L);
+CHECK_ARRAY(a3, STD_ARRAY(long, 2), 1L, 1L);
+CHECK_ARRAY(a4, STD_ARRAY(long, 0));
+  }
+
+  // Make sure that reference_wrappers can be used when an explicit element
+  // type is given.
+  {
+int i = 1;
+auto with_ref_wrapper = make_array(0, std::reference_wrapper(i));
+CHECK_ARRAY(with_ref_wrapper, STD_ARRAY(int, 2), 0, 1);
+  }
+
+  // Make sure that it works correctly with constexpr.
+  {
+constexpr auto a = make_array(0, 1, 2);
+static_assert(std::is_same>::value
+  && a[0] == 0 && a[1] == 1 && a[2] == 2,
+  "constexpr array was made incorrectly.");
+  }
+}
Index: test/std/experimental/container/array/creation/make_array.fail.cpp
===
--- test/std/experimental/container/array/creation/make_array.fail.cpp
+++ test/std/experimental/container/array/creation/make_array.fail.cpp
@@ -0,0 +1,27 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// 
+#include 
+#include 
+
+static int i = 0;
+
+int main() {
+  using std::experimental::make_array;
+
+  // expected-error@experimental/array:* {{static_assert failed}}
+  au