Re: r300122 - [clang-cl] Make all sanitizer flags available in clang-cl

2017-04-12 Thread Akira Hatanaka via cfe-commits
I think this broke some of the bots.

http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/30152/ 


Could you take a look?
 
> On Apr 12, 2017, at 3:50 PM, Reid Kleckner via cfe-commits 
>  wrote:
> 
> Author: rnk
> Date: Wed Apr 12 17:50:51 2017
> New Revision: 300122
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=300122=rev
> Log:
> [clang-cl] Make all sanitizer flags available in clang-cl
> 
> Summary:
> Use a tablegen let {} block so that new sanitizer flags are available by
> default in all driver modes. This should cut down on time wasted with
> bugs like http://crbug.com/710928.
> 
> Reviewers: vitalybuka, hans
> 
> Subscribers: kcc, llvm-commits
> 
> Differential Revision: https://reviews.llvm.org/D31988
> 
> Modified:
>cfe/trunk/include/clang/Driver/Options.td
>cfe/trunk/test/Driver/fsanitize.c
> 
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300122=300121=300122=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 12 17:50:51 2017
> @@ -778,65 +778,71 @@ def fno_signaling_math : Flag<["-"], "fn
> def fjump_tables : Flag<["-"], "fjump-tables">, Group;
> def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
> Flags<[CC1Option]>,
>   HelpText<"Do not use jump tables for lowering switches">;
> +
> +// Begin sanitizer flags. These should all be core options exposed in all 
> driver
> +// modes.
> +let Flags = [CC1Option, CoreOption] in {
> +
> def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group,
> -   Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
> +   MetaVarName<"">,
>HelpText<"Turn on runtime checks for various forms of 
> undefined "
> "or suspicious behavior. See user manual for 
> available checks">;
> def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, 
> Group,
> -  Flags<[CoreOption]>;
> +  Flags<[CoreOption, DriverOption]>;
> def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
> -  Group, Flags<[CC1Option, 
> CoreOption]>,
> +  Group,
>   HelpText<"Path to blacklist file for sanitizers">;
> def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
>  Group,
>  HelpText<"Don't use blacklist file for 
> sanitizers">;
> def fsanitize_coverage
> : CommaJoined<["-"], "fsanitize-coverage=">,
> -  Group, Flags<[CoreOption]>,
> +  Group,
>   HelpText<"Specify the type of coverage instrumentation for Sanitizers">;
> def fno_sanitize_coverage
> : CommaJoined<["-"], "fno-sanitize-coverage=">,
> -  Group, Flags<[CoreOption]>,
> +  Group, Flags<[CoreOption, DriverOption]>,
>   HelpText<"Disable specified features of coverage instrumentation for "
>"Sanitizers">;
> def fsanitize_memory_track_origins_EQ : Joined<["-"], 
> "fsanitize-memory-track-origins=">,
> -Group, 
> Flags<[CC1Option]>,
> +Group,
> HelpText<"Enable origins tracking in 
> MemorySanitizer">;
> def fsanitize_memory_track_origins : Flag<["-"], 
> "fsanitize-memory-track-origins">,
> - Group, 
> Flags<[CC1Option]>,
> + Group,
>  HelpText<"Enable origins tracking in 
> MemorySanitizer">;
> def fno_sanitize_memory_track_origins : Flag<["-"], 
> "fno-sanitize-memory-track-origins">,
> -Group, 
> Flags<[CC1Option]>,
> +Group,
> +Flags<[CoreOption, DriverOption]>,
> HelpText<"Disable origins tracking in 
> MemorySanitizer">;
> def fsanitize_memory_use_after_dtor : Flag<["-"], 
> "fsanitize-memory-use-after-dtor">,
> - Group, 
> Flags<[CC1Option]>,
> + Group,
>  HelpText<"Enable use-after-destroy 
> detection in MemorySanitizer">;
> def fsanitize_address_field_padding : Joined<["-"], 
> "fsanitize-address-field-padding=">,
> -Group, 
> Flags<[CC1Option]>,
> +Group,
> HelpText<"Level of field padding for 
> AddressSanitizer">;
> def fsanitize_address_use_after_scope : Flag<["-"], 
> "fsanitize-address-use-after-scope">,
> -  

[libcxx] r300175 - Cleanup any_cast failure test

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 13 00:27:55 2017
New Revision: 300175

URL: http://llvm.org/viewvc/llvm-project?rev=300175=rev
Log:
Cleanup any_cast failure test

Modified:

libcxx/trunk/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp

Modified: 
libcxx/trunk/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp?rev=300175=300174=300175=diff
==
--- 
libcxx/trunk/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
 Thu Apr 13 00:27:55 2017
@@ -25,13 +25,30 @@ using std::any_cast;
 int main()
 {
 any a(1);
-any_cast(); // expected-error@any:* 1 {{static_assert failed 
"_ValueType may not be a reference."}}
-any_cast(); // expected-error@any:* 1 {{static_assert failed 
"_ValueType may not be a reference."}}
-any_cast(); // expected-error@any:* 1 {{static_assert 
failed "_ValueType may not be a reference."}}
-any_cast(); // expected-error@any:* 1 {{static_assert 
failed "_ValueType may not be a reference."}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
+
 any const& a2 = a;
-any_cast(); // expected-error@any:* 1 {{static_assert failed 
"_ValueType may not be a reference."}}
-any_cast(); // expected-error@any:* 1 {{static_assert failed 
"_ValueType may not be a reference."}}
-any_cast(); // expected-error@any:* 1 {{static_assert 
failed "_ValueType may not be a reference."}}
-any_cast(); // expected-error@any:* 1 {{static_assert 
failed "_ValueType may not be a reference."}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
+
+// expected-error@any:* 1 {{static_assert failed "_ValueType may not be a 
reference."}}
+any_cast(); // expected-note {{requested here}}
 }


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


[PATCH] D31769: Remove the binders `bind1st`, `bind2nd`, `men_fun`, etc from C++17

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

The `.fail.cpp` tests should use `// UNSUPPORTED: c++98, c++03, c++11, c++14` 
instead of `#error `.

Other than that this LGTM.




Comment at: 
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp:21
+#include "test_macros.h"
+#if TEST_STD_VER <= 14
+#error

`// UNSUPPORTED: c++98, c++03, c++11, c++14`



Comment at: 
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp:21
+#include "test_macros.h"
+#if TEST_STD_VER <= 14
+#error

`// UNSUPPORTED: c++98, c++03, c++11, c++14`



Comment at: 
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp:20
+#include "test_macros.h"
+#if TEST_STD_VER <= 14
+#error

`// UNSUPPORTED: c++98, c++03, c++11, c++14`



Comment at: 
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp:20
+#include "test_macros.h"
+#if TEST_STD_VER <= 14
+#error

`// UNSUPPORTED: c++98, c++03, c++11, c++14`



Comment at: 
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp:21
+#include "test_macros.h"
+#if TEST_STD_VER <= 14
+#error

`// UNSUPPORTED: c++98, c++03, c++11, c++14`



Comment at: 
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp:20
+#include "test_macros.h"
+#if TEST_STD_VER <= 14
+#error

`// UNSUPPORTED: c++98, c++03, c++11, c++14`



Comment at: 
test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp:20
+#include "test_macros.h"
+#if TEST_STD_VER <= 14
+#error

`// UNSUPPORTED: c++98, c++03, c++11, c++14`


https://reviews.llvm.org/D31769



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


[PATCH] D30837: [libcxx] Support for shared_ptr<T()>

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

- Please apply this patch 
 on top of 
yours. It adds tests for the diagnostics produced when the default deleter is 
used.

LGTM other than the inline comments. I'll want to run this by @mclow.lists 
before giving it gets committed though.




Comment at: include/memory:3606
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
+{

I would prefer using an entirely different allocator type, not a specialization 
of `std::allocator`. 

Re-naming this class to `__shared_ptr_dummy_rebind_allocator` and moving it 
closer to `__shared_ptr_default_allocator` would be  good.


https://reviews.llvm.org/D30837



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


[PATCH] D31887: [clangd] Add documentation page

2017-04-12 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson updated this revision to Diff 95078.
malaperle-ericsson added a comment.

Fix mention of "extra Clang tools"


https://reviews.llvm.org/D31887

Files:
  docs/clangd.rst
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -25,6 +25,7 @@
modularize
pp-trace
clang-rename
+   clangd
 
 
 Doxygen Documentation
Index: docs/clangd.rst
===
--- /dev/null
+++ docs/clangd.rst
@@ -0,0 +1,94 @@
+
+Clangd
+
+
+.. contents::
+
+.. toctree::
+   :maxdepth: 1
+
+:program:`clangd` is an implementation of the `Language Server Protocol `_ leveraging Clang.
+Clangd's goal is to provide language "smartness" features like code completion, find references, etc. for clients such as C/C++ Editors.
+
+Using Clangd
+==
+
+:program:`Clangd` is not meant to be used by C/C++ developers directly but rather from a client implementing the protocol.
+A client would be typically implemented in an IDE or an editor.
+
+At the moment, `Visual Studio Code `_ is mainly used
+in order to test :program:`Clangd`` but more clients are likely to make use of :program:`Clangd`` in the
+future as it matures and becomes a production quality tool. If you are interested
+in trying :program:`Clangd`` in combination with Visual Studio Code, you can start by `building Clangd`_,
+then open Visual Studio Code in the clangd-vscode folder and launch the extension.
+
+Building Clangd
+==
+
+You can follow the instructions for `building Clang `_ but "extra Clang tools" is **not** optional.
+
+Current Status
+==
+
+Many features could be implemented in :program:`Clangd``.
+Here is a list of features that could be useful with the status of whether or
+not they are already implemented in :program:`Clangd`` and specified in the Language Server Protocol.
+Note that for some of the features, it is not clear whether or not they should be part of the
+Language Server Protocol, so those features might be eventually developed outside :program:`Clangd``.
+
++-++--+
+| C/C++ Editor feature|  LSP   |  Clangd  |
++=++==+
+| Formatting  | Yes|   Yes|
++-++--+
+| Completion  | Yes|   Yes|
++-++--+
+| Diagnostics | Yes|   Yes|
++-++--+ 
+| Fix-its | Yes|   Yes|
++-++--+
+| Go to Definition| Yes|   No |
++-++--+
+| Source hover| Yes|   No |
++-++--+
+| Signature Help  | Yes|   No |
++-++--+
+| Find References | Yes|   No |
++-++--+
+| Document Highlights | Yes|   No |
++-++--+
+| Rename  | Yes|   No |
++-++--+
+| Code Lens   | Yes|   No |
++-++--+
+| Syntax and Semantic Coloring| No |   No |
++-++--+
+| Code folding| No |   No |
++-++--+
+| Call hierarchy  | No |   No |
++-++--+
+| Type hierarchy  | No |   No |
++-++--+
+| Organize Includes   | No |   No |
++-++--+
+| Quick Assist| No |   No |
++-++--+
+| Extract Local Variable  | No |   No |
++-++--+
+| Extract Function/Method | No |   No |
++-++--+
+| Hide Method

Re: [PATCH] [PPC64]: Add support for Swift calling convention

2017-04-12 Thread Andrew Jeffery via cfe-commits
On Wed, 2017-04-12 at 14:01 -0700, Adrian Prantl wrote:
> Is it possible to add a testcase for this?

I will look into it.

Thanks for the review!

Andrew

> 
> -- adrian
> 
> 
> > On Mar 22, 2017, at 5:00 AM, Andrew Jeffery via cfe-commits 
> >  wrote:
> > 
> > > > Signed-off-by: Andrew Jeffery 
> > ---
> > lib/Basic/Targets.cpp  | 11 +++
> > lib/CodeGen/TargetInfo.cpp | 14 --
> > 2 files changed, 23 insertions(+), 2 deletions(-)
> > 
> > diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
> > index fdedd91a3e15..6d7f37f2479a 100644
> > --- a/lib/Basic/Targets.cpp
> > +++ b/lib/Basic/Targets.cpp
> > @@ -1708,6 +1708,17 @@ public:
> > }
> > return false;
> >   }
> > +
> > +  CallingConvCheckResult checkCallingConvention(CallingConv CC) const 
> > override {
> > +switch (CC) {
> > +case CC_C:
> > +case CC_Swift:
> > +return CCCR_OK;
> > +default:
> > +break;
> > +}
> > +return CCCR_Warning;
> > +  }
> > };
> > 
> > class DarwinPPC32TargetInfo : public DarwinTargetInfo {
> > diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
> > index d2fc3888ef29..6193f6c4ac29 100644
> > --- a/lib/CodeGen/TargetInfo.cpp
> > +++ b/lib/CodeGen/TargetInfo.cpp
> > @@ -4175,7 +4175,7 @@ 
> > PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction 
> > ,
> > 
> > namespace {
> > /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
> > -class PPC64_SVR4_ABIInfo : public ABIInfo {
> > +class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
> > public:
> >   enum ABIKind {
> > ELFv1 = 0,
> > @@ -4219,7 +4219,7 @@ private:
> > public:
> >   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes , ABIKind Kind, bool HasQPX,
> >  bool SoftFloatABI)
> > -  : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
> > +  : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
> > IsSoftFloatABI(SoftFloatABI) {}
> > 
> >   bool isPromotableTypeForABI(QualType Ty) const;
> > @@ -4262,6 +4262,16 @@ public:
> > 
> >   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
> > QualType Ty) const override;
> > +
> > +  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
> > +ArrayRef scalars,
> > +bool asReturnValue) const override {
> > +return occupiesMoreThan(CGT, scalars, /*total*/ 4);
> > +  }
> > +
> > +  bool isSwiftErrorInRegister() const override {
> > +return true;
> > +  }
> > };
> > 
> > class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
> > -- 
> > 2.9.3
> > 
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
> 

signature.asc
Description: This is a digitally signed message part
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D31591: Fix a bug which access nullptr and cause segmentation fault

2017-04-12 Thread Rui Ueyama via cfe-commits
It seems to me the test have already been simplified enough, so I'm not
quite sure what you are trying to do more than this. Isn't this just ready
to submit?

On Wed, Apr 12, 2017 at 5:46 PM, Yuka Takahashi via Phabricator <
revi...@reviews.llvm.org> wrote:

> yamaguchi updated this revision to Diff 95064.
> yamaguchi added a comment.
>
> I've been trying to minimal the testcase, add comments to describe what it
> is testing, and fix styles of the testcase properly.
> However, I don't have clear idea what will be the best. I would like to
> ask for the advice.
>
>
> https://reviews.llvm.org/D31591
>
> Files:
>   lib/Sema/SemaInit.cpp
>   test/Sema/designated-initializers.c
>
>
> Index: lib/Sema/SemaInit.cpp
> ===
> --- lib/Sema/SemaInit.cpp
> +++ lib/Sema/SemaInit.cpp
> @@ -2269,15 +2269,17 @@
>assert(StructuredList->getNumInits() == 1
>   && "A union should never have more than one
> initializer!");
>
> -  // We're about to throw away an initializer, emit warning.
> -  SemaRef.Diag(D->getFieldLoc(),
> -   diag::warn_initializer_overrides)
> -<< D->getSourceRange();
>Expr *ExistingInit = StructuredList->getInit(0);
> -  SemaRef.Diag(ExistingInit->getLocStart(),
> -   diag::note_previous_initializer)
> -<< /*FIXME:has side effects=*/0
> -<< ExistingInit->getSourceRange();
> +  if (ExistingInit) {
> +// We're about to throw away an initializer, emit warning.
> +SemaRef.Diag(D->getFieldLoc(),
> + diag::warn_initializer_overrides)
> +  << D->getSourceRange();
> +SemaRef.Diag(ExistingInit->getLocStart(),
> + diag::note_previous_initializer)
> +  << /*FIXME:has side effects=*/0
> +  << ExistingInit->getSourceRange();
> +  }
>
>// remove existing initializer
>StructuredList->resizeInits(SemaRef.Context, 0);
> Index: test/Sema/designated-initializers.c
> ===
> --- test/Sema/designated-initializers.c
> +++ test/Sema/designated-initializers.c
> @@ -351,3 +351,20 @@
>{ { 'f', 'o', 'o' }, 1 },
>[0].L[4] = 'x' // no-warning
>  };
> +
> +struct {
> +  struct { } s1;
> +  union {
> +int a;
> +int b;
> +  } u1;
> +} s = {
> +  .s1 = {
> +.x = 0, // expected-error{{field designator}}
> +  },
> +
> +  .u1 = {
> +.a = 0,
> +.b = 0,
> +  },
> +};
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300153 - [IR] Take func, ret, and arg attrs separately in AttributeList::get

2017-04-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Apr 12 19:58:09 2017
New Revision: 300153

URL: http://llvm.org/viewvc/llvm-project?rev=300153=rev
Log:
[IR] Take func, ret, and arg attrs separately in AttributeList::get

This seems like a much more natural API, based on Derek Schuff's
comments on r300015. It further hides the implementation detail of
AttributeList that function attributes come last and appear at index
~0U, which is easy for the user to screw up. git diff says it saves code
as well: 97 insertions(+), 137 deletions(-)

This also makes it easier to change the implementation, which I want to
do next.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=300153=300152=300153=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Apr 12 19:58:09 2017
@@ -2935,12 +2935,9 @@ static void replaceUsesOfNonProtoConstan
   continue;
 
 // Get the call site's attribute list.
-SmallVector newAttrs;
+SmallVector newArgAttrs;
 llvm::AttributeList oldAttrs = callSite.getAttributes();
 
-// Collect any return attributes from the call.
-newAttrs.push_back(oldAttrs.getRetAttributes());
-
 // If the function was passed too few arguments, don't transform.
 unsigned newNumArgs = newFn->arg_size();
 if (callSite.arg_size() < newNumArgs) continue;
@@ -2949,21 +2946,19 @@ static void replaceUsesOfNonProtoConstan
 // If any of the types mismatch, we don't transform.
 unsigned argNo = 0;
 bool dontTransform = false;
-for (llvm::Function::arg_iterator ai = newFn->arg_begin(),
-   ae = newFn->arg_end(); ai != ae; ++ai, ++argNo) {
-  if (callSite.getArgument(argNo)->getType() != ai->getType()) {
+for (llvm::Argument  : newFn->args()) {
+  if (callSite.getArgument(argNo)->getType() != A.getType()) {
 dontTransform = true;
 break;
   }
 
   // Add any parameter attributes.
-  newAttrs.push_back(oldAttrs.getParamAttributes(argNo + 1));
+  newArgAttrs.push_back(oldAttrs.getParamAttributes(argNo + 1));
+  argNo++;
 }
 if (dontTransform)
   continue;
 
-newAttrs.push_back(oldAttrs.getFnAttributes());
-
 // Okay, we can transform this.  Create the new call instruction and copy
 // over the required information.
 newArgs.append(callSite.arg_begin(), callSite.arg_begin() + argNo);
@@ -2987,8 +2982,9 @@ static void replaceUsesOfNonProtoConstan
 
 if (!newCall->getType()->isVoidTy())
   newCall->takeName(callSite.getInstruction());
-newCall.setAttributes(
-llvm::AttributeList::get(newFn->getContext(), newAttrs));
+newCall.setAttributes(llvm::AttributeList::get(
+newFn->getContext(), oldAttrs.getFnAttributes(),
+oldAttrs.getRetAttributes(), newArgAttrs));
 newCall.setCallingConv(callSite.getCallingConv());
 
 // Finally, remove the old call, replacing any uses with the new one.


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


[libcxx] r300152 - Fix the default constructibility of __compressed_pair.

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 19:50:45 2017
New Revision: 300152

URL: http://llvm.org/viewvc/llvm-project?rev=300152=rev
Log:
Fix the default constructibility of __compressed_pair.

This patch fixes a bug where the =default default ctor for
__compressed_pair was incorrect for const qualified types.

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=300152=300151=300152=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Apr 12 19:50:45 2017
@@ -2079,7 +2079,13 @@ struct __compressed_pair_elem {
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  __compressed_pair_elem() = default;
+  template , _Dummy>::value
+>::type
+  >
+  _LIBCPP_CONSTEXPR __compressed_pair_elem()
+  _NOEXCEPT_(is_nothrow_default_constructible<_Tp>::value)
+: __value_() {}
 
   template ::value>::type>
@@ -2112,7 +2118,7 @@ struct __compressed_pair_elem<_Tp, _Idx,
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  __compressed_pair_elem() = default;
+  _LIBCPP_CONSTEXPR __compressed_pair_elem() = default;
 
   template ::value>::type>


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


[libcxx] r300165 - Fix template >> within C++03 code

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 21:56:03 2017
New Revision: 300165

URL: http://llvm.org/viewvc/llvm-project?rev=300165=rev
Log:
Fix template >> within C++03 code

Modified:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp?rev=300165=300164=300165=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp
 Wed Apr 12 21:56:03 2017
@@ -36,7 +36,7 @@ public:
 
 void check(int i);
 
-template >
+template  >
 struct B {
   std::unique_ptr a_;
   B();


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


[libcxx] r300164 - Diagnose when reverse_iterator is used on path::iterator.

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 21:54:13 2017
New Revision: 300164

URL: http://llvm.org/viewvc/llvm-project?rev=300164=rev
Log:
Diagnose when reverse_iterator is used on path::iterator.

path::iterator isn't a strictly conforming iterator. Specifically
it stashes the current element inside the iterator. This leads to
UB when used with reverse_iterator since it requires the element
to outlive the lifetime of the iterator.

This patch adds a static_assert inside reverse_iterator to disallow
"stashing iterator types", and it tags path::iterator as such a type.

Additionally this patch removes all uses of reverse_iterator
within the tests.

Added:

libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp
Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/include/iterator

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

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=300164=300163=300164=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Wed Apr 12 21:54:13 2017
@@ -1092,20 +1092,12 @@ class _LIBCPP_TYPE_VIS path::iterator
 public:
 typedef bidirectional_iterator_tag iterator_category;
 
-// FIXME: As of 3/April/2017 Clang warns on `value_type` shadowing the
-// definition in path. Clang should be fixed and this should be removed.
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wshadow"
-#endif
 typedef path   value_type;
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
 typedef std::ptrdiff_t difference_type;
 typedef const path*pointer;
 typedef const path&reference;
+
+typedef void __stashing_iterator_tag; // See reverse_iterator and 
__is_stashing_iterator
 public:
 _LIBCPP_INLINE_VISIBILITY
 iterator() : __stashed_elem_(), __path_ptr_(nullptr),

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=300164=300163=300164=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Wed Apr 12 21:54:13 2017
@@ -615,6 +615,14 @@ prev(_BidiretionalIter __x,
 return __x;
 }
 
+
+template 
+struct __is_stashing_iterator : false_type {};
+
+template 
+struct __is_stashing_iterator<_Tp, typename __void_t::type>
+  : true_type {};
+
 template 
 class _LIBCPP_TEMPLATE_VIS reverse_iterator
 : public iterator::iterator_category,
@@ -625,6 +633,11 @@ class _LIBCPP_TEMPLATE_VIS reverse_itera
 {
 private:
 /*mutable*/ _Iter __t;  // no longer used as of LWG #2360, not removed due 
to ABI break
+
+static_assert(!__is_stashing_iterator<_Iter>::value,
+  "The specified iterator type cannot be used with reverse_iterator; "
+  "Using stashing iterators with reverse_iterator causes undefined 
behavior");
+
 protected:
 _Iter current;
 public:

Added: 
libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp?rev=300164=auto
==
--- 
libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/experimental/filesystem/class.path/path.itr/reverse_iterator_produces_diagnostic.fail.cpp
 Wed Apr 12 21:54:13 2017
@@ -0,0 +1,31 @@
+//===--===//
+//
+// 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
+
+// 
+
+// class path
+
+#include 
+#include 
+
+
+namespace fs = std::experimental::filesystem;
+
+int main() {
+  using namespace fs;
+  using RIt = std::reverse_iterator;
+
+  // expected-error@iterator:* {{static_assert failed "The specified iterator 
type cannot be used with reverse_iterator; Using stashing iterators with 
reverse_iterator causes undefined behavior"}}
+  {
+RIt r;
+((void)r);
+  }
+}

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.decompose/path.decompose.pass.cpp
URL: 

[libcxx] r300159 - Fix C++03 test failures

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 20:13:58 2017
New Revision: 300159

URL: http://llvm.org/viewvc/llvm-project?rev=300159=rev
Log:
Fix C++03 test failures

Modified:
libcxx/trunk/include/memory

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=300159=300158=300159=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Apr 12 20:13:58 2017
@@ -2154,7 +2154,7 @@ class __compressed_pair : private __comp
   // is *almost never* used in a scenario where it's possible for T1 == T2.
   // (The exception is std::function where it is possible that the function
   //  object and the allocator have the same type).
-  static_assert(!is_same<_T1, _T2>::value,
+  static_assert((!is_same<_T1, _T2>::value),
 "__compressed_pair cannot be instantated when T1 and T2 are the same type; 
"
 "The current implementation is NOT ABI-compatible with the previous "
 "implementation for this configuration");

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp?rev=300159=300158=300159=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp
 Wed Apr 12 20:13:58 2017
@@ -19,7 +19,7 @@
 #include 
 #include "test_macros.h"
 
-#if defined(_LIBCPP_VERSION)
+#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11
 _LIBCPP_SAFE_STATIC std::unique_ptr global_static_unique_ptr;
 #endif
 

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp?rev=300159=300158=300159=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp
 Wed Apr 12 20:13:58 2017
@@ -29,7 +29,7 @@
 
 #include "deleter_types.h"
 
-#if defined(_LIBCPP_VERSION)
+#if defined(_LIBCPP_VERSION) && TEST_STD_VER >= 11
 _LIBCPP_SAFE_STATIC std::unique_ptr global_static_unique_ptr;
 #endif
 


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


[libcxx] r300158 - Add tests that std::unique_ptr's default constructor is constexpr.

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 20:11:58 2017
New Revision: 300158

URL: http://llvm.org/viewvc/llvm-project?rev=300158=rev
Log:
Add tests that std::unique_ptr's default constructor is constexpr.

std::unique_ptr's default constructor must be constexpr in order
to allow constant initialization to take place for static objects;
Even though we can never have a constexpr unique_ptr variable since
it's not a literal type.

This patch adds tests that constant initialization takes place by
using the __attribute__((require_constant_initialization)) macro.

Added:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp
  - copied, changed from r300156, 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default_allows_incomplete.pass.cpp
  - copied, changed from r300156, 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
Removed:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
Modified:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp

Copied: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp
 (from r300156, 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp?p2=libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp=libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp=300156=300158=300158=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default.pass.cpp
 Wed Apr 12 20:11:58 2017
@@ -17,31 +17,34 @@
 
 #include 
 #include 
+#include "test_macros.h"
 
-class Deleter
-{
-int state_;
+#if defined(_LIBCPP_VERSION)
+_LIBCPP_SAFE_STATIC std::unique_ptr global_static_unique_ptr;
+#endif
 
-Deleter(Deleter&);
-Deleter& operator=(Deleter&);
+class Deleter {
+  int state_;
+
+  Deleter(Deleter&);
+  Deleter& operator=(Deleter&);
 
 public:
-Deleter() : state_(5) {}
+  Deleter() : state_(5) {}
 
-int state() const {return state_;}
+  int state() const { return state_; }
 
-void operator()(void*) {}
+  void operator()(void*) {}
 };
 
-int main()
-{
-{
+int main() {
+  {
 std::unique_ptr p;
 assert(p.get() == 0);
-}
-{
+  }
+  {
 std::unique_ptr p;
 assert(p.get() == 0);
 assert(p.get_deleter().state() == 5);
-}
+  }
 }

Removed: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp?rev=300157=auto
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
 (removed)
@@ -1,47 +0,0 @@
-//===--===//
-//
-// 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.
-//
-//===--===//
-
-// 
-
-// unique_ptr
-
-// Test unique_ptr default ctor
-
-// default unique_ptr ctor should only require default Deleter ctor
-
-#include 
-#include 
-
-class Deleter
-{
-int state_;
-
-Deleter(Deleter&);
-Deleter& operator=(Deleter&);
-
-public:
-Deleter() : state_(5) {}
-
-int state() const {return state_;}
-
-void operator()(void*) {}
-};
-
-int main()
-{
-{
-std::unique_ptr p;
-assert(p.get() == 0);
-}
-{
-std::unique_ptr p;
-assert(p.get() == 0);
-assert(p.get_deleter().state() == 5);
-}
-}

Removed: 

[libcxx] r300154 - Fix more bad member swap definitions in unordered_map.

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 20:02:41 2017
New Revision: 300154

URL: http://llvm.org/viewvc/llvm-project?rev=300154=rev
Log:
Fix more bad member swap definitions in unordered_map.

The __unordered_map_equal and __unordered_map_hash wrappers
attempt to swap const qualified predicates whenever the predicate
is empty, and is subject to the EBO.

Swapping const values seems blatently incorrect. This patch removes
the const qualifier so the values are swapped as non-const.

Modified:
libcxx/trunk/include/unordered_map

Modified: libcxx/trunk/include/unordered_map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=300154=300153=300154=diff
==
--- libcxx/trunk/include/unordered_map (original)
+++ libcxx/trunk/include/unordered_map Wed Apr 12 20:02:41 2017
@@ -404,7 +404,7 @@ public:
 _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
 {
 using _VSTD::swap;
-swap(static_cast(*this), static_cast(__y));
+swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
 }
 };
 
@@ -475,7 +475,7 @@ public:
 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
 {
 using _VSTD::swap;
-swap(static_cast(*this), static_cast(__y));
+swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
 }
 };
 


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


[libcxx] r300156 - Update tests -verify error messages after r300140.

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 20:03:41 2017
New Revision: 300156

URL: http://llvm.org/viewvc/llvm-project?rev=300156=rev
Log:
Update tests -verify error messages after r300140.

Modified:

libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp

Modified: 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp?rev=300156=300155=300156=diff
==
--- 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 Wed Apr 12 20:03:41 2017
@@ -53,7 +53,7 @@ int main() {
   // FIXME: It would be great to suppress the below diagnostic all together.
   //but for now it's sufficient that it appears last. However there is
   //currently no way to test the order diagnostics are issued.
-  // expected-error@memory:* {{call to implicitly-deleted default constructor 
of 'std::__1::hash >'}}
+  // expected-error@memory:* {{call to implicitly-deleted default constructor 
of '__compressed_pair_elem}}
   }
   {
 using Set = std::unordered_set;


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


[PATCH] D31562: [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:680
+  // likely due to the scope at in which this function is called.
+  auto *VD = Result.getAsSingle();
+  if (!VD) {

@rsmith is this the correct way to build a `DeclRefExpr` to an existing global?


https://reviews.llvm.org/D31562



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


[PATCH] D31562: [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 95074.
EricWF added a comment.
This revision is now accepted and ready to land.

- Add call to `MarkDeclRefReferenced` even though it doesn't prevent the 
assertion.


https://reviews.llvm.org/D31562

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/CoroutineBuilder.h
  lib/Sema/SemaCoroutine.cpp
  test/CodeGenCoroutines/coro-alloc.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -654,6 +654,18 @@
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
 
+namespace std {
+  struct nothrow_t {};
+  constexpr nothrow_t nothrow = {};
+}
+
+using SizeT = decltype(sizeof(int));
+
+void* operator new(SizeT __sz, const std::nothrow_t&) noexcept;
+void  operator delete(void* __p, const std::nothrow_t&) noexcept;
+
+
+
 struct promise_on_alloc_failure_tag {};
 
 template<>
@@ -694,3 +706,24 @@
 }
 template coro dependent_private_alloc_failure_handler(bad_promise_11);
 // expected-note@-1 {{requested here}}
+
+struct bad_promise_12 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void unhandled_exception();
+  void return_void();
+  static coro get_return_object_on_allocation_failure();
+
+  static void* operator new(SizeT);
+  // expected-error@-1 2 {{'operator new' is required to have a non-throwing noexcept specification when the promise type declares 'get_return_object_on_allocation_failure()'}}
+};
+coro throwing_in_class_new() { // expected-note {{call to 'operator new' implicitly required by coroutine function here}}
+  co_return;
+}
+
+template 
+coro dependent_throwing_in_class_new(T) { // expected-note {{call to 'operator new' implicitly required by coroutine function here}}
+   co_return;
+}
+template coro dependent_throwing_in_class_new(bad_promise_12); // expected-note {{requested here}}
Index: test/CodeGenCoroutines/coro-alloc.cpp
===
--- test/CodeGenCoroutines/coro-alloc.cpp
+++ test/CodeGenCoroutines/coro-alloc.cpp
@@ -19,8 +19,19 @@
   coroutine_handle(coroutine_handle) {}
 };
 
-}
-}
+} // end namespace experimental
+
+struct nothrow_t {};
+constexpr nothrow_t nothrow = {};
+
+} // end namespace std
+
+// Required when get_return_object_on_allocation_failure() is defined by
+// the promise.
+using SizeT = decltype(sizeof(int));
+void* operator new(SizeT __sz, const std::nothrow_t&) noexcept;
+void  operator delete(void* __p, const std::nothrow_t&) noexcept;
+
 
 struct suspend_always {
   bool await_ready() { return false; }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -454,7 +454,7 @@
  /*IsImplicit*/ true);
 Suspend = S.ActOnFinishFullExpr(Suspend.get());
 if (Suspend.isInvalid()) {
-  S.Diag(Loc, diag::note_coroutine_promise_call_implicitly_required)
+  S.Diag(Loc, diag::note_coroutine_promise_suspend_implicitly_required)
   << ((Name == "initial_suspend") ? 0 : 1);
   S.Diag(KWLoc, diag::note_declared_coroutine_here) << Keyword;
   return StmtError();
@@ -660,6 +660,43 @@
   return Res;
 }
 
+/// Look up the std::nothrow object.
+static Expr *buildStdNoThrowDeclRef(Sema , SourceLocation Loc) {
+  NamespaceDecl *Std = S.getStdNamespace();
+  assert(Std && "Should already be diagnosed");
+
+  LookupResult Result(S, ().get("nothrow"), Loc,
+  Sema::LookupOrdinaryName);
+  if (!S.LookupQualifiedName(Result, Std)) {
+// FIXME:  should have been included already.
+// If we require it to include  then this diagnostic is no longer
+// needed.
+S.Diag(Loc, diag::err_implicit_coroutine_std_nothrow_type_not_found);
+return nullptr;
+  }
+
+  // FIXME: Mark the variable as ODR used. This currently does not work
+  // likely due to the scope at in which this function is called.
+  auto *VD = Result.getAsSingle();
+  if (!VD) {
+Result.suppressDiagnostics();
+// We found something weird. Complain about the first thing we found.
+NamedDecl *Found = *Result.begin();
+S.Diag(Found->getLocation(), diag::err_malformed_std_nothrow);
+return nullptr;
+  }
+
+  ExprResult DR = S.BuildDeclRefExpr(VD, VD->getType(), VK_LValue, Loc);
+  if (DR.isInvalid())
+return nullptr;
+
+  // FIXME: This doesn't work. The assertion `MaybeODRUseExprs.empty()` in
+  // ActOnFinishFunctionBody still fires.
+  S.MarkDeclRefReferenced(cast(DR.get()));
+
+  return DR.get();
+}
+
 // Find an appropriate delete for the promise.
 static FunctionDecl *findDeleteForPromise(Sema , SourceLocation Loc,
   QualType PromiseType) {
@@ -847,23 +884,51 @@
   if (S.RequireCompleteType(Loc, 

r300151 - Fix broken test. We can't assume that 2MB of args is enough to require a response file.

2017-04-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 12 19:46:50 2017
New Revision: 300151

URL: http://llvm.org/viewvc/llvm-project?rev=300151=rev
Log:
Fix broken test. We can't assume that 2MB of args is enough to require a 
response file.

This test has apparently been broken for years, but we never noticed before
because it's a long test and long tests approximately never get run.

Modified:
cfe/trunk/test/Driver/response-file.c

Modified: cfe/trunk/test/Driver/response-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file.c?rev=300151=300150=300151=diff
==
--- cfe/trunk/test/Driver/response-file.c (original)
+++ cfe/trunk/test/Driver/response-file.c Wed Apr 12 19:46:50 2017
@@ -9,11 +9,12 @@
 
 // Check that clang is able to process long response files, routing a long
 // sequence of arguments to other tools by using response files as well.
-// We generate a 2MB response file to be big enough to surpass any system
-// limit.
+// We generate a 2MB response file to attempt to surpass any system limit.
+// But there's no guarantee that we actually will (the system limit could be
+// *huge*), so just check that invoking cc1 succeeds under these conditions.
+//
 // RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt
 // RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG
-// LONG: Arguments passed via response file
 // LONG: extern int it_works;
 
 #ifdef TEST


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


[libcxx] r300148 - Fix most failures caused by r300140

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 19:34:24 2017
New Revision: 300148

URL: http://llvm.org/viewvc/llvm-project?rev=300148=rev
Log:
Fix most failures caused by r300140

r300140 introduced a bunch of failures by changing the internal
interface provided by __compressed_pair. This patch fixes all of
the failures caused by the new interface by changing the existing
code to use it.

In addition to those changes this patch also fixes two separate
issues causing test failures:

1) Fix the member swap definition for __map_value_compare. Previously
   the swap was incorrectly configured to swap the comparator as const.

2) Fix an assertion failure in futures.task.members/ctor_func_alloc.pass.cpp
that incorrectly expected a move to take place when a single copy is sufficient.

There is one remaining failure regarding make_shared. I'll commit a fix for that
shortly.

Modified:
libcxx/trunk/include/__split_buffer
libcxx/trunk/include/__tree
libcxx/trunk/include/map

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp

Modified: libcxx/trunk/include/__split_buffer
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__split_buffer?rev=300148=300147=300148=diff
==
--- libcxx/trunk/include/__split_buffer (original)
+++ libcxx/trunk/include/__split_buffer Wed Apr 12 19:34:24 2017
@@ -361,7 +361,7 @@ __split_buffer<_Tp, _Allocator>::__split
 
 template 
 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const 
__alloc_rr& __a)
-: __end_cap_(__a)
+: __end_cap_(__second_tag(), __a)
 {
 if (__a == __c.__alloc())
 {

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=300148=300147=300148=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Wed Apr 12 19:34:24 2017
@@ -1502,7 +1502,7 @@ __tree<_Tp, _Compare, _Allocator>::__tre
 template 
 __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
 : __begin_node_(__iter_pointer()),
-  __pair1_(__node_allocator(__a)),
+  __pair1_(__second_tag(), __node_allocator(__a)),
   __pair3_(0)
 {
 __begin_node() = __end_node();
@@ -1512,7 +1512,7 @@ template ::__tree(const value_compare& __comp,
const allocator_type& __a)
 : __begin_node_(__iter_pointer()),
-  __pair1_(__node_allocator(__a)),
+  __pair1_(__second_tag(), __node_allocator(__a)),
   __pair3_(0, __comp)
 {
 __begin_node() = __end_node();
@@ -1669,7 +1669,7 @@ __tree<_Tp, _Compare, _Allocator>::__ass
 template 
 __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
 : __begin_node_(__iter_pointer()),
-  
__pair1_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),
+  __pair1_(__second_tag(), 
__node_traits::select_on_container_copy_construction(__t.__node_alloc())),
   __pair3_(0, __t.value_comp())
 {
 __begin_node() = __end_node();
@@ -1699,7 +1699,7 @@ __tree<_Tp, _Compare, _Allocator>::__tre
 
 template 
 __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& 
__a)
-: __pair1_(__node_allocator(__a)),
+: __pair1_(__second_tag(), __node_allocator(__a)),
   __pair3_(0, _VSTD::move(__t.value_comp()))
 {
 if (__a == __t.__alloc())

Modified: libcxx/trunk/include/map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=300148=300147=300148=diff
==
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Wed Apr 12 19:34:24 2017
@@ -480,8 +480,8 @@ public:
 void swap(__map_value_compare&__y)
 _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
 {
-using _VSTD::swap;
-swap(static_cast(*this), static_cast(__y));
+  using _VSTD::swap;
+  swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));
 }
 
 #if _LIBCPP_STD_VER > 11

Modified: 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp?rev=300148=300147=300148=diff
==
--- 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
 Wed Apr 12 19:34:24 2017
@@ -69,7 +69,7 @@ int main()
 p(3, 'a');
 assert(f.get() == 105.0);
 assert(A::n_copies > 0);
-assert(A::n_moves > 0);
+assert(A::n_moves >= 0);
 }
 assert(test_alloc_base::alloc_count == 0);
 

[PATCH] D31591: Fix a bug which access nullptr and cause segmentation fault

2017-04-12 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 95064.
yamaguchi added a comment.

I've been trying to minimal the testcase, add comments to describe what it is 
testing, and fix styles of the testcase properly. 
However, I don't have clear idea what will be the best. I would like to ask for 
the advice.


https://reviews.llvm.org/D31591

Files:
  lib/Sema/SemaInit.cpp
  test/Sema/designated-initializers.c


Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -2269,15 +2269,17 @@
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // We're about to throw away an initializer, emit warning.
-  SemaRef.Diag(D->getFieldLoc(),
-   diag::warn_initializer_overrides)
-<< D->getSourceRange();
   Expr *ExistingInit = StructuredList->getInit(0);
-  SemaRef.Diag(ExistingInit->getLocStart(),
-   diag::note_previous_initializer)
-<< /*FIXME:has side effects=*/0
-<< ExistingInit->getSourceRange();
+  if (ExistingInit) {
+// We're about to throw away an initializer, emit warning.
+SemaRef.Diag(D->getFieldLoc(),
+ diag::warn_initializer_overrides)
+  << D->getSourceRange();
+SemaRef.Diag(ExistingInit->getLocStart(),
+ diag::note_previous_initializer)
+  << /*FIXME:has side effects=*/0
+  << ExistingInit->getSourceRange();
+  }
 
   // remove existing initializer
   StructuredList->resizeInits(SemaRef.Context, 0);
Index: test/Sema/designated-initializers.c
===
--- test/Sema/designated-initializers.c
+++ test/Sema/designated-initializers.c
@@ -351,3 +351,20 @@
   { { 'f', 'o', 'o' }, 1 },
   [0].L[4] = 'x' // no-warning
 };
+
+struct {
+  struct { } s1;
+  union {
+int a;
+int b;
+  } u1;
+} s = {
+  .s1 = {
+.x = 0, // expected-error{{field designator}}
+  },
+
+  .u1 = {
+.a = 0,
+.b = 0,
+  },
+};


Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -2269,15 +2269,17 @@
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // We're about to throw away an initializer, emit warning.
-  SemaRef.Diag(D->getFieldLoc(),
-   diag::warn_initializer_overrides)
-<< D->getSourceRange();
   Expr *ExistingInit = StructuredList->getInit(0);
-  SemaRef.Diag(ExistingInit->getLocStart(),
-   diag::note_previous_initializer)
-<< /*FIXME:has side effects=*/0
-<< ExistingInit->getSourceRange();
+  if (ExistingInit) {
+// We're about to throw away an initializer, emit warning.
+SemaRef.Diag(D->getFieldLoc(),
+ diag::warn_initializer_overrides)
+  << D->getSourceRange();
+SemaRef.Diag(ExistingInit->getLocStart(),
+ diag::note_previous_initializer)
+  << /*FIXME:has side effects=*/0
+  << ExistingInit->getSourceRange();
+  }
 
   // remove existing initializer
   StructuredList->resizeInits(SemaRef.Context, 0);
Index: test/Sema/designated-initializers.c
===
--- test/Sema/designated-initializers.c
+++ test/Sema/designated-initializers.c
@@ -351,3 +351,20 @@
   { { 'f', 'o', 'o' }, 1 },
   [0].L[4] = 'x' // no-warning
 };
+
+struct {
+  struct { } s1;
+  union {
+int a;
+int b;
+  } u1;
+} s = {
+  .s1 = {
+.x = 0, // expected-error{{field designator}}
+  },
+
+  .u1 = {
+.a = 0,
+.b = 0,
+  },
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300145 - ExternalASTMerger.cpp: Silence another warning. [-Wunused-lambda-capture]

2017-04-12 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Apr 12 19:17:28 2017
New Revision: 300145

URL: http://llvm.org/viewvc/llvm-project?rev=300145=rev
Log:
ExternalASTMerger.cpp: Silence another warning. [-Wunused-lambda-capture]

Modified:
cfe/trunk/lib/AST/ExternalASTMerger.cpp

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=300145=300144=300145=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Wed Apr 12 19:17:28 2017
@@ -178,6 +178,7 @@ void ExternalASTMerger::FindExternalLexi
 IP.Forward->Import(const_cast(SourceDecl));
 assert(ImportedDecl->getDeclContext() == DC);
 (void)ImportedDecl;
+(void)DC;
   }
 }
   });


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


Re: [libcxx] r300140 - [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-12 Thread Eric Fiselier via cfe-commits
This broke a bunch of bots. Fix incoming. Please don't revert.

On Wed, Apr 12, 2017 at 5:45 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Apr 12 18:45:53 2017
> New Revision: 300140
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300140=rev
> Log:
> [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple
> times, and add constexpr.
>
> Summary:
> __compressed_pair takes and passes it's constructor arguments by value.
> This causes arguments to be moved 3 times instead of once. This patch
> addresses that issue and fixes `constexpr` on the constructors.
>
> I would rather have this fix than D27564, and I'm fairly confident it's
> not ABI breaking but I'm not 100% sure.
>
> I prefer this solution because it removes a lot of code and makes the
> implementation *much* smaller.
>
> Reviewers: mclow.lists, K-ballo
>
> Reviewed By: K-ballo
>
> Subscribers: K-ballo, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D27565
>
> Modified:
> libcxx/trunk/include/__hash_table
> libcxx/trunk/include/memory
> libcxx/trunk/include/string
> libcxx/trunk/test/std/utilities/memory/unique.ptr/
> unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
>
> Modified: libcxx/trunk/include/__hash_table
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/_
> _hash_table?rev=300140=300139=300140=diff
> 
> ==
> --- libcxx/trunk/include/__hash_table (original)
> +++ libcxx/trunk/include/__hash_table Wed Apr 12 18:45:53 2017
> @@ -1402,7 +1402,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
> const key_equal&
> __eql,
> const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0, __hf),
>__p3_(1.0f, __eql)
>  {
> @@ -1411,7 +1411,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
>  template 
>  __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0),
>__p3_(1.0f)
>  {
> @@ -1423,7 +1423,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
>__bucket_list_deleter(allocator_traits<__pointer_allocator>::
>select_on_container_copy_construction(
>__u.__bucket_list_.get_deleter().__alloc()), 0)),
> -  __p1_(allocator_traits<__node_allocator>::
> +  __p1_(__second_tag(), allocator_traits<__node_allocator>::
>select_on_container_copy_construction(__u.__node_alloc())),
>__p2_(0, __u.hash_function()),
>__p3_(__u.__p3_)
> @@ -1434,7 +1434,7 @@ template   __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const
> __hash_table& __u,
> const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0, __u.hash_function()),
>__p3_(__u.__p3_)
>  {
> @@ -1468,7 +1468,7 @@ template   __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&&
> __u,
> const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0, _VSTD::move(__u.hash_function())),
>__p3_(_VSTD::move(__u.__p3_))
>  {
>
> Modified: libcxx/trunk/include/memory
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> memory?rev=300140=300139=300140=diff
> 
> ==
> --- libcxx/trunk/include/memory (original)
> +++ libcxx/trunk/include/memory Wed Apr 12 18:45:53 2017
> @@ -653,7 +653,7 @@ void* align(size_t alignment, size_t siz
>  #include 
>  #include 
>  #include 
> -
> +#include 
>  #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
>  #  include 
>  #endif
> @@ -2070,307 +2070,174 @@ public:
>  };
>  #endif
>
> -template  remove_cv<_T1>::type,
> - typename
> remove_cv<_T2>::type>::value,
> -bool = is_empty<_T1>::value
> -   && !__libcpp_is_final<_T1>::value,
> -bool = is_empty<_T2>::value
> -   && !__libcpp_is_final<_T2>::value
> - >
> -struct __libcpp_compressed_pair_switch;
> -
> 

[libcxx] r300132 - Fix test failures with older Clang versions

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 18:17:17 2017
New Revision: 300132

URL: http://llvm.org/viewvc/llvm-project?rev=300132=rev
Log:
Fix test failures with older Clang versions

Modified:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp?rev=300132=300131=300132=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
 Wed Apr 12 18:17:17 2017
@@ -18,6 +18,8 @@
 #include "test_macros.h"
 
 struct Deleter {
+  Deleter() {}
+
   void operator()(void*) const {}
 
   int test() { return 5; }

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp?rev=300132=300131=300132=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
 Wed Apr 12 18:17:17 2017
@@ -18,6 +18,8 @@
 #include "test_macros.h"
 
 struct Deleter {
+  Deleter() {}
+
   void operator()(void*) const {}
 
   int test() { return 5; }


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


[libcxx] r300140 - [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 18:45:53 2017
New Revision: 300140

URL: http://llvm.org/viewvc/llvm-project?rev=300140=rev
Log:
[libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, 
and add constexpr.

Summary:
__compressed_pair takes and passes it's constructor arguments by value. This 
causes arguments to be moved 3 times instead of once. This patch addresses that 
issue and fixes `constexpr` on the constructors.

I would rather have this fix than D27564, and I'm fairly confident it's not ABI 
breaking but I'm not 100% sure.

I prefer this solution because it removes a lot of code and makes the 
implementation *much* smaller.

Reviewers: mclow.lists, K-ballo

Reviewed By: K-ballo

Subscribers: K-ballo, cfe-commits

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

Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/memory
libcxx/trunk/include/string

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=300140=300139=300140=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Wed Apr 12 18:45:53 2017
@@ -1402,7 +1402,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
const key_equal& __eql,
const allocator_type& 
__a)
 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 
0)),
-  __p1_(__node_allocator(__a)),
+  __p1_(__second_tag(), __node_allocator(__a)),
   __p2_(0, __hf),
   __p3_(1.0f, __eql)
 {
@@ -1411,7 +1411,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 template 
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& 
__a)
 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 
0)),
-  __p1_(__node_allocator(__a)),
+  __p1_(__second_tag(), __node_allocator(__a)),
   __p2_(0),
   __p3_(1.0f)
 {
@@ -1423,7 +1423,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
   __bucket_list_deleter(allocator_traits<__pointer_allocator>::
   select_on_container_copy_construction(
   __u.__bucket_list_.get_deleter().__alloc()), 0)),
-  __p1_(allocator_traits<__node_allocator>::
+  __p1_(__second_tag(), allocator_traits<__node_allocator>::
   select_on_container_copy_construction(__u.__node_alloc())),
   __p2_(0, __u.hash_function()),
   __p3_(__u.__p3_)
@@ -1434,7 +1434,7 @@ template ::__hash_table(const __hash_table& __u,
const allocator_type& 
__a)
 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 
0)),
-  __p1_(__node_allocator(__a)),
+  __p1_(__second_tag(), __node_allocator(__a)),
   __p2_(0, __u.hash_function()),
   __p3_(__u.__p3_)
 {
@@ -1468,7 +1468,7 @@ template ::__hash_table(__hash_table&& __u,
const allocator_type& 
__a)
 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 
0)),
-  __p1_(__node_allocator(__a)),
+  __p1_(__second_tag(), __node_allocator(__a)),
   __p2_(0, _VSTD::move(__u.hash_function())),
   __p3_(_VSTD::move(__u.__p3_))
 {

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=300140=300139=300140=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Apr 12 18:45:53 2017
@@ -653,7 +653,7 @@ void* align(size_t alignment, size_t siz
 #include 
 #include 
 #include 
-
+#include 
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 #  include 
 #endif
@@ -2070,307 +2070,174 @@ public:
 };
 #endif
 
-template ::type,
- typename 
remove_cv<_T2>::type>::value,
-bool = is_empty<_T1>::value
-   && !__libcpp_is_final<_T1>::value,
-bool = is_empty<_T2>::value
-   && !__libcpp_is_final<_T2>::value
- >
-struct __libcpp_compressed_pair_switch;
-
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum 
{value = 0};};
+template ::value && !__libcpp_is_final<_Tp>::value>
+struct __compressed_pair_elem {
+  typedef _Tp _ParamT;
+  typedef _Tp& reference;
+  typedef const _Tp& const_reference;
 
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false>  {enum 
{value = 1};};
-
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true>  {enum 
{value = 2};};
-

[PATCH] D27565: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 95058.
EricWF marked an inline comment as done.
EricWF added a comment.

- Add a static assertion that the new `__compressed_pair` 
implementation is never used in a way that would be ABI-incompatible with the 
previous one. Specifically add a static assert that `T1 != T2`.  This case 
should never arise because libc++ never uses `__compressed_pair` in a place 
where both element types should be the same. However assert that it doesn't 
occur just to be explicit.


https://reviews.llvm.org/D27565

Files:
  include/__hash_table
  include/memory
  include/string
  
test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp

Index: test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
===
--- test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
+++ test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
@@ -15,24 +15,25 @@
 
 // default unique_ptr ctor should require default Deleter ctor
 
-
 #include 
+#include "test_macros.h"
 
-class Deleter
-{
-// expected-error@memory:* {{base class 'Deleter' has private default constructor}}
-// expected-note@memory:* + {{in instantiation of member function}}
-Deleter() {} // expected-note {{implicitly declared private here}}
+class Deleter {
+  Deleter() {}
 
 public:
+  Deleter(Deleter&) {}
+  Deleter& operator=(Deleter&) { return *this; }
 
-Deleter(Deleter&) {}
-Deleter& operator=(Deleter&) { return *this; }
-
-void operator()(void*) const {}
+  void operator()(void*) const {}
 };
 
-int main()
-{
-std::unique_ptr p;
+int main() {
+#if TEST_STD_VER >= 11
+  // expected-error@memory:* {{call to implicitly-deleted default constructor}}
+  // expected-note@memory:* {{implicitly deleted because base class 'Deleter' has an inaccessible default constructor}}
+#else
+  // expected-error@memory:* {{base class 'Deleter' has private default constructor}}
+#endif
+  std::unique_ptr p; // expected-note {{requested here}}
 }
Index: include/string
===
--- include/string
+++ include/string
@@ -1511,7 +1511,7 @@
 #else
 _NOEXCEPT
 #endif
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
@@ -1582,7 +1582,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
 __init(__s, traits_type::length(__s));
@@ -1605,7 +1605,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
 __init(__s, __n);
@@ -1616,7 +1616,7 @@
 
 template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
-: __r_(__alloc_traits::select_on_container_copy_construction(__str.__alloc()))
+: __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
 {
 if (!__str.__is_long())
 __r_.first().__r = __str.__r_.first().__r;
@@ -1630,7 +1630,7 @@
 template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(
 const basic_string& __str, const allocator_type& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 if (!__str.__is_long())
 __r_.first().__r = __str.__r_.first().__r;
@@ -1664,7 +1664,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
 __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
@@ -1719,7 +1719,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 __init(__n, __c);
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1731,7 +1731,7 @@
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
 size_type __pos, size_type __n,
 const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 size_type __str_sz = __str.size();
 if (__pos > __str_sz)
@@ -1746,7 

[PATCH] D27565: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-12 Thread Agustín Bergé via Phabricator via cfe-commits
K-ballo accepted this revision.
K-ballo added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D27565



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


r300136 - Update to match LLVM r300135.

2017-04-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 12 18:21:25 2017
New Revision: 300136

URL: http://llvm.org/viewvc/llvm-project?rev=300136=rev
Log:
Update to match LLVM r300135.

Remove "REQUIRES: long_tests" from test/Driver/response-file.c since it is now 
about 10x faster. (We can add that back if it's still too slow for some 
buildbot.)

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/response-file.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=300136=300135=300136=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Apr 12 18:21:25 2017
@@ -1684,7 +1684,8 @@ Darwin::TranslateArgs(const DerivedArgLi
   A = *it;
   assert(A->getOption().getID() == options::OPT_static &&
  "missing expected -static argument");
-  it = DAL->getArgs().erase(it);
+  *it = nullptr;
+  ++it;
 }
   }
 

Modified: cfe/trunk/test/Driver/response-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file.c?rev=300136=300135=300136=diff
==
--- cfe/trunk/test/Driver/response-file.c (original)
+++ cfe/trunk/test/Driver/response-file.c Wed Apr 12 18:21:25 2017
@@ -1,5 +1,3 @@
-// REQUIRES: long_tests
-
 // Check that clang is able to process short response files
 // Since this is a short response file, clang must not use a response file
 // to pass its parameters to other tools. This is only necessary for a large


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


[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-04-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: lib/Sema/SemaDeclObjC.cpp:4309
+  const ObjCMethodDecl *Method) {
+  SourceLocation Loc;
+  QualType T;

Maybe add an assert for `Triple.getArch() == llvm::Triple::x86)` here?


Repository:
  rL LLVM

https://reviews.llvm.org/D28670



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


[PATCH] D31996: Make Gentoo GNU GCC Config override whitespace tolerant

2017-04-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 95054.
erichkeane added a comment.

Oops, yeah, good suggestion.


https://reviews.llvm.org/D31996

Files:
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2173,6 +2173,7 @@
 SmallVector Lines;
 File.get()->getBuffer().split(Lines, "\n");
 for (StringRef Line : Lines) {
+  Line = Line.trim();
   // CURRENT=triple-version
   if (Line.consume_front("CURRENT=")) {
 const std::pair ActiveVersion =


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2173,6 +2173,7 @@
 SmallVector Lines;
 File.get()->getBuffer().split(Lines, "\n");
 for (StringRef Line : Lines) {
+  Line = Line.trim();
   // CURRENT=triple-version
   if (Line.consume_front("CURRENT=")) {
 const std::pair ActiveVersion =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers

2017-04-12 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 95053.
vsk edited the summary of this revision.
vsk added a comment.

Eli pointed out that it's possible to make alignment checks for extern globals 
work better (llvm.org/PR32630). One solution depends on emitting alignment 
checks on bases of member expressions which are DeclRefExprs. I updated this 
patch so that we'll continue to do that. PTAL.


https://reviews.llvm.org/D30283

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/ubsan-global-alignment.cpp
  test/CodeGenCXX/ubsan-suppress-checks.cpp
  test/CodeGenCXX/ubsan-suppress-null-checks.cpp
  test/CodeGenCXX/ubsan-type-checks.cpp

Index: test/CodeGenCXX/ubsan-type-checks.cpp
===
--- test/CodeGenCXX/ubsan-type-checks.cpp
+++ test/CodeGenCXX/ubsan-type-checks.cpp
@@ -5,8 +5,8 @@
 struct A {
   // COMMON-LABEL: define linkonce_odr void @_ZN1A10do_nothingEv
   void do_nothing() {
-// ALIGN-NOT: ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
-// ALIGN-NOT: and i64 %{{.*}}, 7, !nosanitize
+// ALIGN: ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
+// ALIGN: and i64 %{{.*}}, 0, !nosanitize
  
 // NULL: icmp ne %struct.A* %{{.*}}, null, !nosanitize
  
Index: test/CodeGenCXX/ubsan-suppress-null-checks.cpp
===
--- test/CodeGenCXX/ubsan-suppress-null-checks.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null -DCHECK_LAMBDA | FileCheck %s --check-prefix=LAMBDA
-
-struct A {
-  int foo;
-
-  // CHECK-LABEL: define linkonce_odr void @_ZN1A10do_nothingEv
-  void do_nothing() {
-// CHECK: icmp ne %struct.A* %[[THIS1:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS1]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
-// CHECK-NOT: call void @__ubsan_handle_type_mismatch
-// CHECK: ret void
-  }
-
-#ifdef CHECK_LAMBDA
-  // LAMBDA-LABEL: define linkonce_odr void @_ZN1A22do_nothing_with_lambdaEv
-  void do_nothing_with_lambda() {
-// LAMBDA: icmp ne %struct.A* %[[THIS2:[a-z0-9]+]], null, !nosanitize
-// LAMBDA: ptrtoint %struct.A* %[[THIS2]] to i64, !nosanitize
-// LAMBDA-NEXT: call void @__ubsan_handle_type_mismatch
-
-auto f = [&] {
-  foo = 0;
-};
-f();
-
-// LAMBDA: ret void
-  }
-
-// Check the IR for the lambda:
-//
-// LAMBDA-LABEL: define linkonce_odr void @_ZZN1A22do_nothing_with_lambdaEvENKUlvE_clEv
-// LAMBDA: call void @__ubsan_handle_type_mismatch
-// LAMBDA-NOT: call void @__ubsan_handle_type_mismatch
-// LAMBDA: ret void
-#endif
-
-  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11load_memberEv
-  int load_member() {
-// CHECK: icmp ne %struct.A* %[[THIS3:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS3]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
-// CHECK-NOT: call void @__ubsan_handle_type_mismatch
-return foo;
-// CHECK: ret i32
-  }
-
-  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11call_methodEv
-  int call_method() {
-// CHECK: icmp ne %struct.A* %[[THIS4:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS4]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
-// CHECK-NOT: call void @__ubsan_handle_type_mismatch
-return load_member();
-// CHECK: ret i32
-  }
-
-  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_1Ev
-  void assign_member_1() {
-// CHECK: icmp ne %struct.A* %[[THIS5:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS5]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
-// CHECK-NOT: call void @__ubsan_handle_type_mismatch
-foo = 0;
-// CHECK: ret void
-  }
-
-  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_2Ev
-  void assign_member_2() {
-// CHECK: icmp ne %struct.A* %[[THIS6:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS6]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
-// CHECK-NOT: call void @__ubsan_handle_type_mismatch
-(__extension__ (this))->foo = 0;
-// CHECK: ret void
-  }
-
-  // CHECK-LABEL: define linkonce_odr void @_ZNK1A15assign_member_3Ev
-  void assign_member_3() const {
-// CHECK: icmp ne %struct.A* %[[THIS7:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS7]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
-// CHECK-NOT: call void @__ubsan_handle_type_mismatch
-const_cast(this)->foo = 0;
-// CHECK: ret void
-  }
-
-  // CHECK-LABEL: define linkonce_odr i32 

[PATCH] D31996: Make Gentoo GNU GCC Config override whitespace tolerant

2017-04-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.cpp:2176
 for (StringRef Line : Lines) {
+  StringRef TrimLine = Line.trim();
   // CURRENT=triple-version

Can we just do

Line = Line.trim()

so we won't have an extra StringRef and no one can misuse the untrimmed on in 
the future.


https://reviews.llvm.org/D31996



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


[libcxx] r300126 - [libc++] Implement LWG 2911 - add an is_aggregate type-trait

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 18:08:46 2017
New Revision: 300126

URL: http://llvm.org/viewvc/llvm-project?rev=300126=rev
Log:
[libc++] Implement LWG 2911 - add an is_aggregate type-trait

Summary:
This patch implements http://cplusplus.github.io/LWG/lwg-defects.html#2911.

I'm putting this up for review until __is_aggregate is added to clang (See 
D31513)

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

Added:

libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/type_traits
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=300126=300125=300126=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Apr 12 18:08:46 2017
@@ -25,8 +25,12 @@
 
 #ifdef __GNUC__
 #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme
+// introduced in GCC 5.0.
+#define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__)
 #else
 #define _GNUC_VER 0
+#define _GNUC_VER_NEW 0
 #endif
 
 #define _LIBCPP_VERSION 5000
@@ -1061,7 +1065,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 
 #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
-#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
+# define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
 #endif
 
 #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
@@ -1097,6 +1101,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
 #endif
 
+#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001)
+# define _LIBCPP_HAS_NO_IS_AGGREGATE
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=300126=300125=300126=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Wed Apr 12 18:08:46 2017
@@ -97,6 +97,7 @@ namespace std
 template  struct is_polymorphic;
 template  struct is_abstract;
 template  struct is_final; // C++14
+template  struct is_aggregate; // C++17
 
 template  struct is_constructible;
 template struct is_default_constructible;
@@ -286,6 +287,8 @@ namespace std
 = is_abstract::value; // 
C++17
   template  constexpr bool is_final_v
 = is_final::value;// 
C++17
+  template  constexpr bool is_aggregate_v
+= is_aggregate::value;// 
C++17
   template  constexpr bool is_signed_v
 = is_signed::value;   // 
C++17
   template  constexpr bool is_unsigned_v
@@ -1336,6 +1339,19 @@ template  _LIBCPP_CONSTEXPR b
 = is_final<_Tp>::value;
 #endif
 
+// is_aggregate
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
+
+template  struct _LIBCPP_TEMPLATE_VIS
+is_aggregate : public integral_constant {};
+
+#if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+template 
+constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
+#endif
+
+#endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
+
 // is_base_of
 
 #ifdef _LIBCPP_HAS_IS_BASE_OF

Added: 
libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp?rev=300126=auto
==
--- 
libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp
 Wed Apr 12 18:08:46 2017
@@ -0,0 +1,28 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// 
+
+// template  struct is_aggregate;
+// template  constexpr bool is_aggregate_v = is_aggregate::value;
+
+#include 
+
+int main ()
+{
+#ifdef _LIBCPP_HAS_NO_IS_AGGREGATE
+  // This should not compile 

[PATCH] D27565: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked an inline comment as done.
EricWF added inline comments.



Comment at: include/memory:2058
 
-template ::type,
- typename 
remove_cv<_T2>::type>::value,
-bool = is_empty<_T1>::value
-   && !__libcpp_is_final<_T1>::value,
-bool = is_empty<_T2>::value
-   && !__libcpp_is_final<_T2>::value
- >
-struct __libcpp_compressed_pair_switch;
-
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum 
{value = 0};};
-
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false>  {enum 
{value = 1};};
-
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true>  {enum 
{value = 2};};
-
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true>{enum 
{value = 3};};
-
-template 
-struct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true> {enum 
{value = 1};};
-
-template ::value>
-class __libcpp_compressed_pair_imp;
+template ::value
+   && !__libcpp_is_final<_Tp>::value>

K-ballo wrote:
> Should be `_IsEmpty`
Changed to `_CanBeEmptyBase`.



Comment at: include/memory:2063
+  typedef typename remove_reference<_Tp>::type& reference;
+  typedef const typename remove_reference<_Tp>::type& const_reference;
 

K-ballo wrote:
> If `_Tp` can actually be a reference type, turning it into reference to const 
> here doesn't seem right
Agreed. Fixed by correctly collapsing `T&` -> `T&` instead of `T const&`



Comment at: include/memory:2110
+  _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u)
+  : __value_(_VSTD::forward<_Up>(__u)) {};
 

K-ballo wrote:
> This use of `__value_` as a type is overly smart, consider just using `_Tp` 
> for clarity
Changed to `__value_type` instead.


https://reviews.llvm.org/D27565



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


[PATCH] D31996: Make Gentoo GNU GCC Config override whitespace tolerant

2017-04-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

The config-*triple* file handling isn't tolerant of leading/trailing 
whitespace, making it not terribly obvious when a single extraneous 
tab/space/etc will cause the override to be ignored.  This patch simply trims 
the lines to ensure that it is tolerant of whitespace.


https://reviews.llvm.org/D31996

Files:
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2173,10 +2173,11 @@
 SmallVector Lines;
 File.get()->getBuffer().split(Lines, "\n");
 for (StringRef Line : Lines) {
+  StringRef TrimLine = Line.trim();
   // CURRENT=triple-version
-  if (Line.consume_front("CURRENT=")) {
+  if (TrimLine.consume_front("CURRENT=")) {
 const std::pair ActiveVersion =
-  Line.rsplit('-');
+  TrimLine.rsplit('-');
 // Note: Strictly speaking, we should be reading
 // /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
 // contain anything new or especially useful to us.


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2173,10 +2173,11 @@
 SmallVector Lines;
 File.get()->getBuffer().split(Lines, "\n");
 for (StringRef Line : Lines) {
+  StringRef TrimLine = Line.trim();
   // CURRENT=triple-version
-  if (Line.consume_front("CURRENT=")) {
+  if (TrimLine.consume_front("CURRENT=")) {
 const std::pair ActiveVersion =
-  Line.rsplit('-');
+  TrimLine.rsplit('-');
 // Note: Strictly speaking, we should be reading
 // /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
 // contain anything new or especially useful to us.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27565: [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 95051.
EricWF marked 2 inline comments as done.
EricWF added a comment.

- Address all inline comments.


https://reviews.llvm.org/D27565

Files:
  include/__hash_table
  include/memory
  include/string
  
test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp

Index: test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
===
--- test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
+++ test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
@@ -15,24 +15,25 @@
 
 // default unique_ptr ctor should require default Deleter ctor
 
-
 #include 
+#include "test_macros.h"
 
-class Deleter
-{
-// expected-error@memory:* {{base class 'Deleter' has private default constructor}}
-// expected-note@memory:* + {{in instantiation of member function}}
-Deleter() {} // expected-note {{implicitly declared private here}}
+class Deleter {
+  Deleter() {}
 
 public:
+  Deleter(Deleter&) {}
+  Deleter& operator=(Deleter&) { return *this; }
 
-Deleter(Deleter&) {}
-Deleter& operator=(Deleter&) { return *this; }
-
-void operator()(void*) const {}
+  void operator()(void*) const {}
 };
 
-int main()
-{
-std::unique_ptr p;
+int main() {
+#if TEST_STD_VER >= 11
+  // expected-error@memory:* {{call to implicitly-deleted default constructor}}
+  // expected-note@memory:* {{implicitly deleted because base class 'Deleter' has an inaccessible default constructor}}
+#else
+  // expected-error@memory:* {{base class 'Deleter' has private default constructor}}
+#endif
+  std::unique_ptr p; // expected-note {{requested here}}
 }
Index: include/string
===
--- include/string
+++ include/string
@@ -1511,7 +1511,7 @@
 #else
 _NOEXCEPT
 #endif
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
@@ -1582,7 +1582,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
 __init(__s, traits_type::length(__s));
@@ -1605,7 +1605,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
 __init(__s, __n);
@@ -1616,7 +1616,7 @@
 
 template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
-: __r_(__alloc_traits::select_on_container_copy_construction(__str.__alloc()))
+: __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
 {
 if (!__str.__is_long())
 __r_.first().__r = __str.__r_.first().__r;
@@ -1630,7 +1630,7 @@
 template 
 basic_string<_CharT, _Traits, _Allocator>::basic_string(
 const basic_string& __str, const allocator_type& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 if (!__str.__is_long())
 __r_.first().__r = __str.__r_.first().__r;
@@ -1664,7 +1664,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
 __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
@@ -1719,7 +1719,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 __init(__n, __c);
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1731,7 +1731,7 @@
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
 size_type __pos, size_type __n,
 const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 size_type __str_sz = __str.size();
 if (__pos > __str_sz)
@@ -1746,7 +1746,7 @@
 inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
 const _Allocator& __a)
-: __r_(__a)
+: __r_(__second_tag(), __a)
 {
 size_type __str_sz = __str.size();
 if (__pos > __str_sz)
@@ -1762,7 +1762,7 @@
 

[libcxx] r300124 - Additional test file for r300123

2017-04-12 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Apr 12 17:51:56 2017
New Revision: 300124

URL: http://llvm.org/viewvc/llvm-project?rev=300124=rev
Log:
Additional test file for r300123

Modified:

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp?rev=300124=300123=300124=diff
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
 Wed Apr 12 17:51:56 2017
@@ -10,7 +10,7 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// template  void optional::emplace(Args&&... args);
+// template  T& optional::emplace(Args&&... args);
 
 #include 
 #include 
@@ -51,27 +51,35 @@ void test_one_arg() {
 using Opt = std::optional;
 {
 Opt opt;
-opt.emplace();
+auto & v = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(0));
+assert( == &*opt);
 }
 {
 Opt opt;
-opt.emplace(1);
+auto & v = opt.emplace(1);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(1));
+assert( == &*opt);
 }
 {
 Opt opt(2);
-opt.emplace();
+auto & v = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(0));
+assert( == &*opt);
 }
 {
 Opt opt(2);
-opt.emplace(1);
+auto & v = opt.emplace(1);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(1));
+assert( == &*opt);
 }
 }
 
@@ -83,20 +91,26 @@ void test_multi_arg()
 using Opt = std::optional;
 {
 Opt opt;
-opt.emplace(101, 41);
+auto  = opt.emplace(101, 41);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
+assert(   v == T(101, 41));
 assert(*opt == T(101, 41));
 }
 {
 Opt opt;
-opt.emplace({1, 2, 3, 4});
+auto  = opt.emplace({1, 2, 3, 4});
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
-assert(*opt == T(4)); // T sets its value to the size of the init list
+assert(  v == T(4)); // T sets its value to the size of the init list
+assert(*opt == T(4));
 }
 {
 Opt opt;
-opt.emplace({1, 2, 3, 4, 5}, 6);
+auto  = opt.emplace({1, 2, 3, 4, 5}, 6);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
+assert(  v == T(5)); // T sets its value to the size of the init list
 assert(*opt == T(5)); // T sets its value to the size of the init list
 }
 }
@@ -109,73 +123,87 @@ void test_on_test_type() {
 assert(T::alive == 0);
 {
 T::reset_constructors();
-opt.emplace();
+auto  = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::default_constructed == 1);
 assert(T::destroyed == 0);
 assert(static_cast(opt) == true);
 assert(*opt == T());
+assert( == &*opt);
 }
 {
 T::reset_constructors();
-opt.emplace();
+auto  = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::default_constructed == 1);
 assert(T::destroyed == 1);
 assert(static_cast(opt) == true);
 assert(*opt == T());
+assert( == &*opt);
 }
 {
 T::reset_constructors();
-opt.emplace(101);
+auto  = opt.emplace(101);
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::value_constructed == 1);
 assert(T::destroyed == 1);
 assert(static_cast(opt) == true);
 assert(*opt == T(101));
+assert( == &*opt);
 }
 {
 T::reset_constructors();
-opt.emplace(-10, 99);
+auto  = opt.emplace(-10, 99);
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::value_constructed == 1);
 

[libcxx] r300123 - Implement part of LWG#2857 - any/optional. Still to do - variant. Reviewed as https://reviews.llvm.org/D31956

2017-04-12 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Apr 12 17:51:27 2017
New Revision: 300123

URL: http://llvm.org/viewvc/llvm-project?rev=300123=rev
Log:
Implement part of LWG#2857 - any/optional. Still to do - variant. Reviewed as 
https://reviews.llvm.org/D31956

Modified:
libcxx/trunk/include/any
libcxx/trunk/include/optional
libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp

Modified: libcxx/trunk/include/any
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/any?rev=300123=300122=300123=diff
==
--- libcxx/trunk/include/any (original)
+++ libcxx/trunk/include/any Wed Apr 12 17:51:27 2017
@@ -45,6 +45,10 @@ namespace std {
   any& operator=(ValueType&& rhs);
 
 // 6.3.3 any modifiers
+template 
+  decay_t& emplace(Args&&... args);
+template 
+  decay_t& emplace(initializer_list, Args&&...);
 void reset() noexcept;
 void swap(any& rhs) noexcept;
 
@@ -73,8 +77,6 @@ namespace std {
   template
 ValueType* any_cast(any* operand) noexcept;
 
-} // namespace fundamentals_v1
-} // namespace experimental
 } // namespace std
 
 */
@@ -258,7 +260,7 @@ public:
 is_copy_constructible<_Tp>::value>
 >
   _LIBCPP_INLINE_VISIBILITY
-  void emplace(_Args&&... args);
+  _Tp& emplace(_Args&&... args);
 
   template ,
@@ -267,7 +269,7 @@ public:
 is_copy_constructible<_Tp>::value>
   >
   _LIBCPP_INLINE_VISIBILITY
-  void emplace(initializer_list<_Up>, _Args&&...);
+  _Tp& emplace(initializer_list<_Up>, _Args&&...);
 
   // 6.3.3 any modifiers
   _LIBCPP_INLINE_VISIBILITY
@@ -364,9 +366,10 @@ namespace __any_imp
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-static void __create(any & __dest, _Args&&... __args) {
-::new (static_cast(&__dest.__s.__buf)) 
_Tp(_VSTD::forward<_Args>(__args)...);
+static _Tp& __create(any & __dest, _Args&&... __args) {
+_Tp* __ret = ::new (static_cast(&__dest.__s.__buf)) 
_Tp(_VSTD::forward<_Args>(__args)...);
 __dest.__h = &_SmallHandler::__handle;
+return *__ret;
 }
 
   private:
@@ -439,14 +442,15 @@ namespace __any_imp
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-static void __create(any & __dest, _Args&&... __args) {
+static _Tp& __create(any & __dest, _Args&&... __args) {
 typedef allocator<_Tp> _Alloc;
 typedef __allocator_destructor<_Alloc> _Dp;
 _Alloc __a;
 unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);
+_Tp* __ret = ::new ((void*)__hold.get()) 
_Tp(_VSTD::forward<_Args>(__args)...);
 __dest.__s.__ptr = __hold.release();
 __dest.__h = &_LargeHandler::__handle;
+return *__ret;
 }
 
   private:
@@ -519,16 +523,16 @@ any & any::operator=(_ValueType && __v)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-void any::emplace(_Args&&... __args) {
+_Tp& any::emplace(_Args&&... __args) {
   reset();
-  __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
+  return __any_imp::_Handler<_Tp>::__create(*this, 
_VSTD::forward<_Args>(__args)...);
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-void any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
+_Tp& any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
   reset();
-  __any_imp::_Handler<_Tp>::__create(*this, __il, 
_VSTD::forward<_Args>(__args)...);
+  return __any_imp::_Handler<_Tp>::__create(*this, __il, 
_VSTD::forward<_Args>(__args)...);
 }
 
 inline _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=300123=300122=300123=diff
==
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Wed Apr 12 17:51:27 2017
@@ -87,7 +87,7 @@ namespace std {
 constexpr optional() noexcept;
 constexpr optional(nullopt_t) noexcept;
 optional(const optional &);
-optional(optional &&) noexcept(see below );
+optional(optional &&) noexcept(see below);
 template  constexpr explicit optional(in_place_t, Args 
&&...);
 template 
   constexpr explicit optional(in_place_t, initializer_list, Args &&...);
@@ -108,9 +108,9 @@ namespace std {
 template  optional =(U &&);
 template  optional =(const optional &);
 template  optional =(optional &&);
-template  void emplace(Args &&...);
+template  T& emplace(Args &&...);
 template 
-  void emplace(initializer_list, Args &&...);
+  T& emplace(initializer_list, Args &&...);
 
 // 20.6.3.4, swap
 void swap(optional &) noexcept(see below );
@@ -729,11 +729,12 @@ public:
   >
  >
 _LIBCPP_INLINE_VISIBILITY
-void
+_Tp &
 emplace(_Args&&... __args)
 {
 reset();
 

r300122 - [clang-cl] Make all sanitizer flags available in clang-cl

2017-04-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Apr 12 17:50:51 2017
New Revision: 300122

URL: http://llvm.org/viewvc/llvm-project?rev=300122=rev
Log:
[clang-cl] Make all sanitizer flags available in clang-cl

Summary:
Use a tablegen let {} block so that new sanitizer flags are available by
default in all driver modes. This should cut down on time wasted with
bugs like http://crbug.com/710928.

Reviewers: vitalybuka, hans

Subscribers: kcc, llvm-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300122=300121=300122=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 12 17:50:51 2017
@@ -778,65 +778,71 @@ def fno_signaling_math : Flag<["-"], "fn
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+
+// Begin sanitizer flags. These should all be core options exposed in all 
driver
+// modes.
+let Flags = [CC1Option, CoreOption] in {
+
 def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group,
-   Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
+   MetaVarName<"">,
HelpText<"Turn on runtime checks for various forms of 
undefined "
 "or suspicious behavior. See user manual for 
available checks">;
 def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, 
Group,
-  Flags<[CoreOption]>;
+  Flags<[CoreOption, DriverOption]>;
 def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
-  Group, Flags<[CC1Option, CoreOption]>,
+  Group,
   HelpText<"Path to blacklist file for sanitizers">;
 def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
  Group,
  HelpText<"Don't use blacklist file for 
sanitizers">;
 def fsanitize_coverage
 : CommaJoined<["-"], "fsanitize-coverage=">,
-  Group, Flags<[CoreOption]>,
+  Group,
   HelpText<"Specify the type of coverage instrumentation for Sanitizers">;
 def fno_sanitize_coverage
 : CommaJoined<["-"], "fno-sanitize-coverage=">,
-  Group, Flags<[CoreOption]>,
+  Group, Flags<[CoreOption, DriverOption]>,
   HelpText<"Disable specified features of coverage instrumentation for "
"Sanitizers">;
 def fsanitize_memory_track_origins_EQ : Joined<["-"], 
"fsanitize-memory-track-origins=">,
-Group, 
Flags<[CC1Option]>,
+Group,
 HelpText<"Enable origins tracking in 
MemorySanitizer">;
 def fsanitize_memory_track_origins : Flag<["-"], 
"fsanitize-memory-track-origins">,
- Group, Flags<[CC1Option]>,
+ Group,
  HelpText<"Enable origins tracking in 
MemorySanitizer">;
 def fno_sanitize_memory_track_origins : Flag<["-"], 
"fno-sanitize-memory-track-origins">,
-Group, 
Flags<[CC1Option]>,
+Group,
+Flags<[CoreOption, DriverOption]>,
 HelpText<"Disable origins tracking in 
MemorySanitizer">;
 def fsanitize_memory_use_after_dtor : Flag<["-"], 
"fsanitize-memory-use-after-dtor">,
- Group, Flags<[CC1Option]>,
+ Group,
  HelpText<"Enable use-after-destroy 
detection in MemorySanitizer">;
 def fsanitize_address_field_padding : Joined<["-"], 
"fsanitize-address-field-padding=">,
-Group, 
Flags<[CC1Option]>,
+Group,
 HelpText<"Level of field padding for 
AddressSanitizer">;
 def fsanitize_address_use_after_scope : Flag<["-"], 
"fsanitize-address-use-after-scope">,
-Group, 
Flags<[CC1Option]>,
+Group,
 HelpText<"Enable use-after-scope 
detection in AddressSanitizer">;
 def fno_sanitize_address_use_after_scope : Flag<["-"], 
"fno-sanitize-address-use-after-scope">,
-   Group, 
Flags<[CC1Option]>,
+   Group,
+   Flags<[CoreOption, 

[libcxx] r300121 - Fix incorrectly qualified return type from unique_ptr::get_deleter().

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 17:43:49 2017
New Revision: 300121

URL: http://llvm.org/viewvc/llvm-project?rev=300121=rev
Log:
Fix incorrectly qualified return type from  unique_ptr::get_deleter().

For reference deleter types the const qualifier on the return type
of get_deleter() should be ignored, and a non-const deleter should
be returned.

This patch fixes a bug where "const deleter_type&" is incorrectly
formed.

Modified:
libcxx/trunk/include/memory

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
libcxx/trunk/test/support/test_macros.h

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=300121=300120=300121=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Apr 12 17:43:49 2017
@@ -2110,8 +2110,8 @@ public:
 typedef typename remove_reference<_T1>::type& _T1_reference;
 typedef typename remove_reference<_T2>::type& _T2_reference;
 
-typedef const typename remove_reference<_T1>::type& _T1_const_reference;
-typedef const typename remove_reference<_T2>::type& _T2_const_reference;
+typedef typename remove_reference::type>::type& 
_T1_const_reference;
+typedef typename remove_reference::type>::type& 
_T2_const_reference;
 
 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), 
__second_() {}
 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param 
__t1)
@@ -2166,7 +2166,8 @@ public:
 typedef typename remove_reference<_T2>::type& _T2_reference;
 
 typedef const _T1&
_T1_const_reference;
-typedef const typename remove_reference<_T2>::type& _T2_const_reference;
+typedef typename remove_reference::type>::type&
+_T2_const_reference;
 
 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {}
 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param 
__t1)
@@ -2219,7 +2220,8 @@ public:
 typedef typename remove_reference<_T1>::type& _T1_reference;
 typedef _T2&_T2_reference;
 
-typedef const typename remove_reference<_T1>::type& _T1_const_reference;
+typedef typename remove_reference::type>::type&
+_T1_const_reference;
 typedef const _T2&
_T2_const_reference;
 
 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {}
@@ -2459,8 +2461,9 @@ private:
 
 struct __nat {int __for_bool_;};
 
-typedef   typename remove_reference::type& _Dp_reference;
-typedef const typename remove_reference::type& 
_Dp_const_reference;
+typedef typename remove_reference::type& _Dp_reference;
+typedef typename remove_reference::type>::type&
+_Dp_const_reference;
 public:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
 : __ptr_(pointer())
@@ -2648,8 +2651,9 @@ private:
 
 struct __nat {int __for_bool_;};
 
-typedef   typename remove_reference::type& _Dp_reference;
-typedef const typename remove_reference::type& 
_Dp_const_reference;
+typedef typename remove_reference::type& _Dp_reference;
+typedef typename remove_reference::type>::type&
+_Dp_const_reference;
 public:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
 : __ptr_(pointer())

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp?rev=300121=300120=300121=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
 Wed Apr 12 17:43:49 2017
@@ -15,23 +15,42 @@
 
 #include 
 #include 
+#include "test_macros.h"
 
-struct Deleter
-{
-void operator()(void*) {}
+struct Deleter {
+  void operator()(void*) const {}
 
-int test() {return 5;}
-int test() const {return 6;}
+  int test() { return 5; }
+  int test() const { return 6; }
 };
 
-int main()
-{
-{
+int main() {
+  {
 std::unique_ptr p;
 assert(p.get_deleter().test() == 5);
-}
-{
+  }
+  {
 const std::unique_ptr p;
 assert(p.get_deleter().test() == 6);
-}
+  }
+  {
+typedef std::unique_ptr UPtr;
+const Deleter d;
+

[PATCH] D31515: [libc++] Implement LWG 2911 - add an is_aggregate type-trait

2017-04-12 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 95041.
EricWF added a comment.

- Add comment explaining `_GNUC_VER_NEW`.


https://reviews.llvm.org/D31515

Files:
  include/__config
  include/type_traits
  
test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp
  test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -480,7 +480,7 @@
 	http://wg21.link/LWG2904;>2904Make variant move-assignment more exception safeKona
 	http://wg21.link/LWG2905;>2905is_constructible_vunique_ptrP, D, P, D const  should be false when D is not copy constructibleKona
 	http://wg21.link/LWG2908;>2908The less-than operator for shared pointers could do moreKona
-	http://wg21.link/LWG2911;>2911An is_aggregate type trait is neededKona
+	http://wg21.link/LWG2911;>2911An is_aggregate type trait is neededKonaComplete
 	http://wg21.link/LWG2921;>2921packaged_task and type-erased allocatorsKona
 	http://wg21.link/LWG2934;>2934optionalconst T doesn't compare with TKonaComplete
 

r300116 - [Sema] Add __is_aggregate type-trait

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 17:12:15 2017
New Revision: 300116

URL: http://llvm.org/viewvc/llvm-project?rev=300116=rev
Log:
[Sema] Add __is_aggregate type-trait

Summary:
[LWG 2911](http://cplusplus.github.io/LWG/lwg-defects.html#2911) adds 
`std::is_aggregate` to the library, which requires a new builtin trait. This 
patch implements `__is_aggregate`.


Reviewers: rsmith, majnemer, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: STL_MSFT, cfe-commits

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

Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Basic/TypeTraits.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/PCH/cxx-traits.cpp
cfe/trunk/test/PCH/cxx-traits.h
cfe/trunk/test/SemaCXX/type-traits.cpp

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=300116=300115=300116=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Wed Apr 12 17:12:15 2017
@@ -993,6 +993,7 @@ The following type trait primitives are
 * ``__has_trivial_destructor`` (GNU, Microsoft)
 * ``__has_virtual_destructor`` (GNU, Microsoft)
 * ``__is_abstract`` (GNU, Microsoft)
+* ``__is_aggregate`` (GNU, Microsoft)
 * ``__is_base_of`` (GNU, Microsoft)
 * ``__is_class`` (GNU, Microsoft)
 * ``__is_convertible_to`` (Microsoft)

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=300116=300115=300116=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed Apr 12 17:12:15 2017
@@ -432,6 +432,7 @@ TYPE_TRAIT_1(__has_trivial_move_construc
 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)
 TYPE_TRAIT_2(__is_base_of, IsBaseOf, KEYCXX)
 TYPE_TRAIT_1(__is_class, IsClass, KEYCXX)
 TYPE_TRAIT_2(__is_convertible_to, IsConvertibleTo, KEYCXX)

Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TypeTraits.h?rev=300116=300115=300116=diff
==
--- cfe/trunk/include/clang/Basic/TypeTraits.h (original)
+++ cfe/trunk/include/clang/Basic/TypeTraits.h Wed Apr 12 17:12:15 2017
@@ -31,6 +31,7 @@ namespace clang {
 UTT_HasTrivialDestructor,
 UTT_HasVirtualDestructor,
 UTT_IsAbstract,
+UTT_IsAggregate,
 UTT_IsArithmetic,
 UTT_IsArray,
 UTT_IsClass,

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=300116=300115=300116=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Wed Apr 12 17:12:15 2017
@@ -1406,6 +1406,7 @@ void Parser::ParseClassSpecifier(tok::To
   !Tok.isAnnotation() &&
   Tok.getIdentifierInfo() &&
   Tok.isOneOf(tok::kw___is_abstract,
+  tok::kw___is_aggregate,
   tok::kw___is_arithmetic,
   tok::kw___is_array,
   tok::kw___is_assignable,

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=300116=300115=300116=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Apr 12 17:12:15 2017
@@ -676,6 +676,7 @@ class CastExpressionIdValidator : public
 ///   '__is_union'
 ///
 /// [Clang] unary-type-trait:
+///   '__is_aggregate'
 ///   '__trivially_copyable'
 ///
 ///   binary-type-trait:
@@ -804,6 +805,7 @@ ExprResult Parser::ParseCastExpression(b
 = RTT_JOIN(tok::kw_,Name)
 
   REVERTIBLE_TYPE_TRAIT(__is_abstract);
+  REVERTIBLE_TYPE_TRAIT(__is_aggregate);
   REVERTIBLE_TYPE_TRAIT(__is_arithmetic);
   REVERTIBLE_TYPE_TRAIT(__is_array);
   REVERTIBLE_TYPE_TRAIT(__is_assignable);

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=300116=300115=300116=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Apr 12 

[clang-tools-extra] r300115 - Fix clang-tidy shared link with libc++

2017-04-12 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Apr 12 17:07:47 2017
New Revision: 300115

URL: http://llvm.org/viewvc/llvm-project?rev=300115=rev
Log:
Fix clang-tidy shared link with libc++

Currently the ClangTidyMain.cpp fails to link against shared LLVM/Clang 
libraries
due to the missing symbol:

  clang::tooling::operator<(clang::tooling::Replacement const&,
clang::tooling::Replacement const&);

This patch fixes the issue by correctly linking clangToolingCore which contains
the definition.

Modified:
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt?rev=300115=300114=300115=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt Wed Apr 12 17:07:47 
2017
@@ -25,6 +25,7 @@ target_link_libraries(clang-tidy
   clangTidyPerformanceModule
   clangTidyReadabilityModule
   clangTooling
+  clangToolingCore
   )
 
 install(TARGETS clang-tidy


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


r300114 - [analyzer] Add a check for IvarRegion in getExtraInvalidatedValues

2017-04-12 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Wed Apr 12 17:00:13 2017
New Revision: 300114

URL: http://llvm.org/viewvc/llvm-project?rev=300114=rev
Log:
[analyzer] Add a check for IvarRegion in getExtraInvalidatedValues

This diff adds a defensive check in getExtraInvalidatedValues
for the case when there are no regions for the ivar associated with
a property. Corresponding test case added.

Test plan:
make check-clang
make check-clang-analysis

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/properties.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=300114=300113=300114=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Wed Apr 12 17:00:13 2017
@@ -695,13 +695,15 @@ void ObjCMethodCall::getExtraInvalidated
   if (const ObjCPropertyDecl *PropDecl = getAccessedProperty()) {
 if (const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) {
   SVal IvarLVal = getState()->getLValue(PropIvar, getReceiverSVal());
-  const MemRegion *IvarRegion = IvarLVal.getAsRegion();
-  ETraits->setTrait(
+  if (const MemRegion *IvarRegion = IvarLVal.getAsRegion()) {
+ETraits->setTrait(
   IvarRegion,
   RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
-  ETraits->setTrait(IvarRegion,
-RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
-  Values.push_back(IvarLVal);
+ETraits->setTrait(
+  IvarRegion,
+  RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
+Values.push_back(IvarLVal);
+  }
   return;
 }
   }

Modified: cfe/trunk/test/Analysis/properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/properties.m?rev=300114=300113=300114=diff
==
--- cfe/trunk/test/Analysis/properties.m (original)
+++ cfe/trunk/test/Analysis/properties.m Wed Apr 12 17:00:13 2017
@@ -987,5 +987,21 @@ void testOpaqueConsistency(OpaqueIntWrap
 }
 
 @end
+
+@interface Wrapper
+@property(nonatomic, readonly) int value;
+@end
+
+@implementation Wrapper
+@synthesize value;
+@end
+
+void testNoCrashWhenAccessPropertyAndThereAreNoDirectBindingsAtAll() {
+   union {
+Wrapper *wrapper;
+   } u = { 0 };
+   [u.wrapper value];
+}
+
 #endif // non-ARC
 


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


[PATCH] D31887: [clangd] Add documentation page

2017-04-12 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added inline comments.



Comment at: docs/clangd.rst:28
+
+You can follow the instructions for `building Clang 
`_ but "extra Clang Tool" is **not** 
optional.
+

In the reference, it is called "extra Clang tools".


https://reviews.llvm.org/D31887



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


r300110 - [modules] Delay calling DeclMustBeEmitted until it's safe.

2017-04-12 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Apr 12 16:56:05 2017
New Revision: 300110

URL: http://llvm.org/viewvc/llvm-project?rev=300110=rev
Log:
[modules] Delay calling DeclMustBeEmitted until it's safe.

This patch implements the suggestion in D29753 that calling DeclMustBeEmitted in
the middle of deserialization should be avoided and that the actual check should
be deferred until it's safe to do so.

This patch fixes a crash when accessing the invalid redecl chains while trying
to evaluate the value of a const VarDecl that contains a function call.

Patch by Raphael Isemann (D30793)!

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=300110=300109=300110=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Apr 12 16:56:05 2017
@@ -984,14 +984,26 @@ private:
   /// \brief The generation number of each identifier, which keeps track of
   /// the last time we loaded information about this identifier.
   llvm::DenseMap IdentifierGeneration;
-  
-  /// \brief Contains declarations and definitions that will be
+
+  class InterestingDecl {
+Decl *D;
+bool DeclHasPendingBody;
+
+  public:
+InterestingDecl(Decl *D, bool HasBody)
+: D(D), DeclHasPendingBody(HasBody) {}
+Decl *getDecl() { return D; }
+/// Whether the declaration has a pending body.
+bool hasPendingBody() { return DeclHasPendingBody; }
+  };
+
+  /// \brief Contains declarations and definitions that could be
   /// "interesting" to the ASTConsumer, when we get that AST consumer.
   ///
   /// "Interesting" declarations are those that have data that may
   /// need to be emitted, such as inline function definitions or
   /// Objective-C protocols.
-  std::deque InterestingDecls;
+  std::deque PotentiallyInterestingDecls;
 
   /// \brief The list of redeclaration chains that still need to be 
   /// reconstructed, and the local offset to the corresponding list

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=300110=300109=300110=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Apr 12 16:56:05 2017
@@ -7234,31 +7234,6 @@ static void PassObjCImplDeclToConsumer(O
   Consumer->HandleInterestingDecl(DeclGroupRef(ImplD));
 }
 
-void ASTReader::PassInterestingDeclsToConsumer() {
-  assert(Consumer);
-
-  if (PassingDeclsToConsumer)
-return;
-
-  // Guard variable to avoid recursively redoing the process of passing
-  // decls to consumer.
-  SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer,
-   true);
-
-  // Ensure that we've loaded all potentially-interesting declarations
-  // that need to be eagerly loaded.
-  for (auto ID : EagerlyDeserializedDecls)
-GetDecl(ID);
-  EagerlyDeserializedDecls.clear();
-
-  while (!InterestingDecls.empty()) {
-Decl *D = InterestingDecls.front();
-InterestingDecls.pop_front();
-
-PassInterestingDeclToConsumer(D);
-  }
-}
-
 void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
   if (ObjCImplDecl *ImplD = dyn_cast(D))
 PassObjCImplDeclToConsumer(ImplD, Consumer);

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=300110=300109=300110=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Apr 12 16:56:05 2017
@@ -3626,12 +3626,37 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
   // AST consumer might need to know about, queue it.
   // We don't pass it to the consumer immediately because we may be in 
recursive
   // loading, and some declarations may still be initializing.
-  if (isConsumerInterestedIn(Context, D, Reader.hasPendingBody()))
-InterestingDecls.push_back(D);
+  PotentiallyInterestingDecls.push_back(
+  InterestingDecl(D, Reader.hasPendingBody()));
 
   return D;
 }
 
+void ASTReader::PassInterestingDeclsToConsumer() {
+  assert(Consumer);
+
+  if (PassingDeclsToConsumer)
+return;
+
+  // Guard variable to avoid recursively redoing the process of passing
+  // decls to consumer.
+  SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer,
+   true);
+
+  // Ensure that we've loaded all potentially-interesting declarations
+  // that need to be eagerly 

[PATCH] D27604: [Driver] Add compiler option to generate a reproducer

2017-04-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300109: [Driver] Add compiler option to generate a 
reproducer (authored by bruno).

Changed prior to commit:
  https://reviews.llvm.org/D27604?vs=80981=95035#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27604

Files:
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/crash-report-crashfile.m
  cfe/trunk/tools/driver/driver.cpp

Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -91,7 +91,7 @@
   CCCPrintBindings(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), DefaultTargetTriple(DefaultTargetTriple),
   CCCGenericGCCName(""), CheckInputsExist(true), CCCUsePCH(true),
-  SuppressMissingInputWarning(false) {
+  GenReproducer(false), SuppressMissingInputWarning(false) {
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
@@ -620,6 +620,9 @@
 CCCGenericGCCName = A->getValue();
   CCCUsePCH =
   Args.hasFlag(options::OPT_ccc_pch_is_pch, options::OPT_ccc_pch_is_pth);
+  GenReproducer = Args.hasFlag(options::OPT_gen_reproducer,
+   options::OPT_fno_crash_diagnostics,
+   !!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"));
   // FIXME: DefaultTargetTriple is used by the target-prefixed calls to as/ld
   // and getToolChain is const.
   if (IsCLMode()) {
Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -460,8 +460,9 @@
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
   // Force a crash to test the diagnostics.
-  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) {
-Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH";
+  if (TheDriver.GenReproducer) {
+Diags.Report(diag::err_drv_force_crash)
+<< !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
 
 // Pretend that every command failed.
 FailingCommands.clear();
Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -562,6 +562,16 @@
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+Clang is also capable of generating preprocessed source file(s) and associated
+run script(s) even without a crash. This is specially useful when trying to
+generate a reproducer for warnings or errors while using modules.
+
+.. option:: -gen-reproducer
+
+  Generates preprocessed source files, a reproducer script and if relevant, a
+  cache containing: built module pcm's and all headers needed to rebuilt the
+  same modules.
+
 .. _rpass:
 
 Options to Emit Optimization Reports
Index: cfe/trunk/include/clang/Driver/Driver.h
===
--- cfe/trunk/include/clang/Driver/Driver.h
+++ cfe/trunk/include/clang/Driver/Driver.h
@@ -216,6 +216,11 @@
   /// Use lazy precompiled headers for PCH support.
   unsigned CCCUsePCH : 1;
 
+  /// Force clang to emit reproducer for driver invocation. This is enabled
+  /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
+  /// or when using the -gen-reproducer driver flag.
+  unsigned GenReproducer : 1;
+
 private:
   /// Certain options suppress the 'no input files' warning.
   unsigned SuppressMissingInputWarning : 1;
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -265,6 +265,8 @@
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">,
   Flags<[CC1Option]>;
+def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
+  HelpText<"Auto-generates preprocessed source files and a reproduction script">;
 
 def _migrate : Flag<["--"], "migrate">, Flags<[DriverOption]>,
   HelpText<"Run the migrator">;
@@ -701,7 +703,8 @@
 def fconstexpr_steps_EQ : Joined<["-"], "fconstexpr-steps=">, Group;
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], "fconstexpr-backtrace-limit=">,
 Group;
-def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, Group, Flags<[NoArgumentUnused]>;
+def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, Group, Flags<[NoArgumentUnused]>,
+  HelpText<"Disable auto-generation of preprocessed source files and a script for 

[PATCH] D31781: [Modules] Allow local submodule visibility without c++

2017-04-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300108: [Modules] Enable local submodule visibility for 
ObjC/C (authored by bruno).

Changed prior to commit:
  https://reviews.llvm.org/D31781?vs=94407=95034#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31781

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Modules/localsubmodulevis.m


Index: cfe/trunk/test/Modules/localsubmodulevis.m
===
--- cfe/trunk/test/Modules/localsubmodulevis.m
+++ cfe/trunk/test/Modules/localsubmodulevis.m
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.a -I %S/Inputs/preprocess 
-verify %s
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.b -I %S/Inputs/preprocess -x c 
-verify -x c %s
+
+// expected-no-diagnostics
+
+#include "file.h"
+
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2117,12 +2117,6 @@
   Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
(Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
 
-  // For now, we only support local submodule visibility in C++ (because we
-  // heavily depend on the ODR for merging redefinitions).
-  if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< "-fmodules-local-submodule-visibility" << "C";
-
   if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
 switch (llvm::StringSwitch(A->getValue())
   .Case("target", LangOptions::ASMM_Target)


Index: cfe/trunk/test/Modules/localsubmodulevis.m
===
--- cfe/trunk/test/Modules/localsubmodulevis.m
+++ cfe/trunk/test/Modules/localsubmodulevis.m
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fimplicit-module-maps -fmodules-cache-path=%t.a -I %S/Inputs/preprocess -verify %s
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fimplicit-module-maps -fmodules-cache-path=%t.b -I %S/Inputs/preprocess -x c -verify -x c %s
+
+// expected-no-diagnostics
+
+#include "file.h"
+
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2117,12 +2117,6 @@
   Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
(Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
 
-  // For now, we only support local submodule visibility in C++ (because we
-  // heavily depend on the ODR for merging redefinitions).
-  if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< "-fmodules-local-submodule-visibility" << "C";
-
   if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
 switch (llvm::StringSwitch(A->getValue())
   .Case("target", LangOptions::ASMM_Target)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300108 - [Modules] Enable local submodule visibility for ObjC/C

2017-04-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 12 16:46:16 2017
New Revision: 300108

URL: http://llvm.org/viewvc/llvm-project?rev=300108=rev
Log:
[Modules] Enable local submodule visibility for ObjC/C

Remove the restriction where this is only valid with C++

rdar://problem/29055656

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

Added:
cfe/trunk/test/Modules/localsubmodulevis.m
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=300108=300107=300108=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 12 16:46:16 2017
@@ -2117,12 +2117,6 @@ static void ParseLangArgs(LangOptions 
   Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
(Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
 
-  // For now, we only support local submodule visibility in C++ (because we
-  // heavily depend on the ODR for merging redefinitions).
-  if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< "-fmodules-local-submodule-visibility" << "C";
-
   if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
 switch (llvm::StringSwitch(A->getValue())
   .Case("target", LangOptions::ASMM_Target)

Added: cfe/trunk/test/Modules/localsubmodulevis.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/localsubmodulevis.m?rev=300108=auto
==
--- cfe/trunk/test/Modules/localsubmodulevis.m (added)
+++ cfe/trunk/test/Modules/localsubmodulevis.m Wed Apr 12 16:46:16 2017
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.a -I %S/Inputs/preprocess 
-verify %s
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.b -I %S/Inputs/preprocess -x c 
-verify -x c %s
+
+// expected-no-diagnostics
+
+#include "file.h"
+


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


r300109 - [Driver] Add compiler option to generate a reproducer

2017-04-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 12 16:46:20 2017
New Revision: 300109

URL: http://llvm.org/viewvc/llvm-project?rev=300109=rev
Log:
[Driver] Add compiler option to generate a reproducer

One way to currently test the reproducers is to setup
"FORCE_CLANG_DIAGNOSTICS_CRASH=1" before invoking clang. This simulates
a crash and produces the same contents needed by the reproducers.  The
reproducers are specially useful when triaging Modules issues, not only
on crashes, but also for reproducing misleading warnings, errors, etc.

Add a '-gen-reproducer' driver option to clang (or any similar name) and
give users a flag option.

Note that clang already has a -fno-crash-diagnostics, which disables the
crash reproducers. I've decided not to propose "-fcrash-diagnostics"
since it doesn't convey the ideia of reproduction despite a crash.

rdar://problem/24114619

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

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/crash-report-crashfile.m
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=300109=300108=300109=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Apr 12 16:46:20 2017
@@ -562,6 +562,16 @@ control the crash diagnostics.
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+Clang is also capable of generating preprocessed source file(s) and associated
+run script(s) even without a crash. This is specially useful when trying to
+generate a reproducer for warnings or errors while using modules.
+
+.. option:: -gen-reproducer
+
+  Generates preprocessed source files, a reproducer script and if relevant, a
+  cache containing: built module pcm's and all headers needed to rebuilt the
+  same modules.
+
 .. _rpass:
 
 Options to Emit Optimization Reports

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=300109=300108=300109=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Apr 12 16:46:20 
2017
@@ -94,7 +94,7 @@ def err_drv_compilationdatabase : Error<
 def err_drv_command_signalled : Error<
   "%0 command failed due to signal (use -v to see invocation)">;
 def err_drv_force_crash : Error<
-  "failing because environment variable '%0' is set">;
+  "failing because %select{environment variable 
'FORCE_CLANG_DIAGNOSTICS_CRASH' is set|'-gen-reproducer' is used}0">;
 def err_drv_invalid_mfloat_abi : Error<
   "invalid float ABI '%0'">;
 def err_drv_invalid_libcxx_deployment : Error<

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=300109=300108=300109=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Wed Apr 12 16:46:20 2017
@@ -216,6 +216,11 @@ public:
   /// Use lazy precompiled headers for PCH support.
   unsigned CCCUsePCH : 1;
 
+  /// Force clang to emit reproducer for driver invocation. This is enabled
+  /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
+  /// or when using the -gen-reproducer driver flag.
+  unsigned GenReproducer : 1;
+
 private:
   /// Certain options suppress the 'no input files' warning.
   unsigned SuppressMissingInputWarning : 1;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300109=300108=300109=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 12 16:46:20 2017
@@ -265,6 +265,8 @@ def arcmt_migrate_report_output : Separa
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">,
   Flags<[CC1Option]>;
+def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
+  HelpText<"Auto-generates preprocessed source files and a reproduction 
script">;
 
 def _migrate : Flag<["--"], "migrate">, Flags<[DriverOption]>,
   HelpText<"Run the migrator">;
@@ -701,7 +703,8 @@ def fconstexpr_depth_EQ : Joined<["-"],
 def fconstexpr_steps_EQ : Joined<["-"], "fconstexpr-steps=">, Group;
 def fconstexpr_backtrace_limit_EQ 

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev planned changes to this revision.
v.g.vassilev added a comment.

We agreed to implement a special switch for this, eg. `-Wunused-template`


https://reviews.llvm.org/D29877



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


r300106 - Modular Codegen: Include testing for inline asm as well as some commentary on the implementaiton choice.

2017-04-12 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Apr 12 16:14:04 2017
New Revision: 300106

URL: http://llvm.org/viewvc/llvm-project?rev=300106=rev
Log:
Modular Codegen: Include testing for inline asm as well as some commentary on 
the implementaiton choice.

Modified:
cfe/trunk/test/Modules/Inputs/codegen/foo.h
cfe/trunk/test/Modules/codegen.test

Modified: cfe/trunk/test/Modules/Inputs/codegen/foo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/codegen/foo.h?rev=300106=300105=300106=diff
==
--- cfe/trunk/test/Modules/Inputs/codegen/foo.h (original)
+++ cfe/trunk/test/Modules/Inputs/codegen/foo.h Wed Apr 12 16:14:04 2017
@@ -28,3 +28,5 @@ inline void inst_decl() {
   (void)sizeof();
   inst();
 }
+
+asm("narf");

Modified: cfe/trunk/test/Modules/codegen.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/codegen.test?rev=300106=300105=300106=diff
==
--- cfe/trunk/test/Modules/codegen.test (original)
+++ cfe/trunk/test/Modules/codegen.test Wed Apr 12 16:14:04 2017
@@ -6,6 +6,20 @@ RUN: %clang_cc1 -triple=x86_64-linux-gnu
 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited 
-o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
 RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited 
-o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck 
--check-prefix=BOTH --check-prefix=USE %s
 
+For want of any better definition, inline asm goes "everywhere" the same as it
+if it were in a header (with the disadvantage that the inline asm will be
+included in the program if the module is used, even if the header containing
+the inline asm is never included - unlike a non-modular build).
+
+This is inconsistent with how namespace scope static variables are handled -
+where they only appear in the code that includes a header. This functionality
+was implemented to workaround/support the initialization of iostreams
+(implemented as a namespace scope static in the header - only to be provided
+when that specific header is included in the program).
+
+FOO: module asm "narf"
+USE: module asm "narf"
+
 FOO: $_Z2f1PKcz = comdat any
 FOO: $_ZN13implicit_dtorD1Ev = comdat any
 USE: $_Z4instIiEvv = comdat any


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


LLVM buildmaster will be updated and restarted tonight

2017-04-12 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time
today.

Thanks

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


r300105 - Fix up test to handle the now split -fmodules-codegen and -fmodules-debuginfo flags

2017-04-12 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Apr 12 16:09:34 2017
New Revision: 300105

URL: http://llvm.org/viewvc/llvm-project?rev=300105=rev
Log:
Fix up test to handle the now split -fmodules-codegen and -fmodules-debuginfo 
flags

Modified:
cfe/trunk/test/Modules/codegen-nodep.test

Modified: cfe/trunk/test/Modules/codegen-nodep.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/codegen-nodep.test?rev=300105=300104=300105=diff
==
--- cfe/trunk/test/Modules/codegen-nodep.test (original)
+++ cfe/trunk/test/Modules/codegen-nodep.test Wed Apr 12 16:09:34 2017
@@ -1,8 +1,8 @@
 RUN: rm -rf %t
 REQUIRES: x86-registered-target
 
-RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules \
-RUN:-emit-module -fmodule-name=foo \
+RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -fmodules-debuginfo 
\
+RUN:-x c++ -fmodules -emit-module -fmodule-name=foo \
 RUN:%S/Inputs/codegen-nodep/foo.modulemap -o - \
 RUN:  | llvm-bcanalyzer - -dump \
 RUN:  | FileCheck %s


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


[PATCH] D31591: Fix a bug which access nullptr and cause segmentation fault

2017-04-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

ping...


https://reviews.llvm.org/D31591



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


r300104 - Modular Codegen: Separate flags for function and debug info support

2017-04-12 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Apr 12 15:58:33 2017
New Revision: 300104

URL: http://llvm.org/viewvc/llvm-project?rev=300104=rev
Log:
Modular Codegen: Separate flags for function and debug info support

This allows using and testing these two features separately. (noteably,
debug info is, so far as I know, always a win (basically). But function
modular codegen is currently a loss for highly optimized code - where
most of the linkonce_odr definitions are optimized away, so providing
weak_odr definitions is only overhead)

Added:
cfe/trunk/test/Modules/Inputs/codegen-flags/
cfe/trunk/test/Modules/Inputs/codegen-flags/foo.h
cfe/trunk/test/Modules/Inputs/codegen-flags/foo.modulemap
cfe/trunk/test/Modules/Inputs/codegen-flags/use.cpp
cfe/trunk/test/Modules/codegen-flags.test
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/codegen.test

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=300104=300103=300104=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Apr 12 15:58:33 2017
@@ -201,7 +201,8 @@ LANGOPT(SizedDeallocation , 1, 0, "sized
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(NewAlignOverride  , 32, 0, "maximum alignment guaranteed by 
'::operator new(size_t)'")
 LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts")
-BENIGN_LANGOPT(ModularCodegen , 1, 0, "Modular codegen")
+BENIGN_LANGOPT(ModulesCodegen , 1, 0, "Modules code generation")
+BENIGN_LANGOPT(ModulesDebugInfo , 1, 0, "Modules debug info")
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
 BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd 
records")
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 
records in a simple form")

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=300104=300103=300104=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Apr 12 15:58:33 2017
@@ -436,10 +436,14 @@ def fmodules_local_submodule_visibility
   Flag<["-"], "fmodules-local-submodule-visibility">,
   HelpText<"Enforce name visibility rules across submodules of the same "
"top-level module.">;
-def fmodule_codegen :
+def fmodules_codegen :
   Flag<["-"], "fmodules-codegen">,
   HelpText<"Generate code for uses of this module that assumes an explicit "
"object file will be built for the module">;
+def fmodules_debuginfo :
+  Flag<["-"], "fmodules-debuginfo">,
+  HelpText<"Generate debug info for types in an object file built from this "
+   "module and do not generate them elsewhere">;
 def fmodule_format_EQ : Joined<["-"], "fmodule-format=">,
   HelpText<"Select the container format for clang modules and PCH. "
"Supported options are 'raw' and 'obj'.">;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=300104=300103=300104=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 12 15:58:33 2017
@@ -2017,7 +2017,8 @@ static void ParseLangArgs(LangOptions 
   Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
   Opts.ModulesLocalVisibility =
   Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS;
-  Opts.ModularCodegen = Args.hasArg(OPT_fmodule_codegen);
+  Opts.ModulesCodegen = Args.hasArg(OPT_fmodules_codegen);
+  Opts.ModulesDebugInfo = Args.hasArg(OPT_fmodules_debuginfo);
   Opts.ModulesSearchAll = Opts.Modules &&
 !Args.hasArg(OPT_fno_modules_search_all) &&
 Args.hasArg(OPT_fmodules_search_all);

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=300104=300103=300104=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Wed Apr 12 15:58:33 2017
@@ -91,7 +91,6 @@ ModuleMap::ModuleMap(SourceManager 
   HeaderInfo(HeaderInfo), BuiltinIncludeDir(nullptr),
   SourceModule(nullptr), NumCreatedModules(0) {
   MMapLangOpts.LineComment = true;
-  MMapLangOpts.ModularCodegen = 

[PATCH] D28832: Improve redefinition errors pointing to the same header.

2017-04-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Here is an example that we recently had where we would be very happy to see 
better diagnostics:

  MessageTypes.h:
  
  #ifndef ROOT_MessageTypes
  #define ROOT_MessageTypes
  
  enum EMessageTypes {
 kROOTD_OPEN   = 2004, //filename follows + mode
  };
  
  #endif
  
  module.modulemap:
  
  module "libNet.so" {
requires cplusplus
module "TMessage.h" { header "TMessage.h" export * }
module "TNetFile.h" { header "TNetFile.h" export * }
export *
  }
  
  Output:
  
  TNetFile.cxx:1:10: remark: building module 'libNet.so' as 
'/home/teemperor/Downloads/merge_enum/pcms/3MNDY7KURXTXS/libNet.so-141H35WZHCMDE.pcm'
 [-Rmodule-build]
  #include "TNetFile.h"
   ^
  TNetFile.cxx:1:10: remark: finished building module 'libNet.so' 
[-Rmodule-build]
  TNetFile.cxx:2:10: error: declaration of 'kROOTD_OPEN' must be imported from 
module 'libNet.so.TMessage.h' before it is required
  auto v = kROOTD_OPEN;
   ^
  In module 'libNet.so' imported from TNetFile.cxx:1:
  ./MessageTypes.h:5:4: note: previous declaration is here
 kROOTD_OPEN   = 2004, //filename follows + mode
 ^
  1 error generated.
  
  test.sh:
  
  #!/bin/bash
  
  CLANG="/opt/clang/inst/bin/clang"
  
  rm -rf ./pcms/
  # Normal clang invocation
  #"$CLANG" -cc1 -triple x86_64-apple-macosx10.11.0 -fsyntax-only -I . 
-std=c++11 -x c++ TNetFile.cxx -nostdsysteminc
  # Modules clang invocation
  "$CLANG" -cc1 -triple x86_64-apple-macosx10.11.0 -fsyntax-only -I . 
-std=c++11  -fmodules  -fimplicit-module-maps -fmodules-cache-path=./pcms/ 
-fcolor-diagnostics -fdiagnostics-show-option 
-fdiagnostics-show-note-include-stack -x c++ TNetFile.cxx -nostdsysteminc 
-Rmodule-build
  
  TMessage.h:
  
  #ifndef ROOT_TMessage
  #define ROOT_TMessage
  #include "MessageTypes.h"
  #endif
  
  TNetFile.cxx:
  
  #include "TNetFile.h"
  auto v = kROOTD_OPEN;
  
  TNetFile.h:
  
  #ifndef ROOT_TNetFile
  #define ROOT_TNetFile
  #include "MessageTypes.h"
  #endif


https://reviews.llvm.org/D28832



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


Re: [PATCH] [PPC64]: Add support for Swift calling convention

2017-04-12 Thread Adrian Prantl via cfe-commits
Is it possible to add a testcase for this?

-- adrian


> On Mar 22, 2017, at 5:00 AM, Andrew Jeffery via cfe-commits 
>  wrote:
> 
> Signed-off-by: Andrew Jeffery 
> ---
> lib/Basic/Targets.cpp  | 11 +++
> lib/CodeGen/TargetInfo.cpp | 14 --
> 2 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
> index fdedd91a3e15..6d7f37f2479a 100644
> --- a/lib/Basic/Targets.cpp
> +++ b/lib/Basic/Targets.cpp
> @@ -1708,6 +1708,17 @@ public:
> }
> return false;
>   }
> +
> +  CallingConvCheckResult checkCallingConvention(CallingConv CC) const 
> override {
> +switch (CC) {
> +case CC_C:
> +case CC_Swift:
> +return CCCR_OK;
> +default:
> +break;
> +}
> +return CCCR_Warning;
> +  }
> };
> 
> class DarwinPPC32TargetInfo : public DarwinTargetInfo {
> diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
> index d2fc3888ef29..6193f6c4ac29 100644
> --- a/lib/CodeGen/TargetInfo.cpp
> +++ b/lib/CodeGen/TargetInfo.cpp
> @@ -4175,7 +4175,7 @@ 
> PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction ,
> 
> namespace {
> /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
> -class PPC64_SVR4_ABIInfo : public ABIInfo {
> +class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
> public:
>   enum ABIKind {
> ELFv1 = 0,
> @@ -4219,7 +4219,7 @@ private:
> public:
>   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes , ABIKind Kind, bool HasQPX,
>  bool SoftFloatABI)
> -  : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
> +  : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
> IsSoftFloatABI(SoftFloatABI) {}
> 
>   bool isPromotableTypeForABI(QualType Ty) const;
> @@ -4262,6 +4262,16 @@ public:
> 
>   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
> QualType Ty) const override;
> +
> +  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
> +ArrayRef scalars,
> +bool asReturnValue) const override {
> +return occupiesMoreThan(CGT, scalars, /*total*/ 4);
> +  }
> +
> +  bool isSwiftErrorInRegister() const override {
> +return true;
> +  }
> };
> 
> class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
> -- 
> 2.9.3
> 
> ___
> 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] D31702: Append -w when LLVM_ENABLE_WARNINGS is Off.

2017-04-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r300100.


https://reviews.llvm.org/D31702



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


[PATCH] D31540: Prefer non-friend to friend in in redeclaration chain

2017-04-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

LGTM!


https://reviews.llvm.org/D31540



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


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-04-12 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

ping


https://reviews.llvm.org/D31830



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


Re: r300001 - Revert r298824 & r298816, recommit r298742 & r298754

2017-04-12 Thread Richard Trieu via cfe-commits
Yup, that looks like my fault, again.

Thanks, Greg, for the test case.  It's very similar to the final test in
odr_hash.cc, which I thought I had fixed.

On Wed, Apr 12, 2017 at 8:09 AM, Greg Bedwell  wrote:

> We're seeing the same assertion failing in our internal testing (I've not
> bisected to a specific change yet though, but it seems likely it's the same
> thing as in the log from the modules bot).  Here's a reduced example that
> triggers it:
>
> $ cat 2.h
> // 
> template  struct Bravo {
>   void charlie(bool delta = false) {}
> };
> typedef Bravo echo;
> echo foxtrot;
> // 
>
> $ clang.exe -x c++-header 2.h
> Assertion failed: !hasUninstantiatedDefaultArg() && "Default argument is
> not yet instantiated!", file C:\llvm\tools\clang\lib\AST\Decl.cpp, line
> 2424
>
> -Greg
>
>
>
> On 12 April 2017 at 02:52, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Either this or your other ODR hash change seems to have broken the
>> modules buildbot:
>>
>> http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhos
>> t-modules-2/builds/6274/steps/compile.llvm.stage2/logs/stdio
>>
>> On 11 April 2017 at 15:32, Richard Trieu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rtrieu
>>> Date: Tue Apr 11 17:32:03 2017
>>> New Revision: 31
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=31=rev
>>> Log:
>>> Revert r298824 & r298816, recommit r298742 & r298754
>>>
>>> r299989 fixes the underlying issue by waiting long enough to late parsed
>>> arguments to be processed before doing an calculating the hash.
>>>
>>> r298742
>>> [ODRHash] Add error messages for mismatched parameters in methods.
>>>
>>> r298754
>>> [ODRHash] Add support for array and decayed types.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>>> cfe/trunk/lib/AST/ODRHash.cpp
>>> cfe/trunk/lib/Serialization/ASTReader.cpp
>>> cfe/trunk/test/Modules/odr_hash.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/DiagnosticSerializationKinds.td?rev=31=30
>>> 2=31=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>>> (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue
>>> Apr 11 17:32:03 2017
>>> @@ -146,7 +146,12 @@ def err_module_odr_violation_mismatch_de
>>>"method %4 is %select{not static|static}5|"
>>>"method %4 is %select{not volatile|volatile}5|"
>>>"method %4 is %select{not const|const}5|"
>>> -  "method %4 is %select{not inline|inline}5}3">;
>>> +  "method %4 is %select{not inline|inline}5|"
>>> +  "method %4 that has %5 parameter%s5|"
>>> +  "method %4 with %ordinal5 parameter of type %6%select{| decayed from
>>> %8}7|"
>>> +  "method %4 with %ordinal5 parameter named %6|"
>>> +  "method %4 with %ordinal5 parameter with %select{no |}6default
>>> argument|"
>>> +  "method %4 with %ordinal5 parameter with default argument}3">;
>>>
>>>  def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0'
>>> found "
>>>"%select{"
>>> @@ -166,7 +171,12 @@ def note_module_odr_violation_mismatch_d
>>>"method %2 is %select{not static|static}3|"
>>>"method %2 is %select{not volatile|volatile}3|"
>>>"method %2 is %select{not const|const}3|"
>>> -  "method %2 is %select{not inline|inline}3}1">;
>>> +  "method %2 is %select{not inline|inline}3|"
>>> +  "method %2 that has %3 parameter%s3|"
>>> +  "method %2 with %ordinal3 parameter of type %4%select{| decayed from
>>> %6}5|"
>>> +  "method %2 with %ordinal3 parameter named %4|"
>>> +  "method %2 with %ordinal3 parameter with %select{no |}4default
>>> argument|"
>>> +  "method %2 with %ordinal3 parameter with different default
>>> argument}1">;
>>>
>>>  def warn_module_uses_date_time : Warning<
>>>"%select{precompiled header|module}0 uses __DATE__ or __TIME__">,
>>>
>>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHas
>>> h.cpp?rev=31=30=31=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>>> +++ cfe/trunk/lib/AST/ODRHash.cpp Tue Apr 11 17:32:03 2017
>>> @@ -169,6 +169,11 @@ public:
>>>  Inherited::VisitValueDecl(D);
>>>}
>>>
>>> +  void VisitParmVarDecl(const ParmVarDecl *D) {
>>> +AddStmt(D->getDefaultArg());
>>> +Inherited::VisitParmVarDecl(D);
>>> +  }
>>> +
>>>void VisitAccessSpecDecl(const AccessSpecDecl *D) {
>>>  ID.AddInteger(D->getAccess());
>>>  Inherited::VisitAccessSpecDecl(D);
>>> @@ -202,6 +207,12 @@ public:
>>>  Hash.AddBoolean(D->isPure());
>>>  

[libcxx] r300097 - [libc++] Use more appropriate conditional for ABI macro definition

2017-04-12 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Apr 12 14:56:37 2017
New Revision: 300097

URL: http://llvm.org/viewvc/llvm-project?rev=300097=rev
Log:
[libc++] Use more appropriate conditional for ABI macro definition

The inline function definition ABI macro is gated on COFF dllexport
semantics, so it's more appropriate to mark it with the object file
format macro rather than the generic _WIN32 macro. We now have no uses
of _WIN32 apart from those used to define the other Windows macros :)

Clarify the ABI macro comment and make the object file format check
exhaustive while I'm here.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=300097=300096=300097=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Apr 12 14:56:37 2017
@@ -35,6 +35,16 @@
 #define _LIBCPP_ABI_VERSION 1
 #endif
 
+#if defined(__ELF__)
+#define _LIBCPP_OBJECT_FORMAT_ELF   1
+#elif defined(__MACH__)
+#define _LIBCPP_OBJECT_FORMAT_MACHO 1
+#elif defined(_WIN32)
+#define _LIBCPP_OBJECT_FORMAT_COFF  1
+#else
+#error Unknown object file format
+#endif
+
 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
 // Change short string representation so that string data starts at offset 0,
 // improving its alignment in some cases.
@@ -63,9 +73,12 @@
 // using that class define their own copies.
 #define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
 #elif _LIBCPP_ABI_VERSION == 1
-#if !defined(_WIN32)
+#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
 // Enable compiling copies of now inline methods into the dylib to support
-// applications compiled against older libraries.
+// applications compiled against older libraries. This is unnecessary with
+// COFF dllexport semantics, since dllexport forces a non-inline definition
+// of inline functions to be emitted anyway. Our own non-inline copy would
+// conflict with the dllexport-emitted copy, so we disable it.
 #define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
 #endif
 // Feature macros for disabling pre ABI v1 features. All of these options
@@ -572,14 +585,6 @@ namespace std {
 
 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
 
-#if defined(__ELF__)
-#define _LIBCPP_OBJECT_FORMAT_ELF   1
-#elif defined(__MACH__)
-#define _LIBCPP_OBJECT_FORMAT_MACHO 1
-#else
-#define _LIBCPP_OBJECT_FORMAT_COFF  1
-#endif
-
 #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
 #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 # define _LIBCPP_DLL_VIS


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


[PATCH] D31167: Use FPContractModeKind universally

2017-04-12 Thread Adam Nemet via Phabricator via cfe-commits
anemet added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.def:220
+/// \brief FP_CONTRACT mode (on/off/fast).
+ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

hfinkel wrote:
> anemet wrote:
> > hfinkel wrote:
> > > yaxunl wrote:
> > > > hfinkel wrote:
> > > > > yaxunl wrote:
> > > > > > anemet wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > anemet wrote:
> > > > > > > > > yaxunl wrote:
> > > > > > > > > > This change seemed to cause some performance degradations 
> > > > > > > > > > in some OpenCL applications.
> > > > > > > > > > 
> > > > > > > > > > This option used to be on by default. Now it is off by 
> > > > > > > > > > default.
> > > > > > > > > > 
> > > > > > > > > > There are applications do separated compile/link/codegen 
> > > > > > > > > > stages. In the codegen stage, clang is invoked with .bc as 
> > > > > > > > > > input, therefore this option is off by default, whereas it 
> > > > > > > > > > was on by default before this change.
> > > > > > > > > > 
> > > > > > > > > > Is there any reason not to keep the original behavior?
> > > > > > > > > > 
> > > > > > > > > > Thanks.
> > > > > > > > > > This change seemed to cause some performance degradations 
> > > > > > > > > > in some OpenCL applications.
> > > > > > > > > > 
> > > > > > > > > > This option used to be on by default. Now it is off by 
> > > > > > > > > > default.
> > > > > > > > > 
> > > > > > > > > It's always been off.  It was set to fast for CUDA which 
> > > > > > > > > should still be the case.  See the changes further down on 
> > > > > > > > > the patch.
> > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > There are applications do separated compile/link/codegen 
> > > > > > > > > > stages. In the codegen stage, clang is invoked with .bc as 
> > > > > > > > > > input, therefore this option is off by default, whereas it 
> > > > > > > > > > was on by default before this change.
> > > > > > > > > > 
> > > > > > > > > > Is there any reason not to keep the original behavior?
> > > > > > > > > 
> > > > > > > > > Sorry but I am not sure what changed, can you elaborate on 
> > > > > > > > > what you're doing and how things used to work for you?
> > > > > > > > Before your change, -ffp-contract was a codegen option defined 
> > > > > > > > as
> > > > > > > > 
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On)
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > therefore the default value as on. After your change, it 
> > > > > > > > becomes off by default.
> > > > > > > No. -ffp-contract=on was a FE option and -ffp-contract=fast was a 
> > > > > > > backend option.  I still don't understand your use-case.  Can you 
> > > > > > > include a small testcase how this used to work before?
> > > > > > -ffp-contract=on used to be a codegen option before this change. In 
> > > > > > CodeGen/BackendUtil.cpp, before this change:
> > > > > > 
> > > > > > ```
> > > > > > switch (CodeGenOpts.getFPContractMode()) {
> > > > > >   switch (LangOpts.getDefaultFPContractMode()) {
> > > > > >   case LangOptions::FPC_Off:
> > > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > > > > break;
> > > > > >   case LangOptions::FPC_On:
> > > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > > > > break;
> > > > > >   case LangOptions::FPC_Fast:
> > > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > > > > break;
> > > > > >   }
> > > > > > ```
> > > > > > By default, -fp-contract=on, which results in 
> > > > > > llvm::FPOpFusion::Standard in the backend. This options allows 
> > > > > > backend to translate llvm.fmuladd to FMA machine instructions.
> > > > > > 
> > > > > > After this change, it becomes:
> > > > > > 
> > > > > > ```
> > > > > > switch (LangOpts.getDefaultFPContractMode()) {
> > > > > >   case LangOptions::FPC_Off:
> > > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > > > > break;
> > > > > >   case LangOptions::FPC_On:
> > > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > > > > break;
> > > > > >   case LangOptions::FPC_Fast:
> > > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > > > > break;
> > > > > >   }
> > > > > > ```
> > > > > > now by default -ffp-contract=off, which results in  
> > > > > > llvm::FPOpFusion::Strict in the backend. This option disables 
> > > > > > backend translating llvm.fmuladd to FMA machine instructions in 
> > > > > > certain situations.
> > > > > > 
> > > > > > A simple lit test is as follows:
> > > > > > 
> > > > > > 
> > > > > > ```
> > > > > > ; RUN: %clang_cc1 -triple amdgcn -S -o - %s| FileCheck %s
> > > > > > 
> > > > > > define amdgpu_kernel void @f(double addrspace(1)* nocapture %out, 
> > > > > > double %a, double %b, double 

Re: [libcxxabi] r296940 - Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

2017-04-12 Thread Hal Finkel via cfe-commits

Hi Eric,

This does not seem to do the right thing because, at this point, we have 
a fall-back implementation of __cxa_thread_atexit_impl (in 
src/cxa_thread_atexit.cpp), and this will be compiled if libc does not 
provide an implementation. Thus, the test will always pass (unless 
LIBCXXABI_ENABLE_THREADS is not defined, but we already check for that). 
I'm seeing this test unexpectedly pass on older systems. PR25874 should 
be fixed just by having the fallback implementation.


As a result, I think that we can just revert this entirely.

Thanks again,
Hal

On 03/03/2017 07:26 PM, Eric Fiselier via cfe-commits wrote:

Author: ericwf
Date: Fri Mar  3 19:26:41 2017
New Revision: 296940

URL: http://llvm.org/viewvc/llvm-project?rev=296940=rev
Log:
Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

Modified:
 libcxxabi/trunk/test/CMakeLists.txt
 libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
 libcxxabi/trunk/test/libcxxabi/test/config.py
 libcxxabi/trunk/test/lit.site.cfg.in

Modified: libcxxabi/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMakeLists.txt?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/CMakeLists.txt (original)
+++ libcxxabi/trunk/test/CMakeLists.txt Fri Mar  3 19:26:41 2017
@@ -18,6 +18,7 @@ pythonize_bool(LIBCXXABI_ENABLE_THREADS)
  pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
  pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
  pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
+pythonize_bool(LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
  set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
  "TargetInfo to use when setting up test environment.")
  set(LIBCXXABI_EXECUTOR "None" CACHE STRING

Modified: libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp (original)
+++ libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp Fri Mar  3 19:26:41 
2017
@@ -10,6 +10,11 @@
  // UNSUPPORTED: libcxxabi-no-threads
  // REQUIRES: linux
  
+// this test will only work if CMake detects a real __cxa_thread_atexit_impl

+// at configure time. This function, however, was added only in glibc 2.18,
+// and there are still plenty of systems only using 2.17 (Ex RHEL 7).
+// XFAIL: libcxxabi-no-cxa-thread-atexit-impl
+
  #include 
  #include 
  


Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Fri Mar  3 19:26:41 2017
@@ -45,6 +45,9 @@ class Configuration(LibcxxConfiguration)
  # test_exception_storage_nodynmem.pass.cpp fails under this specific 
configuration
  if self.get_lit_bool('cxx_ext_threads', False) and 
self.get_lit_bool('libcxxabi_shared', False):
  
self.config.available_features.add('libcxxabi-shared-externally-threaded')
+if not self.get_lit_bool('has_cxa_thread_atexit_impl', True):
+self.config.available_features.add(
+'libcxxabi-no-cxa-thread-atexit-impl')
  
  def configure_compile_flags(self):

  self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Fri Mar  3 19:26:41 2017
@@ -20,6 +20,7 @@ config.host_triple  = "@LLVM
  config.target_triple= "@TARGET_TRIPLE@"
  config.use_target   = len("@LIBCXXABI_TARGET_TRIPLE@") > 0
  config.cxx_ext_threads  = "@LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY@"
+config.has_cxa_thread_atexit_impl = "@LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL@"
  
  # Let the main config do the real work.

  lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")


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


--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory

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


[PATCH] D31167: Use FPContractModeKind universally

2017-04-12 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.def:220
+/// \brief FP_CONTRACT mode (on/off/fast).
+ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

anemet wrote:
> hfinkel wrote:
> > yaxunl wrote:
> > > hfinkel wrote:
> > > > yaxunl wrote:
> > > > > anemet wrote:
> > > > > > yaxunl wrote:
> > > > > > > anemet wrote:
> > > > > > > > yaxunl wrote:
> > > > > > > > > This change seemed to cause some performance degradations in 
> > > > > > > > > some OpenCL applications.
> > > > > > > > > 
> > > > > > > > > This option used to be on by default. Now it is off by 
> > > > > > > > > default.
> > > > > > > > > 
> > > > > > > > > There are applications do separated compile/link/codegen 
> > > > > > > > > stages. In the codegen stage, clang is invoked with .bc as 
> > > > > > > > > input, therefore this option is off by default, whereas it 
> > > > > > > > > was on by default before this change.
> > > > > > > > > 
> > > > > > > > > Is there any reason not to keep the original behavior?
> > > > > > > > > 
> > > > > > > > > Thanks.
> > > > > > > > > This change seemed to cause some performance degradations in 
> > > > > > > > > some OpenCL applications.
> > > > > > > > > 
> > > > > > > > > This option used to be on by default. Now it is off by 
> > > > > > > > > default.
> > > > > > > > 
> > > > > > > > It's always been off.  It was set to fast for CUDA which should 
> > > > > > > > still be the case.  See the changes further down on the patch.
> > > > > > > > 
> > > > > > > > > 
> > > > > > > > > There are applications do separated compile/link/codegen 
> > > > > > > > > stages. In the codegen stage, clang is invoked with .bc as 
> > > > > > > > > input, therefore this option is off by default, whereas it 
> > > > > > > > > was on by default before this change.
> > > > > > > > > 
> > > > > > > > > Is there any reason not to keep the original behavior?
> > > > > > > > 
> > > > > > > > Sorry but I am not sure what changed, can you elaborate on what 
> > > > > > > > you're doing and how things used to work for you?
> > > > > > > Before your change, -ffp-contract was a codegen option defined as
> > > > > > > 
> > > > > > > 
> > > > > > > ```
> > > > > > > ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On)
> > > > > > > ```
> > > > > > > 
> > > > > > > therefore the default value as on. After your change, it becomes 
> > > > > > > off by default.
> > > > > > No. -ffp-contract=on was a FE option and -ffp-contract=fast was a 
> > > > > > backend option.  I still don't understand your use-case.  Can you 
> > > > > > include a small testcase how this used to work before?
> > > > > -ffp-contract=on used to be a codegen option before this change. In 
> > > > > CodeGen/BackendUtil.cpp, before this change:
> > > > > 
> > > > > ```
> > > > > switch (CodeGenOpts.getFPContractMode()) {
> > > > >   switch (LangOpts.getDefaultFPContractMode()) {
> > > > >   case LangOptions::FPC_Off:
> > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > > > break;
> > > > >   case LangOptions::FPC_On:
> > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > > > break;
> > > > >   case LangOptions::FPC_Fast:
> > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > > > break;
> > > > >   }
> > > > > ```
> > > > > By default, -fp-contract=on, which results in 
> > > > > llvm::FPOpFusion::Standard in the backend. This options allows 
> > > > > backend to translate llvm.fmuladd to FMA machine instructions.
> > > > > 
> > > > > After this change, it becomes:
> > > > > 
> > > > > ```
> > > > > switch (LangOpts.getDefaultFPContractMode()) {
> > > > >   case LangOptions::FPC_Off:
> > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > > > break;
> > > > >   case LangOptions::FPC_On:
> > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > > > break;
> > > > >   case LangOptions::FPC_Fast:
> > > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > > > break;
> > > > >   }
> > > > > ```
> > > > > now by default -ffp-contract=off, which results in  
> > > > > llvm::FPOpFusion::Strict in the backend. This option disables backend 
> > > > > translating llvm.fmuladd to FMA machine instructions in certain 
> > > > > situations.
> > > > > 
> > > > > A simple lit test is as follows:
> > > > > 
> > > > > 
> > > > > ```
> > > > > ; RUN: %clang_cc1 -triple amdgcn -S -o - %s| FileCheck %s
> > > > > 
> > > > > define amdgpu_kernel void @f(double addrspace(1)* nocapture %out, 
> > > > > double %a, double %b, double %c) local_unnamed_addr #0 {
> > > > > entry:
> > > > >   ; CHECK: v_fma_f64
> > > > >   %0 = tail call double @llvm.fmuladd.f64(double %b, double %c, 
> > > > > double %a)
> > > > >   store double %0, double addrspace(1)* %out, align 8, !tbaa !6
> > > > >   

[libcxx] r300079 - [libcxx] [test] Avoid Clang's -Wunused-const-variable in is_constructible.pass.cpp.

2017-04-12 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Apr 12 12:16:38 2017
New Revision: 300079

URL: http://llvm.org/viewvc/llvm-project?rev=300079=rev
Log:
[libcxx] [test] Avoid Clang's -Wunused-const-variable in 
is_constructible.pass.cpp.

This happens when using Clang with MSVC's STL, so there are no actual uses of 
this variable.

Fixes D31966.

Modified:

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

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=300079=300078=300079=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 Wed Apr 12 12:16:38 2017
@@ -251,6 +251,7 @@ int main()
 LIBCPP_STATIC_ASSERT(
 clang_disallows_valid_static_cast_bug !=
 std::__libcpp_is_constructible>::value, "");
+((void)clang_disallows_valid_static_cast_bug); // Prevent unused warning
 #else
 static_assert(clang_disallows_valid_static_cast_bug == false, "");
 LIBCPP_STATIC_ASSERT(std::__libcpp_is_constructible>::value, "");


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


[clang-tools-extra] r300077 - [clangd] Rename ClangDMain.cpp -> ClangdMain.cpp, NFC

2017-04-12 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Apr 12 12:13:08 2017
New Revision: 300077

URL: http://llvm.org/viewvc/llvm-project?rev=300077=rev
Log:
[clangd] Rename ClangDMain.cpp -> ClangdMain.cpp, NFC

Added:
clang-tools-extra/trunk/clangd/ClangdMain.cpp
  - copied, changed from r299961, 
clang-tools-extra/trunk/clangd/ClangDMain.cpp
Removed:
clang-tools-extra/trunk/clangd/ClangDMain.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=300077=300076=300077=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed Apr 12 12:13:08 2017
@@ -1,6 +1,6 @@
 add_clang_executable(clangd
   ASTManager.cpp
-  ClangDMain.cpp
+  ClangdMain.cpp
   JSONRPCDispatcher.cpp
   Protocol.cpp
   ProtocolHandlers.cpp

Removed: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=300076=auto
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp (removed)
@@ -1,122 +0,0 @@
-//===--- ClangDMain.cpp - clangd server loop 
--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "ASTManager.h"
-#include "DocumentStore.h"
-#include "JSONRPCDispatcher.h"
-#include "ProtocolHandlers.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Program.h"
-#include 
-#include 
-using namespace clang::clangd;
-
-static llvm::cl::opt
-RunSynchronously("run-synchronously",
- llvm::cl::desc("parse on main thread"),
- llvm::cl::init(false), llvm::cl::Hidden);
-
-int main(int argc, char *argv[]) {
-  llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
-  llvm::raw_ostream  = llvm::outs();
-  llvm::raw_ostream  = llvm::errs();
-  JSONOutput Out(Outs, Logs);
-
-  // Change stdin to binary to not lose \r\n on windows.
-  llvm::sys::ChangeStdinToBinary();
-
-  // Set up a document store and intialize all the method handlers for JSONRPC
-  // dispatching.
-  DocumentStore Store;
-  ASTManager AST(Out, Store, RunSynchronously);
-  Store.addListener();
-  JSONRPCDispatcher Dispatcher(llvm::make_unique(Out));
-  Dispatcher.registerHandler("initialize",
- llvm::make_unique(Out));
-  auto ShutdownPtr = llvm::make_unique(Out);
-  auto *ShutdownHandler = ShutdownPtr.get();
-  Dispatcher.registerHandler("shutdown", std::move(ShutdownPtr));
-  Dispatcher.registerHandler(
-  "textDocument/didOpen",
-  llvm::make_unique(Out, Store));
-  Dispatcher.registerHandler(
-  "textDocument/didClose",
-  llvm::make_unique(Out, Store));
-  Dispatcher.registerHandler(
-  "textDocument/didChange",
-  llvm::make_unique(Out, Store));
-  Dispatcher.registerHandler(
-  "textDocument/rangeFormatting",
-  llvm::make_unique(Out, Store));
-  Dispatcher.registerHandler(
-  "textDocument/onTypeFormatting",
-  llvm::make_unique(Out, Store));
-  Dispatcher.registerHandler(
-  "textDocument/formatting",
-  llvm::make_unique(Out, Store));
-  Dispatcher.registerHandler("textDocument/codeAction",
- llvm::make_unique(Out, AST));
-  Dispatcher.registerHandler("textDocument/completion",
- llvm::make_unique(Out, AST));
-
-  while (std::cin.good()) {
-// A Language Server Protocol message starts with a HTTP header, delimited
-// by \r\n.
-std::string Line;
-std::getline(std::cin, Line);
-if (!std::cin.good() && errno == EINTR) {
-  std::cin.clear();
-  continue;
-}
-
-// Skip empty lines.
-llvm::StringRef LineRef(Line);
-if (LineRef.trim().empty())
-  continue;
-
-// We allow YAML-style comments. Technically this isn't part of the
-// LSP specification, but makes writing tests easier.
-if (LineRef.startswith("#"))
-  continue;
-
-unsigned long long Len = 0;
-// FIXME: Content-Type is a specified header, but does nothing.
-// Content-Length is a mandatory header. It specifies the length of the
-// following JSON.
-if (LineRef.consume_front("Content-Length: "))
-  llvm::getAsUnsignedInteger(LineRef.trim(), 0, Len);
-
-// Check if the next line only contains \r\n. If not this is another 
header,
-// which we ignore.
-char NewlineBuf[2];
-std::cin.read(NewlineBuf, 2);
-if (std::memcmp(NewlineBuf, "\r\n", 2) != 

[PATCH] D31840: [analyzer] Fix crash on access to property

2017-04-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Yep, looks good now, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D31840



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


[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

2017-04-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:965
+
+// Performing operator `&' on an lvalue expression is essentially a no-op.
+// Then, if we are taking addresses of fields or elements, these are also

alexshap wrote:
> "Address-of" operator can be overloaded, 
> just wondering - doest this code work correctly in that case ?
In this case we'd see a `CXXOperatorCallExpr` instead of `UnaryOperator` (all 
hail clang AST!).


https://reviews.llvm.org/D31982



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


[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

2017-04-12 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:965
+
+// Performing operator `&' on an lvalue expression is essentially a no-op.
+// Then, if we are taking addresses of fields or elements, these are also

"Address-of" operator can be overloaded, 
just wondering - doest this code work correctly in that case ?


https://reviews.llvm.org/D31982



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


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D29905



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


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-12 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94990.
gtbercea added a comment.

Fix for loop range.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,37 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
+if (Stack.empty())
+  return false;
+
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 
1, Check);
+
+if (Stack.size() > 2)
+  for (unsigned I = Stack.size() - 1; I > 0; --I)
+if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 1, Check))
+  return true;
+return false;
+  }
 
-if (SI == SE)
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> ) {
+if (Stack.size() <= Level)
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+auto StartI = Stack.begin();
+std::advance(StartI, Level);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-  if (MI != SI->MappedExprComponents.end())
-for (auto  : MI->second.Components)
-  if (Check(L, MI->second.Kind))
-return true;
-}
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto  : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
 return false;
   }
 
@@ -912,9 +924,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level + 1, 
[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,37 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
+if (Stack.empty())
+  return false;
+
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 1, Check);
+
+if (Stack.size() > 2)
+  for (unsigned I = Stack.size() - 1; I > 0; --I)
+if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 1, Check))
+  return true;
+return false;
+  }
 
-if (SI == SE)
+  /// Do the check specified in \a Check to all 

[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

2017-04-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.

In code

  void foo(int *p) {
if (p) {}
  }
  void bar(int *p) {
foo(p);
*p = 5;
  }

we suppress the null dereference warning in `*p = 5` because the state split 
within the inlined function is essentially irrelevant, as this is merely a 
defensive check that does not necessarily trigger in this caller context.

The suppression works by tracking the null pointer symbol in a bug report 
visitor and seeing if it was constrained to 0 inside a callee context. The fact 
that we have to rely on such manual suppressions is a downside of the 
inlining-based approach to interprocedural analysis.

The suppression gets confused when the null dereference becomes more complex, 
eg:

  struct S {
int x;
  }
  void foo(struct S *s) {
if (s) {}
  }
  void bar(struct S *s) {
foo(s);
*(&(s->x)) = 5;
  }

In this case `s` is `{reg_$0}`, and `reg_$0` is constrained to 
`[0, 0]`, similarly to the above. However, while computing `s->x` and then 
`&(s->x)`, the symbol is collapsed to a constant `0 (Loc)`, making it harder to 
track the symbol. The visitor is improved to handle this case.

While the fact that //offset of field `x` in struct `S` in our example is equal 
to 0// is purely accidental, with any other offset it'd still be a null 
dereference, worth suppressing. How does the analyzer handle the non-zero 
offset case and still see a null dereference? Simply and powerfully: it 
mis-computes the offset, incorrectly believing that all offsets are equal to 0 
(woohoo!). I add a test case to document this behavior; even though it's 
trivial to fix, the positive side effects of this bug are for now too useful to 
discard.


https://reviews.llvm.org/D31982

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/explain-svals.cpp
  test/Analysis/inlining/inline-defensive-checks.c
  test/Analysis/inlining/inline-defensive-checks.cpp
  test/Analysis/uninit-const.cpp

Index: test/Analysis/uninit-const.cpp
===
--- test/Analysis/uninit-const.cpp
+++ test/Analysis/uninit-const.cpp
@@ -122,7 +122,7 @@
 }
 
 void f_uninit(void) {
-  int x;
+  int x;   // expected-note {{'x' declared without an initial value}}
   doStuff_uninit();  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -70,4 +70,17 @@
 void test(int *p1, int *p2) {
   idc(p1);
 	Foo f(p1);
-}
\ No newline at end of file
+}
+
+struct Bar {
+  int x;
+};
+void idcBar(Bar *b) {
+  if (b)
+;
+}
+void testRefToField(Bar *b) {
+  idcBar(b);
+  int  = b->x; // no-warning
+  x = 5;
+}
Index: test/Analysis/inlining/inline-defensive-checks.c
===
--- test/Analysis/inlining/inline-defensive-checks.c
+++ test/Analysis/inlining/inline-defensive-checks.c
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-inlined-defensive-checks=true -verify %s
 
 // Perform inline defensive checks.
-void idc(int *p) {
+void idc(void *p) {
 	if (p)
 		;
 }
@@ -139,3 +139,42 @@
   int z = y;
   idcTriggerZeroValueThroughCall(z);
 }
+
+struct S {
+  int f1;
+  int f2;
+};
+
+void idcTrackZeroValueThroughUnaryPointerOperators(struct S *s) {
+  idc(s);
+  *(&(s->f1)) = 7; // no-warning
+}
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithOffset1(struct S *s) {
+  idc(s);
+  int *x = &(s->f2);
+  *x = 7; // no-warning
+}
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithOffset2(struct S *s) {
+  idc(s);
+  int *x = &(s->f2) - 1;
+  // FIXME: Should not warn.
+  *x = 7; // expected-warning{{Dereference of null pointer}}
+}
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithAssignment(struct S *s) {
+  idc(s);
+  int *x = &(s->f1);
+  *x = 7; // no-warning
+}
+
+
+struct S2 {
+  int a[1];
+};
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithArrayField(struct S2 *s) {
+  idc(s);
+  *(&(s->a[0])) = 7; // no-warning
+}
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -81,9 +81,10 @@
 
 namespace {
 class C {
+public:
   int x[10];
+  int y;
 
-public:
   void test_5(int i) {
 clang_analyzer_explain(this); // expected-warning-re^pointer to 'this' object$
 clang_analyzer_explain([i]); // expected-warning-re^pointer to element of type 'int' with index 'argument 'i'' of field 'x' of 'this' object$
@@ -96,3 +97,9 @@
   

r300074 - Revert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"

2017-04-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Apr 12 11:40:26 2017
New Revision: 300074

URL: http://llvm.org/viewvc/llvm-project?rev=300074=rev
Log:
Revert r31 "Revert r298824 & r298816, recommit r298742 & r298754"

It caused PR32640.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=300074=300073=300074=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Wed Apr 12 
11:40:26 2017
@@ -146,12 +146,7 @@ def err_module_odr_violation_mismatch_de
   "method %4 is %select{not static|static}5|"
   "method %4 is %select{not volatile|volatile}5|"
   "method %4 is %select{not const|const}5|"
-  "method %4 is %select{not inline|inline}5|"
-  "method %4 that has %5 parameter%s5|"
-  "method %4 with %ordinal5 parameter of type %6%select{| decayed from %8}7|"
-  "method %4 with %ordinal5 parameter named %6|"
-  "method %4 with %ordinal5 parameter with %select{no |}6default argument|"
-  "method %4 with %ordinal5 parameter with default argument}3">;
+  "method %4 is %select{not inline|inline}5}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -171,12 +166,7 @@ def note_module_odr_violation_mismatch_d
   "method %2 is %select{not static|static}3|"
   "method %2 is %select{not volatile|volatile}3|"
   "method %2 is %select{not const|const}3|"
-  "method %2 is %select{not inline|inline}3|"
-  "method %2 that has %3 parameter%s3|"
-  "method %2 with %ordinal3 parameter of type %4%select{| decayed from %6}5|"
-  "method %2 with %ordinal3 parameter named %4|"
-  "method %2 with %ordinal3 parameter with %select{no |}4default argument|"
-  "method %2 with %ordinal3 parameter with different default argument}1">;
+  "method %2 is %select{not inline|inline}3}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=300074=300073=300074=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Apr 12 11:40:26 2017
@@ -169,11 +169,6 @@ public:
 Inherited::VisitValueDecl(D);
   }
 
-  void VisitParmVarDecl(const ParmVarDecl *D) {
-AddStmt(D->getDefaultArg());
-Inherited::VisitParmVarDecl(D);
-  }
-
   void VisitAccessSpecDecl(const AccessSpecDecl *D) {
 ID.AddInteger(D->getAccess());
 Inherited::VisitAccessSpecDecl(D);
@@ -207,12 +202,6 @@ public:
 Hash.AddBoolean(D->isPure());
 Hash.AddBoolean(D->isDeletedAsWritten());
 
-ID.AddInteger(D->param_size());
-
-for (auto *Param : D->parameters()) {
-  Hash.AddSubDecl(Param);
-}
-
 Inherited::VisitFunctionDecl(D);
   }
 
@@ -326,14 +315,6 @@ public:
 }
   }
 
-  void AddQualType(QualType T) {
-Hash.AddQualType(T);
-  }
-
-  void VisitQualifiers(Qualifiers Quals) {
-ID.AddInteger(Quals.getAsOpaqueValue());
-  }
-
   void Visit(const Type *T) {
 ID.AddInteger(T->getTypeClass());
 Inherited::Visit(T);
@@ -341,92 +322,11 @@ public:
 
   void VisitType(const Type *T) {}
 
-  void VisitAdjustedType(const AdjustedType *T) {
-AddQualType(T->getOriginalType());
-AddQualType(T->getAdjustedType());
-VisitType(T);
-  }
-
-  void VisitDecayedType(const DecayedType *T) {
-AddQualType(T->getDecayedType());
-AddQualType(T->getPointeeType());
-VisitAdjustedType(T);
-  }
-
-  void VisitArrayType(const ArrayType *T) {
-AddQualType(T->getElementType());
-ID.AddInteger(T->getSizeModifier());
-VisitQualifiers(T->getIndexTypeQualifiers());
-VisitType(T);
-  }
-  void VisitConstantArrayType(const ConstantArrayType *T) {
-T->getSize().Profile(ID);
-VisitArrayType(T);
-  }
-
-  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-AddStmt(T->getSizeExpr());
-VisitArrayType(T);
-  }
-
-  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
-VisitArrayType(T);
-  }
-
-  void VisitVariableArrayType(const VariableArrayType *T) {
-AddStmt(T->getSizeExpr());
-VisitArrayType(T);
-  }
-
   void VisitBuiltinType(const BuiltinType *T) {
 ID.AddInteger(T->getKind());
 VisitType(T);
   }
 
-  void VisitFunctionType(const FunctionType *T) {
-AddQualType(T->getReturnType());
-T->getExtInfo().Profile(ID);
-Hash.AddBoolean(T->isConst());
-Hash.AddBoolean(T->isVolatile());
-Hash.AddBoolean(T->isRestrict());
-VisitType(T);
-  }
-
-  

[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-12 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94985.
gtbercea added a comment.

Refactor code.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,37 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
+if (Stack.empty())
+  return false;
+
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 
1, Check);
+
+if (Stack.size() > 2)
+  for (unsigned I = Stack.size() - 2; I > 0; --I)
+if (checkMappableExprComponentListsForDeclAtLevel(VD, I, Check))
+  return true;
+return false;
+  }
 
-if (SI == SE)
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> ) {
+if (Stack.size() <= Level)
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+auto StartI = Stack.begin();
+std::advance(StartI, Level);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-  if (MI != SI->MappedExprComponents.end())
-for (auto  : MI->second.Components)
-  if (Check(L, MI->second.Kind))
-return true;
-}
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto  : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
 return false;
   }
 
@@ -912,9 +924,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level + 1, 
[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,37 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
+if (Stack.empty())
+  return false;
+
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 1, Check);
+
+if (Stack.size() > 2)
+  for (unsigned I = Stack.size() - 2; I > 0; --I)
+if (checkMappableExprComponentListsForDeclAtLevel(VD, I, Check))
+  return true;
+return false;
+  }
 
-if (SI == SE)
+  /// Do the check specified in \a Check to all component lists at 

[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-12 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94983.
gtbercea added a comment.

Clean-up.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,36 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
-
-if (SI == SE)
+if (Stack.empty())
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 
2, Check);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-  if (MI != SI->MappedExprComponents.end())
-for (auto  : MI->second.Components)
-  if (Check(L, MI->second.Kind))
-return true;
-}
+for (unsigned I = Stack.size() - 1; I > 0; --I)
+  if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 2, Check))
+return true;
+return false;
+  }
+
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> ) {
+auto StartI = Stack.begin();
+auto EndI = Stack.end();
+if (std::distance(StartI, EndI) <= (int)(Level + 1))
+  return false;
+std::advance(StartI, Level + 1);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto  : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
 return false;
   }
 
@@ -912,9 +923,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level, [&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,36 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
-
-if (SI == SE)
+if (Stack.empty())
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 2, Check);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-  if (MI != SI->MappedExprComponents.end())
-for (auto  : 

r300071 - Moving a C++ test out of Sema and into SemaCXX; NFC.

2017-04-12 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Apr 12 10:56:02 2017
New Revision: 300071

URL: http://llvm.org/viewvc/llvm-project?rev=300071=rev
Log:
Moving a C++ test out of Sema and into SemaCXX; NFC.

Added:
cfe/trunk/test/SemaCXX/template-specialization.cpp
Removed:
cfe/trunk/test/Sema/template-specialization.cpp

Removed: cfe/trunk/test/Sema/template-specialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/template-specialization.cpp?rev=300070=auto
==
--- cfe/trunk/test/Sema/template-specialization.cpp (original)
+++ cfe/trunk/test/Sema/template-specialization.cpp (removed)
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
-// Verify the absence of assertion failures when solving calls to unresolved
-// template member functions.
-
-struct A {
-  template 
-  static void bar(int) { } // expected-note {{candidate template ignored: 
couldn't infer template argument 'T'}}
-};
-
-struct B {
-  template 
-  static void foo() {
-int array[i];
-A::template bar(array[0]); // expected-error {{no matching function for 
call to 'bar'}}
-  }
-};
-
-int main() {
-  B::foo<4>(); // expected-note {{in instantiation of function template 
specialization 'B::foo<4>'}}
-  return 0;
-}

Added: cfe/trunk/test/SemaCXX/template-specialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/template-specialization.cpp?rev=300071=auto
==
--- cfe/trunk/test/SemaCXX/template-specialization.cpp (added)
+++ cfe/trunk/test/SemaCXX/template-specialization.cpp Wed Apr 12 10:56:02 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// Verify the absence of assertion failures when solving calls to unresolved
+// template member functions.
+
+struct A {
+  template 
+  static void bar(int) { } // expected-note {{candidate template ignored: 
couldn't infer template argument 'T'}}
+};
+
+struct B {
+  template 
+  static void foo() {
+int array[i];
+A::template bar(array[0]); // expected-error {{no matching function for 
call to 'bar'}}
+  }
+};
+
+int main() {
+  B::foo<4>(); // expected-note {{in instantiation of function template 
specialization 'B::foo<4>'}}
+  return 0;
+}


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


[PATCH] D31886: [analyzer] Simplify values in binary operations more aggressively

2017-04-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D31886#724796, @xazax.hun wrote:

> maybe we want to skip this kind of simplification in case of Z3?


Hmm, that depends on how would we want to use it eventually.

- If Z3 acts all alone and fires only over actual bug reports, then yeah, it 
turns this simplification procedure into a dry-run no-op. However, the much 
bigger performance problem would be the increased path explosion from not 
removing infeasible paths early on.
- If we try to filter out infeasible paths continuously, either by employing 
RangeConstraintManager as a filter, or by employing Z3 as a filter, then Z3 
would anyway benefit from simpler symbolic expressions. In the worst case 
("that's what Z3 would have done itself anyway), we'd, i guess, have little 
effect on quality *or* performance

Generally, i've a feeling that simplifying SVals is a safe thing to do.


https://reviews.llvm.org/D31886



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


[PATCH] D31717: CodeGen: Let lifetime intrinsic use alloca address space

2017-04-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 94980.
yaxunl retitled this revision from "CodeGen: Emit lifetime intrinsics with 
pointer argument in alloca address space" to "CodeGen: Let lifetime intrinsic 
use alloca address space".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Rebased.


https://reviews.llvm.org/D31717

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenTypeCache.h
  test/CodeGenOpenCL/lifetime.cl


Index: test/CodeGenOpenCL/lifetime.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/lifetime.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---amdgizcl %s | FileCheck %s 
-check-prefix=AMDGIZ
+
+void use(char *a);
+
+__attribute__((always_inline)) void helper_no_markers() {
+  char a;
+  use();
+}
+
+void lifetime_test() {
+// CHECK: @llvm.lifetime.start.p0i
+// AMDGIZ: @llvm.lifetime.start.p5i
+  helper_no_markers();
+}
Index: lib/CodeGen/CodeGenTypeCache.h
===
--- lib/CodeGen/CodeGenTypeCache.h
+++ lib/CodeGen/CodeGenTypeCache.h
@@ -60,6 +60,12 @@
 llvm::PointerType *Int8PtrPtrTy;
   };
 
+  /// void* in alloca address space
+  union {
+llvm::PointerType *AllocaVoidPtrTy;
+llvm::PointerType *AllocaInt8PtrTy;
+  };
+
   /// The size and alignment of the builtin C type 'int'.  This comes
   /// up enough in various ABI lowering tasks to be worth pre-computing.
   union {
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -111,6 +111,8 @@
 C.getTargetInfo().getMaxPointerWidth());
   Int8PtrTy = Int8Ty->getPointerTo(0);
   Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
+  AllocaInt8PtrTy = Int8Ty->getPointerTo(
+  M.getDataLayout().getAllocaAddrSpace());
 
   RuntimeCC = getTargetCodeGenInfo().getABIInfo().getRuntimeCC();
   BuiltinCC = getTargetCodeGenInfo().getABIInfo().getBuiltinCC();
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -924,15 +924,15 @@
 return nullptr;
 
   llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size);
-  Addr = Builder.CreateBitCast(Addr, Int8PtrTy);
+  Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
   llvm::CallInst *C =
   Builder.CreateCall(CGM.getLLVMLifetimeStartFn(), {SizeV, Addr});
   C->setDoesNotThrow();
   return SizeV;
 }
 
 void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr) {
-  Addr = Builder.CreateBitCast(Addr, Int8PtrTy);
+  Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
   llvm::CallInst *C =
   Builder.CreateCall(CGM.getLLVMLifetimeEndFn(), {Size, Addr});
   C->setDoesNotThrow();
@@ -1729,16 +1729,16 @@
   if (LifetimeStartFn)
 return LifetimeStartFn;
   LifetimeStartFn = llvm::Intrinsic::getDeclaration((),
-llvm::Intrinsic::lifetime_start, Int8PtrTy);
+llvm::Intrinsic::lifetime_start, AllocaInt8PtrTy);
   return LifetimeStartFn;
 }
 
 /// Lazily declare the @llvm.lifetime.end intrinsic.
 llvm::Constant *CodeGenModule::getLLVMLifetimeEndFn() {
   if (LifetimeEndFn)
 return LifetimeEndFn;
   LifetimeEndFn = llvm::Intrinsic::getDeclaration((),
-llvm::Intrinsic::lifetime_end, Int8PtrTy);
+llvm::Intrinsic::lifetime_end, AllocaInt8PtrTy);
   return LifetimeEndFn;
 }
 


Index: test/CodeGenOpenCL/lifetime.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/lifetime.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---amdgizcl %s | FileCheck %s -check-prefix=AMDGIZ
+
+void use(char *a);
+
+__attribute__((always_inline)) void helper_no_markers() {
+  char a;
+  use();
+}
+
+void lifetime_test() {
+// CHECK: @llvm.lifetime.start.p0i
+// AMDGIZ: @llvm.lifetime.start.p5i
+  helper_no_markers();
+}
Index: lib/CodeGen/CodeGenTypeCache.h
===
--- lib/CodeGen/CodeGenTypeCache.h
+++ lib/CodeGen/CodeGenTypeCache.h
@@ -60,6 +60,12 @@
 llvm::PointerType *Int8PtrPtrTy;
   };
 
+  /// void* in alloca address space
+  union {
+llvm::PointerType *AllocaVoidPtrTy;
+llvm::PointerType *AllocaInt8PtrTy;
+  };
+
   /// The size and alignment of the builtin C type 'int'.  This comes
   /// up enough in various ABI lowering tasks to be worth pre-computing.
   union {
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -111,6 +111,8 @@
 C.getTargetInfo().getMaxPointerWidth());
   Int8PtrTy = Int8Ty->getPointerTo(0);
   Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
+  AllocaInt8PtrTy = 

[PATCH] D31966: [libcxx] [test] Avoid Clang's -Wunused-const-variable in is_constructible.pass.cpp.

2017-04-12 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D31966



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


[PATCH] D31428: [x86] fix AVX FP cmp intrinsic documentation (PR28110)

2017-04-12 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300068: [x86] fix AVX FP cmp intrinsic documentation 
(PR28110) (authored by spatel).

Changed prior to commit:
  https://reviews.llvm.org/D31428?vs=93366=94976#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31428

Files:
  cfe/trunk/lib/Headers/avxintrin.h

Index: cfe/trunk/lib/Headers/avxintrin.h
===
--- cfe/trunk/lib/Headers/avxintrin.h
+++ cfe/trunk/lib/Headers/avxintrin.h
@@ -1613,9 +1613,9 @@
 #define _CMP_NEQ_UQ   0x04 /* Not-equal (unordered, non-signaling)  */
 #define _CMP_NLT_US   0x05 /* Not-less-than (unordered, signaling)  */
 #define _CMP_NLE_US   0x06 /* Not-less-than-or-equal (unordered, signaling)  */
-#define _CMP_ORD_Q0x07 /* Ordered (nonsignaling)   */
+#define _CMP_ORD_Q0x07 /* Ordered (non-signaling)   */
 #define _CMP_EQ_UQ0x08 /* Equal (unordered, non-signaling)  */
-#define _CMP_NGE_US   0x09 /* Not-greater-than-or-equal (unord, signaling)  */
+#define _CMP_NGE_US   0x09 /* Not-greater-than-or-equal (unordered, signaling)  */
 #define _CMP_NGT_US   0x0a /* Not-greater-than (unordered, signaling)  */
 #define _CMP_FALSE_OQ 0x0b /* False (ordered, non-signaling)  */
 #define _CMP_NEQ_OQ   0x0c /* Not-equal (ordered, non-signaling)  */
@@ -1628,10 +1628,10 @@
 #define _CMP_UNORD_S  0x13 /* Unordered (signaling)  */
 #define _CMP_NEQ_US   0x14 /* Not-equal (unordered, signaling)  */
 #define _CMP_NLT_UQ   0x15 /* Not-less-than (unordered, non-signaling)  */
-#define _CMP_NLE_UQ   0x16 /* Not-less-than-or-equal (unord, non-signaling)  */
+#define _CMP_NLE_UQ   0x16 /* Not-less-than-or-equal (unordered, non-signaling)  */
 #define _CMP_ORD_S0x17 /* Ordered (signaling)  */
 #define _CMP_EQ_US0x18 /* Equal (unordered, signaling)  */
-#define _CMP_NGE_UQ   0x19 /* Not-greater-than-or-equal (unord, non-sign)  */
+#define _CMP_NGE_UQ   0x19 /* Not-greater-than-or-equal (unordered, non-signaling)  */
 #define _CMP_NGT_UQ   0x1a /* Not-greater-than (unordered, non-signaling)  */
 #define _CMP_FALSE_OS 0x1b /* False (ordered, signaling)  */
 #define _CMP_NEQ_OS   0x1c /* Not-equal (ordered, signaling)  */
@@ -1660,17 +1660,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///00h, 08h, 10h, 18h: Equal \n
-///01h, 09h, 11h, 19h: Less than \n
-///02h, 0Ah, 12h, 1Ah: Less than or equal / Greater than or equal
-///(swapped operands) \n
-///03h, 0Bh, 13h, 1Bh: Unordered \n
-///04h, 0Ch, 14h, 1Ch: Not equal \n
-///05h, 0Dh, 15h, 1Dh: Not less than / Not greater than
-///(swapped operands) \n
-///06h, 0Eh, 16h, 1Eh: Not less than or equal / Not greater than or equal
-///(swapped operands) \n
-///07h, 0Fh, 17h, 1Fh: Ordered
+///0x00 : Equal (ordered, non-signaling)
+///0x01 : Less-than (ordered, signaling)
+///0x02 : Less-than-or-equal (ordered, signaling)
+///0x03 : Unordered (non-signaling)
+///0x04 : Not-equal (unordered, non-signaling)
+///0x05 : Not-less-than (unordered, signaling)
+///0x06 : Not-less-than-or-equal (unordered, signaling)
+///0x07 : Ordered (non-signaling)
+///0x08 : Equal (unordered, non-signaling)
+///0x09 : Not-greater-than-or-equal (unordered, signaling)
+///0x0a : Not-greater-than (unordered, signaling)
+///0x0b : False (ordered, non-signaling)
+///0x0c : Not-equal (ordered, non-signaling)
+///0x0d : Greater-than-or-equal (ordered, signaling)
+///0x0e : Greater-than (ordered, signaling)
+///0x0f : True (unordered, non-signaling)
+///0x10 : Equal (ordered, signaling)
+///0x11 : Less-than (ordered, non-signaling)
+///0x12 : Less-than-or-equal (ordered, non-signaling)
+///0x13 : Unordered (signaling)
+///0x14 : Not-equal (unordered, signaling)
+///0x15 : Not-less-than (unordered, non-signaling)
+///0x16 : Not-less-than-or-equal (unordered, non-signaling)
+///0x17 : Ordered (signaling)
+///0x18 : Equal (unordered, signaling)
+///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
+///0x1a : Not-greater-than (unordered, non-signaling)
+///0x1b : False (ordered, signaling)
+///0x1c : Not-equal (ordered, signaling)
+///0x1d : Greater-than-or-equal (ordered, non-signaling)
+///0x1e : Greater-than (ordered, non-signaling)
+///0x1f : True (unordered, signaling)
 /// \returns A 128-bit vector of [2 x double] containing the comparison results.
 #define _mm_cmp_pd(a, b, c) __extension__ ({ \
   (__m128d)__builtin_ia32_cmppd((__v2df)(__m128d)(a), \
@@ -1697,17 +1718,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///00h, 08h, 10h, 18h: Equal \n
-///01h, 09h, 11h, 19h: Less than \n
-///02h, 0Ah, 12h, 

r300068 - [x86] fix AVX FP cmp intrinsic documentation (PR28110)

2017-04-12 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Wed Apr 12 10:19:08 2017
New Revision: 300068

URL: http://llvm.org/viewvc/llvm-project?rev=300068=rev
Log:
[x86] fix AVX FP cmp intrinsic documentation (PR28110)

This copies the text used in the #define statements to the code comments. 
The conflicting text comes from AMD manuals, but those are wrong. Sadly, 
that FP cmp text has not been updated even after some docs were updated 
for Zen:
http://support.amd.com/en-us/search/tech-docs 
( AMD64 Architecture Programmer's Manual Volume 4 )

See PR28110 for more discussion:
https://bugs.llvm.org/show_bug.cgi?id=28110

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

Modified:
cfe/trunk/lib/Headers/avxintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=300068=300067=300068=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Wed Apr 12 10:19:08 2017
@@ -1613,9 +1613,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b,
 #define _CMP_NEQ_UQ   0x04 /* Not-equal (unordered, non-signaling)  */
 #define _CMP_NLT_US   0x05 /* Not-less-than (unordered, signaling)  */
 #define _CMP_NLE_US   0x06 /* Not-less-than-or-equal (unordered, signaling)  */
-#define _CMP_ORD_Q0x07 /* Ordered (nonsignaling)   */
+#define _CMP_ORD_Q0x07 /* Ordered (non-signaling)   */
 #define _CMP_EQ_UQ0x08 /* Equal (unordered, non-signaling)  */
-#define _CMP_NGE_US   0x09 /* Not-greater-than-or-equal (unord, signaling)  */
+#define _CMP_NGE_US   0x09 /* Not-greater-than-or-equal (unordered, signaling) 
 */
 #define _CMP_NGT_US   0x0a /* Not-greater-than (unordered, signaling)  */
 #define _CMP_FALSE_OQ 0x0b /* False (ordered, non-signaling)  */
 #define _CMP_NEQ_OQ   0x0c /* Not-equal (ordered, non-signaling)  */
@@ -1628,10 +1628,10 @@ _mm256_blendv_ps(__m256 __a, __m256 __b,
 #define _CMP_UNORD_S  0x13 /* Unordered (signaling)  */
 #define _CMP_NEQ_US   0x14 /* Not-equal (unordered, signaling)  */
 #define _CMP_NLT_UQ   0x15 /* Not-less-than (unordered, non-signaling)  */
-#define _CMP_NLE_UQ   0x16 /* Not-less-than-or-equal (unord, non-signaling)  */
+#define _CMP_NLE_UQ   0x16 /* Not-less-than-or-equal (unordered, 
non-signaling)  */
 #define _CMP_ORD_S0x17 /* Ordered (signaling)  */
 #define _CMP_EQ_US0x18 /* Equal (unordered, signaling)  */
-#define _CMP_NGE_UQ   0x19 /* Not-greater-than-or-equal (unord, non-sign)  */
+#define _CMP_NGE_UQ   0x19 /* Not-greater-than-or-equal (unordered, 
non-signaling)  */
 #define _CMP_NGT_UQ   0x1a /* Not-greater-than (unordered, non-signaling)  */
 #define _CMP_FALSE_OS 0x1b /* False (ordered, signaling)  */
 #define _CMP_NEQ_OS   0x1c /* Not-equal (ordered, signaling)  */
@@ -1660,17 +1660,38 @@ _mm256_blendv_ps(__m256 __a, __m256 __b,
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which 
comparison
 ///operation to use: \n
-///00h, 08h, 10h, 18h: Equal \n
-///01h, 09h, 11h, 19h: Less than \n
-///02h, 0Ah, 12h, 1Ah: Less than or equal / Greater than or equal
-///(swapped operands) \n
-///03h, 0Bh, 13h, 1Bh: Unordered \n
-///04h, 0Ch, 14h, 1Ch: Not equal \n
-///05h, 0Dh, 15h, 1Dh: Not less than / Not greater than
-///(swapped operands) \n
-///06h, 0Eh, 16h, 1Eh: Not less than or equal / Not greater than or equal
-///(swapped operands) \n
-///07h, 0Fh, 17h, 1Fh: Ordered
+///0x00 : Equal (ordered, non-signaling)
+///0x01 : Less-than (ordered, signaling)
+///0x02 : Less-than-or-equal (ordered, signaling)
+///0x03 : Unordered (non-signaling)
+///0x04 : Not-equal (unordered, non-signaling)
+///0x05 : Not-less-than (unordered, signaling)
+///0x06 : Not-less-than-or-equal (unordered, signaling)
+///0x07 : Ordered (non-signaling)
+///0x08 : Equal (unordered, non-signaling)
+///0x09 : Not-greater-than-or-equal (unordered, signaling)
+///0x0a : Not-greater-than (unordered, signaling)
+///0x0b : False (ordered, non-signaling)
+///0x0c : Not-equal (ordered, non-signaling)
+///0x0d : Greater-than-or-equal (ordered, signaling)
+///0x0e : Greater-than (ordered, signaling)
+///0x0f : True (unordered, non-signaling)
+///0x10 : Equal (ordered, signaling)
+///0x11 : Less-than (ordered, non-signaling)
+///0x12 : Less-than-or-equal (ordered, non-signaling)
+///0x13 : Unordered (signaling)
+///0x14 : Not-equal (unordered, signaling)
+///0x15 : Not-less-than (unordered, non-signaling)
+///0x16 : Not-less-than-or-equal (unordered, non-signaling)
+///0x17 : Ordered (signaling)
+///0x18 : Equal (unordered, signaling)
+///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
+///0x1a : Not-greater-than (unordered, non-signaling)
+///0x1b : False (ordered, signaling)
+///0x1c : 

[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:343
+for (unsigned I = Stack.size() - 1; I > 0; --I)
+  if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 2, Check))
+return true;

Are you sure this is correct? If I is 1, I-2 will give you 0x. Please, 
check everything one more time



Comment at: lib/Sema/SemaOpenMP.cpp:355
+   OpenMPClauseKind)> ) {
+// auto StartI = std::next(Stack.begin());
+auto StartI = Stack.begin();

Please, remove this commented code


Repository:
  rL LLVM

https://reviews.llvm.org/D29905



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


Re: r300001 - Revert r298824 & r298816, recommit r298742 & r298754

2017-04-12 Thread Greg Bedwell via cfe-commits
We're seeing the same assertion failing in our internal testing (I've not
bisected to a specific change yet though, but it seems likely it's the same
thing as in the log from the modules bot).  Here's a reduced example that
triggers it:

$ cat 2.h
// 
template  struct Bravo {
  void charlie(bool delta = false) {}
};
typedef Bravo echo;
echo foxtrot;
// 

$ clang.exe -x c++-header 2.h
Assertion failed: !hasUninstantiatedDefaultArg() && "Default argument is
not yet instantiated!", file C:\llvm\tools\clang\lib\AST\Decl.cpp, line 2424

-Greg



On 12 April 2017 at 02:52, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Either this or your other ODR hash change seems to have broken the modules
> buildbot:
>
> http://lab.llvm.org:8011/builders/clang-x86_64-linux-
> selfhost-modules-2/builds/6274/steps/compile.llvm.stage2/logs/stdio
>
> On 11 April 2017 at 15:32, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Tue Apr 11 17:32:03 2017
>> New Revision: 31
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=31=rev
>> Log:
>> Revert r298824 & r298816, recommit r298742 & r298754
>>
>> r299989 fixes the underlying issue by waiting long enough to late parsed
>> arguments to be processed before doing an calculating the hash.
>>
>> r298742
>> [ODRHash] Add error messages for mismatched parameters in methods.
>>
>> r298754
>> [ODRHash] Add support for array and decayed types.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>> cfe/trunk/lib/AST/ODRHash.cpp
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/test/Modules/odr_hash.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSerializationKinds.td?rev=31=30&
>> r2=31=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>> (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue
>> Apr 11 17:32:03 2017
>> @@ -146,7 +146,12 @@ def err_module_odr_violation_mismatch_de
>>"method %4 is %select{not static|static}5|"
>>"method %4 is %select{not volatile|volatile}5|"
>>"method %4 is %select{not const|const}5|"
>> -  "method %4 is %select{not inline|inline}5}3">;
>> +  "method %4 is %select{not inline|inline}5|"
>> +  "method %4 that has %5 parameter%s5|"
>> +  "method %4 with %ordinal5 parameter of type %6%select{| decayed from
>> %8}7|"
>> +  "method %4 with %ordinal5 parameter named %6|"
>> +  "method %4 with %ordinal5 parameter with %select{no |}6default
>> argument|"
>> +  "method %4 with %ordinal5 parameter with default argument}3">;
>>
>>  def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0'
>> found "
>>"%select{"
>> @@ -166,7 +171,12 @@ def note_module_odr_violation_mismatch_d
>>"method %2 is %select{not static|static}3|"
>>"method %2 is %select{not volatile|volatile}3|"
>>"method %2 is %select{not const|const}3|"
>> -  "method %2 is %select{not inline|inline}3}1">;
>> +  "method %2 is %select{not inline|inline}3|"
>> +  "method %2 that has %3 parameter%s3|"
>> +  "method %2 with %ordinal3 parameter of type %4%select{| decayed from
>> %6}5|"
>> +  "method %2 with %ordinal3 parameter named %4|"
>> +  "method %2 with %ordinal3 parameter with %select{no |}4default
>> argument|"
>> +  "method %2 with %ordinal3 parameter with different default
>> argument}1">;
>>
>>  def warn_module_uses_date_time : Warning<
>>"%select{precompiled header|module}0 uses __DATE__ or __TIME__">,
>>
>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHas
>> h.cpp?rev=31=30=31=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>> +++ cfe/trunk/lib/AST/ODRHash.cpp Tue Apr 11 17:32:03 2017
>> @@ -169,6 +169,11 @@ public:
>>  Inherited::VisitValueDecl(D);
>>}
>>
>> +  void VisitParmVarDecl(const ParmVarDecl *D) {
>> +AddStmt(D->getDefaultArg());
>> +Inherited::VisitParmVarDecl(D);
>> +  }
>> +
>>void VisitAccessSpecDecl(const AccessSpecDecl *D) {
>>  ID.AddInteger(D->getAccess());
>>  Inherited::VisitAccessSpecDecl(D);
>> @@ -202,6 +207,12 @@ public:
>>  Hash.AddBoolean(D->isPure());
>>  Hash.AddBoolean(D->isDeletedAsWritten());
>>
>> +ID.AddInteger(D->param_size());
>> +
>> +for (auto *Param : D->parameters()) {
>> +  Hash.AddSubDecl(Param);
>> +}
>> +
>>  Inherited::VisitFunctionDecl(D);
>>}
>>
>> @@ -315,6 +326,14 @@ public:
>>  }
>>}
>>
>> +  void AddQualType(QualType T) {
>> +Hash.AddQualType(T);
>> +  }
>> +
>> +  void VisitQualifiers(Qualifiers 

[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-12 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94972.
gtbercea added a comment.

Pass correct levels. Refactor code.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,37 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
-
-if (SI == SE)
+if (Stack.empty())
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 
2, Check);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-  if (MI != SI->MappedExprComponents.end())
-for (auto  : MI->second.Components)
-  if (Check(L, MI->second.Kind))
-return true;
-}
+for (unsigned I = Stack.size() - 1; I > 0; --I)
+  if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 2, Check))
+return true;
+return false;
+  }
+
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> ) {
+// auto StartI = std::next(Stack.begin());
+auto StartI = Stack.begin();
+auto EndI = Stack.end();
+if (std::distance(StartI, EndI) <= (int)(Level + 1))
+  return false;
+std::advance(StartI, Level + 1);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto  : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
 return false;
   }
 
@@ -912,9 +924,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level, [&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,37 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
-
-if (SI == SE)
+if (Stack.empty())
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 2, Check);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-   

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

friendly ping @alexfh.




Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+  hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+  .bind("for_loop"),

aaron.ballman wrote:
> hokein wrote:
> > aaron.ballman wrote:
> > > hokein wrote:
> > > > aaron.ballman wrote:
> > > > > hokein wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > I'm really not keen on this. It will catch trivial cases, so 
> > > > > > > there is some utility, but this will quickly fall apart with 
> > > > > > > anything past the trivial case.
> > > > > > The motivation of this check is to find code patterns like `for 
> > > > > > (int i = 0; i < n; ++i) { v.push_back(i); }` and clean them in our 
> > > > > > codebase (we have lots of similar cases). 
> > > > > > [These](https://docs.google.com/document/d/1Bbc-6DlNs6zQujWD5-XOHWbfPJVMG7Z_T27Kv0WcFb4/edit?usp=sharing)
> > > > > >  are all cases we want to support. Using `hasParent` is a simple 
> > > > > > and sufficient way to do it IMO.
> > > > > I'm not convinced of the utility without implementing this in a more 
> > > > > sensitive way. Have you run this across any large code bases and 
> > > > > found that it catches issues?
> > > > Yeah, the check catches ~2800 cases (regexp shows ~17,000 total usages) 
> > > > in our internal codebase. And all caught cases are what we are 
> > > > interested in. It would catch more if we support for-range loops and 
> > > > iterator-based for-loops. 
> > > I wasn't worried about it not triggering often enough, I was worried 
> > > about it triggering too often because of the lack of sensitivity. If you 
> > > randomly sample some of those 2800 cases, do they reserve the space in a 
> > > way that your check isn't catching?
> > Ok, I see your concern now, thanks for pointing it out.
> > 
> > I have read through these caught cases. The results look reasonable. Most 
> > cases (> 95%) are what we expected, the code pattern is like `vector v; 
> > for (...) { v.push_back(...); }` where the vector definition statement and 
> > for-loop statement are consecutive. Another option is to make the check 
> > more strict (only detects the consecutive code pattern).
> Okay, that sounds like it has utility then. Thank you for clarifying!
I improved the way of catching the preallocations before the loop. Could you 
take a look again?


https://reviews.llvm.org/D31757



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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 94969.
hokein added a comment.

Improve the way of detecting pre-allocation usage before the loop.


https://reviews.llvm.org/D31757

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  test/clang-tidy/performance-inefficient-vector-operation.cpp

Index: test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -0,0 +1,162 @@
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm --
+
+typedef int size_t;
+
+namespace std {
+template 
+class vector {
+ public:
+  typedef T* iterator;
+  typedef const T* const_iterator;
+  typedef T& reference;
+  typedef const T& const_reference;
+  typedef size_t size_type;
+
+  explicit vector();
+  explicit vector(size_type n);
+
+  void push_back(const T& val);
+  void reserve(size_t n);
+  void resize(size_t n);
+
+  size_t size();
+  const_reference operator[] (size_type) const;
+  reference operator[] (size_type);
+};
+} // namespace std
+
+void f(std::vector& t) {
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; ++i)
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called inside a loop; consider pre-allocating the vector capacity before the loop
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(5);
+for (int i = 0; i < 5; ++i) {
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+// CHECK-FIXES-NOT: v.reserve(10);
+for (int i = 0; i < 10; ++i) {
+  // No fix for this loop as we encounter the prior loops.
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+std::vector v2;
+v2.reserve(3);
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; ++i)
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (size_t i = 0; i < t.size(); ++i) {
+  v.push_back(t[i]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size() - 1);
+for (size_t i = 0; i < t.size() - 1; ++i) {
+  v.push_back(t[i]);
+} // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+  }
+
+  //  Non-fixed Cases 
+  {
+std::vector v;
+v.reserve(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a "reserve" call already.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+v.reserve(5);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a "reserve" call already.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+v.resize(5);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a ref usage of v before the loop.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+v.push_back(0);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a ref usage of v before the loop.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+f(v);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a ref usage of v before the loop.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// v is not constructed with default constructor.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop is not started with 0.
+for (int i = 1; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(t.size());
+// v isn't referenced in for-loop body.
+for (size_t i = 0; i < t.size(); ++i) {
+  t.push_back(i);
+}
+  }
+  {
+std::vector v;
+int k;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop isn't a fixable loop.
+for (size_t i = 0; k < 10; ++i) {
+  v.push_back(t[i]);
+}
+  }
+  {
+std::vector v;
+int k;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop isn't a fixable loop.
+for (size_t i = 0; i < 10; ++k) {
+  v.push_back(t[i]);
+}
+  }
+}
Index: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
===
--- /dev/null
+++ 

[PATCH] D31886: [analyzer] Simplify values in binary operations more aggressively

2017-04-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

One last question: maybe we want to skip this kind of simplification in case of 
Z3?
Probably the constraint managers could have a flag like 
"wantsSimplifiedConstraints"?
Maybe somehow the checkers that are doing their own simplification could 
respect this flag as well somehow?


https://reviews.llvm.org/D31886



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


[PATCH] D31886: [analyzer] Simplify values in binary operations more aggressively

2017-04-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for working on this!


https://reviews.llvm.org/D31886



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


[PATCH] D31976: Avoid assert when a non-static member function is qualified with __unaligned

2017-04-12 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.

Under `-fms-extensions` `__unaligned` is a type-qualifier that can be applied 
to a non-static member function declaration.

This causes an assertion when mangling the name under Itanium, where that 
qualifier is not mangled.

This patch justs makes the minimal change to avoid the crash and avoid mangling 
`__unaligned`.

The test just makes sure the clash is actually detected.


https://reviews.llvm.org/D31976

Files:
  lib/AST/ItaniumMangle.cpp
  test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp


Index: test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
===
--- /dev/null
+++ test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only 
%s -verify
+
+struct A
+{
+int x;
+void foo() __unaligned;
+void foo();
+};
+
+void A::foo() __unaligned
+{
+this->x++;
+}
+
+void A::foo() // expected-error {{definition with same mangled name as another 
definition}}
+  // expected-note@-6 {{previous definition is here}}
+{
+this->x++;
+}
+
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -1455,10 +1455,12 @@
   Out << 'N';
   if (const CXXMethodDecl *Method = dyn_cast(ND)) {
 Qualifiers MethodQuals =
-Qualifiers::fromCVRMask(Method->getTypeQualifiers());
+Qualifiers::fromCVRUMask(Method->getTypeQualifiers());
 // We do not consider restrict a distinguishing attribute for overloading
 // purposes so we must not mangle it.
 MethodQuals.removeRestrict();
+// __unaligned is not currently mangled in any way, so remove it.
+MethodQuals.removeUnaligned();
 mangleQualifiers(MethodQuals);
 mangleRefQualifier(Method->getRefQualifier());
   }


Index: test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
===
--- /dev/null
+++ test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only %s -verify
+
+struct A
+{
+int x;
+void foo() __unaligned;
+void foo();
+};
+
+void A::foo() __unaligned
+{
+this->x++;
+}
+
+void A::foo() // expected-error {{definition with same mangled name as another definition}}
+  // expected-note@-6 {{previous definition is here}}
+{
+this->x++;
+}
+
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -1455,10 +1455,12 @@
   Out << 'N';
   if (const CXXMethodDecl *Method = dyn_cast(ND)) {
 Qualifiers MethodQuals =
-Qualifiers::fromCVRMask(Method->getTypeQualifiers());
+Qualifiers::fromCVRUMask(Method->getTypeQualifiers());
 // We do not consider restrict a distinguishing attribute for overloading
 // purposes so we must not mangle it.
 MethodQuals.removeRestrict();
+// __unaligned is not currently mangled in any way, so remove it.
+MethodQuals.removeUnaligned();
 mangleQualifiers(MethodQuals);
 mangleRefQualifier(Method->getRefQualifier());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31540: Prefer non-friend to friend in in redeclaration chain

2017-04-12 Thread Yaron Keren via Phabricator via cfe-commits
yaron.keren updated this revision to Diff 94961.
yaron.keren added a comment.

Added attribute test.


https://reviews.llvm.org/D31540

Files:
  tools/clang/include/clang/AST/DeclBase.h
  tools/clang/lib/AST/Decl.cpp
  tools/clang/lib/AST/DeclBase.cpp
  tools/clang/test/SemaTemplate/friend-template.cpp

Index: tools/clang/test/SemaTemplate/friend-template.cpp
===
--- tools/clang/test/SemaTemplate/friend-template.cpp
+++ tools/clang/test/SemaTemplate/friend-template.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
 // PR5057
 namespace test0 {
   namespace std {
@@ -68,17 +68,12 @@
   Foo foo;
 
   template struct X2a;
-
-  template struct X2b;
+  template struct X2b;// expected-note {{previous non-type template parameter with type 'int' is here}}
 
   template
   class X3 {
 template friend struct X2a;
-
-// FIXME: the redeclaration note ends up here because redeclaration
-// lookup ends up finding the friend target from X3.
-template friend struct X2b; // expected-error {{template non-type parameter has a different type 'long' in template redeclaration}} \
-  // expected-note {{previous non-type template parameter with type 'int' is here}}
+template friend struct X2b; // expected-error {{template non-type parameter has a different type 'long' in template redeclaration}} 
   };
 
   X3 x3i; // okay
@@ -297,14 +292,11 @@
   int n = C::D().f();
 
   struct F {
-template struct G;
+template struct G; // expected-note {{previous}}
   };
   template struct H {
-// FIXME: As with cases above, the note here is on an unhelpful declaration,
-// and should point to the declaration of G within F.
 template friend struct F::G; // \
-  // expected-error {{different type 'char' in template redeclaration}} \
-  // expected-note {{previous}}
+  // expected-error {{different type 'char' in template redeclaration}}
   };
   H h1; // ok
   H h2; // expected-note {{instantiation}}
@@ -329,3 +321,11 @@
 foo(b); // expected-note {{in instantiation}}
   }
 }
+namespace PR30994 {
+  void f();
+  struct A {
+[[deprecated]] friend void f() {} // \
+  expected-note {{has been explicitly marked deprecated here}}
+  };
+  void g() { f(); } // expected-warning {{is deprecated}}
+}
Index: tools/clang/lib/AST/DeclBase.cpp
===
--- tools/clang/lib/AST/DeclBase.cpp
+++ tools/clang/lib/AST/DeclBase.cpp
@@ -861,6 +861,21 @@
   return Ty->getAs();
 }
 
+bool Decl::isThisDeclarationADefinition() const {
+  if (auto *TD = dyn_cast(this))
+return TD->isThisDeclarationADefinition();
+  if (auto *FD = dyn_cast(this))
+return FD->isThisDeclarationADefinition();
+  if (auto *VD = dyn_cast(this))
+return VD->isThisDeclarationADefinition();
+  if (auto *CTD = dyn_cast(this))
+return CTD->isThisDeclarationADefinition();
+  if (auto *FTD = dyn_cast(this))
+return FTD->isThisDeclarationADefinition();
+  if (auto *VTD = dyn_cast(this))
+return VTD->isThisDeclarationADefinition();
+  return false;
+}
 
 /// Starting at a given context (a Decl or DeclContext), look for a
 /// code context that is not a closure (a lambda, block, etc.).
Index: tools/clang/lib/AST/Decl.cpp
===
--- tools/clang/lib/AST/Decl.cpp
+++ tools/clang/lib/AST/Decl.cpp
@@ -1536,6 +1536,10 @@
   if (isa(this))
 return false;
 
+  if (getFriendObjectKind() > OldD->getFriendObjectKind() &&
+  !isThisDeclarationADefinition())
+return false;
+
   // For parameters, pick the newer one. This is either an error or (in
   // Objective-C) permitted as an extension.
   if (isa(this))
Index: tools/clang/include/clang/AST/DeclBase.h
===
--- tools/clang/include/clang/AST/DeclBase.h
+++ tools/clang/include/clang/AST/DeclBase.h
@@ -417,6 +417,8 @@
 return const_cast(this)->getTranslationUnitDecl();
   }
 
+  bool isThisDeclarationADefinition() const;
+
   bool isInAnonymousNamespace() const;
 
   bool isInStdNamespace() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-04-12 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment.

Hi Daniel,

Thanks for your review!

Sorry I am not available until this Friday, then I will update my patch.

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-04-12 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D28670



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


[PATCH] D31886: [analyzer] Simplify values in binary operations more aggressively

2017-04-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 94955.
NoQ marked 5 inline comments as done.
NoQ added a comment.

Thanks for the comments! Updated.

Performance didn't degrade in my test runs.


https://reviews.llvm.org/D31886

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/additive-folding.cpp

Index: test/Analysis/additive-folding.cpp
===
--- test/Analysis/additive-folding.cpp
+++ test/Analysis/additive-folding.cpp
@@ -205,3 +205,12 @@
 
   clang_analyzer_eval(x == 3); // expected-warning{{UNKNOWN}}
 }
+
+void additiveSymSymFolding(int x, int y) {
+  // We should simplify 'x - 1' to '0' and handle the comparison,
+  // despite both sides being complicated symbols.
+  int z = x - 1;
+  if (x == 1)
+if (y >= 0)
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 
 using namespace clang;
 using namespace ento;
@@ -44,6 +45,10 @@
   ///  (integer) value, that value is returned. Otherwise, returns NULL.
   const llvm::APSInt *getKnownValue(ProgramStateRef state, SVal V) override;
 
+  /// Recursively descends into symbolic expressions and replaces symbols
+  /// with their known values (in the sense of the getKnownValue() method).
+  SVal simplifySVal(ProgramStateRef State, SVal V) override;
+
   SVal MakeSymIntVal(const SymExpr *LHS, BinaryOperator::Opcode op,
  const llvm::APSInt , QualType resultTy);
 };
@@ -537,11 +542,12 @@
   // Does the symbolic expression simplify to a constant?
   // If so, "fold" the constant by setting 'lhs' to a ConcreteInt
   // and try again.
-  ConstraintManager  = state->getConstraintManager();
-  if (const llvm::APSInt *Constant = CMgr.getSymVal(state, Sym)) {
-lhs = nonloc::ConcreteInt(*Constant);
-continue;
-  }
+  SVal simplifiedLhs = simplifySVal(state, lhs);
+  if (simplifiedLhs != lhs)
+if (auto simplifiedLhsAsNonLoc = simplifiedLhs.getAs()) {
+  lhs = *simplifiedLhsAsNonLoc;
+  continue;
+}
 
   // Is the RHS a constant?
   if (const llvm::APSInt *RHSValue = getKnownValue(state, rhs))
@@ -993,3 +999,74 @@
   // FIXME: Add support for SymExprs.
   return nullptr;
 }
+
+SVal SimpleSValBuilder::simplifySVal(ProgramStateRef State, SVal V) {
+  // For now, this function tries to constant-fold symbols inside a
+  // nonloc::SymbolVal, and does nothing else. More simplifications should
+  // be possible, such as constant-folding an index in an ElementRegion.
+
+  class Simplifier : public FullSValVisitor {
+ProgramStateRef State;
+SValBuilder 
+
+  public:
+Simplifier(ProgramStateRef State)
+: State(State), SVB(State->getStateManager().getSValBuilder()) {}
+
+SVal VisitSymbolData(const SymbolData *S) {
+  if (const llvm::APSInt *I =
+  SVB.getKnownValue(State, nonloc::SymbolVal(S)))
+return Loc::isLocType(S->getType()) ? (SVal)SVB.makeIntLocVal(*I)
+: (SVal)SVB.makeIntVal(*I);
+  return nonloc::SymbolVal(S);
+}
+
+// TODO: Support SymbolCast. Support IntSymExpr when/if we actually
+// start producing them.
+
+SVal VisitSymIntExpr(const SymIntExpr *S) {
+  SVal LHS = Visit(S->getLHS());
+  SVal RHS;
+  // By looking at the APSInt in the right-hand side of S, we cannot
+  // figure out if it should be treated as a Loc or as a NonLoc.
+  // So make our guess by recalling that we cannot multiply pointers
+  // or compare a pointer to an integer.
+  if (Loc::isLocType(S->getLHS()->getType()) &&
+  BinaryOperator::isComparisonOp(S->getOpcode())) {
+// The usual conversion of $sym to {$sym}, as they have
+// the same meaning for Loc-type symbols, but the latter form
+// is preferred in SVal computations for being Loc itself.
+if (SymbolRef Sym = LHS.getAsSymbol()) {
+  assert(Loc::isLocType(Sym->getType()));
+  LHS = SVB.makeLoc(Sym);
+}
+RHS = SVB.makeIntLocVal(S->getRHS());
+  } else {
+RHS = SVB.makeIntVal(S->getRHS());
+  }
+  return SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+}
+
+SVal VisitSymSymExpr(const SymSymExpr *S) {
+  SVal LHS = Visit(S->getLHS());
+  SVal RHS = Visit(S->getRHS());
+  return SVB.evalBinOp(State, S->getOpcode(), 

[PATCH] D28771: [Analyzer] Various fixes for the IteratorPastEnd checker

2017-04-12 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware abandoned this revision.
baloghadamsoftware added a comment.

Whole checker superseeded by https://reviews.llvm.org/D31975.


https://reviews.llvm.org/D28771



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


[PATCH] D29419: [Analyzer] Checker for mismatched iterators

2017-04-12 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware abandoned this revision.
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

Superseeded by patch https://reviews.llvm.org/D31975.


https://reviews.llvm.org/D29419



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


[PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2017-04-12 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud abandoned this revision.
aaboud marked an inline comment as not done.
aaboud added a comment.

Changes in this patch are being reviewed in a new patch 
https://reviews.llvm.org/D31871.


https://reviews.llvm.org/D22045



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


[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-04-12 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h:45
+:  public ProgramStatePartialTrait {
+  static void *GDMIndex() { static int index = 0; return  }
+};

Nit:  =0 is redundant


https://reviews.llvm.org/D30909



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


[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-04-12 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

Thanks! Looks like a valueable addition.




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2004
+void CStringChecker::evalMemset(CheckerContext , const CallExpr *CE) const {
+  if (CE->getNumArgs() < 3)
+return;

even better:  != 3



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2009
+
+  const Expr *S = CE->getArg(0);
+  const Expr *Size = CE->getArg(2);

The name "S" does not tell me much.. how about something like Data / DataArg / 
PtrArg / ..?



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2011
+  const Expr *Size = CE->getArg(2);
+  ProgramStateRef state = C.getState();
+

Variables should start with capital.. State, SizeVal, SizeTy, ...



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2034
+  // If the size can be nonzero, we have to check the other arguments.
+  if (stateNonZeroSize) {
+state = stateNonZeroSize;

use early return:

  if (!stateNonZeroSize)
return;


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


[PATCH] D31886: [analyzer] Simplify values in binary operations more aggressively

2017-04-12 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:49
+  /// Recursively descends into symbolic expressions and replaces symbols
+  /// with thier known values (in the sense of the getKnownValue() method).
+  SVal simplifySVal(ProgramStateRef State, SVal V) override;

thier => their


https://reviews.llvm.org/D31886



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


  1   2   >