[PATCH] D59298: [RISCV] Pass -target-abi to -cc1as

2019-03-25 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Thanks Alex. I will commit it shortly.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59298/new/

https://reviews.llvm.org/D59298



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


[clang-tools-extra] r356974 - [clangd][xpc][cmake] Respect explicit value of CLANGD_BUILD_XPC

2019-03-25 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 25 20:48:25 2019
New Revision: 356974

URL: http://llvm.org/viewvc/llvm-project?rev=356974&view=rev
Log:
[clangd][xpc][cmake] Respect explicit value of CLANGD_BUILD_XPC

We shouldn't prevent user from disabling XPC framework build on Darwin.
However, by keeping it on by default our CI systems also test
it by default on macOS.

Based on user request:
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061778.html

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

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

Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=356974&r1=356973&r2=356974&view=diff
==
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Mon Mar 25 20:48:25 2019
@@ -1,6 +1,13 @@
-option(CLANGD_BUILD_XPC "Build XPC Support For Clangd." OFF)
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-  set(CLANGD_BUILD_XPC ON CACHE BOOL "" FORCE)
+if (NOT DEFINED CLANGD_BUILD_XPC)
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+set(CLANGD_BUILD_XPC_DEFAULT ON)
+  else ()
+set(CLANGD_BUILD_XPC_DEFAULT OFF)
+  endif ()
+
+  set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC 
Support For Clangd." FORCE)
+
+  unset(CLANGD_BUILD_XPC_DEFAULT)
 endif ()
 
 add_subdirectory(clang-apply-replacements)


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


[PATCH] D59765: [Lex] Warn about invisible Hangul whitespace

2019-03-25 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

I wonder if we should handle Unicode codepoints that are in the whitespace 
category as a whole, instead of handling each codepoint individually.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59765/new/

https://reviews.llvm.org/D59765



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


[PATCH] D59622: [analyzer] C++17: PR41142: Ignore transparent InitListExprs in ExprEngine as well.

2019-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

(the commit message shouldn't have said "CFG", sry)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59622/new/

https://reviews.llvm.org/D59622



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 192238.
hintonda added a comment.

- Address additional comments, and move  to LLVM.h.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802

Files:
  clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp
  clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.h
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
  clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
  clang/include/clang/Basic/LLVM.h

Index: clang/include/clang/Basic/LLVM.h
===
--- clang/include/clang/Basic/LLVM.h
+++ clang/include/clang/Basic/LLVM.h
@@ -31,6 +31,7 @@
   template class ArrayRef;
   template class MutableArrayRef;
   template class OwningArrayRef;
+  template  class SmallSet;
   template class SmallString;
   template class SmallVector;
   template class SmallVectorImpl;
@@ -66,6 +67,7 @@
   using llvm::Optional;
   using llvm::OwningArrayRef;
   using llvm::SaveAndRestore;
+  using llvm::SmallSet;
   using llvm::SmallString;
   using llvm::SmallVector;
   using llvm::SmallVectorImpl;
Index: clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s llvm-avoid-cast-in-conditional %t
+
+struct X;
+struct Y;
+struct Z {
+  int foo();
+};
+
+template 
+X* cast(Y*);
+
+bool foo(Y* y) {
+  if (auto x = cast(y))
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*llvm-avoid-cast-in-conditional}}
+return true;
+  if (cast(y))
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning:  {{.*llvm-avoid-cast-in-conditional}}
+return true;
+
+  // Does not trigger warning.
+  if (cast(y)->foo())
+return true;
+  return false;
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - llvm-avoid-cast-in-conditional
+
+llvm-avoid-cast-in-conditional
+==
+
+Finds cases of ``cast<>`` used as the condition of a conditional
+statements which will assert on failure in Debug builds. The use of
+cast<> implies that the operation cannot fail, and should not be used
+as the condition of a conditional statement.
+
+.. code-block:: c++
+
+  // Finds cases like these:
+  if (auto x = cast(y)) <...>
+  if (cast(y)) <...>
+
+  // But not cases like these:
+  if (auto f = cast(y)->foo()) <...>
+  if (cast(y)->foo()) <...>
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -175,6 +175,7 @@
hicpp-use-nullptr (redirects to modernize-use-nullptr) 
hicpp-use-override (redirects to modernize-use-override) 
hicpp-vararg (redirects to cppcoreguidelines-pro-type-vararg) 
+   llvm-avoid-cast-in-conditional
llvm-header-guard
llvm-include-order
llvm-namespace-comment
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -130,6 +130,12 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`llvm-avoid-cast-in-conditional
+  ` check.
+
+  Finds cases of ``cast<>`` used as condition in conditional statements
+  which will assert on failure in Debug builds.
+
 - New :doc:`openmp-exception-escape
   ` check.
 
Index: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
@@ -18,7 +18,7 @@
 namespace tidy {
 namespace utils {
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 
 /// \brief Checks whether expansion location of \p Loc is in header file.
 bool isExpansionLocInHeaderFile(
Index: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
+++ clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyM

[PATCH] D59347: [DebugInfo] Combine Trivial and NonTrivial flags

2019-03-25 Thread Aaron Smith via Phabricator via cfe-commits
asmith added a comment.

Either way. It was fewer changes to use FlagNonTrivial. Which flag do people 
want to keep?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59347/new/

https://reviews.llvm.org/D59347



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


Re: [clang-tools-extra] r356849 - [pp-trace] Modernize the code

2019-03-25 Thread Fāng-ruì Sòng via cfe-commits
There was another change rCTE356893 which rewrote this part.

On Tue, Mar 26, 2019 at 1:24 AM  wrote:
>
> Hi,
>
> Yes, it appears to have been fixed as of r356878.
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/24580
>
> Douglas Yung
>
> -Original Message-
> From: Fāng-ruì Sòng 
> Sent: Monday, March 25, 2019 4:41
> To: Yung, Douglas 
> Cc: cfe-commits 
> Subject: Re: [clang-tools-extra] r356849 - [pp-trace] Modernize the code
>
> Is it fixed now?
>
> On Mon, Mar 25, 2019 at 7:25 AM  wrote:
> >
> > Hi Fangrui,
> >
> > This change is causing the PS4 Windows bot to fail to build:
> >
> > http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windo
> > ws10pro-fast/builds/24560/steps/build/logs/stdio
> >
> > FAILED: 
> > tools/clang/tools/extra/pp-trace/CMakeFiles/pp-trace.dir/PPTrace.cpp.obj
> > C:\PROGRA~2\MIB055~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe
> >   /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE 
> > -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE 
> > -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 
> > -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
> > -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> > -Itools\clang\tools\extra\pp-trace 
> > -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\pp-trace
> >  
> > -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\include
> >  -Itools\clang\include -Iinclude 
> > -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include
> >  /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 
> > -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 
> > -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 
> > -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 
> > -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 
> > -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /MD /O2 /Ob2   -UNDEBUG  
> > /EHs-c- /GR- /showIncludes 
> > /Fotools\clang\tools\extra\pp-trace\CMakeFiles\pp-trace.dir\PPTrace.cpp.obj 
> > /Fdtools\clang\tools\extra\pp-trace\CMakeFiles\pp-trace.dir\ /FS -c 
> > C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp
> > C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\ll
> > vm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp(93): error C2668:
> > 'llvm::make_unique': ambiguous call to overloaded function
> > C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/ADT/STLExtras.h(1348):
> >  note: could be 
> > 'std::unique_ptr> 
> > llvm::make_unique > FilterType&,std::vector>&,clang::Preprocessor&>(const
> >  FilterType &,std::vector> 
> > &,clang::Preprocessor &)'
> > with
> > [
> > _Ty=PPCallbacksTracker
> > ]
> > C:\Program Files (x86)\Microsoft Visual 
> > Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(2537): note: 
> > or   'std::unique_ptr> 
> > std::make_unique > FilterType&,std::vector>&,clang::Preprocessor&,0>(const
> >  FilterType &,std::vector> 
> > &,clang::Preprocessor &)' [found using argument-dependent lookup]
> > with
> > [
> > _Ty=PPCallbacksTracker
> > ]
> > C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp(93):
> >  note: while trying to match the argument list '(const FilterType, 
> > std::vector>, clang::Preprocessor)'
> > with
> > [
> > _Ty=CallbackCall
> > ]
> > C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\ll
> > vm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp(155): error C2668:
> > 'llvm::make_unique': ambiguous call to overloaded function
> > C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/ADT/STLExtras.h(1348):
> >  note: could be 
> > 'std::unique_ptr<`anonymous-namespace'::PPTraceFrontendActionFactory,std::default_delete<_Ty>>
> >  
> > llvm::make_unique<`anonymous-namespace'::PPTraceFrontendActionFactory,FilterType&,llvm::raw_fd_ostream&>(FilterType
> >  &,llvm::raw_fd_ostream &)'
> > with
> > [
> > _Ty=`anonymous-namespace'::PPTraceFrontendActionFactory
> > ]
> > C:\Program Files (x86)\Microsoft Visual 
> > Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(2537): note: 
> > or   
> > 'std::unique_ptr<`anonymous-namespace'::PPTraceFrontendActionFactory,std::default_delete<_Ty>>
> >  
> > std::make_unique<`anonymous-namespace'::PPTraceFrontendActionFactory,FilterType&,llvm::raw_fd_ostream&,0>(FilterType
> >  &,llvm::raw_fd_ostream &)' [found using argument-dependent lookup]
> > with
> >   

[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:17
 
+using llvm::SmallSet;
+

hintonda wrote:
> Eugene.Zelenko wrote:
> > It'll be easier to use llvm::SmallSet in using statement.
> Unfortunately, that won't compile.
> 
> The reason is that the llvm checkers live in `namespace 
> clang::clang-tidy::llvm`, so if you include an llvm checker header, which 
> opens the `clang::clang-tidy::llvm` namespace, clang doesn't know whether to 
> look in `llvm` or `clang::clang-tidy::llvm` since you are in 
> `clang::clang-tidy`.
> 
> The error does suggest using `::llvm::SmallSet`, but that seems sorta klugey.
> 
> Since this looks ugly, how about I add `using llvm::SmallSet;` to ` 
> clang/include/clang/LLVM.h`?
> 
Btw, the reason this never caused a problem before was that the first llvm 
checker header included in 
`clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp` was 
`HeaderGuardCheck.h`, which only include `HeaderGuardCheck.h` before opening 
the new `clang::clang-tidy::llvm` namespace.  Once I added this checker, which 
was included before `HeaderGuardCheck.h`, it made the new `llvm` namespace was 
ambiguous within `clang-tidy`, hence the error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:17
 
+using llvm::SmallSet;
+

Eugene.Zelenko wrote:
> It'll be easier to use llvm::SmallSet in using statement.
Unfortunately, that won't compile.

The reason is that the llvm checkers live in `namespace 
clang::clang-tidy::llvm`, so if you include an llvm checker header, which opens 
the `clang::clang-tidy::llvm` namespace, clang doesn't know whether to look in 
`llvm` or `clang::clang-tidy::llvm` since you are in `clang::clang-tidy`.

The error does suggest using `::llvm::SmallSet`, but that seems sorta klugey.

Since this looks ugly, how about I add `using llvm::SmallSet;` to ` 
clang/include/clang/LLVM.h`?



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802



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


[PATCH] D57072: Don't codegen an unreachable return block

2019-03-25 Thread Brad Moody via Phabricator via cfe-commits
bmoody added a comment.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

Ping! Any chance you could commit this on my behalf? Otherwise I can try the 
mailing list.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57072/new/

https://reviews.llvm.org/D57072



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


[PATCH] D59806: [clang-tidy] Add a check for [super self] in initializers 🔍

2019-03-25 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore created this revision.
Herald added subscribers: cfe-commits, jdoerfert, xazax.hun, mgorny.
Herald added a project: clang.
stephanemoore edited the summary of this revision.

This check aims to address a relatively common benign error where
Objective-C subclass initializers call -self on their superclass instead
of invoking a superclass initializer, typically -init. The error is
typically benign because libobjc recognizes that improper initializer
chaining is common¹.

One theory for the frequency of this error might be that -init and -self
have the same return type which could potentially cause inappropriate
autocompletion to -self instead of -init. The equal selector lengths and
triviality of common initializer code probably contribute to errors like
this slipping through code review undetected.

This check aims to flag errors of this form in the interests of
correctness and reduce incidence of initialization failing to chain to
-[NSObject init].

[1] "In practice, it will be hard to rely on this function. Many classes do not 
properly chain -init calls."
>From  _objc_rootInit in 
>https://opensource.apple.com/source/objc4/objc4-750.1/runtime/NSObject.mm.auto.html.

Test Notes:
Verified via `make check-clang-tools`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59806

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp
  clang-tools-extra/clang-tidy/objc/SuperSelfCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/objc-super-self.rst
  clang-tools-extra/test/clang-tidy/objc-super-self.m

Index: clang-tools-extra/test/clang-tidy/objc-super-self.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/objc-super-self.m
@@ -0,0 +1,54 @@
+// RUN: %check_clang_tidy %s objc-super-self %t
+
+@interface NSObject
+- (instancetype)init;
+- (instancetype)self;
+@end
+
+@interface NSObjectDerivedClass : NSObject
+@end
+
+@implementation NSObjectDerivedClass
+
+- (instancetype)init {
+  return [super self];
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious invocation of -[NSObject self] in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
+// CHECK-FIXES: return [super init];
+}
+
+- (instancetype)initWithObject:(NSObject *)obj {
+  self = [super self];
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious invocation of -[NSObject self] in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
+// CHECK-FIXES: self = [super init];
+  if (self) {
+// ...
+  }
+  return self;
+}
+
+- (instancetype)foo {
+  return [super self];
+}
+
+- (instancetype)bar {
+  return [self self];
+}
+
+@end
+
+@interface RootClass
+- (instancetype)init;
+- (instancetype)self;
+@end
+
+@interface NotNSObjectDerivedClass : RootClass
+@end
+
+@implementation NotNSObjectDerivedClass
+
+- (instancetype)init {
+  return [super self];
+}
+
+@end
+
Index: clang-tools-extra/docs/clang-tidy/checks/objc-super-self.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-super-self.rst
@@ -0,0 +1,14 @@
+.. title:: clang-tidy - objc-super-self
+
+objc-super-self
+===
+
+Finds invocations of -self on super instances (`[super self]`) in initializers
+of subclasses of NSObject and recommends invoking a superclass initializer
+instead.
+
+`[super self]` is a common programmer error when the programmer's original
+intent is to call a superclass initializer. Failing to call a superclass
+initializer breaks initializer chaining and can result in invalid object
+initialization.
+
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -227,6 +227,7 @@
objc-avoid-spinlock
objc-forbidden-subclassing
objc-property-declaration
+   objc-super-self
performance-faster-string-find
performance-for-range-copy
performance-implicit-conversion-in-loop
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -104,6 +104,11 @@
   Checks whether there are underscores in googletest test and test case names in
   test macros, which is prohibited by the Googletest FAQ.
 
+- New :doc:`objc-super-self ` check.
+
+  Finds invocations of -self on super instances in initializers of subclasses
+  of NSObject and recommends calling a superclass initializer instead.
+
 - New alias :doc:`cppcoreguidelines-explicit-virtual-functions
   ` to
   :doc:`modernize-use-override
Index: cl

[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:17
 
+using llvm::SmallSet;
+

It'll be easier to use llvm::SmallSet in using statement.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:136
+
+  Finds cases of `cast<>` used as condition in conditional statements
+  which will assert on failure in Debug builds.

Please use double, not single `.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 192234.
hintonda added a comment.

- Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802

Files:
  clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp
  clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.h
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
  clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp

Index: clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s llvm-avoid-cast-in-conditional %t
+
+struct X;
+struct Y;
+struct Z {
+  int foo();
+};
+
+template 
+X* cast(Y*);
+
+bool foo(Y* y) {
+  if (auto x = cast(y))
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*llvm-avoid-cast-in-conditional}}
+return true;
+  if (cast(y))
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning:  {{.*llvm-avoid-cast-in-conditional}}
+return true;
+
+  // Does not trigger warning.
+  if (cast(y)->foo())
+return true;
+  return false;
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - llvm-avoid-cast-in-conditional
+
+llvm-avoid-cast-in-conditional
+==
+
+Finds cases of `cast<>` used as the condition of a conditional
+statements which will assert on failure in Debug builds.  The use of
+cast<> implies that the operation cannot fail, and should not be used
+as the condition of a conditional statement.
+
+.. code-block:: c++
+
+  // Finds cases like these:
+  if (auto x = cast(y)) <...>
+  if (cast(y)) <...>
+
+  // But not cases like these:
+  if (auto f = cast(y)->foo()) <...>
+  if (cast(y)->foo()) <...>
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -175,6 +175,7 @@
hicpp-use-nullptr (redirects to modernize-use-nullptr) 
hicpp-use-override (redirects to modernize-use-override) 
hicpp-vararg (redirects to cppcoreguidelines-pro-type-vararg) 
+   llvm-avoid-cast-in-conditional
llvm-header-guard
llvm-include-order
llvm-namespace-comment
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -130,6 +130,12 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`llvm-avoid-cast-in-conditional
+  ` check.
+
+  Finds cases of `cast<>` used as condition in conditional statements
+  which will assert on failure in Debug builds.
+
 - New :doc:`openmp-exception-escape
   ` check.
 
Index: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
@@ -14,11 +14,13 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
 
+using llvm::SmallSet;
+
 namespace clang {
 namespace tidy {
 namespace utils {
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 
 /// \brief Checks whether expansion location of \p Loc is in header file.
 bool isExpansionLocInHeaderFile(
Index: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
+++ clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../readability/NamespaceCommentCheck.h"
+#include "AvoidCastInConditionalCheck.h"
 #include "HeaderGuardCheck.h"
 #include "IncludeOrderCheck.h"
 #include "TwineLocalCheck.h"
@@ -21,6 +22,8 @@
 class LLVMModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"llvm-avoid-cast-in-conditional");
 CheckFactories.registerCheck("llvm-header-guard");
 CheckFactories.registerCheck("llvm-include-order");
 CheckFactories.

[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 192233.
hintonda added a comment.

- Missed one set of braces.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp

Index: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a %s -verify
+// RUN: %clang_cc1 -std=c++2a %s -verify -pedantic
 
 namespace class_with_ctor {
   struct A { // expected-note 6{{candidate}}
@@ -21,3 +21,21 @@
   C c1 = {{}, {}}; // ok, call default ctor twice
   C c2 = {{1, 2}, {3, 4}}; // expected-error 2{{no matching constructor}}
 }
+
+namespace designator {
+struct A { int x, y; };
+struct B { A a; };
+
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a C99 feature}}
+
+// array designator
+int arr[3] = {[1] = 5}; // expected-warning {{designated initializers are a C99 feature}}
+
+// nested designator
+B b = {.a.x = 0}; // expected-warning {{designated initializers are a C99 feature}}
+
+// mixed designator and non-designator
+A a2 = {.x = 1, 2}; // expected-warning {{designated initializers are a C99 feature}}
+A a3 = {1, .y = 2}; // expected-warning {{designated initializers are a C99 feature}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1999,6 +1999,7 @@
   bool CheckForMissingFields =
 !IList->isIdiomaticZeroInitializer(SemaRef.getLangOpts());
   bool HasDesignatedInit = false;
+  bool HasNonDesignatedInit = false;
 
   while (Index < IList->getNumInits()) {
 Expr *Init = IList->getInit(Index);
@@ -2013,6 +2014,10 @@
 
   HasDesignatedInit = true;
 
+  auto LastIdx = Field != FieldEnd
+ ? Field->getFieldIndex()
+ : std::distance(RD->field_begin(), RD->field_end());
+
   // Handle this designated initializer. Field will be updated to
   // the next field that we'll be initializing.
   if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
@@ -2032,6 +2037,16 @@
 }
   }
 
+  // Warn on out of order and mixed designators in C++20.
+  auto NextIdx = Field != FieldEnd
+ ? Field->getFieldIndex()
+ : std::distance(RD->field_begin(), RD->field_end());
+  if (!VerifyOnly && (LastIdx >= NextIdx || HasNonDesignatedInit) &&
+  SemaRef.getLangOpts().CPlusPlus2a) {
+SemaRef.Diag(Init->getBeginLoc(), diag::ext_designated_init)
+<< Init->getSourceRange();
+  }
+
   InitializedSomething = true;
 
   // Disable check for missing fields when designators are used.
@@ -2045,6 +2060,14 @@
   break;
 }
 
+HasNonDesignatedInit = true;
+
+// Warn on mixed designators in C++20.
+if (!VerifyOnly && HasDesignatedInit && SemaRef.getLangOpts().CPlusPlus2a) {
+  SemaRef.Diag(Init->getBeginLoc(), diag::ext_designated_init)
+  << Init->getSourceRange();
+}
+
 // We've already initialized a member of a union. We're done.
 if (InitializedSomething && DeclType->isUnionType())
   break;
@@ -2980,6 +3003,7 @@
   bool Invalid = false;
   SmallVector Designators;
   SmallVector InitExpressions;
+  bool HasArrayDesignator = false;
 
   // Build designators and check array designator expressions.
   for (unsigned Idx = 0; Idx < Desig.getNumDesignators(); ++Idx) {
@@ -3003,6 +3027,7 @@
 D.getRBracketLoc()));
 InitExpressions.push_back(Index);
   }
+  HasArrayDesignator = true;
   break;
 }
 
@@ -3046,6 +3071,7 @@
   InitExpressions.push_back(EndIndex);
 }
   }
+  HasArrayDesignator = true;
   break;
 }
 }
@@ -3063,9 +3089,14 @@
  InitExpressions, Loc, GNUSyntax,
  Init.getAs());
 
-  if (!getLangOpts().C99)
-Diag(DIE->getBeginLoc(), diag::ext_designated_init)
-<< DIE->getSourceRange();
+  if (!getLangOpts().C99) {
+// Warn on nested and array designators in C++20.
+if (!getLangOpts().CPlusPlus2a || Desig.getNumDesignators() > 1 ||
+HasArrayDesignator) {
+  Diag(DIE->getBeginLoc(), diag::ext_designated_init)
+  << DIE->getSourceRange();
+}
+  }
 
   return DIE;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 192232.
hintonda added a comment.

- Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp

Index: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a %s -verify
+// RUN: %clang_cc1 -std=c++2a %s -verify -pedantic
 
 namespace class_with_ctor {
   struct A { // expected-note 6{{candidate}}
@@ -21,3 +21,21 @@
   C c1 = {{}, {}}; // ok, call default ctor twice
   C c2 = {{1, 2}, {3, 4}}; // expected-error 2{{no matching constructor}}
 }
+
+namespace designator {
+struct A { int x, y; };
+struct B { A a; };
+
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a C99 feature}}
+
+// array designator
+int arr[3] = {[1] = 5}; // expected-warning {{designated initializers are a C99 feature}}
+
+// nested designator
+B b = {.a.x = 0}; // expected-warning {{designated initializers are a C99 feature}}
+
+// mixed designator and non-designator
+A a2 = {.x = 1, 2}; // expected-warning {{designated initializers are a C99 feature}}
+A a3 = {1, .y = 2}; // expected-warning {{designated initializers are a C99 feature}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1999,6 +1999,7 @@
   bool CheckForMissingFields =
 !IList->isIdiomaticZeroInitializer(SemaRef.getLangOpts());
   bool HasDesignatedInit = false;
+  bool HasNonDesignatedInit = false;
 
   while (Index < IList->getNumInits()) {
 Expr *Init = IList->getInit(Index);
@@ -2013,6 +2014,10 @@
 
   HasDesignatedInit = true;
 
+  auto LastIdx = Field != FieldEnd
+ ? Field->getFieldIndex()
+ : std::distance(RD->field_begin(), RD->field_end());
+
   // Handle this designated initializer. Field will be updated to
   // the next field that we'll be initializing.
   if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
@@ -2032,6 +2037,15 @@
 }
   }
 
+  // Warn on out of order and mixed designators in C++20.
+  auto NextIdx = Field != FieldEnd
+ ? Field->getFieldIndex()
+ : std::distance(RD->field_begin(), RD->field_end());
+  if (!VerifyOnly && (LastIdx >= NextIdx || HasNonDesignatedInit) &&
+  SemaRef.getLangOpts().CPlusPlus2a)
+SemaRef.Diag(Init->getBeginLoc(), diag::ext_designated_init)
+<< Init->getSourceRange();
+
   InitializedSomething = true;
 
   // Disable check for missing fields when designators are used.
@@ -2045,6 +2059,14 @@
   break;
 }
 
+HasNonDesignatedInit = true;
+
+// Warn on mixed designators in C++20.
+if (!VerifyOnly && HasDesignatedInit && SemaRef.getLangOpts().CPlusPlus2a) {
+  SemaRef.Diag(Init->getBeginLoc(), diag::ext_designated_init)
+  << Init->getSourceRange();
+}
+
 // We've already initialized a member of a union. We're done.
 if (InitializedSomething && DeclType->isUnionType())
   break;
@@ -2980,6 +3002,7 @@
   bool Invalid = false;
   SmallVector Designators;
   SmallVector InitExpressions;
+  bool HasArrayDesignator = false;
 
   // Build designators and check array designator expressions.
   for (unsigned Idx = 0; Idx < Desig.getNumDesignators(); ++Idx) {
@@ -3003,6 +3026,7 @@
 D.getRBracketLoc()));
 InitExpressions.push_back(Index);
   }
+  HasArrayDesignator = true;
   break;
 }
 
@@ -3046,6 +3070,7 @@
   InitExpressions.push_back(EndIndex);
 }
   }
+  HasArrayDesignator = true;
   break;
 }
 }
@@ -3063,9 +3088,14 @@
  InitExpressions, Loc, GNUSyntax,
  Init.getAs());
 
-  if (!getLangOpts().C99)
-Diag(DIE->getBeginLoc(), diag::ext_designated_init)
-<< DIE->getSourceRange();
+  if (!getLangOpts().C99) {
+// Warn on nested and array designators in C++20.
+if (!getLangOpts().CPlusPlus2a || Desig.getNumDesignators() > 1 ||
+HasArrayDesignator) {
+  Diag(DIE->getBeginLoc(), diag::ext_designated_init)
+  << DIE->getSourceRange();
+}
+  }
 
   return DIE;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59725: Additions to creduce script

2019-03-25 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 192230.
akhuang added a comment.

fix issue with grouping two command line args together


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725

Files:
  clang/utils/creduce-clang-crash.py

Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -1,8 +1,14 @@
 #!/usr/bin/env python
 """Calls C-Reduce to create a minimal reproducer for clang crashes.
+
+Output files:
+  *.reduced.sh -- crash reproducer with minimal arguments
+  *.reduced.cpp -- the reduced file
+  *.test.sh -- interestingness test for C-Reduce
 """
 
-from argparse import ArgumentParser
+from __future__ import print_function
+from argparse import ArgumentParser, RawTextHelpFormatter
 import os
 import re
 import stat
@@ -15,10 +21,14 @@
 from distutils.spawn import find_executable
 
 verbose = False
-llvm_bin = None
 creduce_cmd = None
+clang_cmd = None
 not_cmd = None
 
+def verbose_print(*args, **kwargs):
+  if verbose:
+print(*args, **kwargs)
+
 def check_file(fname):
   if not os.path.isfile(fname):
 sys.exit("ERROR: %s does not exist" % (fname))
@@ -33,166 +43,310 @@
 cmd = find_executable(cmd_path)
 if cmd:
   return cmd
-sys.exit("ERROR: executable %s not found" % (cmd_path))
+sys.exit("ERROR: executable `%s` not found" % (cmd_path))
 
   cmd = find_executable(cmd_name, path=cmd_dir)
   if cmd:
 return cmd
-  sys.exit("ERROR: %s not found in %s" % (cmd_name, cmd_dir))
 
-def quote_cmd(cmd):
-  return ' '.join(arg if arg.startswith('$') else pipes.quote(arg)
-  for arg in cmd)
-
-def get_crash_cmd(crash_script):
-  with open(crash_script) as f:
-# Assume clang call is on the last line of the script
-line = f.readlines()[-1]
-cmd = shlex.split(line)
-
-# Overwrite the script's clang with the user's clang path
-new_clang = check_cmd('clang', llvm_bin)
-cmd[0] = pipes.quote(new_clang)
-return cmd
+  if not cmd_dir:
+cmd_dir = "$PATH"
+  sys.exit("ERROR: `%s` not found in %s" % (cmd_name, cmd_dir))
 
-def has_expected_output(crash_cmd, expected_output):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-  return all(msg in crash_output for msg in expected_output)
-
-def get_expected_output(crash_cmd):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-
-  # If there is an assertion failure, use that;
-  # otherwise use the last five stack trace functions
-  assertion_re = r'Assertion `([^\']+)\' failed'
-  assertion_match = re.search(assertion_re, crash_output)
-  if assertion_match:
-return [assertion_match.group(1)]
-  else:
-stacktrace_re = r'#[0-9]+\s+0[xX][0-9a-fA-F]+\s*([^(]+)\('
-matches = re.findall(stacktrace_re, crash_output)
-return matches[-5:]
-
-def write_interestingness_test(testfile, crash_cmd, expected_output,
-   file_to_reduce):
-  filename = os.path.basename(file_to_reduce)
-  if filename not in crash_cmd:
-sys.exit("ERROR: expected %s to be in the crash command" % filename)
-
-  # Replace all instances of file_to_reduce with a command line variable
-  output = ['#!/bin/bash',
-'if [ -z "$1" ] ; then',
-'  f=%s' % (pipes.quote(filename)),
-'else',
-'  f="$1"',
-'fi']
-  cmd = ['$f' if s == filename else s for s in crash_cmd]
-
-  output.append('%s --crash %s >& t.log || exit 1' % (pipes.quote(not_cmd),
-  quote_cmd(cmd)))
-
-  for msg in expected_output:
-output.append('grep %s t.log || exit 1' % pipes.quote(msg))
-
-  with open(testfile, 'w') as f:
-f.write('\n'.join(output))
-  os.chmod(testfile, os.stat(testfile).st_mode | stat.S_IEXEC)
-
-def check_interestingness(testfile, file_to_reduce):
-  testfile = os.path.abspath(testfile)
-
-  # Check that the test considers the original file interesting
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call(testfile, stdout=devnull)
-  if returncode:
-sys.exit("The interestingness test does not pass for the original file.")
-
-  # Check that an empty file is not interesting
-  _, empty_file = tempfile.mkstemp()
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call([testfile, empty_file], stdout=devnull)
-  os.remove(empty_file)
-  if not returncode:
-sys.exit("The interestingness test passes for an empty file.")
-
-def clang_preprocess(file_to_reduce, crash_cmd, expected_output):
-  _, tmpfile = tempfile.mkstemp()
-  shutil.copy(file_to_reduce, tmpfile)
-
-  cmd = crash_cmd + ['-E', '-P']
-  p = subprocess.Popen(cmd,
-

[PATCH] D59725: Additions to creduce script

2019-03-25 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked 2 inline comments as done.
akhuang added inline comments.



Comment at: clang/utils/creduce-clang-crash.py:223
+  if len(x) > 0 and x[-1].startswith('-') and not y.startswith('-'):
+x[-1] += ' ' + y
+return x

george.burgess.iv wrote:
> akhuang wrote:
> > george.burgess.iv wrote:
> > > Should we be `shlex.quote`'ing y here (and probably in the `return x + 
> > > [y]` below)?
> > It quotes everything right before writing to file - are there reasons to 
> > quote here instead?
> We're `shlex.split`ing groups below, and I assume the intent is 
> `Reduce.ungroup_args(Reduce.group_args_by_dash(args)) == args`.
> 
> If we don't want to quote here, we can also have `ungroup_args` and 
> `group_args_by_dash` deal in lists of nonempty lists.
good point- I guess the whole grouping thing is unnecessarily complicated, so I 
got rid of it and it now removes the next arg in `try_remove_arg_by_index` 



Comment at: clang/utils/creduce-clang-crash.py:306
+# Remove other cases that aren't covered by the heuristic
+new_args = self.try_remove_args(new_args, msg="Removed -mllvm",
+opts_one_arg_startswith=["-mllvm"])

george.burgess.iv wrote:
> george.burgess.iv wrote:
> > Probably want to do a similar thing for `-Xclang` (which, as far as this 
> > code is concerned, acts a lot like `-mllvm`)
> (You can ignore this comment if we're dealing in cc1; `-Xclang` is just "pass 
> this directly as a cc1 arg")
ah, ok. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725



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


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:2044
+ : std::distance(RD->field_begin(), RD->field_end());
+  if (VerifyOnly && (LastIdx >= NextIdx || HasNonDesignatedInit) &&
+  SemaRef.getLangOpts().CPlusPlus2a)

Rakete wrote:
> `!VerifyOnly` and braces please.
Will commit this change as soon as check-clang finishes, but not sure I grok 
the VerityOnly/!VerifyOnly criteria.  Could you help me out? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D59803: [CMake][Fuchsia] Merge static libunwind and libc++abi into libc++ on Darwin

2019-03-25 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356970: [CMake][Fuchsia] Merge static libunwind and 
libc++abi into libc++ on Darwin (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59803?vs=192225&id=192229#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59803/new/

https://reviews.llvm.org/D59803

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -37,6 +37,18 @@
 
   set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
+
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 endif()
 
 foreach(target 
aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;x86_64-linux-gnu)


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -37,6 +37,18 @@
 
   set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
+
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 endif()
 
 foreach(target aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;x86_64-linux-gnu)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356970 - [CMake][Fuchsia] Merge static libunwind and libc++abi into libc++ on Darwin

2019-03-25 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Mar 25 17:43:29 2019
New Revision: 356970

URL: http://llvm.org/viewvc/llvm-project?rev=356970&view=rev
Log:
[CMake][Fuchsia] Merge static libunwind and libc++abi into libc++ on Darwin

We want to distribute only a single archive so -lc++ does the right
thing and users don't have to explicitly link -lc++abi and -lunwind.

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=356970&r1=356969&r2=356970&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Mon Mar 25 17:43:29 2019
@@ -37,6 +37,18 @@ if(APPLE)
 
   set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
+
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 endif()
 
 foreach(target 
aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;x86_64-linux-gnu)


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


[PATCH] D59622: [analyzer] C++17: PR41142: Ignore transparent InitListExprs in ExprEngine as well.

2019-03-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356969: [CFG] [analyzer] pr41142: C++17: Skip transparent 
InitListExprs in ExprEngine. (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59622?vs=191606&id=192227#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59622/new/

https://reviews.llvm.org/D59622

Files:
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Analysis/initializer.cpp


Index: test/Analysis/initializer.cpp
===
--- test/Analysis/initializer.cpp
+++ test/Analysis/initializer.cpp
@@ -1,7 +1,17 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 -verify %s
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++11 
-DTEST_INLINABLE_ALLOCATORS -verify %s
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 
-DTEST_INLINABLE_ALLOCATORS -verify %s
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++11
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++17
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++11\
+// RUN:   -DTEST_INLINABLE_ALLOCATORS
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++17\
+// RUN:   -DTEST_INLINABLE_ALLOCATORS
 
 void clang_analyzer_eval(bool);
 
@@ -232,7 +242,7 @@
 
   D d = {}; // no-crash
 
-#ifdef CPLUSPLUS17
+#if __cplusplus >= 201703L
   C cd = {{}}; // no-crash
   const C &cdl = {{}}; // no-crash
   C &&cdr = {{}}; // no-crash
@@ -260,4 +270,8 @@
 void foo2() {
   C c { coo() }; // no-crash
 }
+
+B foo_recursive() {
+  B b { foo_recursive() };
+}
 } // namespace CXX17_transparent_init_list_exprs
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -704,7 +704,7 @@
   QualType T = getContext().getCanonicalType(IE->getType());
   unsigned NumInitElements = IE->getNumInits();
 
-  if (!IE->isGLValue() &&
+  if (!IE->isGLValue() && !IE->isTransparent() &&
   (T->isArrayType() || T->isRecordType() || T->isVectorType() ||
T->isAnyComplexType())) {
 llvm::ImmutableList vals = getBasicVals().getEmptySValList();


Index: test/Analysis/initializer.cpp
===
--- test/Analysis/initializer.cpp
+++ test/Analysis/initializer.cpp
@@ -1,7 +1,17 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 -DTEST_INLINABLE_ALLOCATORS -verify %s
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++11
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++17
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++11\
+// RUN:   -DTEST_INLINABLE_ALLOCATORS
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++17\
+// RUN:   -DTEST_IN

r356969 - [CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in ExprEngine.

2019-03-25 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Mar 25 17:36:53 2019
New Revision: 356969

URL: http://llvm.org/viewvc/llvm-project?rev=356969&view=rev
Log:
[CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in ExprEngine.

r356634 didn't fix all the problems caused by r356222 - even though simple
constructors involving transparent init-list expressions are now evaluated
precisely, many more complicated constructors aren't, for other reasons.

The attached test case is an example of a constructor that will never be
evaluated precisely - simply because there isn't a constructor there (instead,
the program invokes run-time undefined behavior by returning without a return
statement that should have constructed the return value).

Fix another part of the problem for such situations: evaluate transparent
init-list expressions transparently, so that to avoid creating ill-formed
"transparent" nonloc::CompoundVals.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/test/Analysis/initializer.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=356969&r1=356968&r2=356969&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Mon Mar 25 17:36:53 2019
@@ -704,7 +704,7 @@ void ExprEngine::VisitInitListExpr(const
   QualType T = getContext().getCanonicalType(IE->getType());
   unsigned NumInitElements = IE->getNumInits();
 
-  if (!IE->isGLValue() &&
+  if (!IE->isGLValue() && !IE->isTransparent() &&
   (T->isArrayType() || T->isRecordType() || T->isVectorType() ||
T->isAnyComplexType())) {
 llvm::ImmutableList vals = getBasicVals().getEmptySValList();

Modified: cfe/trunk/test/Analysis/initializer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/initializer.cpp?rev=356969&r1=356968&r2=356969&view=diff
==
--- cfe/trunk/test/Analysis/initializer.cpp (original)
+++ cfe/trunk/test/Analysis/initializer.cpp Mon Mar 25 17:36:53 2019
@@ -1,7 +1,17 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 -verify %s
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++11 
-DTEST_INLINABLE_ALLOCATORS -verify %s
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection
 -analyzer-config c++-inlining=constructors -std=c++17 -DCPLUSPLUS17 
-DTEST_INLINABLE_ALLOCATORS -verify %s
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++11
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++17
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++11\
+// RUN:   -DTEST_INLINABLE_ALLOCATORS
+// RUN: %clang_analyze_cc1 -w -verify %s\
+// RUN:   -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks\
+// RUN:   -analyzer-checker=debug.ExprInspection -std=c++17\
+// RUN:   -DTEST_INLINABLE_ALLOCATORS
 
 void clang_analyzer_eval(bool);
 
@@ -232,7 +242,7 @@ void foo() {
 
   D d = {}; // no-crash
 
-#ifdef CPLUSPLUS17
+#if __cplusplus >= 201703L
   C cd = {{}}; // no-crash
   const C &cdl = {{}}; // no-crash
   C &&cdr = {{}}; // no-crash
@@ -260,4 +270,8 @@ C coo();
 void foo2() {
   C c { coo() }; // no-crash
 }
+
+B foo_recursive() {
+  B b { foo_recursive() };
+}
 } // namespace CXX17_transparent_init_list_exprs


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


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:30
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a 
C99 feature}}
+

Rakete wrote:
> hintonda wrote:
> > lebedev.ri wrote:
> > > hintonda wrote:
> > > > Rakete wrote:
> > > > > Those warnings are misleading, since C++20 does have designated 
> > > > > initializers; they just don't support some stuff that C99 does. It 
> > > > > would be better  IMO if you could separate them. As in, the above 
> > > > > should give you: `out-of-order designated initializers are a C99 
> > > > > feature` or something like that.
> > > > I think that would be a good idea as well, but wanted to get advise 
> > > > first.
> > > > As in, the above should give you: out-of-order designated initializers 
> > > > are a C99 feature or something like that.
> > > 
> > > I suppose also the question is, whether to error-out, or support them as 
> > > an extension?
> > > 
> > Although most of them seem fine, the nested ones can be problematic.  
> > Please see https://reviews.llvm.org/D17407 for a proposal on how to fix 
> > them.
> > I suppose also the question is, whether to error-out, or support them as an 
> > extension?
> 
> Yes that's true. gcc doesn't support them at all in C++, and it seems like we 
> accept it as well, but only for C classes (constructors make clang crash).
> 
> But making it an error now breaks backwards compatibility. So I think the 
> best solution is to accept it for now, as an extension.
Btw, several cpp tests use nested designated initializers.  Here's a quick list 
I got by temporarily making it an error:

  CodeGenCXX/mangle-exprs.cpp
  SemaCXX/cxx2a-initializer-aggregates.cpp
  SemaCXX/decltype.cpp
  SemaTemplate/instantiate-init.cpp

I believe there are a several out of order ones as well, but those might have 
been unintentional.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D59797: [COFF] Reorder fields in Chunk and SectionChunk to reduce their size

2019-03-25 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: lld/COFF/Chunks.cpp:47
 
+namespace {
+// This class exists just for the purpose of calculating the expected size of

pcc wrote:
> rnk wrote:
> > ruiu wrote:
> > > rnk wrote:
> > > > ruiu wrote:
> > > > > rnk wrote:
> > > > > > ruiu wrote:
> > > > > > > This might be useful but at the same time it looks a bit overly 
> > > > > > > cautious? Perhaps the symbol size is more important but we don't 
> > > > > > > have something like this for them, for example.
> > > > > > Well, we don't have checks for symbol size yet. :)
> > > > > > 
> > > > > > Given that we don't have performance monitoring, I really want 
> > > > > > people to think hard before they casually add another field to 
> > > > > > SectionChunk. I wouldn't insist on it if we did, but these types of 
> > > > > > static_asserts have proven useful in LLVM for preventing size creep.
> > > > > Then maybe reiterating everything again, how about checking directly 
> > > > > with a number like `static_assert(sizeof(Chunk) == 48)`? This should 
> > > > > suffice to prevent making the struct larger by accident.
> > > > It would be wrong for 32-bit. Rather than trying to express it as math 
> > > > on sizeof(void*), I think the struct makes it clearer. And it helps 
> > > > document hidden members like vptr.
> > > Yeah, but it still feels weird to me to repeat all the members again in a 
> > > different file just for the purpose of assertion. For 32-bit, we can just 
> > > set the upper bound like `static_assert(sizeof(Chunk) <= 48)` where 48 is 
> > > the size of the struct in 64-bit.
> > Fair enough. Honestly, writing down all the fields in one place helped me 
> > identify the profitable reorderings, but we don't need to commit it.
> I found D59044 (and, to a lesser extent, D59269) by staring at the output of 
> clang with `-Xclang -fdump-record-layouts`. Maybe it would be worth adding 
> this trick to the documentation somewhere?
The clang static analyzer has a padding checker 
(https://clang.llvm.org/docs/analyzer/checkers.html#optin-performance-padding), 
and clang-tools-extra has clang-reorder-fields to automatically reorder fields 
according to the padding checker's findings. I haven't used those myself, but a 
coworker had success with them in the past.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59797/new/

https://reviews.llvm.org/D59797



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


[PATCH] D53701: [Analyzer] Instead of recording comparisons in interator checkers do an eager state split

2019-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:822-831
+assignToContainer(C, CE, LVal, Cont);
+if (!(LPos = getIteratorPosition(State, LVal)))
   return;
-State = saveComparison(State, Condition, LVal, RVal, Op == OO_EqualEqual);
-C.addTransition(State);
-  } else if (const auto TruthVal = RetVal.getAs()) {
-if ((State = processComparison(
- State, getRegionOrSymbol(LVal), getRegionOrSymbol(RVal),
- (Op == OO_EqualEqual) == (TruthVal->getValue() != 0 {
+  } else if (!RPos) {
+assignToContainer(C, CE, RVal, Cont);
+if (!(RPos = getIteratorPosition(State, RVal)))
+  return;

NoQ wrote:
> Welcome to the `addTransition()` hell!
> 
> Each of the `assignToContainer()` may add a transition, and then 
> `processComparison()` also adds transitions. I suspect that it may lead to 
> more state splits that were intended. I.e., the execution path on which the 
> iterator is assigned to a container would be different from the two execution 
> paths on which the comparison was processed.
> 
> You can chain `addTransition()`s to each other, eg.:
> ```lang=c++
> // Return the node produced by the inner addTransition()
> ExplodedNode *N = assignToContainer(...);
> 
> // And then in processComparison(N, ...)
> C.addTransition(N->getState()->assume(*ConditionVal, false), N);
> C.addTransition(N->getState()->assume(*ConditionVal, true), N);
> ```
> 
> It should also be possible to avoid transitions until the final state is 
> computed, if the code is easy enough to refactor this way:
> ```lang=c++
> // No addTransition() calls within, just produce the state
> ProgramStateRef State = assignToContainer(...);
> 
> // And then in processComparison(N, ...)
> C.addTransition(State->assume(*ConditionVal, false), N);
> C.addTransition(State->assume(*ConditionVal, true), N);
> ```
> 
> This sort of stuff can be tested via `clang_analyzer_numTimesReached()` - see 
> if you made exactly as many state splits as you wanted to.
My feel is that a better `.addTransition()` API should capture the user's 
intent more straightforwardly, so that we could check dynamically that the 
resulting topology is indeed exactly what the user expects.

I.e., produce multiple narrow-purpose APIs for common patterns: 
`C.updateState(State)`, `C.splitState(State1, State2, ..., StateN)` - both 
would fail if there were previous transitions in the same `CheckerContext` or 
if more transitions are made after them. The `updateState()` variant should 
probably try to lazily collapse multiple updates into a single node. Maybe 
instead don't require all branches to be specified simultaneously, i.e. instead 
do `addBranch(State)` that wouldn't fail in presence of other branches but 
would still conflict with `updateState()`.

These narrow-purpose APIs are too clumsy to cover the current use-case, but at 
least they would've caught the problem. Maybe a better design could make it 
also comfortable to use.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53701/new/

https://reviews.llvm.org/D53701



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


[PATCH] D59008: [AMDGPU] Switch default dwarf version to 5

2019-03-25 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D59008#1442256 , @t-tye wrote:

> In D59008#1442014 , @dblaikie wrote:
>
> > In D59008#1441903 , @t-tye wrote:
> >
> > > LGTM
> > >
> > > Do we know the state of split DWARF and DWARF compression for DWARF 5 
> > > (compared to DWARF 2)?
> >
> >
> > State of them in what sense? Compression is pretty orthogonal to any DWARF 
> > version - it's more about the container (ELF, etc) you use. Split DWARF is 
> > non-standardly supported in pre-v5, and I think it's functioning in the 
> > standards conformant v5 mode too.
>
>
> I had heard mention that at least split DWARF may not be fully supported yet 
> for DWARF 5 in LLVM. But maybe that is old news:-)


Might be - nothing I know of right now. (type units aren't fully supported in 
DWARFv5 - but that's the only big thing on my list)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59008/new/

https://reviews.llvm.org/D59008



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


[PATCH] D59803: [CMake][Fuchsia] Merge static libunwind and libc++abi into libc++ on Darwin

2019-03-25 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: juliehockett, jakehehrlich.
Herald added subscribers: cfe-commits, mgorny.
Herald added a reviewer: EricWF.
Herald added a project: clang.

We want to distribute only a single archive so -lc++ does the right
thing and users don't have to explicitly link -lc++abi and -lunwind.


Repository:
  rC Clang

https://reviews.llvm.org/D59803

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -37,6 +37,18 @@
 
   set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
+
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 endif()
 
 foreach(target 
aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;x86_64-linux-gnu)


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -37,6 +37,18 @@
 
   set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
   set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
+
+  set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+  set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+  set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 endif()
 
 foreach(target aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;x86_64-linux-gnu)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54978: Move the SMT API to LLVM

2019-03-25 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I'm afraid this broke some bots that build with `LLVM_ENABLE_MODULES=1`.

For example:

http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/22411/consoleFull#710926295dd1929ea-7054-4089-b7ef-4624c3781fa4

  Undefined symbols for architecture x86_64:
"llvm::errs()", referenced from:
llvm::SMTExpr::dump() const in 
liblldbDebugserverCommon.a(RNBSocket.cpp.o)
llvm::SMTSolver::dump() const in 
liblldbDebugserverCommon.a(RNBSocket.cpp.o)
llvm::SMTSort::dump() const in 
liblldbDebugserverCommon.a(RNBSocket.cpp.o)
llvm::SMTExpr::dump() const in 
liblldbDebugserverCommon.a(SocketAddress.cpp.o)
llvm::SMTSolver::dump() const in 
liblldbDebugserverCommon.a(SocketAddress.cpp.o)
llvm::SMTSort::dump() const in 
liblldbDebugserverCommon.a(SocketAddress.cpp.o)

Long story short: You can't have an LLVM_DUMP_METHOD defined inline inside of a 
module.

One way to fix this would be to move the function body of the various

  LLVM_DUMP_METHOD void dump() const { print(llvm::errs()); }

functions into .cpp files.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54978/new/

https://reviews.llvm.org/D54978



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


[PATCH] D59797: [COFF] Reorder fields in Chunk and SectionChunk to reduce their size

2019-03-25 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: lld/COFF/Chunks.cpp:47
 
+namespace {
+// This class exists just for the purpose of calculating the expected size of

rnk wrote:
> ruiu wrote:
> > rnk wrote:
> > > ruiu wrote:
> > > > rnk wrote:
> > > > > ruiu wrote:
> > > > > > This might be useful but at the same time it looks a bit overly 
> > > > > > cautious? Perhaps the symbol size is more important but we don't 
> > > > > > have something like this for them, for example.
> > > > > Well, we don't have checks for symbol size yet. :)
> > > > > 
> > > > > Given that we don't have performance monitoring, I really want people 
> > > > > to think hard before they casually add another field to SectionChunk. 
> > > > > I wouldn't insist on it if we did, but these types of static_asserts 
> > > > > have proven useful in LLVM for preventing size creep.
> > > > Then maybe reiterating everything again, how about checking directly 
> > > > with a number like `static_assert(sizeof(Chunk) == 48)`? This should 
> > > > suffice to prevent making the struct larger by accident.
> > > It would be wrong for 32-bit. Rather than trying to express it as math on 
> > > sizeof(void*), I think the struct makes it clearer. And it helps document 
> > > hidden members like vptr.
> > Yeah, but it still feels weird to me to repeat all the members again in a 
> > different file just for the purpose of assertion. For 32-bit, we can just 
> > set the upper bound like `static_assert(sizeof(Chunk) <= 48)` where 48 is 
> > the size of the struct in 64-bit.
> Fair enough. Honestly, writing down all the fields in one place helped me 
> identify the profitable reorderings, but we don't need to commit it.
I found D59044 (and, to a lesser extent, D59269) by staring at the output of 
clang with `-Xclang -fdump-record-layouts`. Maybe it would be worth adding this 
trick to the documentation somewhere?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59797/new/

https://reviews.llvm.org/D59797



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


[PATCH] D59797: [COFF] Reorder fields in Chunk and SectionChunk to reduce their size

2019-03-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk marked 4 inline comments as done.
rnk added inline comments.



Comment at: lld/COFF/Chunks.cpp:47
 
+namespace {
+// This class exists just for the purpose of calculating the expected size of

ruiu wrote:
> rnk wrote:
> > ruiu wrote:
> > > rnk wrote:
> > > > ruiu wrote:
> > > > > This might be useful but at the same time it looks a bit overly 
> > > > > cautious? Perhaps the symbol size is more important but we don't have 
> > > > > something like this for them, for example.
> > > > Well, we don't have checks for symbol size yet. :)
> > > > 
> > > > Given that we don't have performance monitoring, I really want people 
> > > > to think hard before they casually add another field to SectionChunk. I 
> > > > wouldn't insist on it if we did, but these types of static_asserts have 
> > > > proven useful in LLVM for preventing size creep.
> > > Then maybe reiterating everything again, how about checking directly with 
> > > a number like `static_assert(sizeof(Chunk) == 48)`? This should suffice 
> > > to prevent making the struct larger by accident.
> > It would be wrong for 32-bit. Rather than trying to express it as math on 
> > sizeof(void*), I think the struct makes it clearer. And it helps document 
> > hidden members like vptr.
> Yeah, but it still feels weird to me to repeat all the members again in a 
> different file just for the purpose of assertion. For 32-bit, we can just set 
> the upper bound like `static_assert(sizeof(Chunk) <= 48)` where 48 is the 
> size of the struct in 64-bit.
Fair enough. Honestly, writing down all the fields in one place helped me 
identify the profitable reorderings, but we don't need to commit it.



Comment at: lld/COFF/Chunks.h:232
+  // Relocations for this section.
   ArrayRef Relocs;
 

I'm not sure we need to store this, actually, it's pretty easy to recompute on 
demand. At the very least, we could shorten the size to 32-bits. I think ~4 
billion is a reasonable implementation limit on relocations.



Comment at: lld/COFF/Chunks.h:236
   // the thunk instead of the actual original target Symbol.
   std::vector RelocTargets;
 

riccibruno wrote:
> I think that `llvm::SmallVector` is one pointer smaller, with 
> the drawback that it is limited to `2^32-1` elements.
My plan is to see if I can eliminate it completely, but I wanted to treat it 
separately once I established that the size of this was important and put a cap 
on it.



Comment at: lld/COFF/Chunks.h:259
   StringRef SectionName;
   std::vector AssocChildren;
 

This, for example, is typically 2-3 elements long: each comdat .text section 
will have a an assoc pdata and xdata. A singly linked list could suffice 
instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59797/new/

https://reviews.llvm.org/D59797



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


[PATCH] D59797: [COFF] Reorder fields in Chunk and SectionChunk to reduce their size

2019-03-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 192223.
rnk added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- replace struct with current size


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59797/new/

https://reviews.llvm.org/D59797

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaCXX/declspec-allocator.cpp
  lld/COFF/Chunks.cpp
  lld/COFF/Chunks.h
  llvm/include/llvm/BinaryFormat/COFF.h

Index: llvm/include/llvm/BinaryFormat/COFF.h
===
--- llvm/include/llvm/BinaryFormat/COFF.h
+++ llvm/include/llvm/BinaryFormat/COFF.h
@@ -402,7 +402,7 @@
   IMAGE_REL_ARM64_REL32 = 0x0011,
 };
 
-enum COMDATType : unsigned {
+enum COMDATType : uint8_t {
   IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
   IMAGE_COMDAT_SELECT_ANY,
   IMAGE_COMDAT_SELECT_SAME_SIZE,
Index: lld/COFF/Chunks.h
===
--- lld/COFF/Chunks.h
+++ lld/COFF/Chunks.h
@@ -50,7 +50,7 @@
 // doesn't even have actual data (if common or bss).
 class Chunk {
 public:
-  enum Kind { SectionKind, OtherKind };
+  enum Kind : uint8_t { SectionKind, OtherKind };
   Kind kind() const { return ChunkKind; }
   virtual ~Chunk() = default;
 
@@ -114,6 +114,12 @@
   Chunk(Kind K = OtherKind) : ChunkKind(K) {}
   const Kind ChunkKind;
 
+public:
+  // Whether this section needs to be kept distinct from other sections during
+  // ICF. This is set by the driver using address-significance tables.
+  bool KeepUnique = false;
+
+protected:
   // The RVA of this chunk in the output. The writer sets a value.
   uint64_t RVA = 0;
 
@@ -123,10 +129,6 @@
 public:
   // The offset from beginning of the output section. The writer sets a value.
   uint64_t OutputSectionOff = 0;
-
-  // Whether this section needs to be kept distinct from other sections during
-  // ICF. This is set by the driver using address-significance tables.
-  bool KeepUnique = false;
 };
 
 // A chunk corresponding a section of an input file.
@@ -217,36 +219,41 @@
 
   bool isHotPatchable() const override { return File->HotPatchable; }
 
-  // A pointer pointing to a replacement for this chunk.
-  // Initially it points to "this" object. If this chunk is merged
-  // with other chunk by ICF, it points to another chunk,
-  // and this chunk is considered as dead.
-  SectionChunk *Repl;
-
-  // The CRC of the contents as described in the COFF spec 4.5.5.
-  // Auxiliary Format 5: Section Definitions. Used for ICF.
-  uint32_t Checksum = 0;
-
-  const coff_section *Header;
-
   // The file that this chunk was created from.
   ObjFile *File;
 
+  // Pointer to the COFF section header in the input file.
+  const coff_section *Header;
+
   // The COMDAT leader symbol if this is a COMDAT chunk.
   DefinedRegular *Sym = nullptr;
 
-  // The COMDAT selection if this is a COMDAT chunk.
-  llvm::COFF::COMDATType Selection = (llvm::COFF::COMDATType)0;
-
+  // Relocations for this section.
   ArrayRef Relocs;
 
-  // Used by the garbage collector.
-  bool Live;
-
   // When inserting a thunk, we need to adjust a relocation to point to
   // the thunk instead of the actual original target Symbol.
   std::vector RelocTargets;
 
+  // The CRC of the contents as described in the COFF spec 4.5.5.
+  // Auxiliary Format 5: Section Definitions. Used for ICF.
+  uint32_t Checksum = 0;
+
+  // Indicates whether the section should be included in the output file.
+  // Sections may become dead if the garbage collector discards them, if ICF
+  // replaces them, or if they are associated with a non-prevailing comdat
+  // section.
+  bool Live;
+
+  // The COMDAT selection if this is a COMDAT chunk.
+  llvm::COFF::COMDATType Selection = (llvm::COFF::COMDATType)0;
+
+  // A pointer pointing to a replacement for this chunk.
+  // Initially it points to "this" object. If this chunk is merged
+  // with other chunk by ICF, it points to another chunk,
+  // and this chunk is considered as dead.
+  SectionChunk *Repl;
+
 private:
   StringRef SectionName;
   std::vector AssocChildren;
Index: lld/COFF/Chunks.cpp
===
--- lld/COFF/Chunks.cpp
+++ lld/COFF/Chunks.cpp
@@ -30,8 +30,8 @@
 namespace coff {
 
 SectionChunk::SectionChunk(ObjFile *F, const coff_section *H)
-: Chunk(SectionKind), Repl(this), Header(H), File(F),
-  Relocs(File->getCOFFObj()->getRelocations(Header)) {
+: Chunk(SectionKind), File(F), Header(H),
+  Relocs(File->getCOFFObj()->getRelocations(Header)), Repl(this) {
   // Initialize SectionName.
   File->getCOFFObj()->getSectionName(Header, SectionName);
 
@@ -44,6 +44,11 @@
   Live = !Config->DoGC || !isCOMDAT();
 }
 
+// SectionChunk is one of the most frequently allocated classes, so it is
+// important to keep it as compac

r356964 - [MS] Add frontend support for __declspec(allocator)

2019-03-25 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Mar 25 16:20:18 2019
New Revision: 356964

URL: http://llvm.org/viewvc/llvm-project?rev=356964&view=rev
Log:
[MS] Add frontend support for __declspec(allocator)

The intention is to add metadata to direct call sites of functions
marked with __declspec(allocator), which will ultimately result in some
S_HEAPALLOCSITE debug info records when emitting codeview.

This is a piece of PR38491

Added:
cfe/trunk/test/SemaCXX/declspec-allocator.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=356964&r1=356963&r2=356964&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar 25 16:20:18 2019
@@ -2757,6 +2757,12 @@ def : IgnoredAttr {
   let Spellings = [Declspec<"property">];
 }
 
+def MSAllocator : InheritableAttr {
+  let Spellings = [Declspec<"allocator">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [MSAllocatorDocs];
+}
+
 def MSStruct : InheritableAttr {
   let Spellings = [GCC<"ms_struct">];
   let Subjects = SubjectList<[Record]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=356964&r1=356963&r2=356964&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar 25 16:20:18 2019
@@ -4089,3 +4089,20 @@ it will be automatically applied to over
 attribute can also be written using C++11 syntax: ``[[mig::server_routine]]``.
 }];
 }
+
+def MSAllocatorDocs : Documentation {
+  let Category = DocCatType;
+  let Content = [{
+The ``__declspec(allocator)`` attribute is applied to functions that allocate
+memory, such as operator new in C++. When CodeView debug information is emitted
+(enabled by ``clang -gcodeview`` or ``clang-cl /Z7``), Clang will attempt to
+record the code offset of heap allocation call sites in the debug info. It will
+also record the type being allocated using some local heuristics. The Visual
+Studio debugger uses this information to `profile memory usage`_.
+
+.. _profile memory usage: 
https://docs.microsoft.com/en-us/visualstudio/profiling/memory-usage
+
+This attribute does not affect optimizations in any way, unlike GCC's
+``__attribute__((malloc))``.
+}];
+}

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=356964&r1=356963&r2=356964&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Mar 25 16:20:18 
2019
@@ -2956,6 +2956,9 @@ def err_base_specifier_attribute : Error
   "%0 attribute cannot be applied to a base specifier">;
 def err_invalid_attribute_on_virtual_function : Error<
   "%0 attribute cannot be applied to virtual functions">;
+def warn_declspec_allocator_nonpointer : Warning<
+  "ignoring __declspec(allocator) because the function return type %0 is not "
+  "a pointer or reference type">, InGroup;
 
 def ext_cannot_use_trivial_abi : ExtWarn<
   "'trivial_abi' cannot be applied to %0">, InGroup;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=356964&r1=356963&r2=356964&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Mar 25 16:20:18 2019
@@ -6548,6 +6548,20 @@ static void handleMIGServerRoutineAttr(S
   handleSimpleAttribute(S, D, AL);
 }
 
+static void handleMSAllocatorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // Warn if the return type is not a pointer or reference type.
+  if (auto *FD = dyn_cast(D)) {
+QualType RetTy = FD->getReturnType();
+if (!RetTy->isPointerType() && !RetTy->isReferenceType()) {
+  S.Diag(AL.getLoc(), diag::warn_declspec_allocator_nonpointer)
+  << AL.getRange() << RetTy;
+  return;
+}
+  }
+
+  handleSimpleAttribute(S, D, AL);
+}
+
 
//===--===//
 // Top Level Sema Entry Points
 
//===--===//
@@ -7281,6 +7295,10 @@ static void ProcessDeclAttribute(Sema &S
   case ParsedAttr::AT_MIGServerRoutine:
 handleMIGServerRoutineAttr(S, D, AL);
 break;
+
+  case ParsedAttr::AT_MSAllocator:
+handleMSAllocatorAttr

[PATCH] D59725: Additions to creduce script

2019-03-25 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv marked an inline comment as done.
george.burgess.iv added inline comments.



Comment at: clang/utils/creduce-clang-crash.py:223
+  if len(x) > 0 and x[-1].startswith('-') and not y.startswith('-'):
+x[-1] += ' ' + y
+return x

akhuang wrote:
> george.burgess.iv wrote:
> > Should we be `shlex.quote`'ing y here (and probably in the `return x + [y]` 
> > below)?
> It quotes everything right before writing to file - are there reasons to 
> quote here instead?
We're `shlex.split`ing groups below, and I assume the intent is 
`Reduce.ungroup_args(Reduce.group_args_by_dash(args)) == args`.

If we don't want to quote here, we can also have `ungroup_args` and 
`group_args_by_dash` deal in lists of nonempty lists.



Comment at: clang/utils/creduce-clang-crash.py:279
+ "-debugger-tuning=",
+ "-gdwarf"])
+new_args = self.try_remove_args(new_args,

akhuang wrote:
> george.burgess.iv wrote:
> > If we're replacing other args with their effective negation, does it also 
> > make sense to replace all debug-ish options with `-g0`?
> I guess `-g0` is not a cc1 option, nor is `-gdwarf`? So this is essentially 
> just removing `-gcodeview`. I'm actually not sure what the other flags do. 
Ah, I didn't realize this was dealing with cc1 args. My mistake.

I'm not immediately sure either, but grepping through the code, it looks like 
`-debug-info-kind=` may be the main interesting one to us here.



Comment at: clang/utils/creduce-clang-crash.py:306
+# Remove other cases that aren't covered by the heuristic
+new_args = self.try_remove_args(new_args, msg="Removed -mllvm",
+opts_one_arg_startswith=["-mllvm"])

george.burgess.iv wrote:
> Probably want to do a similar thing for `-Xclang` (which, as far as this code 
> is concerned, acts a lot like `-mllvm`)
(You can ignore this comment if we're dealing in cc1; `-Xclang` is just "pass 
this directly as a cc1 arg")



Comment at: clang/utils/creduce-clang-crash.py:362
+  r = Reduce(crash_script, file_to_reduce)
+  r.simplify_clang_args()
+  r.write_interestingness_test()

akhuang wrote:
> george.burgess.iv wrote:
> > I'm unclear on why we do a partial simplification of clang args here, then 
> > a full reduction after creduce. Is there a disadvantage to instead doing:
> > 
> > r.write_interestingness_test()
> > r.clang_preprocess()
> > r.reduce_clang_args()
> > r.run_creduce()
> > r.reduce_clang_args()
> > 
> > ?
> > 
> > The final `reduce_clang_args` being there to remove extra `-D`/`-I`/etc. 
> > args if preprocessing failed somehow, to remove `-std=foo` args if those 
> > aren't relevant after reduction, etc.
> > 
> > The advantage to this being that we no longer need to maintain a `simplify` 
> > function, and creduce runs with a relatively minimal set of args to start 
> > with.
> > 
> > In any case, can we please add comments explaining why we chose whatever 
> > order we end up going with, especially where subtleties make it counter to 
> > what someone might naively expect?
> Basically the disadvantage is that clang takes longer to run before the 
> reduction, so it takes unnecessary time to iterate through all the arguments 
> beforehand. 
> And yeah, the final `reduce_clang_args` is there to minimize the clang 
> arguments needed to reproduce the crash on the reduced source file. 
> 
> If that makes sense, I can add comments for this-
Eh, I don't have a strong opinion here. My inclination is to prefer a simpler 
reduction script if the difference is len(args) clang invocations, since I 
assume creduce is going to invoke clang way more than len(args) times. I see a 
docstring detailing that `simplify` is only meant to speed things up now, so 
I'm content with the way things are.



Comment at: clang/utils/creduce-clang-crash.py:303
+opts_startswith=["-O"])
+self.clang_args = new_args
+verbose_print("Simplified command:", quote_cmd(self.get_crash_cmd()))

FWIW, opportunistically trying to add `-fsyntax-only` may help here: if the 
crash is in the frontend, it means that non-repros will stop before codegen, 
rather than trying to generate object files, or whatever they were trying to 
generate in the first place.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:23
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+typedef SmallSet HeaderFileExtensionsSet;
 

hintonda wrote:
> Eugene.Zelenko wrote:
> > Please use using. See modernize-use-using.
> Normally I'd agree, but since the llvm checkers live in the llvm namespace, 
> including any llvm checker prior to this header will prevent clang from 
> finding `llvm::SmallSet`.  As you can see, the other llvm classes don't need 
> the `llvm::` prefix, but that's because `clang/include/clang/Basic/LLVM.h` 
> already has a bunch of `using` statements.
> 
> So, this code won't compile without this change, or the addition of `using 
> llvm::SmallSet;` to `clang/include/clang/Basic/LLVM.h`.  Should I make that 
> change first?  Then just remove the `llvm::` prefix?
Oh, sorry, didn't read closely enough.  I can get rid of the typedef.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802



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


[PATCH] D59725: Additions to creduce script

2019-03-25 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 192218.
akhuang marked an inline comment as done.
akhuang added a comment.

Style nits, added comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725

Files:
  clang/utils/creduce-clang-crash.py

Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -1,8 +1,14 @@
 #!/usr/bin/env python
 """Calls C-Reduce to create a minimal reproducer for clang crashes.
+
+Output files:
+  *.reduced.sh -- crash reproducer with minimal arguments
+  *.reduced.cpp -- the reduced file
+  *.test.sh -- interestingness test for C-Reduce
 """
 
-from argparse import ArgumentParser
+from __future__ import print_function
+from argparse import ArgumentParser, RawTextHelpFormatter
 import os
 import re
 import stat
@@ -15,10 +21,14 @@
 from distutils.spawn import find_executable
 
 verbose = False
-llvm_bin = None
 creduce_cmd = None
+clang_cmd = None
 not_cmd = None
 
+def verbose_print(*args, **kwargs):
+  if verbose:
+print(*args, **kwargs)
+
 def check_file(fname):
   if not os.path.isfile(fname):
 sys.exit("ERROR: %s does not exist" % (fname))
@@ -33,166 +43,326 @@
 cmd = find_executable(cmd_path)
 if cmd:
   return cmd
-sys.exit("ERROR: executable %s not found" % (cmd_path))
+sys.exit("ERROR: executable `%s` not found" % (cmd_path))
 
   cmd = find_executable(cmd_name, path=cmd_dir)
   if cmd:
 return cmd
-  sys.exit("ERROR: %s not found in %s" % (cmd_name, cmd_dir))
 
-def quote_cmd(cmd):
-  return ' '.join(arg if arg.startswith('$') else pipes.quote(arg)
-  for arg in cmd)
-
-def get_crash_cmd(crash_script):
-  with open(crash_script) as f:
-# Assume clang call is on the last line of the script
-line = f.readlines()[-1]
-cmd = shlex.split(line)
-
-# Overwrite the script's clang with the user's clang path
-new_clang = check_cmd('clang', llvm_bin)
-cmd[0] = pipes.quote(new_clang)
-return cmd
+  if not cmd_dir:
+cmd_dir = "$PATH"
+  sys.exit("ERROR: `%s` not found in %s" % (cmd_name, cmd_dir))
 
-def has_expected_output(crash_cmd, expected_output):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-  return all(msg in crash_output for msg in expected_output)
-
-def get_expected_output(crash_cmd):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-
-  # If there is an assertion failure, use that;
-  # otherwise use the last five stack trace functions
-  assertion_re = r'Assertion `([^\']+)\' failed'
-  assertion_match = re.search(assertion_re, crash_output)
-  if assertion_match:
-return [assertion_match.group(1)]
-  else:
-stacktrace_re = r'#[0-9]+\s+0[xX][0-9a-fA-F]+\s*([^(]+)\('
-matches = re.findall(stacktrace_re, crash_output)
-return matches[-5:]
-
-def write_interestingness_test(testfile, crash_cmd, expected_output,
-   file_to_reduce):
-  filename = os.path.basename(file_to_reduce)
-  if filename not in crash_cmd:
-sys.exit("ERROR: expected %s to be in the crash command" % filename)
-
-  # Replace all instances of file_to_reduce with a command line variable
-  output = ['#!/bin/bash',
-'if [ -z "$1" ] ; then',
-'  f=%s' % (pipes.quote(filename)),
-'else',
-'  f="$1"',
-'fi']
-  cmd = ['$f' if s == filename else s for s in crash_cmd]
-
-  output.append('%s --crash %s >& t.log || exit 1' % (pipes.quote(not_cmd),
-  quote_cmd(cmd)))
-
-  for msg in expected_output:
-output.append('grep %s t.log || exit 1' % pipes.quote(msg))
-
-  with open(testfile, 'w') as f:
-f.write('\n'.join(output))
-  os.chmod(testfile, os.stat(testfile).st_mode | stat.S_IEXEC)
-
-def check_interestingness(testfile, file_to_reduce):
-  testfile = os.path.abspath(testfile)
-
-  # Check that the test considers the original file interesting
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call(testfile, stdout=devnull)
-  if returncode:
-sys.exit("The interestingness test does not pass for the original file.")
-
-  # Check that an empty file is not interesting
-  _, empty_file = tempfile.mkstemp()
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call([testfile, empty_file], stdout=devnull)
-  os.remove(empty_file)
-  if not returncode:
-sys.exit("The interestingness test passes for an empty file.")
-
-def clang_preprocess(file_to_reduce, crash_cmd, expected_output):
-  _, tmpfile = tempfile.mkstemp()
-  shutil.copy(file_to_reduce, tmpfile)
-
-  cmd = crash_cmd + ['-E', '-P']
-  p = subprocess.Popen(cmd,

[PATCH] D59725: Additions to creduce script

2019-03-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I recently discovered NamedTemporaryFile, maybe that would help simplify up the 
various mkstemp usages.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:23
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+typedef SmallSet HeaderFileExtensionsSet;
 

Eugene.Zelenko wrote:
> Please use using. See modernize-use-using.
Normally I'd agree, but since the llvm checkers live in the llvm namespace, 
including any llvm checker prior to this header will prevent clang from finding 
`llvm::SmallSet`.  As you can see, the other llvm classes don't need the 
`llvm::` prefix, but that's because `clang/include/clang/Basic/LLVM.h` already 
has a bunch of `using` statements.

So, this code won't compile without this change, or the addition of `using 
llvm::SmallSet;` to `clang/include/clang/Basic/LLVM.h`.  Should I make that 
change first?  Then just remove the `llvm::` prefix?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:23
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+typedef SmallSet HeaderFileExtensionsSet;
 

Please use using. See modernize-use-using.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:136
+
+  Finds cases of cast<> used as condition in conditional statements which will
+  assert on failure in Debug builds.

Please enclose cast<> in ``.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst:6
+
+Finds cases of cast<> used as the condition of a conditional
+statements which will assert on failure in Debug builds.  The use of

Please enclose cast<> in ``. Same below.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst:7
+Finds cases of cast<> used as the condition of a conditional
+statements which will assert on failure in Debug builds.  The use of
+cast<> implies that the operation cannot fail, and should not be used

Please fix double space.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst:9
+cast<> implies that the operation cannot fail, and should not be used
+as the condition of a conditional statement..
+

Please fix double dot.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59802/new/

https://reviews.llvm.org/D59802



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-avoid-cast-in-conditional

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda created this revision.
hintonda added reviewers: alexfh, rjmccall.
Herald added subscribers: xazax.hun, mgorny.
Herald added a project: clang.

Finds cases of cast<> used as the condition of a conditional
statements which will assert on failure in Debug builds.  The use of
cast<> implies that the operation cannot fail, and should not be used
as the condition of a conditional statement..

.. code-block:: c++

  // Finds cases like these:
  if (auto x = cast(y)) <...>
  if (cast(y)) <...>
  
  // But not cases like these:
  if (auto f = cast(y)->foo()) <...>
  if (cast(y)->foo()) <...>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59802

Files:
  clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp
  clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.h
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
  clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp

Index: clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-avoid-cast-in-conditional.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s llvm-avoid-cast-in-conditional %t
+
+struct X;
+struct Y;
+struct Z {
+  int foo();
+};
+
+template 
+X* cast(Y*);
+
+bool foo(Y* y) {
+  if (auto x = cast(y))
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*llvm-avoid-cast-in-conditional}}
+return true;
+  if (cast(y))
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning:  {{.*llvm-avoid-cast-in-conditional}}
+return true;
+
+  // Does not trigger warning.
+  if (cast(y)->foo())
+return true;
+  return false;
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvm-avoid-cast-in-conditional.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - llvm-avoid-cast-in-conditional
+
+llvm-avoid-cast-in-conditional
+==
+
+Finds cases of cast<> used as the condition of a conditional
+statements which will assert on failure in Debug builds.  The use of
+cast<> implies that the operation cannot fail, and should not be used
+as the condition of a conditional statement..
+
+.. code-block:: c++
+
+  // Finds cases like these:
+  if (auto x = cast(y)) <...>
+  if (cast(y)) <...>
+
+  // But not cases like these:
+  if (auto f = cast(y)->foo()) <...>
+  if (cast(y)->foo()) <...>
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -175,6 +175,7 @@
hicpp-use-nullptr (redirects to modernize-use-nullptr) 
hicpp-use-override (redirects to modernize-use-override) 
hicpp-vararg (redirects to cppcoreguidelines-pro-type-vararg) 
+   llvm-avoid-cast-in-conditional
llvm-header-guard
llvm-include-order
llvm-namespace-comment
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -130,6 +130,12 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`llvm-avoid-cast-in-conditional
+  ` check.
+
+  Finds cases of cast<> used as condition in conditional statements which will
+  assert on failure in Debug builds.
+
 - New :doc:`openmp-exception-escape
   ` check.
 
Index: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h
@@ -14,11 +14,13 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
 
+using llvm::SmallSet;
+
 namespace clang {
 namespace tidy {
 namespace utils {
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+typedef SmallSet HeaderFileExtensionsSet;
 
 /// \brief Checks whether expansion location of \p Loc is in header file.
 bool isExpansionLocInHeaderFile(
Index: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
+++ clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../readability/NamespaceCommentCheck.h"
+#include "AvoidCastInConditionalCheck.h"
 #include "HeaderG

[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added inline comments.



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:30
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a 
C99 feature}}
+

hintonda wrote:
> lebedev.ri wrote:
> > hintonda wrote:
> > > Rakete wrote:
> > > > Those warnings are misleading, since C++20 does have designated 
> > > > initializers; they just don't support some stuff that C99 does. It 
> > > > would be better  IMO if you could separate them. As in, the above 
> > > > should give you: `out-of-order designated initializers are a C99 
> > > > feature` or something like that.
> > > I think that would be a good idea as well, but wanted to get advise first.
> > > As in, the above should give you: out-of-order designated initializers 
> > > are a C99 feature or something like that.
> > 
> > I suppose also the question is, whether to error-out, or support them as an 
> > extension?
> > 
> Although most of them seem fine, the nested ones can be problematic.  Please 
> see https://reviews.llvm.org/D17407 for a proposal on how to fix them.
> I suppose also the question is, whether to error-out, or support them as an 
> extension?

Yes that's true. gcc doesn't support them at all in C++, and it seems like we 
accept it as well, but only for C classes (constructors make clang crash).

But making it an error now breaks backwards compatibility. So I think the best 
solution is to accept it for now, as an extension.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D53701: [Analyzer] Instead of recording comparisons in interator checkers do an eager state split

2019-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:822-831
+assignToContainer(C, CE, LVal, Cont);
+if (!(LPos = getIteratorPosition(State, LVal)))
   return;
-State = saveComparison(State, Condition, LVal, RVal, Op == OO_EqualEqual);
-C.addTransition(State);
-  } else if (const auto TruthVal = RetVal.getAs()) {
-if ((State = processComparison(
- State, getRegionOrSymbol(LVal), getRegionOrSymbol(RVal),
- (Op == OO_EqualEqual) == (TruthVal->getValue() != 0 {
+  } else if (!RPos) {
+assignToContainer(C, CE, RVal, Cont);
+if (!(RPos = getIteratorPosition(State, RVal)))
+  return;

Welcome to the `addTransition()` hell!

Each of the `assignToContainer()` may add a transition, and then 
`processComparison()` also adds transitions. I suspect that it may lead to more 
state splits that were intended. I.e., the execution path on which the iterator 
is assigned to a container would be different from the two execution paths on 
which the comparison was processed.

You can chain `addTransition()`s to each other, eg.:
```lang=c++
// Return the node produced by the inner addTransition()
ExplodedNode *N = assignToContainer(...);

// And then in processComparison(N, ...)
C.addTransition(N->getState()->assume(*ConditionVal, false), N);
C.addTransition(N->getState()->assume(*ConditionVal, true), N);
```

It should also be possible to avoid transitions until the final state is 
computed, if the code is easy enough to refactor this way:
```lang=c++
// No addTransition() calls within, just produce the state
ProgramStateRef State = assignToContainer(...);

// And then in processComparison(N, ...)
C.addTransition(State->assume(*ConditionVal, false), N);
C.addTransition(State->assume(*ConditionVal, true), N);
```

This sort of stuff can be tested via `clang_analyzer_numTimesReached()` - see 
if you made exactly as many state splits as you wanted to.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53701/new/

https://reviews.llvm.org/D53701



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


[PATCH] D59725: Additions to creduce script

2019-03-25 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked 15 inline comments as done.
akhuang added inline comments.



Comment at: clang/utils/creduce-clang-crash.py:137
+
+# If no message was found, use the top five stack trace functions,
+# ignoring some common functions

george.burgess.iv wrote:
> Please expand a bit on why 5 was chosen (is there some deep reason behind it, 
> or does it just seem like a sensible number?)
There is no deep reason - it was an arbitrary smallish number to hopefully not 
only pick up common stack trace functions



Comment at: clang/utils/creduce-clang-crash.py:202
+cmd = self.get_crash_cmd() + ['-E', '-P']
+p = subprocess.Popen(self.get_crash_cmd() + ['-E', '-P'],
+ stdout=subprocess.PIPE,

george.burgess.iv wrote:
> was this intended to use `cmd`?
yep



Comment at: clang/utils/creduce-clang-crash.py:205
+ stderr=subprocess.STDOUT)
+preprocessed, _ = p.communicate()
+

george.burgess.iv wrote:
> Do we want to check the exit code of this? Or do we assume that if clang 
> crashes during preprocessing, we'll just see a different error during 
> `check_expected_output`? (In the latter case, please add a comment)
I think checking the exit code is a good idea



Comment at: clang/utils/creduce-clang-crash.py:222
+def append_flags(x, y):
+  if len(x) > 0 and x[-1].startswith('-') and not y.startswith('-'):
+x[-1] += ' ' + y

george.burgess.iv wrote:
> Is it intentional to group multiple consecutive non-dashed args? e.g. it 
> seems that `clang -ffoo bar baz` will turn into `['clang', '-ffoo bar baz']`
> 
> 
I guess that was originally the intention, although now that I think of it it 
makes more sense to group at most one argument. 



Comment at: clang/utils/creduce-clang-crash.py:223
+  if len(x) > 0 and x[-1].startswith('-') and not y.startswith('-'):
+x[-1] += ' ' + y
+return x

george.burgess.iv wrote:
> Should we be `shlex.quote`'ing y here (and probably in the `return x + [y]` 
> below)?
It quotes everything right before writing to file - are there reasons to quote 
here instead?



Comment at: clang/utils/creduce-clang-crash.py:279
+ "-debugger-tuning=",
+ "-gdwarf"])
+new_args = self.try_remove_args(new_args,

george.burgess.iv wrote:
> If we're replacing other args with their effective negation, does it also 
> make sense to replace all debug-ish options with `-g0`?
I guess `-g0` is not a cc1 option, nor is `-gdwarf`? So this is essentially 
just removing `-gcodeview`. I'm actually not sure what the other flags do. 



Comment at: clang/utils/creduce-clang-crash.py:362
+  r = Reduce(crash_script, file_to_reduce)
+  r.simplify_clang_args()
+  r.write_interestingness_test()

george.burgess.iv wrote:
> I'm unclear on why we do a partial simplification of clang args here, then a 
> full reduction after creduce. Is there a disadvantage to instead doing:
> 
> r.write_interestingness_test()
> r.clang_preprocess()
> r.reduce_clang_args()
> r.run_creduce()
> r.reduce_clang_args()
> 
> ?
> 
> The final `reduce_clang_args` being there to remove extra `-D`/`-I`/etc. args 
> if preprocessing failed somehow, to remove `-std=foo` args if those aren't 
> relevant after reduction, etc.
> 
> The advantage to this being that we no longer need to maintain a `simplify` 
> function, and creduce runs with a relatively minimal set of args to start 
> with.
> 
> In any case, can we please add comments explaining why we chose whatever 
> order we end up going with, especially where subtleties make it counter to 
> what someone might naively expect?
Basically the disadvantage is that clang takes longer to run before the 
reduction, so it takes unnecessary time to iterate through all the arguments 
beforehand. 
And yeah, the final `reduce_clang_args` is there to minimize the clang 
arguments needed to reproduce the crash on the reduced source file. 

If that makes sense, I can add comments for this-


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725



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


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:30
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a 
C99 feature}}
+

lebedev.ri wrote:
> hintonda wrote:
> > Rakete wrote:
> > > Those warnings are misleading, since C++20 does have designated 
> > > initializers; they just don't support some stuff that C99 does. It would 
> > > be better  IMO if you could separate them. As in, the above should give 
> > > you: `out-of-order designated initializers are a C99 feature` or 
> > > something like that.
> > I think that would be a good idea as well, but wanted to get advise first.
> > As in, the above should give you: out-of-order designated initializers are 
> > a C99 feature or something like that.
> 
> I suppose also the question is, whether to error-out, or support them as an 
> extension?
> 
Although most of them seem fine, the nested ones can be problematic.  Please 
see https://reviews.llvm.org/D17407 for a proposal on how to fix them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:30
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a 
C99 feature}}
+

hintonda wrote:
> Rakete wrote:
> > Those warnings are misleading, since C++20 does have designated 
> > initializers; they just don't support some stuff that C99 does. It would be 
> > better  IMO if you could separate them. As in, the above should give you: 
> > `out-of-order designated initializers are a C99 feature` or something like 
> > that.
> I think that would be a good idea as well, but wanted to get advise first.
> As in, the above should give you: out-of-order designated initializers are a 
> C99 feature or something like that.

I suppose also the question is, whether to error-out, or support them as an 
extension?



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked 2 inline comments as done.
hintonda added a comment.

Thanks for the review.




Comment at: clang/lib/Sema/SemaInit.cpp:2017
 
+  auto LastIdx = Field != FieldEnd
+ ? Field->getFieldIndex()

Rakete wrote:
> Can `Field` ever be `FieldEnd` at this point?
Yes.  If the last trip through the loop was a designated initializer, and it 
happened to be the last field in the RecordDecl, Field will be equal FieldEnd.  
At this point, the loop will exit below unless there's another designated 
initializer that's out of order.



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:30
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a 
C99 feature}}
+

Rakete wrote:
> Those warnings are misleading, since C++20 does have designated initializers; 
> they just don't support some stuff that C99 does. It would be better  IMO if 
> you could separate them. As in, the above should give you: `out-of-order 
> designated initializers are a C99 feature` or something like that.
I think that would be a good idea as well, but wanted to get advise first.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D57265: [PM/CC1] Add -f[no-]split-cold-code CC1 options to toggle splitting

2019-03-25 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 192210.
vsk edited the summary of this revision.
vsk added a comment.
Herald added subscribers: jdoerfert, dexonsmith, steven_wu, eraman.

Use a function attribute to implement the -fsplit-cold-code option. This 
removes some complexity from the old/new PMs and ensures consistent behavior 
when LTO is enabled.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57265/new/

https://reviews.llvm.org/D57265

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/split-cold-code.c
  clang/test/Frontend/split-cold-code.c
  llvm/include/llvm/Transforms/IPO/HotColdSplitting.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/HotColdSplitting.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/test/Other/X86/lto-hot-cold-split.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Other/opt-hot-cold-split.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/CodeExtractor/extract-assume.ll
  llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
  llvm/test/Transforms/HotColdSplit/addr-taken.ll
  llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll
  llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll
  llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll
  llvm/test/Transforms/HotColdSplit/apply-successor-penalty.ll
  llvm/test/Transforms/HotColdSplit/coldentrycount.ll
  llvm/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll
  llvm/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll
  llvm/test/Transforms/HotColdSplit/eh-pads.ll
  llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll
  llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
  llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-1.ll
  llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll
  llvm/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll
  llvm/test/Transforms/HotColdSplit/minsize.ll
  llvm/test/Transforms/HotColdSplit/multiple-exits.ll
  llvm/test/Transforms/HotColdSplit/noreturn.ll
  llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll
  llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
  llvm/test/Transforms/HotColdSplit/outline-if-then-else.ll
  llvm/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll
  llvm/test/Transforms/HotColdSplit/outline-while-loop.ll
  llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
  llvm/test/Transforms/HotColdSplit/region-overlap.ll
  llvm/test/Transforms/HotColdSplit/resume.ll
  llvm/test/Transforms/HotColdSplit/split-cold-2.ll
  llvm/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll
  llvm/test/Transforms/HotColdSplit/split-phis-in-exit-blocks.ll
  llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
  llvm/test/Transforms/HotColdSplit/swifterror.ll
  llvm/test/Transforms/HotColdSplit/unwind.ll

Index: llvm/test/Transforms/HotColdSplit/unwind.ll
===
--- llvm/test/Transforms/HotColdSplit/unwind.ll
+++ llvm/test/Transforms/HotColdSplit/unwind.ll
@@ -11,7 +11,7 @@
 
 ; CHECK-NOT: noreturn
 
-define i32 @foo() personality i8 0 {
+define i32 @foo() "hot-cold-split" personality i8 0 {
 entry:
   invoke void @llvm.donothing() to label %normal unwind label %exception
 
Index: llvm/test/Transforms/HotColdSplit/swifterror.ll
===
--- llvm/test/Transforms/HotColdSplit/swifterror.ll
+++ llvm/test/Transforms/HotColdSplit/swifterror.ll
@@ -9,7 +9,7 @@
 
 ; CHECK-LABEL: define {{.*}}@in_arg(
 ; CHECK: call void @in_arg.cold.1(%swift_error** swifterror
-define void @in_arg(%swift_error** swifterror %error_ptr_ref) {
+define void @in_arg(%swift_error** swifterror %error_ptr_ref) "hot-cold-split" {
   br i1 undef, label %cold, label %exit
 
 cold:
@@ -23,7 +23,7 @@
 
 ; CHECK-LABEL: define {{.*}}@in_alloca(
 ; CHECK: call void @in_alloca.cold.1(%swift_error** swifterror
-define void @in_alloca() {
+define void @in_alloca() "hot-cold-split" {
   %err = alloca swifterror %swift_error*
   br i1 undef, label %cold, label %exit
 
Index: llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
===
--- llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
+++ llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
@@ -7,7 +7,7 @@
 ; CHECK: call {{.*}}@exit_block_with_same_incoming_vals.cold.1(
 ; CHECK-NOT: br i1 undef
 ; CHECK: phi i32 [ 0, %entry ], [ %p.ce.reload, %codeRepl ]
-define void @exit_bl

[PATCH] D59776: [Sema] Don't check for array bounds when the types in the base expression are dependent.

2019-03-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356957: [Sema] Don't check for array bounds when the 
types in the base expression are… (authored by brunoricci, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59776?vs=192115&id=192209#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59776/new/

https://reviews.llvm.org/D59776

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/SemaCXX/array-bounds.cpp


Index: cfe/trunk/test/SemaCXX/array-bounds.cpp
===
--- cfe/trunk/test/SemaCXX/array-bounds.cpp
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp
@@ -296,3 +296,16 @@
   // We can still diagnose this.
   C &h() { return reinterpret_cast(xxx)[-1]; } // expected-warning 
{{array index -1 is before the beginning of the array}}
 }
+
+namespace PR41087 {
+  template  void foo() {
+Ty buffer[2]; // expected-note 3{{array 'buffer' declared here}}
+((char *)buffer)[2] = 'A'; // expected-warning 1{{array index 2 is past 
the end of the array (which contains 2 elements)}}
+((char *)buffer)[-1] = 'A'; // expected-warning 2{{array index -1 is 
before the beginning of the array}}
+  }
+
+  void f() {
+foo(); // expected-note 1{{in instantiation of function template 
specialization}}
+foo(); // expected-note 1{{in instantiation of function template 
specialization}}
+  };
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -12522,6 +12522,8 @@
 return;
 
   const Type *BaseType = ArrayTy->getElementType().getTypePtr();
+  if (EffectiveType->isDependentType() || BaseType->isDependentType())
+return;
 
   Expr::EvalResult Result;
   if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects))


Index: cfe/trunk/test/SemaCXX/array-bounds.cpp
===
--- cfe/trunk/test/SemaCXX/array-bounds.cpp
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp
@@ -296,3 +296,16 @@
   // We can still diagnose this.
   C &h() { return reinterpret_cast(xxx)[-1]; } // expected-warning {{array index -1 is before the beginning of the array}}
 }
+
+namespace PR41087 {
+  template  void foo() {
+Ty buffer[2]; // expected-note 3{{array 'buffer' declared here}}
+((char *)buffer)[2] = 'A'; // expected-warning 1{{array index 2 is past the end of the array (which contains 2 elements)}}
+((char *)buffer)[-1] = 'A'; // expected-warning 2{{array index -1 is before the beginning of the array}}
+  }
+
+  void f() {
+foo(); // expected-note 1{{in instantiation of function template specialization}}
+foo(); // expected-note 1{{in instantiation of function template specialization}}
+  };
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -12522,6 +12522,8 @@
 return;
 
   const Type *BaseType = ArrayTy->getElementType().getTypePtr();
+  if (EffectiveType->isDependentType() || BaseType->isDependentType())
+return;
 
   Expr::EvalResult Result;
   if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356957 - [Sema] Don't check for array bounds when the types in the base expression are dependent

2019-03-25 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Mon Mar 25 14:37:10 2019
New Revision: 356957

URL: http://llvm.org/viewvc/llvm-project?rev=356957&view=rev
Log:
[Sema] Don't check for array bounds when the types in the base expression are 
dependent

Bail-out of CheckArrayAccess when the types of the base expression before
and after eventual casts are dependent. We will get another chance to check
for array bounds during instantiation. Fixes PR41087.

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

Reviewed By: efriedma


Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/array-bounds.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=356957&r1=356956&r2=356957&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Mar 25 14:37:10 2019
@@ -12522,6 +12522,8 @@ void Sema::CheckArrayAccess(const Expr *
 return;
 
   const Type *BaseType = ArrayTy->getElementType().getTypePtr();
+  if (EffectiveType->isDependentType() || BaseType->isDependentType())
+return;
 
   Expr::EvalResult Result;
   if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects))

Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=356957&r1=356956&r2=356957&view=diff
==
--- cfe/trunk/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp Mon Mar 25 14:37:10 2019
@@ -296,3 +296,16 @@ namespace PR39746 {
   // We can still diagnose this.
   C &h() { return reinterpret_cast(xxx)[-1]; } // expected-warning 
{{array index -1 is before the beginning of the array}}
 }
+
+namespace PR41087 {
+  template  void foo() {
+Ty buffer[2]; // expected-note 3{{array 'buffer' declared here}}
+((char *)buffer)[2] = 'A'; // expected-warning 1{{array index 2 is past 
the end of the array (which contains 2 elements)}}
+((char *)buffer)[-1] = 'A'; // expected-warning 2{{array index -1 is 
before the beginning of the array}}
+  }
+
+  void f() {
+foo(); // expected-note 1{{in instantiation of function template 
specialization}}
+foo(); // expected-note 1{{in instantiation of function template 
specialization}}
+  };
+}


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


[PATCH] D59555: [analyzer] Add yaml parser to GenericTaintChecker

2019-03-25 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 marked an inline comment as done.
boga95 added a comment.

Why is it better not to use `static` functions/variables? Has it any 
performance impact?




Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:73-75
   static const unsigned InvalidArgIndex = UINT_MAX;
   /// Denotes the return vale.
   static const unsigned ReturnValueIndex = UINT_MAX - 1;

Szelethus wrote:
> We should definitely change these, not only is the large integer number 
> impossible to remember, but this value could differ on different platforms.
I tried to use int, but I got a lot of warnings because of the `getNumArgs()` 
returns an unsigned value.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59555/new/

https://reviews.llvm.org/D59555



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


[PATCH] D59665: Call to HandleNameConflict in VisitEnumDecl mistakeningly using Name instead of SearchName

2019-03-25 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik marked an inline comment as done.
shafik added a comment.

@martong your idea does not work b/c default construction `DeclarationName()` 
treats it the same as being empty. So `if (!Name)` is still `true`.




Comment at: lib/AST/ASTImporter.cpp:2463
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),

a_sidorin wrote:
> If I understand correctly, this will replace Name with SearchName causing an 
> anonymous enum to be imported as a named a few lines below. It doesn't look 
> like a correct behaviour to me.
This is correct because either `SearchName` is `Name` or it is the name of the 
typedef for the anonymous enum set via `ImportInto(SearchName, 
D->getTypedefNameForAnonDecl()->getDeclName())`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59665/new/

https://reviews.llvm.org/D59665



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


[PATCH] D46140: [coroutines] std::task type (WIP)

2019-03-25 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker updated this revision to Diff 192208.
lewissbaker added a comment.

Fix race condition in __oneshot_event::set() method used by sync_wait().


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D46140/new/

https://reviews.llvm.org/D46140

Files:
  include/CMakeLists.txt
  include/experimental/__memory
  include/experimental/memory_resource
  include/experimental/task
  include/module.modulemap
  test/std/experimental/task/awaitable_traits.hpp
  test/std/experimental/task/counted.hpp
  test/std/experimental/task/lit.local.cfg
  test/std/experimental/task/manual_reset_event.hpp
  test/std/experimental/task/sync_wait.hpp
  test/std/experimental/task/task.basic/task_custom_allocator.pass.cpp
  test/std/experimental/task/task.basic/task_of_value.pass.cpp
  test/std/experimental/task/task.basic/task_of_void.pass.cpp
  test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp
  test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp

Index: test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp
===
--- /dev/null
+++ test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+#include 
+
+#include "../counted.hpp"
+#include "../sync_wait.hpp"
+
+DEFINE_COUNTED_VARIABLES();
+
+void test_return_value_lifetime()
+{
+  counted::reset();
+
+  auto f = [](bool x) -> std::experimental::task
+  {
+if (x) {
+  counted c;
+  co_return std::move(c);
+}
+co_return {};
+  };
+
+  {
+auto t = f(true);
+
+assert(counted::active_instance_count() == 0);
+assert(counted::copy_constructor_count() == 0);
+assert(counted::move_constructor_count() == 0);
+
+{
+  auto c = sync_wait(std::move(t));
+  assert(c.id() == 1);
+
+  assert(counted::active_instance_count() == 2);
+  assert(counted::copy_constructor_count() == 0);
+  assert(counted::move_constructor_count() > 0);
+  assert(counted::default_constructor_count() == 1);
+}
+
+// The result value in 't' is still alive until 't' destructs.
+assert(counted::active_instance_count() == 1);
+  }
+
+  assert(counted::active_instance_count() == 0);
+
+  counted::reset();
+
+  {
+auto t = f(false);
+
+assert(counted::active_instance_count() == 0);
+assert(counted::copy_constructor_count() == 0);
+assert(counted::move_constructor_count() == 0);
+
+{
+  auto c = sync_wait(std::move(t));
+  assert(c.id() == 1);
+
+  assert(counted::active_instance_count() == 2);
+  assert(counted::copy_constructor_count() == 0);
+  assert(counted::move_constructor_count() > 0);
+  assert(counted::default_constructor_count() == 1);
+}
+
+// The result value in 't' is still alive until 't' destructs.
+assert(counted::active_instance_count() == 1);
+  }
+}
+
+int main()
+{
+  test_return_value_lifetime();
+  return 0;
+}
Index: test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp
===
--- /dev/null
+++ test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "../counted.hpp"
+#include "../sync_wait.hpp"
+
+DEFINE_COUNTED_VARIABLES();
+
+void test_parameter_lifetime()
+{
+  counted::reset();
+
+  auto f = [](counted c) -> std::experimental::task
+  {
+co_return c.id();
+  };
+
+  {
+auto t = f({});
+
+assert(counted::active_instance_count() == 1);
+assert(counted::copy_constructor_count() == 0);
+assert(counted::move_constructor_count() <= 2); // Ideally <= 1
+
+auto id = sync_wait(t);
+assert(id == 1);
+
+assert(counted::active_instance_count() == 1);
+assert(counted::copy_constructor_count() == 0);
+
+// We are relying on C++17 copy-elision when passing the temporary counter
+// into f(). Then f() must move the parameter into the coroutine frame by
+// calling the move-constructor. This move could also potentially be
+// elided

[PATCH] D59195: [analyzer] Remove the default value arg from getChecker*Option

2019-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:148-150
+  assert(Ret &&
+ "This option should be either 'true' or 'false', and should've been "
+ "validated by CheckerRegisrty!");

Even though `operator*()` would have asserted that there's a value, i really 
appreciate the user-friendly assert message.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59195/new/

https://reviews.llvm.org/D59195



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


[PATCH] D46140: [coroutines] std::task type (WIP)

2019-03-25 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker updated this revision to Diff 192203.
lewissbaker edited the summary of this revision.
lewissbaker added a comment.
Herald added subscribers: libcxx-commits, jdoerfert.

- Don't use __allocator as variable name (it is #defined to NASTY_MACRO).
- Remove workaround in test for https://bugs.llvm.org/show_bug.cgi?id=37265
- Add support for custom allocators on member functions.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D46140/new/

https://reviews.llvm.org/D46140

Files:
  include/CMakeLists.txt
  include/experimental/__memory
  include/experimental/memory_resource
  include/experimental/task
  include/module.modulemap
  test/std/experimental/task/awaitable_traits.hpp
  test/std/experimental/task/counted.hpp
  test/std/experimental/task/lit.local.cfg
  test/std/experimental/task/manual_reset_event.hpp
  test/std/experimental/task/sync_wait.hpp
  test/std/experimental/task/task.basic/task_custom_allocator.pass.cpp
  test/std/experimental/task/task.basic/task_of_value.pass.cpp
  test/std/experimental/task/task.basic/task_of_void.pass.cpp
  test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp
  test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp

Index: test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp
===
--- /dev/null
+++ test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+#include 
+
+#include "../counted.hpp"
+#include "../sync_wait.hpp"
+
+DEFINE_COUNTED_VARIABLES();
+
+void test_return_value_lifetime()
+{
+  counted::reset();
+
+  auto f = [](bool x) -> std::experimental::task
+  {
+if (x) {
+  counted c;
+  co_return std::move(c);
+}
+co_return {};
+  };
+
+  {
+auto t = f(true);
+
+assert(counted::active_instance_count() == 0);
+assert(counted::copy_constructor_count() == 0);
+assert(counted::move_constructor_count() == 0);
+
+{
+  auto c = sync_wait(std::move(t));
+  assert(c.id() == 1);
+
+  assert(counted::active_instance_count() == 2);
+  assert(counted::copy_constructor_count() == 0);
+  assert(counted::move_constructor_count() > 0);
+  assert(counted::default_constructor_count() == 1);
+}
+
+// The result value in 't' is still alive until 't' destructs.
+assert(counted::active_instance_count() == 1);
+  }
+
+  assert(counted::active_instance_count() == 0);
+
+  counted::reset();
+
+  {
+auto t = f(false);
+
+assert(counted::active_instance_count() == 0);
+assert(counted::copy_constructor_count() == 0);
+assert(counted::move_constructor_count() == 0);
+
+{
+  auto c = sync_wait(std::move(t));
+  assert(c.id() == 1);
+
+  assert(counted::active_instance_count() == 2);
+  assert(counted::copy_constructor_count() == 0);
+  assert(counted::move_constructor_count() > 0);
+  assert(counted::default_constructor_count() == 1);
+}
+
+// The result value in 't' is still alive until 't' destructs.
+assert(counted::active_instance_count() == 1);
+  }
+}
+
+int main()
+{
+  test_return_value_lifetime();
+  return 0;
+}
Index: test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp
===
--- /dev/null
+++ test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "../counted.hpp"
+#include "../sync_wait.hpp"
+
+DEFINE_COUNTED_VARIABLES();
+
+void test_parameter_lifetime()
+{
+  counted::reset();
+
+  auto f = [](counted c) -> std::experimental::task
+  {
+co_return c.id();
+  };
+
+  {
+auto t = f({});
+
+assert(counted::active_instance_count() == 1);
+assert(counted::copy_constructor_count() == 0);
+assert(counted::move_constructor_count() <= 2); // Ideally <= 1
+
+auto id = sync_wait(t);
+assert(id == 1);
+
+assert(counted::active_instance_count() == 1);
+assert(counted::copy_constructor_count() == 0);
+
+// We 

[PATCH] D53076: [analyzer] ConditionBRVisitor: enhance to write out more information

2019-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Btw, did you try running this patch against big projects? 'Cause it's a 
high-impact change and we'd have to be careful with it.

I ran it on LLVM real quick and noticed that 97.3% (!) of reports contained at 
least one of the new notes, with number of HTML path pieces increased by 23.7% 
on average (note that the impact on plist reports would be much higher because 
they don't have any text for gray pieces).

I'll try to get back with some actual hand-picked examples to demonstrate my 
impressions. My overall feel was that it increases quality of life quite a bit 
by reducing the amount of time spent scrolling and jumping around the report - 
the necessary information becomes available exactly where you need it and it's 
wonderful. At the same time, i noticed a few corner-cases where the new pieces 
were duplicating the existing information or otherwise not helpful:

F8520276: operator_question_mark.png  
F8520282: operator_question_mark.html 

F8520283: more_repeats.png  F8520285: 
more_repeats.html 

This doesn't look like a fundamental problem to me; it should be possible to 
improve upon these corner-cases by varying note messages; probably it also 
makes sense to skip some of them when they're clearly saying the same info 10 
times in a row, but i'm not sure it's easy to decide where to apply that.

Because it might be a large amount of work, i'm thinking about committing this 
new feature off-by-default first (eg., `-analyzer-config 
knowing-notes=[false|true]`) and then doing follow-up commits (you already have 
quite a bit!) to make sure it's polished when we turn it on for everyone, WDYT?




Comment at: 
include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:169-173
+  // If the constraint information is changed between the current and the
+  // previous program state we assuming the newly seen constraint information.
+  // If we cannot evaluate the condition (and the constraints are the same)
+  // the analyzer has no information about the value and just assuming it.
+  bool IsAssuming;

Does this absolutely need to be a member variable? Maybe pass it down the 
stack, like `tookTrue`? I understand that there are already a lot of flags 
passed down, but global mutable state is still more dangerous and can easily 
get out of hand.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:187-190
+  // The value may hard-coded.
+  SVal HardCodedSVal = State->getSVal(CondVarExpr, LCtx);
+  if (auto HardCodedCI = HardCodedSVal.getAs())
+return &HardCodedCI->getValue();

I don't see this triggered on tests. It looks to me that this function is for 
now only applied to `DeclRefExpr`s that are always glvalues and therefore 
should never be evaluated to a `nonloc` value.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1991-1992
   return std::make_shared(
-  Loc, tookTrue ? GenericTrueMessage : GenericFalseMessage);
+  Loc, IsAssuming ? tookTrue ? AssumingTrueMessage : AssumingFalseMessage
+  : tookTrue ? TrueMessage : FalseMessage);
 }

I advocate for more parentheses :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53076/new/

https://reviews.llvm.org/D53076



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


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-03-25 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:2017
 
+  auto LastIdx = Field != FieldEnd
+ ? Field->getFieldIndex()

Can `Field` ever be `FieldEnd` at this point?



Comment at: clang/lib/Sema/SemaInit.cpp:2044
+ : std::distance(RD->field_begin(), RD->field_end());
+  if (VerifyOnly && (LastIdx >= NextIdx || HasNonDesignatedInit) &&
+  SemaRef.getLangOpts().CPlusPlus2a)

`!VerifyOnly` and braces please.



Comment at: clang/lib/Sema/SemaInit.cpp:2065
+// Warn on mixed designators in C++20
+if (VerifyOnly && HasDesignatedInit && SemaRef.getLangOpts().CPlusPlus2a)
+  SemaRef.Diag(Init->getBeginLoc(), diag::ext_designated_init)

Same here. It should be `!VerifyOnly`. Also braces for the if statement.



Comment at: clang/lib/Sema/SemaInit.cpp:3087
   if (!getLangOpts().C99)
-Diag(DIE->getBeginLoc(), diag::ext_designated_init)
-<< DIE->getSourceRange();
+// Warn on nested and array designators in C++20
+if (!getLangOpts().CPlusPlus2a || Desig.getNumDesignators() > 1 ||

Missing dot.



Comment at: clang/lib/Sema/SemaInit.cpp:3089
+if (!getLangOpts().CPlusPlus2a || Desig.getNumDesignators() > 1 ||
+HasArrayDesignator)
+  Diag(DIE->getBeginLoc(), diag::ext_designated_init)

Braces.



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:30
+// out of order designators
+A a1 = {.y = 1, .x = 2}; // expected-warning {{designated initializers are a 
C99 feature}}
+

Those warnings are misleading, since C++20 does have designated initializers; 
they just don't support some stuff that C99 does. It would be better  IMO if 
you could separate them. As in, the above should give you: `out-of-order 
designated initializers are a C99 feature` or something like that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D59743: [WebAssembly] Don't use default GetLinkerPath

2019-03-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356953: [WebAssembly] Don't use default GetLinkerPath 
(authored by sbc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59743?vs=192126&id=192201#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59743/new/

https://reviews.llvm.org/D59743

Files:
  lib/Driver/ToolChains/WebAssembly.cpp
  lib/Driver/ToolChains/WebAssembly.h
  test/Driver/wasm-toolchain.c
  test/Driver/wasm-toolchain.cpp

Index: lib/Driver/ToolChains/WebAssembly.h
===
--- lib/Driver/ToolChains/WebAssembly.h
+++ lib/Driver/ToolChains/WebAssembly.h
@@ -23,6 +23,7 @@
   explicit Linker(const ToolChain &TC);
   bool isLinkJob() const override;
   bool hasIntegratedCPP() const override;
+  std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -12,6 +12,8 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Option/ArgList.h"
 
 using namespace clang::driver;
@@ -36,6 +38,25 @@
 
 bool wasm::Linker::hasIntegratedCPP() const { return false; }
 
+std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
+  const ToolChain &ToolChain = getToolChain();
+  if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
+StringRef UseLinker = A->getValue();
+if (!UseLinker.empty()) {
+  if (llvm::sys::path::is_absolute(UseLinker) &&
+  llvm::sys::fs::can_execute(UseLinker))
+return UseLinker;
+
+  // Accept 'lld', and 'ld' as aliases for the default linker
+  if (UseLinker != "lld" && UseLinker != "ld")
+ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
+<< A->getAsString(Args);
+}
+  }
+
+  return ToolChain.getDefaultLinker();
+}
+
 void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output,
 const InputInfoList &Inputs,
@@ -43,7 +64,7 @@
 const char *LinkingOutput) const {
 
   const ToolChain &ToolChain = getToolChain();
-  const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
+  const char *Linker = Args.MakeArgString(getLinkerPath(Args));
   ArgStringList CmdArgs;
 
   if (Args.hasArg(options::OPT_s))
Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -12,25 +12,25 @@
 
 // A basic C++ link command-line with unknown OS.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization with unknown OS.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=wasm-ld 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with known OS.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo -fuse-ld=wasm-ld --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi-musl" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization with known OS.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-wa

r356953 - [WebAssembly] Don't use default GetLinkerPath

2019-03-25 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Mon Mar 25 14:14:26 2019
New Revision: 356953

URL: http://llvm.org/viewvc/llvm-project?rev=356953&view=rev
Log:
[WebAssembly] Don't use default GetLinkerPath

We can't (don't want to) honor the same set of "-fuse-ld" flags with
WebAssembly since the ELF linkers (ld.lld, ld.gnu, etc) don't work with
wasm object files.

Instead we implement our own linker finding logic, similar or other
non-ELF platforms like MSVC.

We've had a few issues with CLANG_DEFAULT_LINKER overriding the
WebAssembly linker which doesn't make sense since there is no generic
linker that can handle WebAssembly today.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=356953&r1=356952&r2=356953&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Mon Mar 25 14:14:26 2019
@@ -12,6 +12,8 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Option/ArgList.h"
 
 using namespace clang::driver;
@@ -36,6 +38,25 @@ bool wasm::Linker::isLinkJob() const { r
 
 bool wasm::Linker::hasIntegratedCPP() const { return false; }
 
+std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
+  const ToolChain &ToolChain = getToolChain();
+  if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
+StringRef UseLinker = A->getValue();
+if (!UseLinker.empty()) {
+  if (llvm::sys::path::is_absolute(UseLinker) &&
+  llvm::sys::fs::can_execute(UseLinker))
+return UseLinker;
+
+  // Accept 'lld', and 'ld' as aliases for the default linker
+  if (UseLinker != "lld" && UseLinker != "ld")
+ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
+<< A->getAsString(Args);
+}
+  }
+
+  return ToolChain.getDefaultLinker();
+}
+
 void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output,
 const InputInfoList &Inputs,
@@ -43,7 +64,7 @@ void wasm::Linker::ConstructJob(Compilat
 const char *LinkingOutput) const {
 
   const ToolChain &ToolChain = getToolChain();
-  const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
+  const char *Linker = Args.MakeArgString(getLinkerPath(Args));
   ArgStringList CmdArgs;
 
   if (Args.hasArg(options::OPT_s))

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=356953&r1=356952&r2=356953&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Mon Mar 25 14:14:26 2019
@@ -23,6 +23,7 @@ public:
   explicit Linker(const ToolChain &TC);
   bool isLinkJob() const override;
   bool hasIntegratedCPP() const override;
+  std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=356953&r1=356952&r2=356953&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Mar 25 14:14:26 2019
@@ -12,25 +12,25 @@
 
 // A basic C link command-line with unknown OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with unknown OS.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %

[PATCH] D59008: [AMDGPU] Switch default dwarf version to 5

2019-03-25 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59008/new/

https://reviews.llvm.org/D59008



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


[PATCH] D59008: [AMDGPU] Switch default dwarf version to 5

2019-03-25 Thread Tony Tye via Phabricator via cfe-commits
t-tye added a comment.

In D59008#1442014 , @dblaikie wrote:

> In D59008#1441903 , @t-tye wrote:
>
> > LGTM
> >
> > Do we know the state of split DWARF and DWARF compression for DWARF 5 
> > (compared to DWARF 2)?
>
>
> State of them in what sense? Compression is pretty orthogonal to any DWARF 
> version - it's more about the container (ELF, etc) you use. Split DWARF is 
> non-standardly supported in pre-v5, and I think it's functioning in the 
> standards conformant v5 mode too.


I had heard mention that at least split DWARF may not be fully supported yet 
for DWARF 5 in LLVM. But maybe that is old news:-)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59008/new/

https://reviews.llvm.org/D59008



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


[PATCH] D59494: AMDGPU: Add support for cross address space synchronization scopes (clang)

2019-03-25 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356947: AMDGPU: Add support for cross address space 
synchronization scopes (clang) (authored by kzhuravl, committed by ).
Herald added a subscriber: ebevhan.
Herald added a project: clang.

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59494/new/

https://reviews.llvm.org/D59494

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/atomic-ops.cl

Index: lib/CodeGen/CGAtomic.cpp
===
--- lib/CodeGen/CGAtomic.cpp
+++ lib/CodeGen/CGAtomic.cpp
@@ -679,7 +679,8 @@
   // Handle constant scope.
   if (auto SC = dyn_cast(Scope)) {
 auto SCID = CGF.getTargetHooks().getLLVMSyncScopeID(
-ScopeModel->map(SC->getZExtValue()), CGF.CGM.getLLVMContext());
+CGF.CGM.getLangOpts(), ScopeModel->map(SC->getZExtValue()),
+Order, CGF.CGM.getLLVMContext());
 EmitAtomicOp(CGF, Expr, Dest, Ptr, Val1, Val2, IsWeak, FailureOrder, Size,
  Order, SCID);
 return;
@@ -708,7 +709,9 @@
 Builder.SetInsertPoint(B);
 EmitAtomicOp(CGF, Expr, Dest, Ptr, Val1, Val2, IsWeak, FailureOrder, Size,
  Order,
- CGF.getTargetHooks().getLLVMSyncScopeID(ScopeModel->map(S),
+ CGF.getTargetHooks().getLLVMSyncScopeID(CGF.CGM.getLangOpts(),
+ ScopeModel->map(S),
+ Order,
  CGF.getLLVMContext()));
 Builder.CreateBr(ContBB);
   }
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -268,8 +268,10 @@
llvm::Type *DestTy) const;
 
   /// Get the syncscope used in LLVM IR.
-  virtual llvm::SyncScope::ID getLLVMSyncScopeID(SyncScope S,
- llvm::LLVMContext &C) const;
+  virtual llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
+ SyncScope Scope,
+ llvm::AtomicOrdering Ordering,
+ llvm::LLVMContext &Ctx) const;
 
   /// Interface class for filling custom fields of a block literal for OpenCL.
   class TargetOpenCLBlockHelper {
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -462,8 +462,11 @@
 }
 
 llvm::SyncScope::ID
-TargetCodeGenInfo::getLLVMSyncScopeID(SyncScope S, llvm::LLVMContext &C) const {
-  return C.getOrInsertSyncScopeID(""); /* default sync scope */
+TargetCodeGenInfo::getLLVMSyncScopeID(const LangOptions &LangOpts,
+  SyncScope Scope,
+  llvm::AtomicOrdering Ordering,
+  llvm::LLVMContext &Ctx) const {
+  return Ctx.getOrInsertSyncScopeID(""); /* default sync scope */
 }
 
 static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays);
@@ -7824,8 +7827,10 @@
   }
   LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
   const VarDecl *D) const override;
-  llvm::SyncScope::ID getLLVMSyncScopeID(SyncScope S,
- llvm::LLVMContext &C) const override;
+  llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
+ SyncScope Scope,
+ llvm::AtomicOrdering Ordering,
+ llvm::LLVMContext &Ctx) const override;
   llvm::Function *
   createEnqueuedBlockKernel(CodeGenFunction &CGF,
 llvm::Function *BlockInvokeFunc,
@@ -7971,10 +7976,12 @@
 }
 
 llvm::SyncScope::ID
-AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(SyncScope S,
-llvm::LLVMContext &C) const {
-  StringRef Name;
-  switch (S) {
+AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(const LangOptions &LangOpts,
+SyncScope Scope,
+llvm::AtomicOrdering Ordering,
+llvm::LLVMContext &Ctx) const {
+  std::string Name;
+  switch (Scope) {
   case SyncScope::OpenCLWorkGroup:
 Name = "workgroup";
 break;
@@ -7987,7 +7994,15 @@
   case SyncScope::OpenCLSubGroup:
 Name = "wavefront";
   }
-  return C.getOrInsertSyncScopeID(Name);
+
+  if (Ordering != llvm::AtomicOrdering::SequentiallyConsistent) {
+if (!Name.empty())
+  Name = Twine(Twine(Name) + Twine("-")).str();
+
+Name = Twine(Twine(Name) + Twi

r356947 - AMDGPU: Add support for cross address space synchronization scopes (clang)

2019-03-25 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Mon Mar 25 13:54:00 2019
New Revision: 356947

URL: http://llvm.org/viewvc/llvm-project?rev=356947&view=rev
Log:
AMDGPU: Add support for cross address space synchronization scopes (clang)

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

Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=356947&r1=356946&r2=356947&view=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Mar 25 13:54:00 2019
@@ -679,7 +679,8 @@ static void EmitAtomicOp(CodeGenFunction
   // Handle constant scope.
   if (auto SC = dyn_cast(Scope)) {
 auto SCID = CGF.getTargetHooks().getLLVMSyncScopeID(
-ScopeModel->map(SC->getZExtValue()), CGF.CGM.getLLVMContext());
+CGF.CGM.getLangOpts(), ScopeModel->map(SC->getZExtValue()),
+Order, CGF.CGM.getLLVMContext());
 EmitAtomicOp(CGF, Expr, Dest, Ptr, Val1, Val2, IsWeak, FailureOrder, Size,
  Order, SCID);
 return;
@@ -708,7 +709,9 @@ static void EmitAtomicOp(CodeGenFunction
 Builder.SetInsertPoint(B);
 EmitAtomicOp(CGF, Expr, Dest, Ptr, Val1, Val2, IsWeak, FailureOrder, Size,
  Order,
- CGF.getTargetHooks().getLLVMSyncScopeID(ScopeModel->map(S),
+ CGF.getTargetHooks().getLLVMSyncScopeID(CGF.CGM.getLangOpts(),
+ ScopeModel->map(S),
+ Order,
  
CGF.getLLVMContext()));
 Builder.CreateBr(ContBB);
   }

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=356947&r1=356946&r2=356947&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Mar 25 13:54:00 2019
@@ -462,8 +462,11 @@ TargetCodeGenInfo::performAddrSpaceCast(
 }
 
 llvm::SyncScope::ID
-TargetCodeGenInfo::getLLVMSyncScopeID(SyncScope S, llvm::LLVMContext &C) const 
{
-  return C.getOrInsertSyncScopeID(""); /* default sync scope */
+TargetCodeGenInfo::getLLVMSyncScopeID(const LangOptions &LangOpts,
+  SyncScope Scope,
+  llvm::AtomicOrdering Ordering,
+  llvm::LLVMContext &Ctx) const {
+  return Ctx.getOrInsertSyncScopeID(""); /* default sync scope */
 }
 
 static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays);
@@ -7824,8 +7827,10 @@ public:
   }
   LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
   const VarDecl *D) const override;
-  llvm::SyncScope::ID getLLVMSyncScopeID(SyncScope S,
- llvm::LLVMContext &C) const override;
+  llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
+ SyncScope Scope,
+ llvm::AtomicOrdering Ordering,
+ llvm::LLVMContext &Ctx) const 
override;
   llvm::Function *
   createEnqueuedBlockKernel(CodeGenFunction &CGF,
 llvm::Function *BlockInvokeFunc,
@@ -7971,10 +7976,12 @@ AMDGPUTargetCodeGenInfo::getGlobalVarAdd
 }
 
 llvm::SyncScope::ID
-AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(SyncScope S,
-llvm::LLVMContext &C) const {
-  StringRef Name;
-  switch (S) {
+AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(const LangOptions &LangOpts,
+SyncScope Scope,
+llvm::AtomicOrdering Ordering,
+llvm::LLVMContext &Ctx) const {
+  std::string Name;
+  switch (Scope) {
   case SyncScope::OpenCLWorkGroup:
 Name = "workgroup";
 break;
@@ -7987,7 +7994,15 @@ AMDGPUTargetCodeGenInfo::getLLVMSyncScop
   case SyncScope::OpenCLSubGroup:
 Name = "wavefront";
   }
-  return C.getOrInsertSyncScopeID(Name);
+
+  if (Ordering != llvm::AtomicOrdering::SequentiallyConsistent) {
+if (!Name.empty())
+  Name = Twine(Twine(Name) + Twine("-")).str();
+
+Name = Twine(Twine(Name) + Twine("one-as")).str();
+  }
+
+  return Ctx.getOrInsertSyncScopeID(Name);
 }
 
 bool AMDGPUTargetCodeGenInfo::shouldEmitStaticExternCAliases() const {

Modified: cfe/trunk/lib/CodeGen/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.h?rev=356947&r1=356946&r2=356947&view=diff
=

[PATCH] D59798: Add analyzer option to limit the number of imported TUs

2019-03-25 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 created this revision.
Herald added subscribers: cfe-commits, jdoerfert, dkrupp, donat.nagy, 
Szelethus, a.sidorin, baloghadamsoftware, whisperity.
Herald added a reviewer: martong.
Herald added a project: clang.

During CTU analysis of complex projects, the loaded AST-contents of
imported TUs can grow bigger than available system memory. This option
introduces a threshold on the number of TUs to be imported for a single
TU in order to prevent such cases.


Repository:
  rC Clang

https://reviews.llvm.org/D59798

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/ctu-import-threshold.c
  unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -23,8 +23,9 @@
 
 class CTUASTConsumer : public clang::ASTConsumer {
 public:
-  explicit CTUASTConsumer(clang::CompilerInstance &CI, bool *Success)
-  : CTU(CI), Success(Success) {}
+  explicit CTUASTConsumer(clang::CompilerInstance &CI, bool *Success,
+  unsigned ImportLimit)
+  : CTU(CI), Success(Success), ImportLimit(ImportLimit) {}
 
   void HandleTranslationUnit(ASTContext &Ctx) {
 const TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
@@ -70,41 +71,54 @@
 EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
 
 // Load the definition from the AST file.
-llvm::Expected NewFDorError =
-CTU.getCrossTUDefinition(FD, "", IndexFileName);
-EXPECT_TRUE((bool)NewFDorError);
-const FunctionDecl *NewFD = *NewFDorError;
+llvm::Expected NewFDorError = handleExpected(
+CTU.getCrossTUDefinition(FD, "", IndexFileName, false, ImportLimit),
+[]() { return nullptr; }, [](IndexError &) {});
 
-*Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
+if (NewFDorError) {
+  const FunctionDecl *NewFD = *NewFDorError;
+  *Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
+}
   }
 
 private:
   CrossTranslationUnitContext CTU;
   bool *Success;
+  unsigned ImportLimit;
 };
 
 class CTUAction : public clang::ASTFrontendAction {
 public:
-  CTUAction(bool *Success) : Success(Success) {}
+  CTUAction(bool *Success, unsigned ImportLimit)
+  : Success(Success), ImportLimit(ImportLimit) {}
 
 protected:
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
-return llvm::make_unique(CI, Success);
+return llvm::make_unique(CI, Success, ImportLimit);
   }
 
 private:
   bool *Success;
+  unsigned ImportLimit;
 };
 
 } // end namespace
 
 TEST(CrossTranslationUnit, CanLoadFunctionDefinition) {
   bool Success = false;
-  EXPECT_TRUE(tooling::runToolOnCode(new CTUAction(&Success), "int f(int);"));
+  EXPECT_TRUE(
+  tooling::runToolOnCode(new CTUAction(&Success, 1u), "int f(int);"));
   EXPECT_TRUE(Success);
 }
 
+TEST(CrossTranslationUnit, RespectsLoadThreshold) {
+  bool Success = false;
+  EXPECT_TRUE(
+  tooling::runToolOnCode(new CTUAction(&Success, 0u), "int f(int);"));
+  EXPECT_FALSE(Success);
+}
+
 TEST(CrossTranslationUnit, IndexFormatCanBeParsed) {
   llvm::StringMap Index;
   Index["a"] = "/b/f1";
Index: test/Analysis/ctu-import-threshold.c
===
--- /dev/null
+++ test/Analysis/ctu-import-threshold.c
@@ -0,0 +1,6 @@
+// Ensure analyzer-ctu-import-threshold option is a recognized option.
+//
+// RUN: %clang_cc1 -analyze -analyzer-ctu-import-threshold 500 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-ctu-import-threshold=500 -verify %s
+//
+// expected-no-diagnostics
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -571,8 +571,9 @@
   cross_tu::CrossTranslationUnitContext &CTUCtx =
   *Engine.getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir, Opts.CTUIndexName,
-  Opts.DisplayCTUProgress);
+  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName(),
+  Opts.AnalyzerDisplayCtuProgress,
+  Opts.CTUImportThreshold);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -301,6 +301,10 @@
   Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
  

[PATCH] D57978: [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-03-25 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D57978#1440894 , @dmgreen wrote:

> This could maybe do with a few extra tests. Am I correct in saying something 
> like this:
>
>   #pragma unroll_and_jam(4)
>   for(int j = 0; j < n; j++) {
> #pragma unroll(4)
> for(int k = 0; k < n; k++) {
>   x[j*n+k] = 10;
> }
>   }
>
>
> would end up with a llvm.loop.unroll_and_jam.followup_inner with a 
> llvm.loop.unroll_count?


correct. I added a new test `pragma-followup_inner.cpp` where this can be seen.




Comment at: lib/CodeGen/CGLoopInfo.cpp:500
+// Unroll-and-jam of an inner loop and unroll-and-jam of the same loop as
+// the outer loop does not make much sense, but we have to pick an order.
+AfterJam.UnrollAndJamCount = Attrs.UnrollAndJamCount;

dmgreen wrote:
> I was having trouble parsing this sentance. Does it mean both the inner loop 
> and the outer loop both have unroll-and-jam? UnrollAndJam processes loops 
> from inner to outer, so if this is working as I think, maybe it should be put 
> into BeforeJam.
> Does it mean both the inner loop and the outer loop both have unroll-and-jam? 

Correct. I was thinking of such a case:
```
#pragma unroll_and_jam(2)
for (int i = 0; i < m; i+=1)
  #pragma unroll_and_jam(3)
  for (int j = 0; j < n; j+=1)
```

Assuming the inner unroll-and-jam would do something, would it happen before or 
after the outer transformation. As you mentioned, there is an argument to put 
it into `BeforeJam`. Changed.



Comment at: lib/CodeGen/CGLoopInfo.cpp:502
+AfterJam.UnrollAndJamCount = Attrs.UnrollAndJamCount;
+AfterJam.UnrollAndJamEnable = AfterJam.UnrollAndJamEnable;
+

dmgreen wrote:
>  = Attrs.UnrollAndJamEnable ?
thanks


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57978/new/

https://reviews.llvm.org/D57978



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


[PATCH] D57978: [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-03-25 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 192194.
Meinersbur marked 5 inline comments as done.
Meinersbur added a comment.

- Rebase
- Add two test cases for all attributes combined (as inner and outer loop for 
of an unroll-and-jam)
- Of two nested unroll-and-jams, apply the inner first
- Typos and comment clarification
- Add missing llvm.loop.isvectorized when attributes are split between 
BeforeJam and AfterJam


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57978/new/

https://reviews.llvm.org/D57978

Files:
  lib/CodeGen/CGLoopInfo.cpp
  lib/CodeGen/CGLoopInfo.h
  test/CodeGenCXX/pragma-followup_inner.cpp
  test/CodeGenCXX/pragma-followup_outer.cpp
  test/CodeGenCXX/pragma-loop-safety-imperfectly_nested.cpp
  test/CodeGenCXX/pragma-loop-safety-nested.cpp
  test/CodeGenCXX/pragma-loop-safety-outer.cpp
  test/CodeGenCXX/pragma-loop-safety.cpp
  test/CodeGenCXX/pragma-loop.cpp
  test/CodeGenCXX/pragma-unroll-and-jam.cpp
  test/OpenMP/simd_metadata.c

Index: test/OpenMP/simd_metadata.c
===
--- test/OpenMP/simd_metadata.c
+++ test/OpenMP/simd_metadata.c
@@ -147,16 +147,16 @@
 // CHECK: [[LOOP_H1_HEADER:![0-9]+]] = distinct !{[[LOOP_H1_HEADER]], [[LOOP_WIDTH_8:![0-9]+]], [[LOOP_VEC_ENABLE]]}
 // CHECK: [[LOOP_WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}
 // CHECK: ![[ACCESS_GROUP_7]] = distinct !{}
-// CHECK: [[LOOP_H1_HEADER:![0-9]+]] = distinct !{[[LOOP_H1_HEADER]], [[LOOP_WIDTH_8]], [[LOOP_VEC_ENABLE]], ![[PARALLEL_ACCESSES_9:[0-9]+]]}
+// CHECK: [[LOOP_H1_HEADER:![0-9]+]] = distinct !{[[LOOP_H1_HEADER]], ![[PARALLEL_ACCESSES_9:[0-9]+]], [[LOOP_WIDTH_8]], [[LOOP_VEC_ENABLE]]}
 // CHECK: ![[PARALLEL_ACCESSES_9]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_7]]}
 //
 // Metadata for h2:
 // CHECK: ![[ACCESS_GROUP_10]] = distinct !{}
-// CHECK: [[LOOP_H2_HEADER]] = distinct !{[[LOOP_H2_HEADER]], [[LOOP_VEC_ENABLE]], ![[PARALLEL_ACCESSES_12:[0-9]+]]}
+// CHECK: [[LOOP_H2_HEADER]] = distinct !{[[LOOP_H2_HEADER]], ![[PARALLEL_ACCESSES_12:[0-9]+]], [[LOOP_VEC_ENABLE]]}
 // CHECK: ![[PARALLEL_ACCESSES_12]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_10]]}
 //
 // Metadata for h3:
 // CHECK: ![[ACCESS_GROUP_13]] = distinct !{}
-// CHECK: [[LOOP_H3_HEADER]] = distinct !{[[LOOP_H3_HEADER]], [[LOOP_VEC_ENABLE]], ![[PARALLEL_ACCESSES_15:[0-9]+]]}
+// CHECK: [[LOOP_H3_HEADER]] = distinct !{[[LOOP_H3_HEADER]], ![[PARALLEL_ACCESSES_15:[0-9]+]], [[LOOP_VEC_ENABLE]]}
 // CHECK: ![[PARALLEL_ACCESSES_15]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_13]]}
 //
Index: test/CodeGenCXX/pragma-unroll-and-jam.cpp
===
--- test/CodeGenCXX/pragma-unroll-and-jam.cpp
+++ test/CodeGenCXX/pragma-unroll-and-jam.cpp
@@ -51,5 +51,5 @@
 // CHECK: ![[UNJ_4]] = !{!"llvm.loop.unroll_and_jam.count", i32 4}
 // CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[UNJ_DISABLE:.*]]}
 // CHECK: ![[UNJ_DISABLE]] = !{!"llvm.loop.unroll_and_jam.disable"}
-// CHECK: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[UNROLL_4:.*]], ![[UNJ_DISABLE:.*]]}
+// CHECK: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[UNJ_DISABLE:.*]], ![[UNROLL_4:.*]]}
 // CHECK: ![[UNROLL_4]] = !{!"llvm.loop.unroll.count", i32 4}
Index: test/CodeGenCXX/pragma-loop.cpp
===
--- test/CodeGenCXX/pragma-loop.cpp
+++ test/CodeGenCXX/pragma-loop.cpp
@@ -158,37 +158,60 @@
   for_template_constant_expression_test(List, Length);
 }
 
-// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[WIDTH_4:.*]], ![[INTERLEAVE_4:.*]], ![[INTENABLE_1:.*]], ![[UNROLL_FULL:.*]], ![[DISTRIBUTE_ENABLE:.*]]}
-// CHECK: ![[WIDTH_4]] = !{!"llvm.loop.vectorize.width", i32 4}
-// CHECK: ![[INTERLEAVE_4]] = !{!"llvm.loop.interleave.count", i32 4}
-// CHECK: ![[INTENABLE_1]] = !{!"llvm.loop.vectorize.enable", i1 true}
+// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_FULL:.*]]}
 // CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"}
-// CHECK: ![[DISTRIBUTE_ENABLE]] = !{!"llvm.loop.distribute.enable", i1 true}
-// CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2:.*]], ![[WIDTH_8:.*]], ![[INTERLEAVE_4:.*]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]]}
-// CHECK: ![[WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}
+
+// CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_8:.*]], ![[INTERLEAVE_4:.*]]}
 // CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"}
 // CHECK: ![[DISTRIBUTE_DISABLE]] = !{!"llvm.loop.distribute.enable", i1 false}
-// CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[INTERLEAVE_4:.*]], ![[UNROLL_8:.*]], ![[INTENABLE_1:.*]]}
+// CHECK: ![[WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}
+// CHECK: ![[INTERLEAVE_4]] = !{!"llvm.loop.interleave.count", i32 4}
+
+// CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[INTERLEAVE_4:.*]], ![[INTENABLE_1:.*]], ![[FOLLOWUP_VECTOR_3:.*]]}
+// CHECK: ![[INTENAB

[PATCH] D59627: [clang-format] Keep protobuf "package" statement on one line

2019-03-25 Thread Donald Chai via Phabricator via cfe-commits
dchai added a comment.

Just to confirm, the regression is in the number of spaces before a trailing 
comment?

Before (2 spaces):

  package foo.bar;  // foo.bar package

After (1 space):

  package foo.bar; // foo.bar package

Top-level options are handled the same way.  I'll see if I can address these 
both.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59627/new/

https://reviews.llvm.org/D59627



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


[PATCH] D59523: Thread Safety: also look at ObjC methods

2019-03-25 Thread JF Bastien via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356940: Thread Safety: also look at ObjC methods (authored 
by jfb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59523/new/

https://reviews.llvm.org/D59523

Files:
  cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
  cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm
  cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h
  cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm

Index: cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
===
--- cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
+++ cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
@@ -276,18 +276,23 @@
 
   // Function parameters require substitution and/or renaming.
   if (const auto *PV = dyn_cast_or_null(VD)) {
-const auto *FD =
-cast(PV->getDeclContext())->getCanonicalDecl();
 unsigned I = PV->getFunctionScopeIndex();
-
-if (Ctx && Ctx->FunArgs && FD == Ctx->AttrDecl->getCanonicalDecl()) {
-  // Substitute call arguments for references to function parameters
-  assert(I < Ctx->NumArgs);
-  return translate(Ctx->FunArgs[I], Ctx->Prev);
+const DeclContext *D = PV->getDeclContext();
+if (Ctx && Ctx->FunArgs) {
+  const Decl *Canonical = Ctx->AttrDecl->getCanonicalDecl();
+  if (isa(D)
+  ? (cast(D)->getCanonicalDecl() == Canonical)
+  : (cast(D)->getCanonicalDecl() == Canonical)) {
+// Substitute call arguments for references to function parameters
+assert(I < Ctx->NumArgs);
+return translate(Ctx->FunArgs[I], Ctx->Prev);
+  }
 }
 // Map the param back to the param of the original function declaration
 // for consistent comparisons.
-VD = FD->getParamDecl(I);
+VD = isa(D)
+ ? cast(D)->getCanonicalDecl()->getParamDecl(I)
+ : cast(D)->getCanonicalDecl()->getParamDecl(I);
   }
 
   // For non-local variables, treat it as a reference to a named object.
Index: cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h
===
--- cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h
+++ cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h
@@ -0,0 +1,17 @@
+class __attribute__((lockable)) Lock {
+public:
+  void Acquire() __attribute__((exclusive_lock_function())) {}
+  void Release() __attribute__((unlock_function())) {}
+};
+
+class __attribute__((scoped_lockable)) AutoLock {
+public:
+  AutoLock(Lock &lock) __attribute__((exclusive_lock_function(lock)))
+  : lock_(lock) {
+lock.Acquire();
+  }
+  ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); }
+
+private:
+  Lock &lock_;
+};
Index: cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm
===
--- cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm
+++ cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wthread-safety -Wno-objc-root-class %s
+
+// Thread safety analysis used to crash when used with ObjC methods.
+
+#include "thread-safety-analysis.h"
+
+@interface MyInterface
+- (void)doIt:(class Lock *)myLock;
+@end
+
+@implementation MyInterface
+- (void)doIt:(class Lock *)myLock {
+  AutoLock lock(*myLock);
+}
+@end
Index: cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm
===
--- cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm
+++ cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm
@@ -1,22 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -Wno-objc-root-class %s
 
-class __attribute__((lockable)) Lock {
-public:
-  void Acquire() __attribute__((exclusive_lock_function())) {}
-  void Release() __attribute__((unlock_function())) {}
-};
-
-class __attribute__((scoped_lockable)) AutoLock {
-public:
-  AutoLock(Lock &lock) __attribute__((exclusive_lock_function(lock)))
-  : lock_(lock) {
-lock.Acquire();
-  }
-  ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); }
-
-private:
-  Lock &lock_;
-};
+#include "thread-safety-analysis.h"
 
 @interface MyInterface {
 @private
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356940 - Thread Safety: also look at ObjC methods

2019-03-25 Thread JF Bastien via cfe-commits
Author: jfb
Date: Mon Mar 25 13:06:32 2019
New Revision: 356940

URL: http://llvm.org/viewvc/llvm-project?rev=356940&view=rev
Log:
Thread Safety: also look at ObjC methods

Summary:
SExprBuilder::translateDeclRefExpr was only looking at FunctionDecl and not 
also looking at ObjCMethodDecl. It should consider both because the attributes 
can be used on Objective-C as well.



Reviewers: dexonsmith, erik.pilkington

Subscribers: jkorous, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm
cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h
Modified:
cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm

Modified: cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp?rev=356940&r1=356939&r2=356940&view=diff
==
--- cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp Mon Mar 25 13:06:32 2019
@@ -276,18 +276,23 @@ til::SExpr *SExprBuilder::translateDeclR
 
   // Function parameters require substitution and/or renaming.
   if (const auto *PV = dyn_cast_or_null(VD)) {
-const auto *FD =
-cast(PV->getDeclContext())->getCanonicalDecl();
 unsigned I = PV->getFunctionScopeIndex();
-
-if (Ctx && Ctx->FunArgs && FD == Ctx->AttrDecl->getCanonicalDecl()) {
-  // Substitute call arguments for references to function parameters
-  assert(I < Ctx->NumArgs);
-  return translate(Ctx->FunArgs[I], Ctx->Prev);
+const DeclContext *D = PV->getDeclContext();
+if (Ctx && Ctx->FunArgs) {
+  const Decl *Canonical = Ctx->AttrDecl->getCanonicalDecl();
+  if (isa(D)
+  ? (cast(D)->getCanonicalDecl() == Canonical)
+  : (cast(D)->getCanonicalDecl() == Canonical)) {
+// Substitute call arguments for references to function parameters
+assert(I < Ctx->NumArgs);
+return translate(Ctx->FunArgs[I], Ctx->Prev);
+  }
 }
 // Map the param back to the param of the original function declaration
 // for consistent comparisons.
-VD = FD->getParamDecl(I);
+VD = isa(D)
+ ? cast(D)->getCanonicalDecl()->getParamDecl(I)
+ : cast(D)->getCanonicalDecl()->getParamDecl(I);
   }
 
   // For non-local variables, treat it as a reference to a named object.

Added: cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm?rev=356940&view=auto
==
--- cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm (added)
+++ cfe/trunk/test/SemaObjCXX/no-crash-thread-safety-analysis.mm Mon Mar 25 
13:06:32 2019
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wthread-safety -Wno-objc-root-class %s
+
+// Thread safety analysis used to crash when used with ObjC methods.
+
+#include "thread-safety-analysis.h"
+
+@interface MyInterface
+- (void)doIt:(class Lock *)myLock;
+@end
+
+@implementation MyInterface
+- (void)doIt:(class Lock *)myLock {
+  AutoLock lock(*myLock);
+}
+@end

Added: cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h?rev=356940&view=auto
==
--- cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h (added)
+++ cfe/trunk/test/SemaObjCXX/thread-safety-analysis.h Mon Mar 25 13:06:32 2019
@@ -0,0 +1,17 @@
+class __attribute__((lockable)) Lock {
+public:
+  void Acquire() __attribute__((exclusive_lock_function())) {}
+  void Release() __attribute__((unlock_function())) {}
+};
+
+class __attribute__((scoped_lockable)) AutoLock {
+public:
+  AutoLock(Lock &lock) __attribute__((exclusive_lock_function(lock)))
+  : lock_(lock) {
+lock.Acquire();
+  }
+  ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); }
+
+private:
+  Lock &lock_;
+};

Modified: cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm?rev=356940&r1=356939&r2=356940&view=diff
==
--- cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm (original)
+++ cfe/trunk/test/SemaObjCXX/warn-thread-safety-analysis.mm Mon Mar 25 
13:06:32 2019
@@ -1,22 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta 
-Wno-objc-root-class %s
 
-class __attribute__((lockable)) Lock {
-public:
-  void Acquire() __attribute__((exclusive_lock_function())) {}
-  void Release() __attribute__((unlock_function())) {}
-};
-
-class __attribute__

[PATCH] D59776: [Sema] Don't check for array bounds when the types in the base expression are dependent.

2019-03-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59776/new/

https://reviews.llvm.org/D59776



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


[PATCH] D59371: [LibTooling] Add Stencil library for format-string style codegen.

2019-03-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

gentle ping...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59371/new/

https://reviews.llvm.org/D59371



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


[PATCH] D59725: Additions to creduce script

2019-03-25 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for this!




Comment at: clang/utils/creduce-clang-crash.py:137
+
+# If no message was found, use the top five stack trace functions,
+# ignoring some common functions

Please expand a bit on why 5 was chosen (is there some deep reason behind it, 
or does it just seem like a sensible number?)



Comment at: clang/utils/creduce-clang-crash.py:145
+  matches = re.findall(stacktrace_re, crash_output)
+  result = filter(lambda x: x and x.strip() not in filters, matches)[:5]
+  for msg in result:

nit: please prefer `[x for x in matches if x and x.strip() not in 
filters][:5]`. py3's filter returns a generator, whereas py2's returns a list.



Comment at: clang/utils/creduce-clang-crash.py:193
+# Instead of modifying the filename in the test file, just run the command
+_, empty_file = tempfile.mkstemp()
+if self.check_expected_output(filename=empty_file):

I think `_` is an open file descriptor; please `os.close` it if we don't want 
to use it



Comment at: clang/utils/creduce-clang-crash.py:199
+print("\nTrying to preprocess the source file...")
+_, tmpfile = tempfile.mkstemp()
+

Same nit



Comment at: clang/utils/creduce-clang-crash.py:202
+cmd = self.get_crash_cmd() + ['-E', '-P']
+p = subprocess.Popen(self.get_crash_cmd() + ['-E', '-P'],
+ stdout=subprocess.PIPE,

was this intended to use `cmd`?



Comment at: clang/utils/creduce-clang-crash.py:205
+ stderr=subprocess.STDOUT)
+preprocessed, _ = p.communicate()
+

Do we want to check the exit code of this? Or do we assume that if clang 
crashes during preprocessing, we'll just see a different error during 
`check_expected_output`? (In the latter case, please add a comment)



Comment at: clang/utils/creduce-clang-crash.py:222
+def append_flags(x, y):
+  if len(x) > 0 and x[-1].startswith('-') and not y.startswith('-'):
+x[-1] += ' ' + y

Is it intentional to group multiple consecutive non-dashed args? e.g. it seems 
that `clang -ffoo bar baz` will turn into `['clang', '-ffoo bar baz']`





Comment at: clang/utils/creduce-clang-crash.py:223
+  if len(x) > 0 and x[-1].startswith('-') and not y.startswith('-'):
+x[-1] += ' ' + y
+return x

Should we be `shlex.quote`'ing y here (and probably in the `return x + [y]` 
below)?



Comment at: clang/utils/creduce-clang-crash.py:251
+new_args = self.filter_args(args, **kwargs)
+if extra_arg and extra_arg not in new_args:
+  new_args.append(extra_arg)

IMO, if even `extra_arg` is in `new_args`, we should still move it near the 
end. Arg ordering matters in clang, generally with later args taking precedence 
over earlier ones. e.g. the -g$N args in https://godbolt.org/z/Mua8cs



Comment at: clang/utils/creduce-clang-crash.py:279
+ "-debugger-tuning=",
+ "-gdwarf"])
+new_args = self.try_remove_args(new_args,

If we're replacing other args with their effective negation, does it also make 
sense to replace all debug-ish options with `-g0`?



Comment at: clang/utils/creduce-clang-crash.py:296
+new_args = self.try_remove_args(new_args, msg="Removed -D options",
+opts_startswith=["-D "])
+new_args = self.try_remove_args(new_args, msg="Removed -I options",

Might not want to have a space here; `-DFOO=1` is valid (same for `-I` below)



Comment at: clang/utils/creduce-clang-crash.py:306
+# Remove other cases that aren't covered by the heuristic
+new_args = self.try_remove_args(new_args, msg="Removed -mllvm",
+opts_one_arg_startswith=["-mllvm"])

Probably want to do a similar thing for `-Xclang` (which, as far as this code 
is concerned, acts a lot like `-mllvm`)



Comment at: clang/utils/creduce-clang-crash.py:362
+  r = Reduce(crash_script, file_to_reduce)
+  r.simplify_clang_args()
+  r.write_interestingness_test()

I'm unclear on why we do a partial simplification of clang args here, then a 
full reduction after creduce. Is there a disadvantage to instead doing:

r.write_interestingness_test()
r.clang_preprocess()
r.reduce_clang_args()
r.run_creduce()
r.reduce_clang_args()

?

The final `reduce_clang_args` being there to remove extra `-D`/`-I`/etc. args 
if preprocessing failed somehow, to remove `-std=foo` args if those aren't 
relevant after reduction, etc.

The advantage to this being that we no longer nee

[PATCH] D59329: [LibTooling] Add NodeId, a strong type for AST-matcher node identifiers.

2019-03-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

gentle ping...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59329/new/

https://reviews.llvm.org/D59329



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


[PATCH] D59008: [AMDGPU] Switch default dwarf version to 5

2019-03-25 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D59008#1441903 , @t-tye wrote:

> LGTM
>
> Do we know the state of split DWARF and DWARF compression for DWARF 5 
> (compared to DWARF 2)?


State of them in what sense? Compression is pretty orthogonal to any DWARF 
version - it's more about the container (ELF, etc) you use. Split DWARF is 
non-standardly supported in pre-v5, and I think it's functioning in the 
standards conformant v5 mode too.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59008/new/

https://reviews.llvm.org/D59008



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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-03-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 10 inline comments as done.
ymandel added a comment.

Addressed the most major comments. Still working on some smaller ones. PTAL.  
Thanks!




Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:54
+/// boolean expression language for constructing filters.
+class MatchFilter {
+public:

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > Intuitively, it feels that any filtering should be possible at the level 
> > > of the AST matchers. Is that not the case?
> > > Could you provide some motivating examples where AST matchers cannot be 
> > > used to nail down the matching nodes and we need `MatchFilter`? 
> > > 
> > > Please note I have limited experience with AST matchers, so there might 
> > > be some obvious things that I'm missing.
> > Good point. The examples I have would actually be perfectly suited to a 
> > matcher.  That said, there is not matcher support for a simple predicate of 
> > this form, along the lines of gtest's `Truly(predicate)`. I'll remove this 
> > and separately try to add something like `Truly` to the matchers.
> Makes sense! Maybe put a `FIXME` here to let the readers know this is moving 
> to the ast matchers?
I've removed the where clause entirely. I'll separately add the matcher support 
(I've figured out how to do it within the existing framework).



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:85
+  Node,
+  /// Given a \c MemberExpr, selects the member's token.
+  Member,

ilya-biryukov wrote:
> What happens if member is composed of multiple tokens? E.g.
> ```
> foo.bar::baz; // member tokens are ['bar', '::', 'baz']
> foo.template baz; // member tokens are ['template', 'baz', '<', 'int', 
> '>']
> foo.operator +; // member tokens are ['operator', '+']
> ```
> 
> I might be misinterpreting the meaning of "member" token.
Good catch! I've updated to handle these correctly (I believe). Added some 
tests, plan to add some more.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:89
+  /// relevant name, not including qualifiers.
+  Name,
+};

ilya-biryukov wrote:
> Same here, what happens to the template arguments and multi-token names, e.g.
> `operator +` or `foo`?
Good point. This seems difficult to get right, since NamedDecl does not carry 
sufficient loc data.  However, I've updated the code to explicitly fail in such 
cases, so at least we won't have bad rewrites.

BTW, any idea whether constructor initializers can ever be multi token?



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:135
+// \endcode
+class RewriteRule {
+public:

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > ymandel wrote:
> > > > ilya-biryukov wrote:
> > > > > Maybe consider separating the fluent API to build the rewrite rule 
> > > > > from the rewrite rule itself?
> > > > > 
> > > > > Not opposed to having the fluent builder API, this does look nice and 
> > > > > seems to nicely align with the matcher APIs.
> > > > > However, it is somewhat hard to figure out what can `RewriteRule` do 
> > > > > **after** it was built when looking at the code right now.
> > > > > ```
> > > > > class RewriteRule {
> > > > > public:
> > > > >   RewriteRule(DynTypedMatcher, TextGenerator Replacement, 
> > > > > TextGenerator Explanation);
> > > > > 
> > > > >   DynTypedMatcher matcher() const;
> > > > >   Expected replacement() const;
> > > > >   Expected explanation() const;
> > > > > };
> > > > > 
> > > > > struct RewriteRuleBuilder { // Having a better name than 'Builder' 
> > > > > would be nice.
> > > > >   RewriteRule finish() &&; // produce the final RewriteRule.
> > > > > 
> > > > >   template 
> > > > >   RewriteRuleBuilder &change(const TypedNodeId &Target,
> > > > >   NodePart Part = NodePart::Node) &;
> > > > >   RewriteRuleBuilder &replaceWith(TextGenerator Replacement) &;
> > > > >   RewriteRuleBuilder &because(TextGenerator Explanation) &;
> > > > > private:
> > > > >   RewriteRule RuleInProgress;
> > > > > };
> > > > > RewriteRuleBuilder makeRewriteRule();
> > > > > ```
> > > > I see your point, but do you think it might be enough to improve the 
> > > > comments on the class? My concern with a builder is the mental burden 
> > > > on the user of another concept (the builder) and the need for an extra 
> > > > `.build()` everywhere. To a lesser extent, I also don't love the cost 
> > > > of an extra copy, although I doubt it matters and I suppose we could 
> > > > support moves in the build method.
> > > The issues with the builder interface is that it requires lots of 
> > > boilerplate, which is hard to throw away when reading the code of the 
> > > class. I agree that having a separate builder class is also annoying 
> > > (more concepts, etc).
> > > 
> > > Keeping them separate would be my personal preference, but if you'd 
> >

[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-03-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 192172.
ymandel marked an inline comment as done.
ymandel added a comment.

Split RewriteRule into two classes, remove support for where clause, support 
multi-token targets, and add corresponding tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59376/new/

https://reviews.llvm.org/D59376

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -0,0 +1,447 @@
+//===- unittest/Tooling/TransformerTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/Transformer.h"
+
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+using ::clang::ast_matchers::anyOf;
+using ::clang::ast_matchers::argumentCountIs;
+using ::clang::ast_matchers::callee;
+using ::clang::ast_matchers::callExpr;
+using ::clang::ast_matchers::cxxMemberCallExpr;
+using ::clang::ast_matchers::cxxMethodDecl;
+using ::clang::ast_matchers::cxxRecordDecl;
+using ::clang::ast_matchers::declRefExpr;
+using ::clang::ast_matchers::expr;
+using ::clang::ast_matchers::functionDecl;
+using ::clang::ast_matchers::hasAnyName;
+using ::clang::ast_matchers::hasArgument;
+using ::clang::ast_matchers::hasDeclaration;
+using ::clang::ast_matchers::hasElse;
+using ::clang::ast_matchers::hasName;
+using ::clang::ast_matchers::hasType;
+using ::clang::ast_matchers::ifStmt;
+using ::clang::ast_matchers::member;
+using ::clang::ast_matchers::memberExpr;
+using ::clang::ast_matchers::namedDecl;
+using ::clang::ast_matchers::on;
+using ::clang::ast_matchers::pointsTo;
+using ::clang::ast_matchers::to;
+using ::clang::ast_matchers::unless;
+
+constexpr char KHeaderContents[] = R"cc(
+  struct string {
+string(const char*);
+char* c_str();
+int size();
+  };
+  int strlen(const char*);
+
+  namespace proto {
+  struct PCFProto {
+int foo();
+  };
+  struct ProtoCommandLineFlag : PCFProto {
+PCFProto& GetProto();
+  };
+  }  // namespace proto
+)cc";
+} // namespace
+
+static clang::ast_matchers::internal::Matcher
+isOrPointsTo(const DeclarationMatcher &TypeMatcher) {
+  return anyOf(hasDeclaration(TypeMatcher), pointsTo(TypeMatcher));
+}
+
+static std::string format(llvm::StringRef Code) {
+  const std::vector Ranges(1, Range(0, Code.size()));
+  auto Style = format::getLLVMStyle();
+  const auto Replacements = format::reformat(Style, Code, Ranges);
+  auto Formatted = applyAllReplacements(Code, Replacements);
+  if (!Formatted) {
+ADD_FAILURE() << "Could not format code: "
+  << llvm::toString(Formatted.takeError());
+return std::string();
+  }
+  return *Formatted;
+}
+
+void compareSnippets(llvm::StringRef Expected,
+ const llvm::Optional &MaybeActual) {
+  ASSERT_TRUE(MaybeActual) << "Rewrite failed. Expecting: " << Expected;
+  auto Actual = *MaybeActual;
+  std::string HL = "#include \"header.h\"\n";
+  auto I = Actual.find(HL);
+  if (I != std::string::npos) {
+Actual.erase(I, HL.size());
+  }
+  EXPECT_EQ(format(Expected), format(Actual));
+}
+
+// FIXME: consider separating this class into its own file(s).
+class ClangRefactoringTestBase : public testing::Test {
+protected:
+  void appendToHeader(llvm::StringRef S) { FileContents[0].second += S; }
+
+  void addFile(llvm::StringRef Filename, llvm::StringRef Content) {
+FileContents.emplace_back(Filename, Content);
+  }
+
+  llvm::Optional rewrite(llvm::StringRef Input) {
+std::string Code = ("#include \"header.h\"\n" + Input).str();
+auto Factory = newFrontendActionFactory(&MatchFinder);
+if (!runToolOnCodeWithArgs(
+Factory->create(), Code, std::vector(), "input.cc",
+"clang-tool", std::make_shared(),
+FileContents)) {
+  return None;
+}
+auto ChangedCodeOrErr =
+applyAtomicChanges("input.cc", Code, Changes, ApplyChangesSpec());
+if (auto Err = ChangedCodeOrErr.takeError()) {
+  llvm::errs() << "Change failed: " << llvm::toString(std::move(Err))
+   << "\n";
+  return None;
+}
+return *ChangedCodeOrErr;
+  }
+
+  clang::ast_matchers::MatchFinder MatchFinder;
+  AtomicChanges Changes;
+
+private:
+  FileContentMappings FileContents = {{

[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D56803#1441876 , @sylvestre.ledru 
wrote:

> @rnk btw, do you think it should be added to the clang release notes?


I think it is release-note worthy. If you change __VERSION__, you can mention 
that as well.




Comment at: lib/Driver/Driver.cpp:1631
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";

sylvestre.ledru wrote:
> rnk wrote:
> > We really ought to reconsider `__VERSION__` as well, although I don't think 
> > anyone checks that. Today I get this for it:
> >   "4.2.1 Compatible Clang 9.0.0 (g...@github.com:llvm/llvm-project.git 
> > bd6354105b055af6193fb2b7561fe6f5ae0eb0d8)"
> I can have a look to that if you want
If you're feeling motivated, I think it's worth doing to try to get us into a 
more consistent state.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56803/new/

https://reviews.llvm.org/D56803



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


[PATCH] D59008: [AMDGPU] Switch default dwarf version to 5

2019-03-25 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM

Do we know the state of split DWARF and DWARF compression for DWARF 5 (compared 
to DWARF 2)?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59008/new/

https://reviews.llvm.org/D59008



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


[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356931: clang -dumpversion returns 4.2.1 for legacy reason, 
update it (authored by sylvestre, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56803/new/

https://reviews.llvm.org/D56803

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/immediate-options.c


Index: cfe/trunk/test/Driver/immediate-options.c
===
--- cfe/trunk/test/Driver/immediate-options.c
+++ cfe/trunk/test/Driver/immediate-options.c
@@ -7,7 +7,7 @@
 // HELP-HIDDEN: driver-mode
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
 // RUN: %clang -print-search-dirs | FileCheck %s 
-check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1640,11 +1640,7 @@
   if (C.getArgs().hasArg(options::OPT_dumpversion)) {
 // Since -dumpversion is only implemented for pedantic GCC compatibility, 
we
 // return an answer which matches our definition of __VERSION__.
-//
-// If we want to return a more correct answer some day, then we should
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";
+llvm::outs() << CLANG_VERSION_STRING << "\n";
 return false;
   }
 


Index: cfe/trunk/test/Driver/immediate-options.c
===
--- cfe/trunk/test/Driver/immediate-options.c
+++ cfe/trunk/test/Driver/immediate-options.c
@@ -7,7 +7,7 @@
 // HELP-HIDDEN: driver-mode
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
 // RUN: %clang -print-search-dirs | FileCheck %s -check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1640,11 +1640,7 @@
   if (C.getArgs().hasArg(options::OPT_dumpversion)) {
 // Since -dumpversion is only implemented for pedantic GCC compatibility, we
 // return an answer which matches our definition of __VERSION__.
-//
-// If we want to return a more correct answer some day, then we should
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";
+llvm::outs() << CLANG_VERSION_STRING << "\n";
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356931 - clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-25 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Mon Mar 25 11:06:20 2019
New Revision: 356931

URL: http://llvm.org/viewvc/llvm-project?rev=356931&view=rev
Log:
clang -dumpversion returns 4.2.1 for legacy reason, update it

Summary:
It has been introduced in 2011 for gcc compat:
https://github.com/llvm-mirror/clang/commit/95a907fc0f2f717dca38a379c1d2353bfea06d4f
it is probably time to remove it to remove the confusion.

reported: https://bugs.llvm.org/show_bug.cgi?id=38836
https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1810860

Reviewers: ddunbar, rnk

Reviewed By: rnk

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/immediate-options.c

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=356931&r1=356930&r2=356931&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Mar 25 11:06:20 2019
@@ -1640,11 +1640,7 @@ bool Driver::HandleImmediateArgs(const C
   if (C.getArgs().hasArg(options::OPT_dumpversion)) {
 // Since -dumpversion is only implemented for pedantic GCC compatibility, 
we
 // return an answer which matches our definition of __VERSION__.
-//
-// If we want to return a more correct answer some day, then we should
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";
+llvm::outs() << CLANG_VERSION_STRING << "\n";
 return false;
   }
 

Modified: cfe/trunk/test/Driver/immediate-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/immediate-options.c?rev=356931&r1=356930&r2=356931&view=diff
==
--- cfe/trunk/test/Driver/immediate-options.c (original)
+++ cfe/trunk/test/Driver/immediate-options.c Mon Mar 25 11:06:20 2019
@@ -7,7 +7,7 @@
 // HELP-HIDDEN: driver-mode
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
 // RUN: %clang -print-search-dirs | FileCheck %s 
-check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}


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


[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-25 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 192159.
sylvestre.ledru marked 3 inline comments as done.
sylvestre.ledru edited the summary of this revision.
sylvestre.ledru added a comment.

Improve the test (thanks rnk)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56803/new/

https://reviews.llvm.org/D56803

Files:
  clang/
  clang/include/
  clang/include/clang/
  clang/include/clang/Format/
  clang/include/clang/Tooling/
  clang/include/clang/Tooling/Inclusions/
  lib/Driver/Driver.cpp
  test/Driver/immediate-options.c


Index: test/Driver/immediate-options.c
===
--- test/Driver/immediate-options.c
+++ test/Driver/immediate-options.c
@@ -7,7 +7,7 @@
 // HELP-HIDDEN: driver-mode
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
 // RUN: %clang -print-search-dirs | FileCheck %s 
-check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1640,11 +1640,7 @@
   if (C.getArgs().hasArg(options::OPT_dumpversion)) {
 // Since -dumpversion is only implemented for pedantic GCC compatibility, 
we
 // return an answer which matches our definition of __VERSION__.
-//
-// If we want to return a more correct answer some day, then we should
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";
+llvm::outs() << CLANG_VERSION_STRING << "\n";
 return false;
   }
 


Index: test/Driver/immediate-options.c
===
--- test/Driver/immediate-options.c
+++ test/Driver/immediate-options.c
@@ -7,7 +7,7 @@
 // HELP-HIDDEN: driver-mode
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
 // RUN: %clang -print-search-dirs | FileCheck %s -check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1640,11 +1640,7 @@
   if (C.getArgs().hasArg(options::OPT_dumpversion)) {
 // Since -dumpversion is only implemented for pedantic GCC compatibility, we
 // return an answer which matches our definition of __VERSION__.
-//
-// If we want to return a more correct answer some day, then we should
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";
+llvm::outs() << CLANG_VERSION_STRING << "\n";
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-25 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 192160.
sylvestre.ledru added a comment.

Remove the empty directories


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56803/new/

https://reviews.llvm.org/D56803

Files:
  lib/Driver/Driver.cpp
  test/Driver/immediate-options.c


Index: test/Driver/immediate-options.c
===
--- test/Driver/immediate-options.c
+++ test/Driver/immediate-options.c
@@ -7,7 +7,7 @@
 // HELP-HIDDEN: driver-mode
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
 // RUN: %clang -print-search-dirs | FileCheck %s 
-check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1640,11 +1640,7 @@
   if (C.getArgs().hasArg(options::OPT_dumpversion)) {
 // Since -dumpversion is only implemented for pedantic GCC compatibility, 
we
 // return an answer which matches our definition of __VERSION__.
-//
-// If we want to return a more correct answer some day, then we should
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";
+llvm::outs() << CLANG_VERSION_STRING << "\n";
 return false;
   }
 


Index: test/Driver/immediate-options.c
===
--- test/Driver/immediate-options.c
+++ test/Driver/immediate-options.c
@@ -7,7 +7,7 @@
 // HELP-HIDDEN: driver-mode
 
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
 
 // RUN: %clang -print-search-dirs | FileCheck %s -check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1640,11 +1640,7 @@
   if (C.getArgs().hasArg(options::OPT_dumpversion)) {
 // Since -dumpversion is only implemented for pedantic GCC compatibility, we
 // return an answer which matches our definition of __VERSION__.
-//
-// If we want to return a more correct answer some day, then we should
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";
+llvm::outs() << CLANG_VERSION_STRING << "\n";
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-25 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@rnk btw, do you think it should be added to the clang release notes?




Comment at: lib/Driver/Driver.cpp:1631
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";

rnk wrote:
> We really ought to reconsider `__VERSION__` as well, although I don't think 
> anyone checks that. Today I get this for it:
>   "4.2.1 Compatible Clang 9.0.0 (g...@github.com:llvm/llvm-project.git 
> bd6354105b055af6193fb2b7561fe6f5ae0eb0d8)"
I can have a look to that if you want


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56803/new/

https://reviews.llvm.org/D56803



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


[PATCH] D59725: Additions to creduce script

2019-03-25 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 192149.
akhuang added a comment.

reuploaded diff with full context


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725

Files:
  clang/utils/creduce-clang-crash.py

Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -1,8 +1,14 @@
 #!/usr/bin/env python
 """Calls C-Reduce to create a minimal reproducer for clang crashes.
+
+Output files:
+  *.reduced.sh -- crash reproducer with minimal arguments
+  *.reduced.cpp -- the reduced file
+  *.test.sh -- interestingness test for C-Reduce
 """
 
-from argparse import ArgumentParser
+from __future__ import print_function
+from argparse import ArgumentParser, RawTextHelpFormatter
 import os
 import re
 import stat
@@ -15,10 +21,14 @@
 from distutils.spawn import find_executable
 
 verbose = False
-llvm_bin = None
 creduce_cmd = None
+clang_cmd = None
 not_cmd = None
 
+def verbose_print(*args, **kwargs):
+  if verbose:
+print(*args, **kwargs)
+
 def check_file(fname):
   if not os.path.isfile(fname):
 sys.exit("ERROR: %s does not exist" % (fname))
@@ -33,166 +43,306 @@
 cmd = find_executable(cmd_path)
 if cmd:
   return cmd
-sys.exit("ERROR: executable %s not found" % (cmd_path))
+sys.exit("ERROR: executable `%s` not found" % (cmd_path))
 
   cmd = find_executable(cmd_name, path=cmd_dir)
   if cmd:
 return cmd
-  sys.exit("ERROR: %s not found in %s" % (cmd_name, cmd_dir))
 
-def quote_cmd(cmd):
-  return ' '.join(arg if arg.startswith('$') else pipes.quote(arg)
-  for arg in cmd)
-
-def get_crash_cmd(crash_script):
-  with open(crash_script) as f:
-# Assume clang call is on the last line of the script
-line = f.readlines()[-1]
-cmd = shlex.split(line)
-
-# Overwrite the script's clang with the user's clang path
-new_clang = check_cmd('clang', llvm_bin)
-cmd[0] = pipes.quote(new_clang)
-return cmd
+  if not cmd_dir:
+cmd_dir = "$PATH"
+  sys.exit("ERROR: `%s` not found in %s" % (cmd_name, cmd_dir))
 
-def has_expected_output(crash_cmd, expected_output):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-  return all(msg in crash_output for msg in expected_output)
-
-def get_expected_output(crash_cmd):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-
-  # If there is an assertion failure, use that;
-  # otherwise use the last five stack trace functions
-  assertion_re = r'Assertion `([^\']+)\' failed'
-  assertion_match = re.search(assertion_re, crash_output)
-  if assertion_match:
-return [assertion_match.group(1)]
-  else:
-stacktrace_re = r'#[0-9]+\s+0[xX][0-9a-fA-F]+\s*([^(]+)\('
-matches = re.findall(stacktrace_re, crash_output)
-return matches[-5:]
-
-def write_interestingness_test(testfile, crash_cmd, expected_output,
-   file_to_reduce):
-  filename = os.path.basename(file_to_reduce)
-  if filename not in crash_cmd:
-sys.exit("ERROR: expected %s to be in the crash command" % filename)
-
-  # Replace all instances of file_to_reduce with a command line variable
-  output = ['#!/bin/bash',
-'if [ -z "$1" ] ; then',
-'  f=%s' % (pipes.quote(filename)),
-'else',
-'  f="$1"',
-'fi']
-  cmd = ['$f' if s == filename else s for s in crash_cmd]
-
-  output.append('%s --crash %s >& t.log || exit 1' % (pipes.quote(not_cmd),
-  quote_cmd(cmd)))
-
-  for msg in expected_output:
-output.append('grep %s t.log || exit 1' % pipes.quote(msg))
-
-  with open(testfile, 'w') as f:
-f.write('\n'.join(output))
-  os.chmod(testfile, os.stat(testfile).st_mode | stat.S_IEXEC)
-
-def check_interestingness(testfile, file_to_reduce):
-  testfile = os.path.abspath(testfile)
-
-  # Check that the test considers the original file interesting
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call(testfile, stdout=devnull)
-  if returncode:
-sys.exit("The interestingness test does not pass for the original file.")
-
-  # Check that an empty file is not interesting
-  _, empty_file = tempfile.mkstemp()
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call([testfile, empty_file], stdout=devnull)
-  os.remove(empty_file)
-  if not returncode:
-sys.exit("The interestingness test passes for an empty file.")
-
-def clang_preprocess(file_to_reduce, crash_cmd, expected_output):
-  _, tmpfile = tempfile.mkstemp()
-  shutil.copy(file_to_reduce, tmpfile)
-
-  cmd = crash_cmd + ['-E', '-P']
-  p = subprocess.Popen(cmd,
-   stdout=sub

r356929 - Moved everything SMT-related to LLVM and updated the cmake scripts.

2019-03-25 Thread Mikhail R. Gadelha via cfe-commits
Author: mramalho
Date: Mon Mar 25 10:47:45 2019
New Revision: 356929

URL: http://llvm.org/viewvc/llvm-project?rev=356929&view=rev
Log:
Moved everything SMT-related to LLVM and updated the cmake scripts.

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

Added:
cfe/trunk/lib/StaticAnalyzer/Core/SMTConstraintManager.cpp
Removed:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTAPI.h
cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/FindZ3.cmake
cfe/trunk/include/clang/Config/config.h.cmake

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/lit.site.cfg.py.in

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=356929&r1=356928&r2=356929&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Mar 25 10:47:45 2019
@@ -447,34 +447,9 @@ option(CLANG_BUILD_TOOLS
 option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
 option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON)
 
-set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 
solver.")
-
-find_package(Z3 4.7.1)
-
-if (CLANG_ANALYZER_Z3_INSTALL_DIR)
-  if (NOT Z3_FOUND)
-message(FATAL_ERROR "Z3 4.7.1 has not been found in 
CLANG_ANALYZER_Z3_INSTALL_DIR: ${CLANG_ANALYZER_Z3_INSTALL_DIR}.")
-  endif()
-endif()
-
-set(CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
-
-option(CLANG_ANALYZER_ENABLE_Z3_SOLVER
-  "Enable Support for the Z3 constraint solver in the Clang Static Analyzer."
-  ${CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT}
-)
-
-if (CLANG_ANALYZER_ENABLE_Z3_SOLVER)
-  if (NOT Z3_FOUND)
-message(FATAL_ERROR "CLANG_ANALYZER_ENABLE_Z3_SOLVER cannot be enabled 
when Z3 is not available.")
-  endif()
-
-  set(CLANG_ANALYZER_WITH_Z3 1)
-endif()
-
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
-if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR 
CLANG_ANALYZER_ENABLE_Z3_SOLVER))
+if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
   message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or 
Z3")
 endif()
 

Modified: cfe/trunk/cmake/modules/FindZ3.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/FindZ3.cmake?rev=356929&r1=356928&r2=356929&view=diff
==
--- cfe/trunk/cmake/modules/FindZ3.cmake (original)
+++ cfe/trunk/cmake/modules/FindZ3.cmake Mon Mar 25 10:47:45 2019
@@ -1,51 +0,0 @@
-# Looking for Z3 in CLANG_ANALYZER_Z3_INSTALL_DIR
-find_path(Z3_INCLUDE_DIR NAMES z3.h
-   NO_DEFAULT_PATH
-   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}/include
-   PATH_SUFFIXES libz3 z3
-   )
-
-find_library(Z3_LIBRARIES NAMES z3 libz3
-   NO_DEFAULT_PATH
-   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
-   PATH_SUFFIXES lib bin
-   )
-
-find_program(Z3_EXECUTABLE z3
-   NO_DEFAULT_PATH
-   PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}
-   PATH_SUFFIXES bin
-   )
-
-# If Z3 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR look in the 
default directories
-find_path(Z3_INCLUDE_DIR NAMES z3.h
-   PATH_SUFFIXES libz3 z3
-   )
-
-find_library(Z3_LIBRARIES NAMES z3 libz3
-   PATH_SUFFIXES lib bin
-   )
-
-find_program(Z3_EXECUTABLE z3
-   PATH_SUFFIXES bin
-   )
-
-if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND Z3_EXECUTABLE)
-execute_process (COMMAND ${Z3_EXECUTABLE} -version
-  OUTPUT_VARIABLE libz3_version_str
-  ERROR_QUIET
-  OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-string(REGEX REPLACE "^Z3 version ([0-9.]+)" "\\1"
-   Z3_VERSION_STRING "${libz3_version_str}")
-unset(libz3_version_str)
-endif()
-
-# handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if
-# all listed variables are TRUE
-include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3
-  REQUIRED_VARS Z3_LIBRARIES Z3_INCLUDE_DIR
-  VERSION_VAR Z3_VERSION_STRING)
-
-mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES)

Modified: cfe/trunk/include/clang/Config/config.h.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=356929&r1=356928&r2=356929&view=diff
==
--- cfe/trunk/include/clang/Config/config.h.cmake (original)
+++ cfe/trunk/include/clang/Config/config.h.cmake Mon Mar 25 10:47:45 2019
@@ -57,9 +57,6 @@
 /* Define if we have libxml2 */
 #cmakedefine CLANG_HAVE_LIBXML ${CLANG_HAVE_LIBXML}
 
-/* Define if we have z3 and want to build it */
-#cmakedefine CLANG_ANALYZER_WI

[PATCH] D59008: [AMDGPU] Switch default dwarf version to 5

2019-03-25 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

Ping


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59008/new/

https://reviews.llvm.org/D59008



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


[PATCH] D59725: Additions to creduce script

2019-03-25 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 192145.
akhuang added a comment.

Fix some typos, pass --tidy flag to creduce


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59725/new/

https://reviews.llvm.org/D59725

Files:
  clang/utils/creduce-clang-crash.py

Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -1,8 +1,14 @@
 #!/usr/bin/env python
 """Calls C-Reduce to create a minimal reproducer for clang crashes.
+
+Output files:
+  *.reduced.sh -- crash reproducer with minimal arguments
+  *.reduced.cpp -- the reduced file
+  *.test.sh -- interestingness test for C-Reduce
 """
 
-from argparse import ArgumentParser
+from __future__ import print_function
+from argparse import ArgumentParser, RawTextHelpFormatter
 import os
 import re
 import stat
@@ -15,10 +21,14 @@
 from distutils.spawn import find_executable
 
 verbose = False
-llvm_bin = None
 creduce_cmd = None
+clang_cmd = None
 not_cmd = None
 
+def verbose_print(*args, **kwargs):
+  if verbose:
+print(*args, **kwargs)
+
 def check_file(fname):
   if not os.path.isfile(fname):
 sys.exit("ERROR: %s does not exist" % (fname))
@@ -33,166 +43,306 @@
 cmd = find_executable(cmd_path)
 if cmd:
   return cmd
-sys.exit("ERROR: executable %s not found" % (cmd_path))
+sys.exit("ERROR: executable `%s` not found" % (cmd_path))
 
   cmd = find_executable(cmd_name, path=cmd_dir)
   if cmd:
 return cmd
-  sys.exit("ERROR: %s not found in %s" % (cmd_name, cmd_dir))
 
-def quote_cmd(cmd):
-  return ' '.join(arg if arg.startswith('$') else pipes.quote(arg)
-  for arg in cmd)
-
-def get_crash_cmd(crash_script):
-  with open(crash_script) as f:
-# Assume clang call is on the last line of the script
-line = f.readlines()[-1]
-cmd = shlex.split(line)
-
-# Overwrite the script's clang with the user's clang path
-new_clang = check_cmd('clang', llvm_bin)
-cmd[0] = pipes.quote(new_clang)
-return cmd
+  if not cmd_dir:
+cmd_dir = "$PATH"
+  sys.exit("ERROR: `%s` not found in %s" % (cmd_name, cmd_dir))
 
-def has_expected_output(crash_cmd, expected_output):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-  return all(msg in crash_output for msg in expected_output)
-
-def get_expected_output(crash_cmd):
-  p = subprocess.Popen(crash_cmd,
-   stdout=subprocess.PIPE,
-   stderr=subprocess.STDOUT)
-  crash_output, _ = p.communicate()
-
-  # If there is an assertion failure, use that;
-  # otherwise use the last five stack trace functions
-  assertion_re = r'Assertion `([^\']+)\' failed'
-  assertion_match = re.search(assertion_re, crash_output)
-  if assertion_match:
-return [assertion_match.group(1)]
-  else:
-stacktrace_re = r'#[0-9]+\s+0[xX][0-9a-fA-F]+\s*([^(]+)\('
-matches = re.findall(stacktrace_re, crash_output)
-return matches[-5:]
-
-def write_interestingness_test(testfile, crash_cmd, expected_output,
-   file_to_reduce):
-  filename = os.path.basename(file_to_reduce)
-  if filename not in crash_cmd:
-sys.exit("ERROR: expected %s to be in the crash command" % filename)
-
-  # Replace all instances of file_to_reduce with a command line variable
-  output = ['#!/bin/bash',
-'if [ -z "$1" ] ; then',
-'  f=%s' % (pipes.quote(filename)),
-'else',
-'  f="$1"',
-'fi']
-  cmd = ['$f' if s == filename else s for s in crash_cmd]
-
-  output.append('%s --crash %s >& t.log || exit 1' % (pipes.quote(not_cmd),
-  quote_cmd(cmd)))
-
-  for msg in expected_output:
-output.append('grep %s t.log || exit 1' % pipes.quote(msg))
-
-  with open(testfile, 'w') as f:
-f.write('\n'.join(output))
-  os.chmod(testfile, os.stat(testfile).st_mode | stat.S_IEXEC)
-
-def check_interestingness(testfile, file_to_reduce):
-  testfile = os.path.abspath(testfile)
-
-  # Check that the test considers the original file interesting
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call(testfile, stdout=devnull)
-  if returncode:
-sys.exit("The interestingness test does not pass for the original file.")
-
-  # Check that an empty file is not interesting
-  _, empty_file = tempfile.mkstemp()
-  with open(os.devnull, 'w') as devnull:
-returncode = subprocess.call([testfile, empty_file], stdout=devnull)
-  os.remove(empty_file)
-  if not returncode:
-sys.exit("The interestingness test passes for an empty file.")
-
-def clang_preprocess(file_to_reduce, crash_cmd, expected_output):
-  _, tmpfile = tempfile.mkstemp()
-  shutil.copy(file_to_reduce, tmpfile)
-
-  cmd = crash_cmd + ['-E', '-P']
-  p = subprocess.Popen(cmd,
-   

[PATCH] D59492: [OpenCL] Allow variadic macros as Clang feature

2019-03-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
Herald added a subscriber: wdng.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59492/new/

https://reviews.llvm.org/D59492



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


[PATCH] D59774: [clang-format] Refine structured binding detection

2019-03-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356928: [clang-format] Refine structured binding detection 
(authored by krasimir, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59774/new/

https://reviews.llvm.org/D59774

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -13,6 +13,7 @@
 
//===--===//
 
 #include "TokenAnnotator.h"
+#include "FormatToken.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
@@ -440,10 +441,11 @@
 Contexts.back().InCSharpAttributeSpecifier;
 
 bool InsideInlineASM = Line.startsWith(tok::kw_asm);
+bool IsCppStructuredBinding = Left->isCppStructuredBinding(Style);
 bool StartsObjCMethodExpr =
-!InsideInlineASM && !CppArrayTemplates && Style.isCpp() &&
-!IsCpp11AttributeSpecifier && Contexts.back().CanBeExpression &&
-Left->isNot(TT_LambdaLSquare) &&
+!IsCppStructuredBinding && !InsideInlineASM && !CppArrayTemplates &&
+Style.isCpp() && !IsCpp11AttributeSpecifier &&
+Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
 !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
 (!Parent ||
  Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
@@ -451,14 +453,12 @@
  Parent->isUnaryOperator() ||
  // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
- // for (auto && [A,B] : C)  && structure binding seen as 
ObjCMethodExpr
- (Parent->isNot(tok::ampamp) &&
-  getBinOpPrecedence(Parent->Tok.getKind(), true, true) >
-  prec::Unknown));
+ (getBinOpPrecedence(Parent->Tok.getKind(), true, true) >
+  prec::Unknown));
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->isCppStructuredBinding(Style)) {
+if (IsCppStructuredBinding) {
   Left->Type = TT_StructuredBindingLSquare;
 } else if (Left->is(TT_Unknown)) {
   if (StartsObjCMethodExpr) {
Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -1357,6 +1357,30 @@
   // verifyFormat("x = ([a foo:bar] >> b->c == 'd');");
 }
 
+TEST_F(FormatTestObjC,  DisambiguatesCallsFromStructuredBindings) {
+  verifyFormat("int f() {\n"
+   "  if (a && [f arg])\n"
+   "return 0;\n"
+   "}");
+  verifyFormat("int f() {\n"
+   "  if (a & [f arg])\n"
+   "return 0;\n"
+   "}");
+  verifyFormat("int f() {\n"
+   "  for (auto &[elem] : list)\n"
+   "return 0;\n"
+   "}");
+  verifyFormat("int f() {\n"
+   "  for (auto &&[elem] : list)\n"
+   "return 0;\n"
+   "}");
+  verifyFormat(
+  "int f() {\n"
+  "  for (auto /**/ const /**/ volatile /**/ && /**/ [elem] : list)\n"
+  "return 0;\n"
+  "}");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "TokenAnnotator.h"
+#include "FormatToken.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
@@ -440,10 +441,11 @@
 Contexts.back().InCSharpAttributeSpecifier;
 
 bool InsideInlineASM = Line.startsWith(tok::kw_asm);
+bool IsCppStructuredBinding = Left->isCppStructuredBinding(Style);
 bool StartsObjCMethodExpr =
-!InsideInlineASM && !CppArrayTemplates && Style.isCpp() &&
-!IsCpp11AttributeSpecifier && Contexts.back().CanBeExpression &&
-Left->isNot(TT_LambdaLSquare) &&
+!IsCppStructuredBinding && !InsideInlineASM && !CppArrayTemplates &&
+Style.isCpp() && !IsCpp11AttributeSpecifier &&
+Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
 !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
 (!Parent ||
  Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
@@ -451,14 +453,12 @@
  Parent->isUnaryOperator() ||
  // FIXME(bug 369

r356928 - [clang-format] Refine structured binding detection

2019-03-25 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Mar 25 10:29:16 2019
New Revision: 356928

URL: http://llvm.org/viewvc/llvm-project?rev=356928&view=rev
Log:
[clang-format] Refine structured binding detection

Summary:
Revision r356575 had the unfortunate consequence that now clang-format never
detects an ObjC call expression after `&&`.

This patch tries harder to distinguish between C++17 structured bindings and
ObjC call expressions and adds a few regression tests.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=356928&r1=356927&r2=356928&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Mar 25 10:29:16 2019
@@ -13,6 +13,7 @@
 
//===--===//
 
 #include "TokenAnnotator.h"
+#include "FormatToken.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
@@ -440,10 +441,11 @@ private:
 Contexts.back().InCSharpAttributeSpecifier;
 
 bool InsideInlineASM = Line.startsWith(tok::kw_asm);
+bool IsCppStructuredBinding = Left->isCppStructuredBinding(Style);
 bool StartsObjCMethodExpr =
-!InsideInlineASM && !CppArrayTemplates && Style.isCpp() &&
-!IsCpp11AttributeSpecifier && Contexts.back().CanBeExpression &&
-Left->isNot(TT_LambdaLSquare) &&
+!IsCppStructuredBinding && !InsideInlineASM && !CppArrayTemplates &&
+Style.isCpp() && !IsCpp11AttributeSpecifier &&
+Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
 !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
 (!Parent ||
  Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
@@ -451,14 +453,12 @@ private:
  Parent->isUnaryOperator() ||
  // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
- // for (auto && [A,B] : C)  && structure binding seen as 
ObjCMethodExpr
- (Parent->isNot(tok::ampamp) &&
-  getBinOpPrecedence(Parent->Tok.getKind(), true, true) >
-  prec::Unknown));
+ (getBinOpPrecedence(Parent->Tok.getKind(), true, true) >
+  prec::Unknown));
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->isCppStructuredBinding(Style)) {
+if (IsCppStructuredBinding) {
   Left->Type = TT_StructuredBindingLSquare;
 } else if (Left->is(TT_Unknown)) {
   if (StartsObjCMethodExpr) {

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=356928&r1=356927&r2=356928&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Mon Mar 25 10:29:16 2019
@@ -1357,6 +1357,30 @@ TEST_F(FormatTestObjC, DisambiguatesCall
   // verifyFormat("x = ([a foo:bar] >> b->c == 'd');");
 }
 
+TEST_F(FormatTestObjC,  DisambiguatesCallsFromStructuredBindings) {
+  verifyFormat("int f() {\n"
+   "  if (a && [f arg])\n"
+   "return 0;\n"
+   "}");
+  verifyFormat("int f() {\n"
+   "  if (a & [f arg])\n"
+   "return 0;\n"
+   "}");
+  verifyFormat("int f() {\n"
+   "  for (auto &[elem] : list)\n"
+   "return 0;\n"
+   "}");
+  verifyFormat("int f() {\n"
+   "  for (auto &&[elem] : list)\n"
+   "return 0;\n"
+   "}");
+  verifyFormat(
+  "int f() {\n"
+  "  for (auto /**/ const /**/ volatile /**/ && /**/ [elem] : list)\n"
+  "return 0;\n"
+  "}");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


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


RE: [clang-tools-extra] r356849 - [pp-trace] Modernize the code

2019-03-25 Thread via cfe-commits
Hi,

Yes, it appears to have been fixed as of r356878.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/24580

Douglas Yung

-Original Message-
From: Fāng-ruì Sòng  
Sent: Monday, March 25, 2019 4:41
To: Yung, Douglas 
Cc: cfe-commits 
Subject: Re: [clang-tools-extra] r356849 - [pp-trace] Modernize the code

Is it fixed now?

On Mon, Mar 25, 2019 at 7:25 AM  wrote:
>
> Hi Fangrui,
>
> This change is causing the PS4 Windows bot to fail to build:
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windo
> ws10pro-fast/builds/24560/steps/build/logs/stdio
>
> FAILED: 
> tools/clang/tools/extra/pp-trace/CMakeFiles/pp-trace.dir/PPTrace.cpp.obj
> C:\PROGRA~2\MIB055~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe
>   /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE 
> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE 
> -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -Itools\clang\tools\extra\pp-trace 
> -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\pp-trace
>  
> -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\include
>  -Itools\clang\include -Iinclude 
> -IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include
>  /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 
> -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 
> -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 
> -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 
> -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 
> -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /MD /O2 /Ob2   -UNDEBUG  
> /EHs-c- /GR- /showIncludes 
> /Fotools\clang\tools\extra\pp-trace\CMakeFiles\pp-trace.dir\PPTrace.cpp.obj 
> /Fdtools\clang\tools\extra\pp-trace\CMakeFiles\pp-trace.dir\ /FS -c 
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\ll
> vm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp(93): error C2668: 
> 'llvm::make_unique': ambiguous call to overloaded function
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/ADT/STLExtras.h(1348):
>  note: could be 'std::unique_ptr> 
> llvm::make_unique FilterType&,std::vector>&,clang::Preprocessor&>(const
>  FilterType &,std::vector> 
> &,clang::Preprocessor &)'
> with
> [
> _Ty=PPCallbacksTracker
> ]
> C:\Program Files (x86)\Microsoft Visual 
> Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(2537): note: 
> or   'std::unique_ptr> 
> std::make_unique FilterType&,std::vector>&,clang::Preprocessor&,0>(const
>  FilterType &,std::vector> 
> &,clang::Preprocessor &)' [found using argument-dependent lookup]
> with
> [
> _Ty=PPCallbacksTracker
> ]
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp(93):
>  note: while trying to match the argument list '(const FilterType, 
> std::vector>, clang::Preprocessor)'
> with
> [
> _Ty=CallbackCall
> ]
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\ll
> vm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp(155): error C2668: 
> 'llvm::make_unique': ambiguous call to overloaded function
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include\llvm/ADT/STLExtras.h(1348):
>  note: could be 
> 'std::unique_ptr<`anonymous-namespace'::PPTraceFrontendActionFactory,std::default_delete<_Ty>>
>  
> llvm::make_unique<`anonymous-namespace'::PPTraceFrontendActionFactory,FilterType&,llvm::raw_fd_ostream&>(FilterType
>  &,llvm::raw_fd_ostream &)'
> with
> [
> _Ty=`anonymous-namespace'::PPTraceFrontendActionFactory
> ]
> C:\Program Files (x86)\Microsoft Visual 
> Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\memory(2537): note: 
> or   
> 'std::unique_ptr<`anonymous-namespace'::PPTraceFrontendActionFactory,std::default_delete<_Ty>>
>  
> std::make_unique<`anonymous-namespace'::PPTraceFrontendActionFactory,FilterType&,llvm::raw_fd_ostream&,0>(FilterType
>  &,llvm::raw_fd_ostream &)' [found using argument-dependent lookup]
> with
> [
> _Ty=`anonymous-namespace'::PPTraceFrontendActionFactory
> ]
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\pp-trace\PPTrace.cpp(155):
>  note: while trying to match the argument list '(FilterType, 
> llvm::raw_fd_ostream)'
>

[PATCH] D59734: [clang-tidy] Handle missing yaml module in run-clang-tidy.py

2019-03-25 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 192137.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59734/new/

https://reviews.llvm.org/D59734

Files:
  clang-tidy/tool/run-clang-tidy.py
  test/clang-tidy/run-clang-tidy.cpp


Index: test/clang-tidy/run-clang-tidy.cpp
===
--- test/clang-tidy/run-clang-tidy.cpp
+++ test/clang-tidy/run-clang-tidy.cpp
@@ -1,3 +1,4 @@
+// RUN: %run_clang_tidy --help
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -47,7 +47,11 @@
 import tempfile
 import threading
 import traceback
-import yaml
+
+try:
+  import yaml
+except ImportError:
+  yaml = None
 
 is_py2 = sys.version[0] == '2'
 
@@ -199,9 +203,10 @@
   'headers to output diagnostics from. Diagnostics from '
   'the main file of each translation unit are always '
   'displayed.')
-  parser.add_argument('-export-fixes', metavar='filename', dest='export_fixes',
-  help='Create a yaml file to store suggested fixes in, '
-  'which can be applied with clang-apply-replacements.')
+  if yaml:
+parser.add_argument('-export-fixes', metavar='filename', 
dest='export_fixes',
+help='Create a yaml file to store suggested fixes in, '
+'which can be applied with clang-apply-replacements.')
   parser.add_argument('-j', type=int, default=0,
   help='number of tidy instances to be run in parallel.')
   parser.add_argument('files', nargs='*', default=['.*'],
@@ -254,7 +259,7 @@
 max_task = multiprocessing.cpu_count()
 
   tmpdir = None
-  if args.fix or args.export_fixes:
+  if args.fix or (yaml and args.export_fixes):
 check_clang_apply_replacements_binary(args)
 tmpdir = tempfile.mkdtemp()
 
@@ -292,7 +297,7 @@
   shutil.rmtree(tmpdir)
 os.kill(0, 9)
 
-  if args.export_fixes:
+  if yaml and args.export_fixes:
 print('Writing fixes to ' + args.export_fixes + ' ...')
 try:
   merge_replacement_files(tmpdir, args.export_fixes)


Index: test/clang-tidy/run-clang-tidy.cpp
===
--- test/clang-tidy/run-clang-tidy.cpp
+++ test/clang-tidy/run-clang-tidy.cpp
@@ -1,3 +1,4 @@
+// RUN: %run_clang_tidy --help
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > %t/compile_commands.json
Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -47,7 +47,11 @@
 import tempfile
 import threading
 import traceback
-import yaml
+
+try:
+  import yaml
+except ImportError:
+  yaml = None
 
 is_py2 = sys.version[0] == '2'
 
@@ -199,9 +203,10 @@
   'headers to output diagnostics from. Diagnostics from '
   'the main file of each translation unit are always '
   'displayed.')
-  parser.add_argument('-export-fixes', metavar='filename', dest='export_fixes',
-  help='Create a yaml file to store suggested fixes in, '
-  'which can be applied with clang-apply-replacements.')
+  if yaml:
+parser.add_argument('-export-fixes', metavar='filename', dest='export_fixes',
+help='Create a yaml file to store suggested fixes in, '
+'which can be applied with clang-apply-replacements.')
   parser.add_argument('-j', type=int, default=0,
   help='number of tidy instances to be run in parallel.')
   parser.add_argument('files', nargs='*', default=['.*'],
@@ -254,7 +259,7 @@
 max_task = multiprocessing.cpu_count()
 
   tmpdir = None
-  if args.fix or args.export_fixes:
+  if args.fix or (yaml and args.export_fixes):
 check_clang_apply_replacements_binary(args)
 tmpdir = tempfile.mkdtemp()
 
@@ -292,7 +297,7 @@
   shutil.rmtree(tmpdir)
 os.kill(0, 9)
 
-  if args.export_fixes:
+  if yaml and args.export_fixes:
 print('Writing fixes to ' + args.export_fixes + ' ...')
 try:
   merge_replacement_files(tmpdir, args.export_fixes)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59734: [clang-tidy] Handle missing yaml module in run-clang-tidy.py

2019-03-25 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked an inline comment as done.
zinovy.nis added inline comments.



Comment at: clang-tidy/tool/run-clang-tidy.py:210
+help='Create a yaml file to store suggested fixes in, '
+'which can be applied with clang-apply-replacements.')
   parser.add_argument('-j', type=int, default=0,

serge-sans-paille wrote:
> could be
> 
> ```
> if yaml:
> parser.add_argument('-export-fixes', metavar='filename', 
> dest='export_fixes',
>   ​help='Create a yaml file to store suggested 
> fixes in, '
>   ​'which can be applied with 
> clang-apply-replacements.')
> else:
> parser.export_fixes = False
> ```
> 
> This would make later condition easier to read.
Looks strange. Not sure this works.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59734/new/

https://reviews.llvm.org/D59734



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


[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-03-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Code lgtm, with a suggestion to tighten the test.




Comment at: lib/Driver/Driver.cpp:1631
-// introduce a non-pedantically GCC compatible mode to Clang in which we
-// provide sensible definitions for -dumpversion, __VERSION__, etc.
-llvm::outs() << "4.2.1\n";

We really ought to reconsider `__VERSION__` as well, although I don't think 
anyone checks that. Today I get this for it:
  "4.2.1 Compatible Clang 9.0.0 (g...@github.com:llvm/llvm-project.git 
bd6354105b055af6193fb2b7561fe6f5ae0eb0d8)"



Comment at: test/Driver/immediate-options.c:10
 // RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: 4.2.1
+// DUMPVERSION: {{[0-9]+\.[0-9]+.*}}
 

Maybe check `{{[0-9]+\.[0-9.]+}}`, to insist that it's a sequence of numbers 
and dots.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56803/new/

https://reviews.llvm.org/D56803



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


[PATCH] D58827: [Sema][NFCI] Don't allocate storage for the various CorrectionCandidateCallback unless we are going to do some typo correction

2019-03-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356925: [Sema][NFCI] Don't allocate storage for the 
various CorrectionCandidateCallback… (authored by brunoricci, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58827?vs=19&id=192134#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58827/new/

https://reviews.llvm.org/D58827

Files:
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Sema/TypoCorrection.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Parse/ParseTentative.cpp
  cfe/trunk/lib/Parse/Parser.cpp
  cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDeclObjC.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprMember.cpp
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
  cfe/trunk/lib/Sema/SemaType.cpp

Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -789,9 +789,8 @@
 /// Annotation was successful.
 ANK_Success
   };
-  AnnotatedNameKind
-  TryAnnotateName(bool IsAddressOfOperand,
-  std::unique_ptr CCC = nullptr);
+  AnnotatedNameKind TryAnnotateName(bool IsAddressOfOperand,
+CorrectionCandidateCallback *CCC = nullptr);
 
   /// Push a tok::annot_cxxscope token onto the token stream.
   void AnnotateScopeToken(CXXScopeSpec &SS, bool IsNewAnnotation);
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1914,11 +1914,11 @@
   ///expression.
   ///
   /// \param CCC The correction callback, if typo correction is desired.
-  NameClassification
-  ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name,
-   SourceLocation NameLoc, const Token &NextToken,
-   bool IsAddressOfOperand,
-   std::unique_ptr CCC = nullptr);
+  NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
+  IdentifierInfo *&Name, SourceLocation NameLoc,
+  const Token &NextToken,
+  bool IsAddressOfOperand,
+  CorrectionCandidateCallback *CCC = nullptr);
 
   /// Describes the detailed kind of a template name. Used in diagnostics.
   enum class TemplateNameKindForDiagnostics {
@@ -3266,7 +3266,7 @@
   makeTypoCorrectionConsumer(const DeclarationNameInfo &Typo,
  Sema::LookupNameKind LookupKind, Scope *S,
  CXXScopeSpec *SS,
- std::unique_ptr CCC,
+ CorrectionCandidateCallback &CCC,
  DeclContext *MemberContext, bool EnteringContext,
  const ObjCObjectPointerType *OPT,
  bool ErrorRecovery);
@@ -3350,7 +3350,7 @@
   TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo,
  Sema::LookupNameKind LookupKind,
  Scope *S, CXXScopeSpec *SS,
- std::unique_ptr CCC,
+ CorrectionCandidateCallback &CCC,
  CorrectTypoKind Mode,
  DeclContext *MemberContext = nullptr,
  bool EnteringContext = false,
@@ -3360,7 +3360,7 @@
   TypoExpr *CorrectTypoDelayed(const DeclarationNameInfo &Typo,
Sema::LookupNameKind LookupKind, Scope *S,
CXXScopeSpec *SS,
-   std::unique_ptr CCC,
+   CorrectionCandidateCallback &CCC,
TypoDiagnosticGenerator TDG,
TypoRecoveryCallback TRC, CorrectTypoKind Mode,
DeclContext *MemberContext = nullptr,
@@ -4230,7 +4230,7 @@
   ExprResult ActOnIdExpression(
   Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
   UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand,
-  std::unique_ptr CCC = nullptr,
+  CorrectionCandidateCallback *CCC =

r356925 - [Sema][NFCI] Don't allocate storage for the various CorrectionCandidateCallback unless we are going to do some typo correction

2019-03-25 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Mon Mar 25 10:08:51 2019
New Revision: 356925

URL: http://llvm.org/viewvc/llvm-project?rev=356925&view=rev
Log:
[Sema][NFCI] Don't allocate storage for the various CorrectionCandidateCallback 
unless we are going to do some typo correction

The various CorrectionCandidateCallbacks are currently heap-allocated
unconditionally. This was needed because of delayed typo correction.
However these allocations represent currently 15.4% of all allocations
(number of allocations) when parsing all of Boost (!), mostly because
of ParseCastExpression, ParseStatementOrDeclarationAfterAttrtibutes
and isCXXDeclarationSpecifier. Note that all of these callback objects
are small. Let's not do this.

Instead initially allocate the callback on the stack, and only do a
heap allocation if we are going to do some typo correction. Do this by:

1. Adding a clone function to each callback, which will do a polymorphic
   clone of the callback. This clone function is required to be implemented
   by every callback (of which there is a fair amount). Make sure this is
   the case by making it pure virtual.

2. Use this clone function when we are going to try to correct a typo.

This additionally cut the time of -fsyntax-only on all of Boost by 0.5%
(not that much, but still something). No functional changes intended.

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

Reviewed By: rnk


Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Sema/TypoCorrection.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=356925&r1=356924&r2=356925&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Mar 25 10:08:51 2019
@@ -789,9 +789,8 @@ private:
 /// Annotation was successful.
 ANK_Success
   };
-  AnnotatedNameKind
-  TryAnnotateName(bool IsAddressOfOperand,
-  std::unique_ptr CCC = nullptr);
+  AnnotatedNameKind TryAnnotateName(bool IsAddressOfOperand,
+CorrectionCandidateCallback *CCC = 
nullptr);
 
   /// Push a tok::annot_cxxscope token onto the token stream.
   void AnnotateScopeToken(CXXScopeSpec &SS, bool IsNewAnnotation);

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=356925&r1=356924&r2=356925&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Mar 25 10:08:51 2019
@@ -1914,11 +1914,11 @@ public:
   ///expression.
   ///
   /// \param CCC The correction callback, if typo correction is desired.
-  NameClassification
-  ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name,
-   SourceLocation NameLoc, const Token &NextToken,
-   bool IsAddressOfOperand,
-   std::unique_ptr CCC = nullptr);
+  NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
+  IdentifierInfo *&Name, SourceLocation 
NameLoc,
+  const Token &NextToken,
+  bool IsAddressOfOperand,
+  CorrectionCandidateCallback *CCC = nullptr);
 
   /// Describes the detailed kind of a template name. Used in diagnostics.
   enum class TemplateNameKindForDiagnostics {
@@ -3266,7 +3266,7 @@ private:
   makeTypoCorrectionConsumer(const DeclarationNameInfo &Typo,
  Sema::LookupNameKind LookupKind, Scope *S,
  CXXScopeSpec *SS,
- std::unique_ptr CCC,
+ CorrectionCandidateCallback &CCC,
  DeclContext *MemberContext, bool EnteringContext,
  const ObjCObjectPointerType *OPT,
  bool E

[clang-tools-extra] r356923 - Attempt to fix sphinx bot after r356897

2019-03-25 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Mar 25 09:50:24 2019
New Revision: 356923

URL: http://llvm.org/viewvc/llvm-project?rev=356923&view=rev
Log:
Attempt to fix sphinx bot after r356897

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=356923&r1=356922&r2=356923&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Mon Mar 25 09:50:24 2019
@@ -144,7 +144,7 @@ Improvements to clang-tidy
   other than ``none``, and suggests to use the ``default(none)`` clause.
 
 Improvements to clang-include-fixer
--
+---
 
 The improvements are...
 


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


r356920 - [clang] Remove cmake warning message (NFC)

2019-03-25 Thread Evandro Menezes via cfe-commits
Author: evandro
Date: Mon Mar 25 09:38:48 2019
New Revision: 356920

URL: http://llvm.org/viewvc/llvm-project?rev=356920&view=rev
Log:
[clang] Remove cmake warning message (NFC)

Recognize an empty string for CLANG_DEFAULT_UNWINDLIB as a valid option.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=356920&r1=356919&r2=356920&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Mar 25 09:38:48 2019
@@ -276,7 +276,8 @@ if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   endif()
 endif()
 
-if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR
+if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "" OR
+CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR
 CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR
 CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
   message(WARNING "Resetting default unwindlib to use platform default")


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


[PATCH] D59743: [WebAssembly] Don't use default GetLinkerPath

2019-03-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Fuchsia.h:89
 
-  const char *getDefaultLinker() const override {
-return "ld.lld";
-  }
+  const char *getDefaultLinker() const override { return "ld.lld"; }
 

phosek wrote:
> This seems unrelated?
You're right.. I shouldn't have tried the sneak that past.  This change makes 
the output of "git grep getDefaultLinker" a lot more useful and confirms with 
the style guide so might still land it.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:57
+
+  return ToolChain.GetProgramPath("wasm-ld");
+}

phosek wrote:
> Nit: you could use `getDefaultLinker()` instead of hardcoding `wasm-ld` here 
> so if the name ever changes you only need to change the getter.
Done. My rational for this was that since the function has exactly one call 
site (here) it made more sense to keep the information local to its use


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59743/new/

https://reviews.llvm.org/D59743



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


[PATCH] D59743: [WebAssembly] Don't use default GetLinkerPath

2019-03-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 192126.
sbc100 marked 4 inline comments as done.
sbc100 added a comment.

- feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59743/new/

https://reviews.llvm.org/D59743

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/test/Driver/wasm-toolchain.c
  clang/test/Driver/wasm-toolchain.cpp

Index: clang/test/Driver/wasm-toolchain.cpp
===
--- clang/test/Driver/wasm-toolchain.cpp
+++ clang/test/Driver/wasm-toolchain.cpp
@@ -12,25 +12,25 @@
 
 // A basic C++ link command-line with unknown OS.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization with unknown OS.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=wasm-ld 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with known OS.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo -fuse-ld=wasm-ld --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi-musl" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization with known OS.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo %s --stdlib=c++ -fuse-ld=wasm-ld 2>&1 | FileCheck -check-prefix=LINK_OPT_KNOWN %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT_KNOWN %s
 // LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi-musl" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -12,25 +12,25 @@
 
 // A basic C link command-line with unknown OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with unknown OS.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with known OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi-musl" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with known OS.
 
-// RUN: %clang -###

[PATCH] D59743: [WebAssembly] Don't use default GetLinkerPath

2019-03-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 192125.
sbc100 marked an inline comment as done.
sbc100 added a comment.

- feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59743/new/

https://reviews.llvm.org/D59743

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/test/Driver/wasm-toolchain.c
  clang/test/Driver/wasm-toolchain.cpp

Index: clang/test/Driver/wasm-toolchain.cpp
===
--- clang/test/Driver/wasm-toolchain.cpp
+++ clang/test/Driver/wasm-toolchain.cpp
@@ -12,25 +12,25 @@
 
 // A basic C++ link command-line with unknown OS.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization with unknown OS.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=wasm-ld 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with known OS.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo -fuse-ld=wasm-ld --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi-musl" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization with known OS.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo %s --stdlib=c++ -fuse-ld=wasm-ld 2>&1 | FileCheck -check-prefix=LINK_OPT_KNOWN %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT_KNOWN %s
 // LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi-musl" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -12,25 +12,25 @@
 
 // A basic C link command-line with unknown OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with unknown OS.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with known OS.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-wasi-musl --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_KNOWN %s
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi-musl" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization with known OS.
 
-// RUN: %clang -###

[PATCH] D59774: [clang-format] Refine structured binding detection

2019-03-25 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59774/new/

https://reviews.llvm.org/D59774



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


  1   2   >