r311428 - Update libprotobuf-mutator revision

2017-08-21 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Aug 21 22:18:28 2017
New Revision: 311428

URL: http://llvm.org/viewvc/llvm-project?rev=311428=rev
Log:
Update libprotobuf-mutator revision

Modified:
cfe/trunk/cmake/modules/ProtobufMutator.cmake

Modified: cfe/trunk/cmake/modules/ProtobufMutator.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/ProtobufMutator.cmake?rev=311428=311427=311428=diff
==
--- cfe/trunk/cmake/modules/ProtobufMutator.cmake (original)
+++ cfe/trunk/cmake/modules/ProtobufMutator.cmake Mon Aug 21 22:18:28 2017
@@ -6,7 +6,7 @@ set(PBM_FUZZ_LIB_PATH ${PBM_PATH}/src/li
 ExternalProject_Add(${PBM_PREFIX}
   PREFIX ${PBM_PREFIX}
   GIT_REPOSITORY https://github.com/google/libprotobuf-mutator.git
-  GIT_TAG 34287f8
+  GIT_TAG 17789d1
   CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
 -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}


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


[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-08-21 Thread wangxin via Phabricator via cfe-commits
wangxindsb added a comment.

@NoQ

In https://reviews.llvm.org/D34275#847434, @NoQ wrote:

> Most importantly, do you think we can enable the checker by default now? Was 
> this checker evaluated on any large codebase, and if so, how many true/false 
> positives did it find, probably compared to the old checker?


I am now runing the checker to check the build of firefox, llvm and 
libreoffice. There are no alarms on the building of firefox and llvm. When use 
scan-build to check the building of libreoffice, the scan-build failed (this 
may because the scan-build. Enable or not enable the virtualcallchecker, the 
build failed all the same, but when I just build the libreoffice and not run 
the scan-build, the build worked well) and there are 105 alarms about the 
virtual function in ctors/dtors, I am evaluating these alarms now.


https://reviews.llvm.org/D34275



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


[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-08-21 Thread wangxin via Phabricator via cfe-commits
wangxindsb updated this revision to Diff 112110.
wangxindsb added a comment.

- Fix the errors of the tests;
- Add `-analyzer-output=text` to the run-line;
- Change the message of the visitor's diagnostic piece.


https://reviews.llvm.org/D34275

Files:
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/virtualcall.cpp

Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,98 +1,86 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
-
-/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
-   from a constructor or destructor. If it is not set, we expect diagnostics
-   only in the constructor or destructor.
-
-   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
-   functions not to non-pure virtual functions.
-*/
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-output=text -verify -std=c++11 %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -analyzer-output=text -verify -std=c++11 %s
 
 class A {
 public:
   A();
-  A(int i);
 
-  ~A() {};
-  
-  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
+  ~A(){};
+
+  virtual int foo() = 0;
   virtual void bar() = 0;
   void f() {
 foo();
-#if INTERPROCEDURAL
-// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
+#if PUREONLY
+	// expected-warning-re@-2 ^}}Call to pure virtual function during construction}}
+	// expected-note-re@-3 ^}}Call to pure virtual function during construction}}
+#else 
+	// expected-warning-re@-5 ^}}Call to virtual function during construction}}
+	// expected-note-re@-6 ^}}Call to virtual function during construction}}
 #endif
   }
 };
 
 class B : public A {
 public:
-  B() {
-foo();
+  B() { // expected-note {{Calling default constructor for 'A'}}
+foo(); 
 #if !PUREONLY
-#if INTERPROCEDURAL
-// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
-#else
-// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+  	// expected-warning-re@-2 ^}}Call to virtual function during construction}}
+	// expected-note-re@-3 ^}}This constructor of an object of type 'B' has not returned when the virtual method was called}}
+  	// expected-note-re@-4 ^}}Call to virtual function during construction}}
 #endif
-#endif
-
   }
   ~B();
-  
+
   virtual int foo();
-  virtual void bar() { foo(); }
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
+  virtual void bar() {
+foo(); 
+#if !PUREONLY
+  	// expected-warning-re@-2 ^}}Call to virtual function during destruction}}
+  	// expected-note-re@-3 ^}}Call to virtual function during destruction}}
 #endif
+  } 
 };
 
-A::A() {
-  f();
-}
-
-A::A(int i) {
-  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
-#if INTERPROCEDURAL
-  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
-#else
-  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
-#endif
+A::A() { 
+  f(); 
+// expected-note-re@-1 ^}}This constructor of an object of type 'A' has not returned when the virtual method was called}}
+// expected-note-re@-2 ^}}Calling 'A::f'}}
 }
 
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-  this->foo();
 #if !PUREONLY
-#if INTERPROCEDURAL
-  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
-#else
-  // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}}
+ 	 // expected-note-re@-2 ^}}This destructor of an object of type '~B' has not returned when the virtual method was called}}
+ 	 // expected-note-re@-3 ^}}Calling 'B::bar'}}
 #endif
+  this->foo(); 
+#if !PUREONLY
+ 	 // expected-warning-re@-2 

[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2017-08-21 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete updated this revision to Diff 112103.
Rakete added a comment.

Rebased and friendly ping.


https://reviews.llvm.org/D36357

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExprCXX.cpp
  test/Parser/cxx0x-lambda-expressions.cpp
  test/SemaCXX/new-delete-0x.cpp


Index: test/SemaCXX/new-delete-0x.cpp
===
--- test/SemaCXX/new-delete-0x.cpp
+++ test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,5 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error{{missing parentheses 
around lambda expression}}
 }
Index: test/Parser/cxx0x-lambda-expressions.cpp
===
--- test/Parser/cxx0x-lambda-expressions.cpp
+++ test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,7 +53,7 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error{{missing parentheses 
around lambda expression}}
 delete [&] { return new int; } (); // ok, lambda
   }
 
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -2885,15 +2885,39 @@
 //   [Footnote: A lambda expression with a lambda-introducer that consists
 //  of empty square brackets can follow the delete keyword if
 //  the lambda expression is enclosed in parentheses.]
-// FIXME: Produce a better diagnostic if the '[]' is unambiguously a
-//lambda-introducer.
-ArrayDelete = true;
-BalancedDelimiterTracker T(*this, tok::l_square);
+TentativeParsingAction TPA(*this);
 
-T.consumeOpen();
-T.consumeClose();
-if (T.getCloseLocation().isInvalid())
-  return ExprError();
+// Basic lookahead to check if we have a lambda expression. If we
+// encounter two braces with a semicolon, we can be pretty sure
+// that this is a lambda, not say a compound literal. 
+if (!SkipUntil(tok::l_brace, SkipUntilFlags::StopAtSemi) ||
+(NextToken().isNot(tok::r_brace) && !SkipUntil(tok::semi)) ||
+!SkipUntil(tok::r_brace, SkipUntilFlags::StopAtSemi)) {
+  TPA.Revert();
+  ArrayDelete = true;
+  BalancedDelimiterTracker T(*this, tok::l_square);
+
+  T.consumeOpen();
+  T.consumeClose();
+  if (T.getCloseLocation().isInvalid())
+return ExprError();
+} else {
+  TPA.Revert();
+
+  // Warn if the non-capturing lambda isn't surrounded by parenthesis
+  // to disambiguate it from 'delete[]'.
+  ExprResult Lambda = TryParseLambdaExpression();
+  if (!Lambda.isInvalid()) {
+SourceLocation StartLoc = Lambda.get()->getLocStart();
+Diag(StartLoc, diag::err_lambda_after_array_delete)
+  << SourceRange(StartLoc, Lambda.get()->getLocEnd());
+
+// Evaluate any postfix expressions used on the lambda.
+Lambda = ParsePostfixExpressionSuffix(Lambda);
+return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false,
+  Lambda.get());
+  }
+}
   }
 
   ExprResult Operand(ParseCastExpression(false));
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -99,6 +99,8 @@
   InGroup, DefaultIgnore;
 def ext_alignof_expr : ExtWarn<
   "%0 applied to an expression is a GNU extension">, 
InGroup;
+def err_lambda_after_array_delete : Error<
+  "missing parentheses around lambda expression">;
 
 def warn_microsoft_dependent_exists : Warning<
   "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, 


Index: test/SemaCXX/new-delete-0x.cpp
===
--- test/SemaCXX/new-delete-0x.cpp
+++ test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,5 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error{{missing parentheses around lambda expression}}
 }
Index: test/Parser/cxx0x-lambda-expressions.cpp
===
--- test/Parser/cxx0x-lambda-expressions.cpp
+++ test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,7 +53,7 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] 

r311422 - Test fix: only add shared libraries to rpath.

2017-08-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Aug 21 19:10:53 2017
New Revision: 311422

URL: http://llvm.org/viewvc/llvm-project?rev=311422=rev
Log:
Test fix: only add shared libraries to rpath.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=311422=311421=311422=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Aug 21 19:10:53 2017
@@ -998,7 +998,7 @@ void DarwinClang::AddLinkSanitizerLibArg
   (Twine("libclang_rt.") + Sanitizer + "_" +
getOSLibraryNameSuffix() + (Shared ? "_dynamic.dylib" : ".a")).str(),
   /*AlwaysLink*/ true, /*IsEmbedded*/ false,
-  /*AddRPath*/ true);
+  /*AddRPath*/ Shared);
 }
 
 ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType(


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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-21 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

It's just too bad llvm::cantFail() doesn't take an optional string.
But the code is cleaner, so I won't comment further.


https://reviews.llvm.org/D36806



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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-21 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

LGTM.  You should probably get one other person to approve though.  I'm hoping 
that @EricWF or @mclow.lists will take a look


https://reviews.llvm.org/D36423



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


r311412 - Fixed driver tests for -fsanitize=fuzzer.

2017-08-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Aug 21 17:04:05 2017
New Revision: 311412

URL: http://llvm.org/viewvc/llvm-project?rev=311412=rev
Log:
Fixed driver tests for -fsanitize=fuzzer.

Modified:
cfe/trunk/test/Driver/fuzzer.c

Modified: cfe/trunk/test/Driver/fuzzer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuzzer.c?rev=311412=311411=311412=diff
==
--- cfe/trunk/test/Driver/fuzzer.c (original)
+++ cfe/trunk/test/Driver/fuzzer.c Mon Aug 21 17:04:05 2017
@@ -2,7 +2,7 @@
 
 // RUN: %clang -fsanitize=fuzzer %s -target x86_64-apple-darwin14 -### 2>&1 | 
FileCheck --check-prefixes=CHECK-FUZZER-LIB,CHECK-COVERAGE-FLAGS %s
 //
-// CHECK-FUZZER-LIB: libclang_rt.libfuzzer
+// CHECK-FUZZER-LIB: libclang_rt.fuzzer
 // CHECK-COVERAGE: -fsanitize-coverage-trace-pc-guard
 // CHECK-COVERAGE-SAME: -fsanitize-coverage-indirect-calls
 // CHECK-COVERAGE-SAME: -fsanitize-coverage-trace-cmp


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


Re: r309226 - Headers: improve ARM EHABI coverage of unwind.h

2017-08-21 Thread Hans Wennborg via cfe-commits
Is there something we need for 5.0.0 here?

On Sat, Aug 12, 2017 at 9:58 PM, Saleem Abdulrasool
 wrote:
> Yeah, we should adjust that.  Technically, it is `_Unwind_Control_Block on
> ARM EHABI.  However, _Unwind_Exception is aliased to that, which is why we
> can use that in the personality routine.  We should adjust the sources for
> the personality routine.
>
> On Fri, Aug 11, 2017 at 1:12 PM, Evgenii Stepanov
>  wrote:
>>
>> Hi,
>>
>> I've noticed that the code in
>> compiler-rt/lib/builtins/gcc_personality_v0.c refers to
>> _Unwind_Exception as "struct _Unwind_Exception". With this change, it
>> is not a struct anymore on ARM. Should that code be fixed, or is it a
>> problem in this change?
>>
>> compiler-rt/lib/builtins/gcc_personality_v0.c:153:23: error:
>> declaration of 'struct _Unwind_Exception' will not be visible outside
>> of this function [-Werror,-Wvisibility]
>> continueUnwind(struct _Unwind_Exception *exceptionObject,
>>
>> On Thu, Jul 27, 2017 at 9:46 AM, Hans Wennborg via cfe-commits
>>  wrote:
>> > Merged to 5.0 in r309290.
>> >
>> > On Wed, Jul 26, 2017 at 3:55 PM, Saleem Abdulrasool via cfe-commits
>> >  wrote:
>> >> Author: compnerd
>> >> Date: Wed Jul 26 15:55:23 2017
>> >> New Revision: 309226
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=309226=rev
>> >> Log:
>> >> Headers: improve ARM EHABI coverage of unwind.h
>> >>
>> >> Ensure that we define the `_Unwind_Control_Block` structure used on ARM
>> >> EHABI targets.  This is needed for building libc++abi with the unwind.h
>> >> from the resource dir.  A minor fallout of this is that we needed to
>> >> create a typedef for _Unwind_Exception to work across ARM EHABI and
>> >> non-EHABI targets.  The structure definitions here are based originally
>> >> on the documentation from ARM under the "Exception Handling ABI for the
>> >> ARM® Architecture" Section 7.2.  They are then adjusted to more closely
>> >> reflect the definition in libunwind from LLVM.  Those changes are
>> >> compatible in layout but permit easier use in libc++abi and help
>> >> maintain compatibility between libunwind and the compiler provided
>> >> definition.
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/Headers/unwind.h
>> >>
>> >> Modified: cfe/trunk/lib/Headers/unwind.h
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/unwind.h?rev=309226=309225=309226=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Headers/unwind.h (original)
>> >> +++ cfe/trunk/lib/Headers/unwind.h Wed Jul 26 15:55:23 2017
>> >> @@ -76,7 +76,13 @@ typedef intptr_t _sleb128_t;
>> >>  typedef uintptr_t _uleb128_t;
>> >>
>> >>  struct _Unwind_Context;
>> >> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) ||
>> >> defined(__ARM_DWARF_EH___))
>> >> +struct _Unwind_Control_Block;
>> >> +typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
>> >> +#else
>> >>  struct _Unwind_Exception;
>> >> +typedef struct _Unwind_Exception _Unwind_Exception;
>> >> +#endif
>> >>  typedef enum {
>> >>_URC_NO_REASON = 0,
>> >>  #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
>> >> @@ -109,8 +115,42 @@ typedef enum {
>> >>  } _Unwind_Action;
>> >>
>> >>  typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code,
>> >> - struct _Unwind_Exception
>> >> *);
>> >> + _Unwind_Exception *);
>> >>
>> >> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) ||
>> >> defined(__ARM_DWARF_EH___))
>> >> +typedef struct _Unwind_Control_Block _Unwind_Control_Block;
>> >> +typedef uint32_t _Unwind_EHT_Header;
>> >> +
>> >> +struct _Unwind_Control_Block {
>> >> +  uint64_t exception_class;
>> >> +  void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block
>> >> *);
>> >> +  /* unwinder cache (private fields for the unwinder's use) */
>> >> +  struct {
>> >> +uint32_t reserved1; /* forced unwind stop function, 0 if not
>> >> forced */
>> >> +uint32_t reserved2; /* personality routine */
>> >> +uint32_t reserved3; /* callsite */
>> >> +uint32_t reserved4; /* forced unwind stop argument */
>> >> +uint32_t reserved5;
>> >> +  } unwinder_cache;
>> >> +  /* propagation barrier cache (valid after phase 1) */
>> >> +  struct {
>> >> +uint32_t sp;
>> >> +uint32_t bitpattern[5];
>> >> +  } barrier_cache;
>> >> +  /* cleanup cache (preserved over cleanup) */
>> >> +  struct {
>> >> +uint32_t bitpattern[4];
>> >> +  } cleanup_cache;
>> >> +  /* personality cache (for personality's benefit) */
>> >> +  struct {
>> >> +uint32_t fnstart; /* function start address */
>> >> +_Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
>> >> +uint32_t additional;  /* additional data */
>> >> +uint32_t reserved1;
>> >> + 

[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-21 Thread don hinton via Phabricator via cfe-commits
hintonda added inline comments.



Comment at: lib/Tooling/Core/Replacement.cpp:505
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));

srhines wrote:
> hintonda wrote:
> > srhines wrote:
> > > hintonda wrote:
> > > > While obviously correct, are you concerned that by removing the 
> > > > explanatory text, this change will obscure the reason for the assert?
> > > The text is now in a comment above the call.
> > Well, that's what I mean.  The reason is no longer in the backtrace.
> The backtrace will point to this exact line, so I assume anyone debugging it 
> will eventually read the comment. It might be better to have an optional 
> message to cantFail(), but that isn't within the scope of this change.
Sorry, I meant the output of llvm::sys::PrintStackTrace(), which include the 
assert.


https://reviews.llvm.org/D36806



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


Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-21 Thread Hans Wennborg via cfe-commits
Clean merge in r311410. Thanks.

On Mon, Aug 21, 2017 at 4:21 PM, Richard Smith  wrote:
> Yes, I'd very much like to get this into the upcoming release.
>
> On 21 August 2017 at 16:16, Hans Wennborg  wrote:
>>
>> PR19668 was marked as a release blocker. Is this suitable for merging?
>>
>> On Tue, Aug 15, 2017 at 6:49 PM, Richard Smith via cfe-commits
>>  wrote:
>> > Author: rsmith
>> > Date: Tue Aug 15 18:49:53 2017
>> > New Revision: 310983
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=310983=rev
>> > Log:
>> > PR19668, PR23034: Fix handling of move constructors and deleted copy
>> > constructors when deciding whether classes should be passed indirectly.
>> >
>> > This fixes ABI differences between Clang and GCC:
>> >
>> >  * Previously, Clang ignored the move constructor when making this
>> >determination. It now takes the move constructor into account, per
>> >https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
>> >seem recent, but the ABI change was agreed on the Itanium C++ ABI
>> >list a long time ago).
>> >
>> >  * Previously, Clang's behavior when the copy constructor was deleted
>> >was unstable -- depending on whether the lazy declaration of the
>> >copy constructor had been triggered, you might get different
>> > behavior.
>> >We now eagerly declare the copy constructor whenever its deletedness
>> >is unclear, and ignore deleted copy/move constructors when looking
>> > for
>> >a trivial such constructor.
>> >
>> > This also fixes an ABI difference between Clang and MSVC:
>> >
>> >  * If the copy constructor would be implicitly deleted (but has not been
>> >lazily declared yet), for instance because the class has an rvalue
>> >reference member, we would pass it directly. We now pass such a class
>> >indirectly, matching MSVC.
>> >
>> > Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
>> > Schmidt, which was based on a patch by Reid Kleckner!
>> >
>> > This is a re-commit of r310401, which was reverted in r310464 due to ARM
>> > failures (which should now be fixed).
>> >
>> > Modified:
>> > cfe/trunk/include/clang/AST/DeclCXX.h
>> > cfe/trunk/lib/AST/ASTImporter.cpp
>> > cfe/trunk/lib/AST/DeclCXX.cpp
>> > cfe/trunk/lib/CodeGen/CGCXXABI.cpp
>> > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>> > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>> > cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>> > cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
>> > cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>> >
>> > Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310983=310982=310983=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> > +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017
>> > @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl
>> >  /// \brief These flags are \c true if a defaulted corresponding
>> > special
>> >  /// member can't be fully analyzed without performing overload
>> > resolution.
>> >  /// @{
>> > +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>> >  unsigned NeedOverloadResolutionForMoveConstructor : 1;
>> >  unsigned NeedOverloadResolutionForMoveAssignment : 1;
>> >  unsigned NeedOverloadResolutionForDestructor : 1;
>> > @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl
>> >  /// \brief These flags are \c true if an implicit defaulted
>> > corresponding
>> >  /// special member would be defined as deleted.
>> >  /// @{
>> > +unsigned DefaultedCopyConstructorIsDeleted : 1;
>> >  unsigned DefaultedMoveConstructorIsDeleted : 1;
>> >  unsigned DefaultedMoveAssignmentIsDeleted : 1;
>> >  unsigned DefaultedDestructorIsDeleted : 1;
>> > @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl
>> >  /// constructor.
>> >  unsigned HasDefaultedDefaultConstructor : 1;
>> >
>> > +/// \brief True if this class can be passed in a
>> > non-address-preserving
>> > +/// fashion (such as in registers) according to the C++ language
>> > rules.
>> > +/// This does not imply anything about how the ABI in use will
>> > actually
>> > +/// pass an object of this class.
>> > +unsigned CanPassInRegisters : 1;
>> > +
>> >  /// \brief True if a defaulted default constructor for this class
>> > would
>> >  /// be constexpr.
>> >  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
>> > @@ -810,18 +818,50 @@ public:
>> >  return data().FirstFriend.isValid();
>> >}
>> >
>> > +  /// \brief \c true if a defaulted copy constructor for this class
>> > would be
>> > +  /// 

[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-21 Thread Stephen Hines via Phabricator via cfe-commits
srhines marked an inline comment as done.
srhines added inline comments.



Comment at: lib/Tooling/Core/Replacement.cpp:505
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));

hintonda wrote:
> srhines wrote:
> > hintonda wrote:
> > > While obviously correct, are you concerned that by removing the 
> > > explanatory text, this change will obscure the reason for the assert?
> > The text is now in a comment above the call.
> Well, that's what I mean.  The reason is no longer in the backtrace.
The backtrace will point to this exact line, so I assume anyone debugging it 
will eventually read the comment. It might be better to have an optional 
message to cantFail(), but that isn't within the scope of this change.


https://reviews.llvm.org/D36806



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


r311406 - Moving libFuzzer to compiler-rt: required updates to the Clang driver.

2017-08-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Aug 21 16:25:19 2017
New Revision: 311406

URL: http://llvm.org/viewvc/llvm-project?rev=311406=rev
Log:
Moving libFuzzer to compiler-rt: required updates to the Clang driver.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.h
cfe/trunk/test/Driver/fuzzer.c

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=311406=311405=311406=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon Aug 21 16:25:19 2017
@@ -597,19 +597,6 @@ collectSanitizerRuntimes(const ToolChain
 StaticRuntimes.push_back("esan");
 }
 
-static void addLibFuzzerRuntime(const ToolChain ,
-const ArgList ,
-ArgStringList ) {
-  StringRef ParentDir =
-  llvm::sys::path::parent_path(TC.getDriver().InstalledDir);
-  SmallString<128> P(ParentDir);
-  llvm::sys::path::append(P, "lib", "libLLVMFuzzer.a");
-  CmdArgs.push_back(Args.MakeArgString(P));
-  if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
-TC.AddCXXStdlibLibArgs(Args, CmdArgs);
-}
-
-
 // Should be called before we add system libraries (C++ ABI, libstdc++/libc++,
 // C runtime, etc). Returns true if sanitizer system deps need to be linked in.
 bool tools::addSanitizerRuntimes(const ToolChain , const ArgList ,
@@ -619,10 +606,14 @@ bool tools::addSanitizerRuntimes(const T
   collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
NonWholeStaticRuntimes, HelperStaticRuntimes,
RequiredSymbols);
+
   // Inject libfuzzer dependencies.
   if (TC.getSanitizerArgs().needsFuzzer()
   && !Args.hasArg(options::OPT_shared)) {
-addLibFuzzerRuntime(TC, Args, CmdArgs);
+
+addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true);
+if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
+  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
   }
 
   for (auto RT : SharedRuntimes)

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=311406=311405=311406=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Aug 21 16:25:19 2017
@@ -930,18 +930,6 @@ void MachO::AddLinkRuntimeLib(const ArgL
   }
 }
 
-void MachO::AddFuzzerLinkArgs(const ArgList , ArgStringList ) 
const {
-
-  // Go up one directory from Clang to find the libfuzzer archive file.
-  StringRef ParentDir = llvm::sys::path::parent_path(getDriver().InstalledDir);
-  SmallString<128> P(ParentDir);
-  llvm::sys::path::append(P, "lib", "libLLVMFuzzer.a");
-  CmdArgs.push_back(Args.MakeArgString(P));
-
-  // Libfuzzer is written in C++ and requires libcxx.
-  AddCXXStdlibLibArgs(Args, CmdArgs);
-}
-
 StringRef Darwin::getPlatformFamily() const {
   switch (TargetPlatform) {
 case DarwinPlatformKind::MacOS:
@@ -1003,11 +991,12 @@ void Darwin::addProfileRTLibs(const ArgL
 
 void DarwinClang::AddLinkSanitizerLibArgs(const ArgList ,
   ArgStringList ,
-  StringRef Sanitizer) const {
+  StringRef Sanitizer,
+  bool Shared) const {
   AddLinkRuntimeLib(
   Args, CmdArgs,
   (Twine("libclang_rt.") + Sanitizer + "_" +
-   getOSLibraryNameSuffix() + "_dynamic.dylib").str(),
+   getOSLibraryNameSuffix() + (Shared ? "_dynamic.dylib" : ".a")).str(),
   /*AlwaysLink*/ true, /*IsEmbedded*/ false,
   /*AddRPath*/ true);
 }
@@ -1053,8 +1042,12 @@ void DarwinClang::AddLinkRuntimeLibArgs(
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
   if (Sanitize.needsTsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
-  if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib))
-AddFuzzerLinkArgs(Args, CmdArgs);
+  if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
+AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false);
+
+// Libfuzzer is written in C++ and requires libcxx.
+AddCXXStdlibLibArgs(Args, CmdArgs);
+  }
   if (Sanitize.needsStatsRt()) {
 StringRef OS = isTargetMacOS() ? "osx" : "iossim";
 AddLinkRuntimeLib(Args, CmdArgs,

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.h?rev=311406=311405=311406=diff
==
--- 

Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-21 Thread Richard Smith via cfe-commits
Yes, I'd very much like to get this into the upcoming release.

On 21 August 2017 at 16:16, Hans Wennborg  wrote:

> PR19668 was marked as a release blocker. Is this suitable for merging?
>
> On Tue, Aug 15, 2017 at 6:49 PM, Richard Smith via cfe-commits
>  wrote:
> > Author: rsmith
> > Date: Tue Aug 15 18:49:53 2017
> > New Revision: 310983
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=310983=rev
> > Log:
> > PR19668, PR23034: Fix handling of move constructors and deleted copy
> > constructors when deciding whether classes should be passed indirectly.
> >
> > This fixes ABI differences between Clang and GCC:
> >
> >  * Previously, Clang ignored the move constructor when making this
> >determination. It now takes the move constructor into account, per
> >https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
> >seem recent, but the ABI change was agreed on the Itanium C++ ABI
> >list a long time ago).
> >
> >  * Previously, Clang's behavior when the copy constructor was deleted
> >was unstable -- depending on whether the lazy declaration of the
> >copy constructor had been triggered, you might get different behavior.
> >We now eagerly declare the copy constructor whenever its deletedness
> >is unclear, and ignore deleted copy/move constructors when looking for
> >a trivial such constructor.
> >
> > This also fixes an ABI difference between Clang and MSVC:
> >
> >  * If the copy constructor would be implicitly deleted (but has not been
> >lazily declared yet), for instance because the class has an rvalue
> >reference member, we would pass it directly. We now pass such a class
> >indirectly, matching MSVC.
> >
> > Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
> > Schmidt, which was based on a patch by Reid Kleckner!
> >
> > This is a re-commit of r310401, which was reverted in r310464 due to ARM
> > failures (which should now be fixed).
> >
> > Modified:
> > cfe/trunk/include/clang/AST/DeclCXX.h
> > cfe/trunk/lib/AST/ASTImporter.cpp
> > cfe/trunk/lib/AST/DeclCXX.cpp
> > cfe/trunk/lib/CodeGen/CGCXXABI.cpp
> > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
> > cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> > cfe/trunk/lib/Serialization/ASTWriter.cpp
> > cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
> > cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
> >
> > Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=310983=310982=310983=diff
> > 
> ==
> > --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> > +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017
> > @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl
> >  /// \brief These flags are \c true if a defaulted corresponding
> special
> >  /// member can't be fully analyzed without performing overload
> resolution.
> >  /// @{
> > +unsigned NeedOverloadResolutionForCopyConstructor : 1;
> >  unsigned NeedOverloadResolutionForMoveConstructor : 1;
> >  unsigned NeedOverloadResolutionForMoveAssignment : 1;
> >  unsigned NeedOverloadResolutionForDestructor : 1;
> > @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl
> >  /// \brief These flags are \c true if an implicit defaulted
> corresponding
> >  /// special member would be defined as deleted.
> >  /// @{
> > +unsigned DefaultedCopyConstructorIsDeleted : 1;
> >  unsigned DefaultedMoveConstructorIsDeleted : 1;
> >  unsigned DefaultedMoveAssignmentIsDeleted : 1;
> >  unsigned DefaultedDestructorIsDeleted : 1;
> > @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl
> >  /// constructor.
> >  unsigned HasDefaultedDefaultConstructor : 1;
> >
> > +/// \brief True if this class can be passed in a
> non-address-preserving
> > +/// fashion (such as in registers) according to the C++ language
> rules.
> > +/// This does not imply anything about how the ABI in use will
> actually
> > +/// pass an object of this class.
> > +unsigned CanPassInRegisters : 1;
> > +
> >  /// \brief True if a defaulted default constructor for this class
> would
> >  /// be constexpr.
> >  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
> > @@ -810,18 +818,50 @@ public:
> >  return data().FirstFriend.isValid();
> >}
> >
> > +  /// \brief \c true if a defaulted copy constructor for this class
> would be
> > +  /// deleted.
> > +  bool defaultedCopyConstructorIsDeleted() const {
> > +assert((!needsOverloadResolutionForCopyConstructor() ||
> > +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
> > +   "this property has not yet been 

Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-21 Thread Hans Wennborg via cfe-commits
PR19668 was marked as a release blocker. Is this suitable for merging?

On Tue, Aug 15, 2017 at 6:49 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Tue Aug 15 18:49:53 2017
> New Revision: 310983
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310983=rev
> Log:
> PR19668, PR23034: Fix handling of move constructors and deleted copy
> constructors when deciding whether classes should be passed indirectly.
>
> This fixes ABI differences between Clang and GCC:
>
>  * Previously, Clang ignored the move constructor when making this
>determination. It now takes the move constructor into account, per
>https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
>seem recent, but the ABI change was agreed on the Itanium C++ ABI
>list a long time ago).
>
>  * Previously, Clang's behavior when the copy constructor was deleted
>was unstable -- depending on whether the lazy declaration of the
>copy constructor had been triggered, you might get different behavior.
>We now eagerly declare the copy constructor whenever its deletedness
>is unclear, and ignore deleted copy/move constructors when looking for
>a trivial such constructor.
>
> This also fixes an ABI difference between Clang and MSVC:
>
>  * If the copy constructor would be implicitly deleted (but has not been
>lazily declared yet), for instance because the class has an rvalue
>reference member, we would pass it directly. We now pass such a class
>indirectly, matching MSVC.
>
> Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
> Schmidt, which was based on a patch by Reid Kleckner!
>
> This is a re-commit of r310401, which was reverted in r310464 due to ARM
> failures (which should now be fixed).
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/CodeGen/CGCXXABI.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310983=310982=310983=diff
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017
> @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if a defaulted corresponding special
>  /// member can't be fully analyzed without performing overload 
> resolution.
>  /// @{
> +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveAssignment : 1;
>  unsigned NeedOverloadResolutionForDestructor : 1;
> @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if an implicit defaulted corresponding
>  /// special member would be defined as deleted.
>  /// @{
> +unsigned DefaultedCopyConstructorIsDeleted : 1;
>  unsigned DefaultedMoveConstructorIsDeleted : 1;
>  unsigned DefaultedMoveAssignmentIsDeleted : 1;
>  unsigned DefaultedDestructorIsDeleted : 1;
> @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl
>  /// constructor.
>  unsigned HasDefaultedDefaultConstructor : 1;
>
> +/// \brief True if this class can be passed in a non-address-preserving
> +/// fashion (such as in registers) according to the C++ language rules.
> +/// This does not imply anything about how the ABI in use will actually
> +/// pass an object of this class.
> +unsigned CanPassInRegisters : 1;
> +
>  /// \brief True if a defaulted default constructor for this class would
>  /// be constexpr.
>  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
> @@ -810,18 +818,50 @@ public:
>  return data().FirstFriend.isValid();
>}
>
> +  /// \brief \c true if a defaulted copy constructor for this class would be
> +  /// deleted.
> +  bool defaultedCopyConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForCopyConstructor() ||
> +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
> +   "this property has not yet been computed by Sema");
> +return data().DefaultedCopyConstructorIsDeleted;
> +  }
> +
> +  /// \brief \c true if a defaulted move constructor for this class would be
> +  /// deleted.
> +  bool defaultedMoveConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForMoveConstructor() ||
> +(data().DeclaredSpecialMembers 

[PATCH] D36989: [clang-diff] Refactor stop-after command-line flag

2017-08-21 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google created this revision.
Herald added subscribers: aheejin, klimek.

Rename stop-after to stop-after-topdown. When building LLVM with
-DLLVM_BUILD_LLVM_DYLIB=ON, stop-after collides with the stop-after
already present in LLVM.

This also refactors the flag to a boolean, to reflect that it can only
be in two states.


https://reviews.llvm.org/D36989

Files:
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-topdown.cpp
  tools/clang-diff/ClangDiff.cpp


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -21,7 +21,7 @@
 using namespace clang;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangDiffCategory("clang-diff options");
+cl::OptionCategory ClangDiffCategory("clang-diff options");
 
 static cl::opt
 ASTDump("ast-dump",
@@ -50,11 +50,6 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static cl::opt StopAfter("stop-after",
-  cl::desc(""),
-  cl::Optional, cl::init(""),
-  cl::cat(ClangDiffCategory));
-
 static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
 cl::init(-1), cl::cat(ClangDiffCategory));
 
@@ -442,14 +437,6 @@
   diff::ComparisonOptions Options;
   if (MaxSize != -1)
 Options.MaxSize = MaxSize;
-  if (!StopAfter.empty()) {
-if (StopAfter == "topdown")
-  Options.StopAfterTopDown = true;
-else if (StopAfter != "bottomup") {
-  llvm::errs() << "Error: Invalid argument for -stop-after\n";
-  return 1;
-}
-  }
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff Diff(SrcTree, DstTree, Options);
Index: test/Tooling/clang-diff-topdown.cpp
===
--- test/Tooling/clang-diff-topdown.cpp
+++ test/Tooling/clang-diff-topdown.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E %s > %t.src.cpp
 // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
-// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- 
-std=c++11 | FileCheck %s
+// RUN: clang-diff -dump-matches -stop-after-topdown %t.src.cpp %t.dst.cpp -- 
-std=c++11 | FileCheck %s
 //
 // Test the top-down matching of identical subtrees only.
 
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -16,14 +16,21 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/PriorityQueue.h"
+#include "llvm/Support/CommandLine.h"
 
 #include 
 #include 
 #include 
 
 using namespace llvm;
 using namespace clang;
 
+extern cl::OptionCategory ClangDiffCategory;
+static cl::opt StopAfterTopDown("stop-after-topdown",
+  cl::desc("Stops after top-down 
matching"),
+  cl::Optional, cl::init(false),
+  cl::cat(ClangDiffCategory));
+
 namespace clang {
 namespace diff {
 
@@ -891,7 +898,7 @@
 
 void ASTDiff::Impl::computeMapping() {
   TheMapping = matchTopDown();
-  if (Options.StopAfterTopDown)
+  if (StopAfterTopDown)
 return;
   matchBottomUp(TheMapping);
 }


Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -21,7 +21,7 @@
 using namespace clang;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangDiffCategory("clang-diff options");
+cl::OptionCategory ClangDiffCategory("clang-diff options");
 
 static cl::opt
 ASTDump("ast-dump",
@@ -50,11 +50,6 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static cl::opt StopAfter("stop-after",
-  cl::desc(""),
-  cl::Optional, cl::init(""),
-  cl::cat(ClangDiffCategory));
-
 static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
 cl::init(-1), cl::cat(ClangDiffCategory));
 
@@ -442,14 +437,6 @@
   diff::ComparisonOptions Options;
   if (MaxSize != -1)
 Options.MaxSize = MaxSize;
-  if (!StopAfter.empty()) {
-if (StopAfter == "topdown")
-  Options.StopAfterTopDown = true;
-else if (StopAfter != "bottomup") {
-  llvm::errs() << "Error: Invalid argument for -stop-after\n";
-  return 1;
-}
-  }
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff Diff(SrcTree, DstTree, Options);
Index: 

r311397 - [Driver][Darwin] Do not pass -munwind-table if -fno-excpetions is

2017-08-21 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Aug 21 15:46:46 2017
New Revision: 311397

URL: http://llvm.org/viewvc/llvm-project?rev=311397=rev
Log:
[Driver][Darwin] Do not pass -munwind-table if -fno-excpetions is
supplied.

With this change, -fno-exceptions disables unwind tables unless
-funwind-tables is supplied too or the target is x86-64 (x86-64 requires
emitting unwind tables).

rdar://problem/33934446

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/clang-translation.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=311397=311396=311397=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Aug 21 15:46:46 2017
@@ -1845,7 +1845,12 @@ Darwin::TranslateArgs(const DerivedArgLi
 }
 
 bool MachO::IsUnwindTablesDefault(const ArgList ) const {
-  return !UseSjLjExceptions(Args);
+  // Unwind tables are not emitted if -fno-exceptions is supplied (except when
+  // targeting x86_64).
+  return getArch() == llvm::Triple::x86_64 ||
+ (!UseSjLjExceptions(Args) &&
+  Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
+   true));
 }
 
 bool MachO::UseDwarfDebugFlags() const {

Modified: cfe/trunk/test/Driver/clang-translation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=311397=311396=311397=diff
==
--- cfe/trunk/test/Driver/clang-translation.c (original)
+++ cfe/trunk/test/Driver/clang-translation.c Mon Aug 21 15:46:46 2017
@@ -73,6 +73,10 @@
 // RUN: FileCheck -check-prefix=ARM64-APPLE %s
 // ARM64-APPLE: -munwind-table
 
+// RUN: %clang -target arm64-apple-ios10 -fno-exceptions -### -S %s -arch 
arm64 2>&1 | \
+// RUN: FileCheck -check-prefix=ARM64-APPLE-EXCEP %s
+// ARM64-APPLE-EXCEP-NOT: -munwind-table
+
 // RUN: %clang -target armv7k-apple-watchos4.0 -### -S %s -arch armv7k 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMV7K-APPLE %s
 // ARMV7K-APPLE: -munwind-table


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


[PATCH] D36853: [Parser] Correct initalizer typos before lambda capture type is deduced.

2017-08-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for review, Alex. I've requested commit access and plan to commit the 
change myself to make sure everything works as expected.


https://reviews.llvm.org/D36853



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


r311391 - [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure.

2017-08-21 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Mon Aug 21 15:19:33 2017
New Revision: 311391

URL: http://llvm.org/viewvc/llvm-project?rev=311391=rev
Log:
[Driver] Recognize DevDiv internal builds of MSVC, with a different directory 
structure.

This is a reasonably non-intrusive change, which I've verified
works for both x86 and x64 DevDiv-internal builds.

The idea is to change `bool IsVS2017OrNewer` into a 3-state
`ToolsetLayout VSLayout`. Either a build is DevDiv-internal,
released VS 2017 or newer, or released VS 2015 or older. When looking at
the directory structure, if instead of `"VC"` we see `"x86ret"`, `"x86chk"`,
`"amd64ret"`, or `"amd64chk"`, we recognize this as a DevDiv-internal build.

After we get past the directory structure validation, we use this knowledge
to regenerate paths appropriately. `llvmArchToDevDivInternalArch()` knows how
we use `"i386"` subdirectories, and `MSVCToolChain::getSubDirectoryPath()`
uses that. It also knows that DevDiv-internal builds have an `"inc"`
subdirectory instead of `"include"`.

This may still not be the "right" fix in any sense, but I believe that it's
non-intrusive in the sense that if the special directory names aren't found,
no codepaths are affected. (`ToolsetLayout::OlderVS` and
`ToolsetLayout::VS2017OrNewer` correspond to `IsVS2017OrNewer` being `false`
or `true`, respectively.) I searched for all references to `IsVS2017OrNewer`,
which are places where Clang cares about VS's directory structure, and the
only one that isn't being patched is some logic to deal with
cross-compilation. I'm fine with that not working for DevDiv-internal builds
for the moment (we typically test the native compilers), so I added a comment.

Fixes D36860.

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

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=311391=311390=311391=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Mon Aug 21 15:19:33 2017
@@ -76,7 +76,7 @@ static bool getSystemRegistryString(cons
 
 // Check various environment variables to try and find a toolchain.
 static bool findVCToolChainViaEnvironment(std::string ,
-  bool ) {
+  MSVCToolChain::ToolsetLayout 
) {
   // These variables are typically set by vcvarsall.bat
   // when launching a developer command prompt.
   if (llvm::Optional VCToolsInstallDir =
@@ -84,7 +84,7 @@ static bool findVCToolChainViaEnvironmen
 // This is only set by newer Visual Studios, and it leads straight to
 // the toolchain directory.
 Path = std::move(*VCToolsInstallDir);
-IsVS2017OrNewer = true;
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
 return true;
   }
   if (llvm::Optional VCInstallDir =
@@ -94,7 +94,7 @@ static bool findVCToolChainViaEnvironmen
 // so this check has to appear second.
 // In older Visual Studios, the VC directory is the toolchain.
 Path = std::move(*VCInstallDir);
-IsVS2017OrNewer = false;
+VSLayout = MSVCToolChain::ToolsetLayout::OlderVS;
 return true;
   }
 
@@ -134,9 +134,16 @@ static bool findVCToolChainViaEnvironmen
   }
   if (IsBin) {
 llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
-if (llvm::sys::path::filename(ParentPath) == "VC") {
+llvm::StringRef ParentFilename = llvm::sys::path::filename(ParentPath);
+if (ParentFilename == "VC") {
   Path = ParentPath;
-  IsVS2017OrNewer = false;
+  VSLayout = MSVCToolChain::ToolsetLayout::OlderVS;
+  return true;
+}
+if (ParentFilename == "x86ret" || ParentFilename == "x86chk"
+  || ParentFilename == "amd64ret" || ParentFilename == "amd64chk") {
+  Path = ParentPath;
+  VSLayout = MSVCToolChain::ToolsetLayout::DevDivInternal;
   return true;
 }
 
@@ -165,7 +172,7 @@ static bool findVCToolChainViaEnvironmen
   ToolChainPath = llvm::sys::path::parent_path(ToolChainPath);
 
 Path = ToolChainPath;
-IsVS2017OrNewer = true;
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
 return true;
   }
 
@@ -181,7 +188,7 @@ static bool findVCToolChainViaEnvironmen
 // This is the preferred way to discover new Visual Studios, as they're no
 // longer listed in the registry.
 static bool findVCToolChainViaSetupConfig(std::string ,
-  bool ) {
+  MSVCToolChain::ToolsetLayout 
) {
 #if !defined(USE_MSVC_SETUP_API)
   return false;
 #else
@@ -263,7 +270,7 @@ static bool findVCToolChainViaSetupConfi
 return false;
 
   Path = ToolchainPath.str();
-  IsVS2017OrNewer = true;
+  VSLayout = 

[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-21 Thread don hinton via Phabricator via cfe-commits
hintonda added inline comments.



Comment at: lib/Tooling/Core/Replacement.cpp:505
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));

srhines wrote:
> hintonda wrote:
> > While obviously correct, are you concerned that by removing the explanatory 
> > text, this change will obscure the reason for the assert?
> The text is now in a comment above the call.
Well, that's what I mean.  The reason is no longer in the backtrace.


https://reviews.llvm.org/D36806



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


Re: r311182 - [analyzer] Fix modeling of constructors

2017-08-21 Thread Alexander Shaposhnikov via cfe-commits
Thanks!

On Mon, Aug 21, 2017 at 1:28 PM, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Merged in r311378.
>
> Thanks,
> Hans
>
> On Mon, Aug 21, 2017 at 1:12 PM, Anna Zaks  wrote:
> > I approve.Thanks Hans!
> > Anna
> >> On Aug 21, 2017, at 1:05 PM, Hans Wennborg  wrote:
> >>
> >> I'm ok with it if Anna approves.
> >>
> >> On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev 
> wrote:
> >>> Hello,
> >>>
> >>> Do we have time to merge this change into release 5.0.0? It's an
> assertion
> >>> failure fix, which shows up on C++ code involving double-inheritance
> with
> >>> empty base classes.
> >>>
> >>> Artem.
> >>>
> >>>
> >>> On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote:
> 
>  Author: alexshap
>  Date: Fri Aug 18 11:20:43 2017
>  New Revision: 311182
> 
>  URL:http://llvm.org/viewvc/llvm-project?rev=311182=rev
>  Log:
>  [analyzer] Fix modeling of constructors
> 
>  This diff fixes analyzer's crash (triggered assert) on the newly added
>  test case.
>  The assert being discussed is assert(!B.lookup(R, BindingKey::Direct))
>  in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is
>  different.
>  For classes with empty bases the offsets might be tricky.
>  For example, let's assume we have
>   struct S: NonEmptyBase, EmptyBase {
>   ...
>   };
>  In this case Clang applies empty base class optimization and
>  the offset of EmptyBase will be 0, it can be verified via
>  clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o
>  /dev/null.
>  When the analyzer tries to perform zero initialization of EmptyBase
>  it will hit the assert because that region
>  has already been "written" by the constructor of NonEmptyBase.
> 
>  Test plan:
>  make check-all
> 
>  Differential revision:https://reviews.llvm.org/D36851
> 
>  Modified:
>  cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>  cfe/trunk/test/Analysis/ctor.mm
> 
>  Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> 
>  URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> StaticAnalyzer/Core/RegionStore.cpp?rev=311182=
> 311181=311182=diff
> 
>  
> ==
>  --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
>  +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18
> 11:20:43
>  2017
>  @@ -409,6 +409,19 @@ public: // Part of public interface to c
>   // BindDefault is only used to initialize a region with a default
>  value.
> StoreRef BindDefault(Store store, const MemRegion *R, SVal V)
> override
>  {
>  +// FIXME: The offsets of empty bases can be tricky because of
>  +// of the so called "empty base class optimization".
>  +// If a base class has been optimized out
>  +// we should not try to create a binding, otherwise we should.
>  +// Unfortunately, at the moment ASTRecordLayout doesn't expose
>  +// the actual sizes of the empty bases
>  +// and trying to infer them from offsets/alignments
>  +// seems to be error-prone and non-trivial because of the
> trailing
>  padding.
>  +// As a temporary mitigation we don't create bindings for empty
>  bases.
>  +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
>  +cast(R)->getDecl()->isEmpty())
>  +  return StoreRef(store, *this);
>  +
>   RegionBindingsRef B = getRegionBindings(store);
>   assert(!B.lookup(R, BindingKey::Direct));
> 
>  Modified: cfe/trunk/test/Analysis/ctor.mm
> 
>  URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Analysis/ctor.mm?rev=311182=311181=311182=diff
> 
>  
> ==
>  --- cfe/trunk/test/Analysis/ctor.mm (original)
>  +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017
>  @@ -704,3 +704,20 @@ namespace PR19579 {
>   };
> }
>   }
>  +
>  +namespace NoCrashOnEmptyBaseOptimization {
>  +  struct NonEmptyBase {
>  +int X;
>  +explicit NonEmptyBase(int X) : X(X) {}
>  +  };
>  +
>  +  struct EmptyBase {};
>  +
>  +  struct S : NonEmptyBase, EmptyBase {
>  +S() : NonEmptyBase(0), EmptyBase() {}
>  +  };
>  +
>  +  void testSCtorNoCrash() {
>  +S s;
>  +  }
>  +}
> 
> 
>  ___
>  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

[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-21 Thread Stephen Hines via Phabricator via cfe-commits
srhines marked an inline comment as done.
srhines added inline comments.



Comment at: lib/Tooling/Core/Replacement.cpp:505
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));

hintonda wrote:
> While obviously correct, are you concerned that by removing the explanatory 
> text, this change will obscure the reason for the assert?
The text is now in a comment above the call.


https://reviews.llvm.org/D36806



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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-21 Thread don hinton via Phabricator via cfe-commits
hintonda added inline comments.



Comment at: lib/Tooling/Core/Replacement.cpp:505
-assert(!Err &&
-   "Replacements must not conflict since ranges have been merged.");
-llvm::consumeError(std::move(Err));

While obviously correct, are you concerned that by removing the explanatory 
text, this change will obscure the reason for the assert?


https://reviews.llvm.org/D36806



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


Re: r311182 - [analyzer] Fix modeling of constructors

2017-08-21 Thread Hans Wennborg via cfe-commits
Merged in r311378.

Thanks,
Hans

On Mon, Aug 21, 2017 at 1:12 PM, Anna Zaks  wrote:
> I approve.Thanks Hans!
> Anna
>> On Aug 21, 2017, at 1:05 PM, Hans Wennborg  wrote:
>>
>> I'm ok with it if Anna approves.
>>
>> On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev  wrote:
>>> Hello,
>>>
>>> Do we have time to merge this change into release 5.0.0? It's an assertion
>>> failure fix, which shows up on C++ code involving double-inheritance with
>>> empty base classes.
>>>
>>> Artem.
>>>
>>>
>>> On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote:

 Author: alexshap
 Date: Fri Aug 18 11:20:43 2017
 New Revision: 311182

 URL:http://llvm.org/viewvc/llvm-project?rev=311182=rev
 Log:
 [analyzer] Fix modeling of constructors

 This diff fixes analyzer's crash (triggered assert) on the newly added
 test case.
 The assert being discussed is assert(!B.lookup(R, BindingKey::Direct))
 in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is
 different.
 For classes with empty bases the offsets might be tricky.
 For example, let's assume we have
  struct S: NonEmptyBase, EmptyBase {
  ...
  };
 In this case Clang applies empty base class optimization and
 the offset of EmptyBase will be 0, it can be verified via
 clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o
 /dev/null.
 When the analyzer tries to perform zero initialization of EmptyBase
 it will hit the assert because that region
 has already been "written" by the constructor of NonEmptyBase.

 Test plan:
 make check-all

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

 Modified:
 cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
 cfe/trunk/test/Analysis/ctor.mm

 Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

 URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182=311181=311182=diff

 ==
 --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
 +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43
 2017
 @@ -409,6 +409,19 @@ public: // Part of public interface to c
  // BindDefault is only used to initialize a region with a default
 value.
StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override
 {
 +// FIXME: The offsets of empty bases can be tricky because of
 +// of the so called "empty base class optimization".
 +// If a base class has been optimized out
 +// we should not try to create a binding, otherwise we should.
 +// Unfortunately, at the moment ASTRecordLayout doesn't expose
 +// the actual sizes of the empty bases
 +// and trying to infer them from offsets/alignments
 +// seems to be error-prone and non-trivial because of the trailing
 padding.
 +// As a temporary mitigation we don't create bindings for empty
 bases.
 +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
 +cast(R)->getDecl()->isEmpty())
 +  return StoreRef(store, *this);
 +
  RegionBindingsRef B = getRegionBindings(store);
  assert(!B.lookup(R, BindingKey::Direct));

 Modified: cfe/trunk/test/Analysis/ctor.mm

 URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182=311181=311182=diff

 ==
 --- cfe/trunk/test/Analysis/ctor.mm (original)
 +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017
 @@ -704,3 +704,20 @@ namespace PR19579 {
  };
}
  }
 +
 +namespace NoCrashOnEmptyBaseOptimization {
 +  struct NonEmptyBase {
 +int X;
 +explicit NonEmptyBase(int X) : X(X) {}
 +  };
 +
 +  struct EmptyBase {};
 +
 +  struct S : NonEmptyBase, EmptyBase {
 +S() : NonEmptyBase(0), EmptyBase() {}
 +  };
 +
 +  void testSCtorNoCrash() {
 +S s;
 +  }
 +}


 ___
 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] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-21 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

Ping.


https://reviews.llvm.org/D36806



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


Re: r311182 - [analyzer] Fix modeling of constructors

2017-08-21 Thread Anna Zaks via cfe-commits
I approve.Thanks Hans!
Anna
> On Aug 21, 2017, at 1:05 PM, Hans Wennborg  wrote:
> 
> I'm ok with it if Anna approves.
> 
> On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev  wrote:
>> Hello,
>> 
>> Do we have time to merge this change into release 5.0.0? It's an assertion
>> failure fix, which shows up on C++ code involving double-inheritance with
>> empty base classes.
>> 
>> Artem.
>> 
>> 
>> On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote:
>>> 
>>> Author: alexshap
>>> Date: Fri Aug 18 11:20:43 2017
>>> New Revision: 311182
>>> 
>>> URL:http://llvm.org/viewvc/llvm-project?rev=311182=rev
>>> Log:
>>> [analyzer] Fix modeling of constructors
>>> 
>>> This diff fixes analyzer's crash (triggered assert) on the newly added
>>> test case.
>>> The assert being discussed is assert(!B.lookup(R, BindingKey::Direct))
>>> in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is
>>> different.
>>> For classes with empty bases the offsets might be tricky.
>>> For example, let's assume we have
>>>  struct S: NonEmptyBase, EmptyBase {
>>>  ...
>>>  };
>>> In this case Clang applies empty base class optimization and
>>> the offset of EmptyBase will be 0, it can be verified via
>>> clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o
>>> /dev/null.
>>> When the analyzer tries to perform zero initialization of EmptyBase
>>> it will hit the assert because that region
>>> has already been "written" by the constructor of NonEmptyBase.
>>> 
>>> Test plan:
>>> make check-all
>>> 
>>> Differential revision:https://reviews.llvm.org/D36851
>>> 
>>> Modified:
>>> cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>>> cfe/trunk/test/Analysis/ctor.mm
>>> 
>>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>>> 
>>> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182=311181=311182=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
>>> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43
>>> 2017
>>> @@ -409,6 +409,19 @@ public: // Part of public interface to c
>>>  // BindDefault is only used to initialize a region with a default
>>> value.
>>>StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override
>>> {
>>> +// FIXME: The offsets of empty bases can be tricky because of
>>> +// of the so called "empty base class optimization".
>>> +// If a base class has been optimized out
>>> +// we should not try to create a binding, otherwise we should.
>>> +// Unfortunately, at the moment ASTRecordLayout doesn't expose
>>> +// the actual sizes of the empty bases
>>> +// and trying to infer them from offsets/alignments
>>> +// seems to be error-prone and non-trivial because of the trailing
>>> padding.
>>> +// As a temporary mitigation we don't create bindings for empty
>>> bases.
>>> +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
>>> +cast(R)->getDecl()->isEmpty())
>>> +  return StoreRef(store, *this);
>>> +
>>>  RegionBindingsRef B = getRegionBindings(store);
>>>  assert(!B.lookup(R, BindingKey::Direct));
>>> 
>>> Modified: cfe/trunk/test/Analysis/ctor.mm
>>> 
>>> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182=311181=311182=diff
>>> 
>>> ==
>>> --- cfe/trunk/test/Analysis/ctor.mm (original)
>>> +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017
>>> @@ -704,3 +704,20 @@ namespace PR19579 {
>>>  };
>>>}
>>>  }
>>> +
>>> +namespace NoCrashOnEmptyBaseOptimization {
>>> +  struct NonEmptyBase {
>>> +int X;
>>> +explicit NonEmptyBase(int X) : X(X) {}
>>> +  };
>>> +
>>> +  struct EmptyBase {};
>>> +
>>> +  struct S : NonEmptyBase, EmptyBase {
>>> +S() : NonEmptyBase(0), EmptyBase() {}
>>> +  };
>>> +
>>> +  void testSCtorNoCrash() {
>>> +S s;
>>> +  }
>>> +}
>>> 
>>> 
>>> ___
>>> 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] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.

2017-08-21 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

ping...


https://reviews.llvm.org/D36347



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


Re: r311182 - [analyzer] Fix modeling of constructors

2017-08-21 Thread Hans Wennborg via cfe-commits
I'm ok with it if Anna approves.

On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev  wrote:
> Hello,
>
> Do we have time to merge this change into release 5.0.0? It's an assertion
> failure fix, which shows up on C++ code involving double-inheritance with
> empty base classes.
>
> Artem.
>
>
> On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote:
>>
>> Author: alexshap
>> Date: Fri Aug 18 11:20:43 2017
>> New Revision: 311182
>>
>> URL:http://llvm.org/viewvc/llvm-project?rev=311182=rev
>> Log:
>> [analyzer] Fix modeling of constructors
>>
>> This diff fixes analyzer's crash (triggered assert) on the newly added
>> test case.
>> The assert being discussed is assert(!B.lookup(R, BindingKey::Direct))
>> in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is
>> different.
>> For classes with empty bases the offsets might be tricky.
>> For example, let's assume we have
>>   struct S: NonEmptyBase, EmptyBase {
>>   ...
>>   };
>> In this case Clang applies empty base class optimization and
>> the offset of EmptyBase will be 0, it can be verified via
>> clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o
>> /dev/null.
>> When the analyzer tries to perform zero initialization of EmptyBase
>> it will hit the assert because that region
>> has already been "written" by the constructor of NonEmptyBase.
>>
>> Test plan:
>> make check-all
>>
>> Differential revision:https://reviews.llvm.org/D36851
>>
>> Modified:
>>  cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>>  cfe/trunk/test/Analysis/ctor.mm
>>
>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>>
>> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182=311181=311182=diff
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
>> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43
>> 2017
>> @@ -409,6 +409,19 @@ public: // Part of public interface to c
>>   // BindDefault is only used to initialize a region with a default
>> value.
>> StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override
>> {
>> +// FIXME: The offsets of empty bases can be tricky because of
>> +// of the so called "empty base class optimization".
>> +// If a base class has been optimized out
>> +// we should not try to create a binding, otherwise we should.
>> +// Unfortunately, at the moment ASTRecordLayout doesn't expose
>> +// the actual sizes of the empty bases
>> +// and trying to infer them from offsets/alignments
>> +// seems to be error-prone and non-trivial because of the trailing
>> padding.
>> +// As a temporary mitigation we don't create bindings for empty
>> bases.
>> +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
>> +cast(R)->getDecl()->isEmpty())
>> +  return StoreRef(store, *this);
>> +
>>   RegionBindingsRef B = getRegionBindings(store);
>>   assert(!B.lookup(R, BindingKey::Direct));
>>
>> Modified: cfe/trunk/test/Analysis/ctor.mm
>>
>> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182=311181=311182=diff
>>
>> ==
>> --- cfe/trunk/test/Analysis/ctor.mm (original)
>> +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017
>> @@ -704,3 +704,20 @@ namespace PR19579 {
>>   };
>> }
>>   }
>> +
>> +namespace NoCrashOnEmptyBaseOptimization {
>> +  struct NonEmptyBase {
>> +int X;
>> +explicit NonEmptyBase(int X) : X(X) {}
>> +  };
>> +
>> +  struct EmptyBase {};
>> +
>> +  struct S : NonEmptyBase, EmptyBase {
>> +S() : NonEmptyBase(0), EmptyBase() {}
>> +  };
>> +
>> +  void testSCtorNoCrash() {
>> +S s;
>> +  }
>> +}
>>
>>
>> ___
>> 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] D36872: Fixed a crash on replaying Preamble's PP conditional stack.

2017-08-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D36872#847416, @nik wrote:

> I see this in trunk/master submitted, but not in the release_50 branch. Could 
> this be cherry-picked to 5.0?


I've replied on the commit message thread. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D36872



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


Re: r311330 - Fixed a crash on replaying Preamble's PP conditional stack.

2017-08-21 Thread Hans Wennborg via cfe-commits
Nikolai suggested this should be merged to 5.0. Richard, what do you think?

On Mon, Aug 21, 2017 at 5:03 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Mon Aug 21 05:03:08 2017
> New Revision: 311330
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311330=rev
> Log:
> Fixed a crash on replaying Preamble's PP conditional stack.
>
> Summary:
> The crash occurs when the first token after a preamble is a macro
> expansion.
> Fixed by moving replayPreambleConditionalStack from Parser into
> Preprocessor. It is now called right after the predefines file is
> processed.
>
> Reviewers: erikjv, bkramer, klimek, yvvan
>
> Reviewed By: bkramer
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D36872
>
> Added:
> cfe/trunk/test/Index/preamble-conditionals-crash.cpp
> cfe/trunk/test/Index/preamble-conditionals.cpp
> Modified:
> cfe/trunk/include/clang/Lex/Preprocessor.h
> cfe/trunk/lib/Lex/PPLexerChange.cpp
> cfe/trunk/lib/Lex/Preprocessor.cpp
> cfe/trunk/lib/Parse/Parser.cpp
>
> Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=311330=311329=311330=diff
> ==
> --- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
> +++ cfe/trunk/include/clang/Lex/Preprocessor.h Mon Aug 21 05:03:08 2017
> @@ -1049,10 +1049,6 @@ public:
>/// which implicitly adds the builtin defines etc.
>void EnterMainSourceFile();
>
> -  /// \brief After parser warm-up, initialize the conditional stack from
> -  /// the preamble.
> -  void replayPreambleConditionalStack();
> -
>/// \brief Inform the preprocessor callbacks that processing is complete.
>void EndSourceFile();
>
> @@ -2026,6 +2022,10 @@ public:
>}
>
>  private:
> +  /// \brief After processing predefined file, initialize the conditional 
> stack from
> +  /// the preamble.
> +  void replayPreambleConditionalStack();
> +
>// Macro handling.
>void HandleDefineDirective(Token , bool 
> ImmediatelyAfterTopLevelIfndef);
>void HandleUndefDirective();
>
> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=311330=311329=311330=diff
> ==
> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Aug 21 05:03:08 2017
> @@ -458,10 +458,16 @@ bool Preprocessor::HandleEndOfFile(Token
>SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs);
>  }
>
> +bool ExitedFromPredefinesFile = false;
>  FileID ExitedFID;
> -if (Callbacks && !isEndOfMacro && CurPPLexer)
> +if (!isEndOfMacro && CurPPLexer) {
>ExitedFID = CurPPLexer->getFileID();
>
> +  assert(PredefinesFileID.isValid() &&
> + "HandleEndOfFile is called before PredefinesFileId is set");
> +  ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID);
> +}
> +
>  if (LeavingSubmodule) {
>// We're done with this submodule.
>Module *M = LeaveSubmodule(/*ForPragma*/false);
> @@ -489,6 +495,11 @@ bool Preprocessor::HandleEndOfFile(Token
>   PPCallbacks::ExitFile, FileType, ExitedFID);
>  }
>
> +// Restore conditional stack from the preamble right after exiting from 
> the
> +// predefines file.
> +if (ExitedFromPredefinesFile)
> +  replayPreambleConditionalStack();
> +
>  // Client should lex another token unless we generated an EOM.
>  return LeavingSubmodule;
>}
>
> Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=311330=311329=311330=diff
> ==
> --- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
> +++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Aug 21 05:03:08 2017
> @@ -540,6 +540,8 @@ void Preprocessor::EnterMainSourceFile()
>  void Preprocessor::replayPreambleConditionalStack() {
>// Restore the conditional stack from the preamble, if there is one.
>if (PreambleConditionalStack.isReplaying()) {
> +assert(CurPPLexer &&
> +   "CurPPLexer is null when calling 
> replayPreambleConditionalStack.");
>  CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack());
>  PreambleConditionalStack.doneReplaying();
>}
>
> Modified: cfe/trunk/lib/Parse/Parser.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=311330=311329=311330=diff
> ==
> --- cfe/trunk/lib/Parse/Parser.cpp (original)
> +++ cfe/trunk/lib/Parse/Parser.cpp Mon Aug 21 05:03:08 2017
> @@ -516,8 +516,6 @@ void Parser::Initialize() {
>
>// Prime 

[PATCH] D36954: [Sema] Update release notes with details of implicit scalar to vector conversions

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

lgtm, please commit to the 5.0 branch


https://reviews.llvm.org/D36954



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


r311365 - Enable libfuzzer on NetBSD/amd64

2017-08-21 Thread Kamil Rytarowski via cfe-commits
Author: kamil
Date: Mon Aug 21 12:12:14 2017
New Revision: 311365

URL: http://llvm.org/viewvc/llvm-project?rev=311365=rev
Log:
Enable libfuzzer on NetBSD/amd64

Summary:
Enable SanitizerKind::Fuzzer and SanitizerKind::FuzzerNoLink on x86_64.

Sponsored by 

Reviewers: joerg, kcc, vitalybuka, george.karpenkov

Reviewed By: vitalybuka

Subscribers: cfe-commits, #sanitizers

Tags: #sanitizers

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp?rev=311365=311364=311365=diff
==
--- cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Mon Aug 21 12:12:14 2017
@@ -428,6 +428,8 @@ SanitizerMask NetBSD::getSupportedSaniti
 Res |= SanitizerKind::Vptr;
   }
   if (IsX86_64) {
+Res |= SanitizerKind::Fuzzer;
+Res |= SanitizerKind::FuzzerNoLink;
 Res |= SanitizerKind::Thread;
   }
   return Res;


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


[PATCH] D35271: Fix printing policy for AST context loaded from file

2017-08-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D35271#847306, @jklaehn wrote:

> In https://reviews.llvm.org/D35271#809159, @vsk wrote:
>
> > I wonder if it's possible to do away with the calls to 'updated()'... it 
> > seems strange that we initialize the same preprocessor repeatedly. Is there 
> > any way to finalize an ASTInfoCollector after ReadAST happens (or 
> > ASTReaderListeners in general)?
>
>
> I can look into this but would prefer to do so in a different patch, as this 
> would require refactoring beyond this simple bug fix. Would it be okay to 
> land this patch as-is?


Not having worked on this code I'm afraid I can't say. Usually it's a good idea 
to include a regression test.


https://reviews.llvm.org/D35271



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


[PATCH] D36931: Update LLVM 5.0 release notes for ms_abi and __builtin_ms_va_list for aarch64

2017-08-21 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311359: Update Clang 5.0 release notes for ms_abi and 
__builtin_ms_va_list for aarch64 (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D36931?vs=111857=112022#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36931

Files:
  cfe/branches/release_50/docs/ReleaseNotes.rst


Index: cfe/branches/release_50/docs/ReleaseNotes.rst
===
--- cfe/branches/release_50/docs/ReleaseNotes.rst
+++ cfe/branches/release_50/docs/ReleaseNotes.rst
@@ -104,6 +104,8 @@
 -  The ``overloadable`` attribute now allows at most one function with a given
name to lack the ``overloadable`` attribute. This unmarked function will not
have its name mangled.
+-  The ```ms_abi`` attribute and the ``__builtin_ms_va_list`` types and 
builtins
+   are now supported on AArch64.
 
 Windows Support
 ---


Index: cfe/branches/release_50/docs/ReleaseNotes.rst
===
--- cfe/branches/release_50/docs/ReleaseNotes.rst
+++ cfe/branches/release_50/docs/ReleaseNotes.rst
@@ -104,6 +104,8 @@
 -  The ``overloadable`` attribute now allows at most one function with a given
name to lack the ``overloadable`` attribute. This unmarked function will not
have its name mangled.
+-  The ```ms_abi`` attribute and the ``__builtin_ms_va_list`` types and builtins
+   are now supported on AArch64.
 
 Windows Support
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36973: [libclang] Add support for querying cursor availability

2017-08-21 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn created this revision.
jklaehn added a project: clang.

This patch allows checking the availability of cursors through libclang and 
clang.cindex (Python).
This e.g. allows to check whether a C++ member function has been marked as 
deleted.


https://reviews.llvm.org/D36973

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py


Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -1,6 +1,7 @@
 import ctypes
 import gc
 
+from clang.cindex import AvailabilityKind
 from clang.cindex import CursorKind
 from clang.cindex import TemplateArgumentKind
 from clang.cindex import TranslationUnit
@@ -385,6 +386,18 @@
 t = foo.result_type
 assert t.kind == TypeKind.INT
 
+def test_availability():
+tu = get_tu('class A { A(A const&) = delete; };', lang='cpp')
+cursors = get_cursors(tu, "A")
+for c in cursors:
+if c.kind == CursorKind.CLASS_DECL:
+assert c.availability == AvailabilityKind.AVAILABLE
+if c.kind == CursorKind.CONSTRUCTOR:
+assert c.availability == AvailabilityKind.NOT_AVAILABLE
+break
+else:
+assert False, "Could not find cursor for deleted constructor"
+
 def test_get_tokens():
 """Ensure we can map cursors back to tokens."""
 tu = get_tu('int foo(int i);')
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1572,6 +1572,16 @@
 
 return StorageClass.from_id(self._storage_class)
 
+@property
+def availability(self):
+"""
+Retrieves the availability of the entity pointed at by the cursor.
+"""
+if not hasattr(self, '_availability'):
+self._availability = conf.lib.clang_getCursorAvailability(self)
+
+return AvailabilityKind.from_id(self._availability)
+
 @property
 def access_specifier(self):
 """
@@ -1909,6 +1919,25 @@
 StorageClass.AUTO = StorageClass(6)
 StorageClass.REGISTER = StorageClass(7)
 
+### Availability Kinds ###
+
+class AvailabilityKind(BaseEnumeration):
+"""
+Describes the availability of an entity.
+"""
+
+# The unique kind objects, indexed by id.
+_kinds = []
+_name_map = None
+
+def __repr__(self):
+return 'AvailabilityKind.%s' % (self.name,)
+
+AvailabilityKind.AVAILABLE = AvailabilityKind(0)
+AvailabilityKind.DEPRECATED = AvailabilityKind(1)
+AvailabilityKind.NOT_AVAILABLE = AvailabilityKind(2)
+AvailabilityKind.NOT_ACCESSIBLE = AvailabilityKind(3)
+
 
 ### C++ access specifiers ###
 
@@ -3440,6 +3469,10 @@
[TranslationUnit, SourceLocation],
Cursor),
 
+  ("clang_getCursorAvailability",
+   [Cursor],
+   c_int),
+
   ("clang_getCursorDefinition",
[Cursor],
Cursor,


Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -1,6 +1,7 @@
 import ctypes
 import gc
 
+from clang.cindex import AvailabilityKind
 from clang.cindex import CursorKind
 from clang.cindex import TemplateArgumentKind
 from clang.cindex import TranslationUnit
@@ -385,6 +386,18 @@
 t = foo.result_type
 assert t.kind == TypeKind.INT
 
+def test_availability():
+tu = get_tu('class A { A(A const&) = delete; };', lang='cpp')
+cursors = get_cursors(tu, "A")
+for c in cursors:
+if c.kind == CursorKind.CLASS_DECL:
+assert c.availability == AvailabilityKind.AVAILABLE
+if c.kind == CursorKind.CONSTRUCTOR:
+assert c.availability == AvailabilityKind.NOT_AVAILABLE
+break
+else:
+assert False, "Could not find cursor for deleted constructor"
+
 def test_get_tokens():
 """Ensure we can map cursors back to tokens."""
 tu = get_tu('int foo(int i);')
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1572,6 +1572,16 @@
 
 return StorageClass.from_id(self._storage_class)
 
+@property
+def availability(self):
+"""
+Retrieves the availability of the entity pointed at by the cursor.
+"""
+if not hasattr(self, '_availability'):
+self._availability = conf.lib.clang_getCursorAvailability(self)
+
+return AvailabilityKind.from_id(self._availability)
+
 @property
 def access_specifier(self):
 """
@@ -1909,6 +1919,25 @@
 StorageClass.AUTO = StorageClass(6)
 StorageClass.REGISTER = StorageClass(7)
 
+### Availability Kinds ###
+
+class AvailabilityKind(BaseEnumeration):
+"""
+Describes the availability of an entity.
+"""

[PATCH] D36969: [Basic] Add a DiagnosticOr type

2017-08-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Would it be more convenient to extend ErrorInfo instead of creating a new 
diagnostic wrapper? E.g one benefit of passing around Expected's is that 
there's some assurance the diagnostics will be reported.


Repository:
  rL LLVM

https://reviews.llvm.org/D36969



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


Re: r292458 - Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection

2017-08-21 Thread Hans Wennborg via cfe-commits
On Fri, Aug 18, 2017 at 5:22 PM, Dehao Chen  wrote:
> On Fri, Aug 18, 2017 at 2:46 PM, Hans Wennborg  wrote:
>>
>> Should we mention this in the release notes?
>>
>>
>> Is the flag documented somewhere?
>
>
> It's documented in the Options.td file, do you think there are other
> documents that need to be added/updated?

Maybe https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization
if we think this is something users should be using.

And if it improves things, perhaps its worth mentioning in the release notes?

Thanks,
Hans


>> On Wed, Jan 18, 2017 at 4:44 PM, Dehao Chen via cfe-commits
>>  wrote:
>> > Author: dehao
>> > Date: Wed Jan 18 18:44:21 2017
>> > New Revision: 292458
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=292458=rev
>> > Log:
>> > Add -fdebug-info-for-profiling to emit more debug info for sample pgo
>> > profile collection
>> >
>> > Summary:
>> > SamplePGO uses profile with debug info to collect profile. Unlike the
>> > traditional debugging purpose, sample pgo needs more accurate debug info to
>> > represent the profile. We add -femit-accurate-debug-info for this purpose.
>> > It can be combined with all debugging modes (-g, -gmlt, etc). It makes sure
>> > that the following pieces of info is always emitted:
>> >
>> > * start line of all subprograms
>> > * linkage name of all subprograms
>> > * standalone subprograms (functions that has neither inlined nor been
>> > inlined)
>> >
>> > The impact on speccpu2006 binary size (size increase comparing with -g0
>> > binary, also includes data for -g binary, which does not change with this
>> > patch):
>> >
>> >-gmlt(orig) -gmlt(patched) -g
>> > 433.milc   4.68%   5.40%  19.73%
>> > 444.namd   8.45%   8.93%  45.99%
>> > 447.dealII 97.43%  115.21%374.89%
>> > 450.soplex 27.75%  31.88% 126.04%
>> > 453.povray 21.81%  26.16% 92.03%
>> > 470.lbm0.60%   0.67%  1.96%
>> > 482.sphinx35.77%   6.47%  26.17%
>> > 400.perlbench  17.81%  19.43% 73.08%
>> > 401.bzip2  3.73%   3.92%  12.18%
>> > 403.gcc31.75%  34.48% 122.75%
>> > 429.mcf0.78%   0.88%  3.89%
>> > 445.gobmk  6.08%   7.92%  42.27%
>> > 456.hmmer  10.36%  11.25% 35.23%
>> > 458.sjeng  5.08%   5.42%  14.36%
>> > 462.libquantum 1.71%   1.96%  6.36%
>> > 464.h264ref15.61%  16.56% 43.92%
>> > 471.omnetpp11.93%  15.84% 60.09%
>> > 473.astar  3.11%   3.69%  14.18%
>> > 483.xalancbmk  56.29%  81.63% 353.22%
>> > geomean15.60%  18.30% 57.81%
>> >
>> > Debug info size change for -gmlt binary with this patch:
>> >
>> > 433.milc   13.46%
>> > 444.namd   5.35%
>> > 447.dealII 18.21%
>> > 450.soplex 14.68%
>> > 453.povray 19.65%
>> > 470.lbm6.03%
>> > 482.sphinx311.21%
>> > 400.perlbench  8.91%
>> > 401.bzip2  4.41%
>> > 403.gcc8.56%
>> > 429.mcf8.24%
>> > 445.gobmk  29.47%
>> > 456.hmmer  8.19%
>> > 458.sjeng  6.05%
>> > 462.libquantum 11.23%
>> > 464.h264ref5.93%
>> > 471.omnetpp31.89%
>> > 473.astar  16.20%
>> > 483.xalancbmk  44.62%
>> > geomean16.83%
>> >
>> > Reviewers: davidxl, andreadb, rob.lougher, dblaikie, echristo
>> >
>> > Reviewed By: dblaikie, echristo
>> >
>> > Subscribers: hfinkel, rob.lougher, andreadb, gbedwell, cfe-commits,
>> > probinson, llvm-commits, mehdi_amini
>> >
>> > Differential Revision: https://reviews.llvm.org/D25435
>> >
>> > Modified:
>> > cfe/trunk/include/clang/Driver/Options.td
>> > cfe/trunk/include/clang/Frontend/CodeGenOptions.def
>> > cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> > cfe/trunk/lib/Driver/Tools.cpp
>> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> > cfe/trunk/test/Driver/clang_f_opts.c
>> >
>> > Modified: cfe/trunk/include/clang/Driver/Options.td
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=292458=292457=292458=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Driver/Options.td (original)
>> > +++ cfe/trunk/include/clang/Driver/Options.td Wed Jan 18 18:44:21 2017
>> > @@ -516,6 +516,12 @@ def fprofile_sample_use_EQ : Joined<["-"
>> >  HelpText<"Enable sample-based profile guided optimizations">;
>> >  def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
>> >  Alias;
>> > +def fdebug_info_for_profiling : Flag<["-"],
>> > "fdebug-info-for-profiling">, Group,
>> > +Flags<[CC1Option]>,
>> > +HelpText<"Emit extra debug info to make sample profile more
>> > accurate.">;
>> > +def fno_debug_info_for_profiling : Flag<["-"],
>> > 

[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-21 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 112018.
hamzasood added a comment.

- Info about a lambda's explicit template parameters is now exposed in the AST 
(see changes to LambdaExpr). It turns out that no extra storage was actually 
needed to achieve this.
- Removed remnants of a previous implementation (unused 
getExplicitTemplateParams function, creation of a TemplateParameterList in 
ActOnLambdaTemplateParameterList).
- Renamed ActOnLambdaTemplateParameterList -> 
ActOnLambdaExplicitTemplateParameterList (which is a bit more clear).
- Changed LambdaScopeInfo::TemplateParams from a vector of Decl* to a vector of 
NamedDecl*.


https://reviews.llvm.org/D36527

Files:
  include/clang/AST/ExprCXX.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/ExprCXX.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -822,7 +822,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2;>P0428R2
-  No
+  SVN
 
 
   Initializer list constructors in class template argument deduction
Index: test/SemaCXX/cxx2a-template-lambdas.cpp
===
--- test/SemaCXX/cxx2a-template-lambdas.cpp
+++ test/SemaCXX/cxx2a-template-lambdas.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+template
+constexpr bool is_same = false;
+
+template
+constexpr bool is_same = true;
+
+template
+struct DummyTemplate { };
+
+void func() {
+  auto L0 = [](T arg) {
+static_assert(is_same);
+  };
+  L0(0);
+
+  auto L1 = [] {
+static_assert(I == 5);
+  };
+  L1.operator()<5>();
+
+  auto L2 = []