[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-06-16 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added a comment.

Please commit on my behalf.


https://reviews.llvm.org/D30406



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


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-06-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM. Thank you!

(Not sure if @NoQ wants to do a final review.)

Do you have commit access or should we commit on your behalf?


https://reviews.llvm.org/D30406



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


[PATCH] D34102: [analyzer] Add portability package for the checkers.

2017-06-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> eg. checkers for portability across linux/bsd should be off on windows by 
> default, checkers for non-portable C++ APIs should be off in plain C code, etc

Is the checker you are moving to portability off and not useful on Windows?


https://reviews.llvm.org/D34102



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


[PATCH] D34266: Static Analyzer - Localizability Checker: New Localizable APIs for macOS High Sierra & iOS 11

2017-06-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Thanks! Do you have commit access?


Repository:
  rL LLVM

https://reviews.llvm.org/D34266



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


[PATCH] D34301: [Sema] Make sure the definition of a referenced virtual function is emitted when it is final

2017-06-16 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

It looks




Comment at: lib/Sema/SemaExpr.cpp:14715
+if (Method->isVirtual() && !(Method->hasAttr() ||
+ Method->getParent()->hasAttr()))
   OdrUse = false;

Do you think it makes sense to eliminate all candidate virtual methods which 
can be devirtualized? If so, you could make "CanDevirtualizeMemberFunctionCall" 
a shared utility between Sema and CodeGen, and use it here. That function 
should give "the truth" about whether or not a call can be devirtualized.



Comment at: lib/Sema/SemaExpr.cpp:14717
   OdrUse = false;
   MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E, OdrUse);
 }

"MarkExprReferenced" has what looks like an incomplete version of 
"CanDevirtualizeMemberFunctionCall". Do you think there is an opportunity to 
share logic there as well?



Comment at: test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp:271
+// Derived::operator() is not emitted, there will be a linker error.
+(*ptr)();
+  }

Have you looked into why "ptr->operator()();" compiles? We are either missing a 
devirtualization opportunity, or we have inconsistent logic for setting 
MightBeOdrUse for member calls. Either way, I think this patch is the right 
vehicle to address the issue.


https://reviews.llvm.org/D34301



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


[PATCH] D34304: Allow CompilerInvocations to generate .d files.

2017-06-16 Thread Eric Christopher via Phabricator via cfe-commits
echristo edited reviewers, added: bkramer; removed: echristo.
echristo added a comment.

Going to let Ben review this. I'd rather not pass the bool down and he might 
know a way to avoid that here by knowing the code more :)


https://reviews.llvm.org/D34304



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


r305619 - Call setMustBuildLookupTable on TagDecls in ExternalASTMerger

2017-06-16 Thread Lang Hames via cfe-commits
Author: lhames
Date: Fri Jun 16 19:12:38 2017
New Revision: 305619

URL: http://llvm.org/viewvc/llvm-project?rev=305619=rev
Log:
Call setMustBuildLookupTable on TagDecls in ExternalASTMerger

Summary:
setMustBuildLookupTable should be called on imported TagDecls otherwise we may 
fail
to import their member decls (if they have any).

Not calling the setMustBuildLookupTable method results in a failure in the 
attached test
case when lookup for the 'x' member fails on struct S, which hasn't had its 
decls imported
elsewhere. (By contrast the member-in-struct testcase hasn't run into this issue
because the import of its decls is triggered when the struct instance is 
defined, and the
member access follows this).

Reviewers: spyffe, rsmith

Reviewed By: spyffe, rsmith

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

Added:
cfe/trunk/test/Import/indirect-struct-member-access/
cfe/trunk/test/Import/indirect-struct-member-access/Inputs/
cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c
cfe/trunk/test/Import/indirect-struct-member-access/test.c
Modified:
cfe/trunk/lib/AST/ExternalASTMerger.cpp

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=305619=305618=305619=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Fri Jun 16 19:12:38 2017
@@ -41,6 +41,7 @@ public:
   Decl *Imported(Decl *From, Decl *To) override {
 if (auto ToTag = dyn_cast(To)) {
   ToTag->setHasExternalLexicalStorage();
+  ToTag->setMustBuildLookupTable();
 } else if (auto ToNamespace = dyn_cast(To)) {
   ToNamespace->setHasExternalVisibleStorage();
 }

Added: cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c?rev=305619=auto
==
--- cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c (added)
+++ cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c Fri Jun 16 
19:12:38 2017
@@ -0,0 +1,3 @@
+struct S {
+  int a;
+};

Added: cfe/trunk/test/Import/indirect-struct-member-access/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/indirect-struct-member-access/test.c?rev=305619=auto
==
--- cfe/trunk/test/Import/indirect-struct-member-access/test.c (added)
+++ cfe/trunk/test/Import/indirect-struct-member-access/test.c Fri Jun 16 
19:12:38 2017
@@ -0,0 +1,4 @@
+// RUN: clang-import-test -import %S/Inputs/S.c -expression %s
+void expr(struct S *MyS) {
+  MyS->a = 3;
+}


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


Buildbot numbers for the week of 06/04/2017 - 06/10/2017

2017-06-16 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 06/04/2017 -
06/10/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername |  was_red
+--
 llvm-clang-x86_64-expensive-checks-win | 105:44:04
 sanitizer-x86_64-linux-bootstrap   | 65:37:52
 sanitizer-x86_64-linux-fast| 64:43:06
 sanitizer-x86_64-linux-autoconf| 37:27:36
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 36:30:01
 lld-x86_64-darwin13| 35:53:14
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 34:43:26
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 34:15:00
 perf-x86_64-penryn-O3  | 29:08:58
 clang-ppc64be-linux-lnt| 27:38:03
 clang-cmake-aarch64-full   | 26:19:16
 clang-s390x-linux-lnt  | 26:11:53
 clang-ppc64be-linux-multistage | 26:01:30
 clang-s390x-linux-multistage   | 25:59:17
 clang-ppc64be-linux| 25:50:59
 clang-s390x-linux  | 25:47:42
 perf-x86_64-penryn-O3-polly| 25:45:29
 clang-ppc64le-linux| 25:41:55
 clang-ppc64le-linux-multistage | 25:41:54
 clang-cmake-aarch64-42vma  | 24:35:42
 clang-cmake-aarch64-39vma  | 24:24:17
 clang-cmake-armv7-a15-full | 24:20:57
 sanitizer-ppc64be-linux| 23:46:25
 clang-cmake-thumbv7-a15-full-sh| 23:27:29
 sanitizer-ppc64le-linux| 22:58:19
 lldb-x86_64-darwin-13.4| 20:28:04
 clang-atom-d525-fedora-rel | 17:20:48
 lldb-x86_64-ubuntu-14.04-android   | 17:00:45
 clang-x64-ninja-win7   | 16:59:17
 libcxx-libcxxabi-libunwind-arm-linux   | 16:27:17
 lldb-amd64-ninja-netbsd8   | 15:35:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 15:15:07
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 14:38:18
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 14:20:13
 sanitizer-x86_64-linux | 14:15:35
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z | 14:05:19
 clang-x86-windows-msvc2015 | 13:50:46
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 13:15:29
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu | 12:50:03
 sanitizer-windows  | 11:40:13
 clang-cmake-aarch64-lld| 10:55:39
 clang-cmake-armv7-a15-selfhost | 09:27:42
 clang-with-lto-ubuntu  | 09:27:19
 clang-with-thin-lto-ubuntu | 08:44:19
 clang-lld-x86_64-2stage| 08:28:01
 clang-x86_64-linux-selfhost-modules| 08:25:41
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions  | 08:15:01
 clang-cuda-build   | 07:58:11
 clang-cmake-aarch64-quick  | 07:49:59
 llvm-hexagon-elf   | 07:47:16
 clang-x86_64-linux-selfhost-modules-2  | 07:42:00
 clang-hexagon-elf  | 07:34:36
 clang-cmake-thumbv7-a15| 07:30:39
 clang-cmake-armv7-a15  | 07:20:34
 clang-bpf-build| 07:18:37
 clang-x86_64-debian-fast   | 07:07:21
 clang-cmake-armv7-a15-selfhost-neon| 05:49:06
 llvm-sphinx-docs   | 04:15:09
 lldb-windows7-android  | 02:27:50
 

Buildbot numbers for the week of 05/28/2017 - 06/03/2017

2017-06-16 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 05/28/2017 - 06/03/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 sanitizer-x86_64-linux-bootstrap   | 84:16:25
 clang-x86_64-linux-selfhost-modules-2  | 82:19:04
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan | 75:27:53
 clang-cmake-armv7-a15-selfhost | 53:14:17
 sanitizer-x86_64-linux | 47:33:56
 llvm-clang-x86_64-expensive-checks-win | 44:09:29
 clang-cmake-aarch64-lld| 32:32:09
 clang-x64-ninja-win7   | 25:44:28
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 25:18:39
 clang-x86-windows-msvc2015 | 24:47:17
 clang-s390x-linux-lnt  | 19:26:17
 sanitizer-ppc64le-linux| 15:27:06
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 14:49:52
 sanitizer-x86_64-linux-fast| 14:31:15
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 14:20:19
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 13:57:47
 sanitizer-x86_64-linux-fuzzer  | 13:35:35
 sanitizer-windows  | 12:54:41
 libcxx-libcxxabi-libunwind-aarch64-linux   | 11:31:46
 clang-cmake-thumbv7-a15| 11:12:50
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 11:03:21
 clang-native-arm-lnt   | 10:57:49
 clang-ppc64be-linux-multistage | 10:57:10
 clang-cmake-aarch64-full   | 10:24:09
 clang-cmake-aarch64-quick  | 10:05:54
 sanitizer-ppc64be-linux| 09:46:16
 clang-ppc64be-linux-lnt| 09:37:43
 clang-with-thin-lto-ubuntu | 08:48:32
 clang-with-lto-ubuntu  | 08:07:48
 clang-ppc64be-linux| 07:53:35
 perf-x86_64-penryn-O3-polly-parallel-fast  | 07:36:58
 perf-x86_64-penryn-O3  | 07:30:41
 perf-x86_64-penryn-O3-polly-fast   | 07:30:25
 clang-x86_64-linux-selfhost-modules| 07:11:06
 clang-ppc64le-linux-multistage | 07:05:49
 clang-lld-x86_64-2stage| 06:56:47
 perf-x86_64-penryn-O3-polly-unprofitable   | 06:50:09
 clang-bpf-build| 06:40:44
 perf-x86_64-penryn-O3-polly| 06:30:04
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 06:26:41
 lldb-x86_64-ubuntu-14.04-buildserver   | 06:11:32
 clang-cmake-armv7-a15-selfhost-neon| 05:43:35
 clang-ppc64le-linux| 05:09:28
 sanitizer-x86_64-linux-autoconf| 05:00:28
 clang-cuda-build   | 04:59:43
 clang-s390x-linux  | 04:54:19
 lldb-x86-windows-msvc2015  | 04:52:10
 lld-x86_64-win7| 04:50:23
 lldb-amd64-ninja-freebsd11 | 04:49:06
 clang-x86_64-debian-fast   | 04:48:19
 lldb-windows7-android  | 04:40:41
 llvm-hexagon-elf   | 04:30:02
 clang-hexagon-elf  | 04:27:18
 clang-cmake-armv7-a15  | 03:55:42
 clang-cmake-armv7-a15-full | 03:52:15
 clang-cmake-thumbv7-a15-full-sh| 03:37:14
 lldb-x86_64-ubuntu-14.04-android   | 03:15:59
 lldb-x86_64-ubuntu-14.04-cmake | 02:52:43
 clang-cmake-aarch64-39vma  | 02:30:11
 clang-cmake-aarch64-42vma

Re: r284060 - Implement MS _BitScan intrinsics

2017-06-16 Thread Duncan P. N. Exon Smith via cfe-commits

> On Jun 16, 2017, at 11:02, Reid Kleckner  wrote:
> 
> We should fix it.

Agreed.

> We just need a new character code in the builtin function prototype encoding. 
> Currently there is no encoding for a portable int32_t that magically becomes 
> "long" on 32-bit Windows. The closest thing we have is 'W', which is used by 
> Neon intrinsics to select between "long" and "long long". It was added in 
> r202004.

Yup, I saw the 'W' as well.  That's the same approach I was using in a patch 
yesterday morning (I picked lowercase L ('l'), but there may be a better 
choice).  Likely Bruno will follow up with a working patch soon (I hit some 
problems with tests and then got tied up).

> On Fri, Jun 16, 2017 at 10:28 AM, Erik Schwiebert  > wrote:
> We (Office developers for Apple platforms at Microsoft) would prefer to have 
> the intrinsics work properly for LP64, as that will generate the most optimal 
> and efficient code. That said, we understand that this may be odd to 
> implement from the compiler's perspective and can work around it if the 
> intrinsics are not supported for ms-extensions+LP64. At the end of the day we 
> need the compiler to clearly adopt one of those two options, and not sit 
> somewhere in the middle as it currently does. We don't turn on any flags 
> other than -fms-extensions; we don’t attempt to define MSC_VER and we do 
> conditionalize code based on __clang__ so the code is aware it is being 
> compiled by clang vs MSVC.
> 
> So I think we'd prefer what Duncan and Apple are offering to do, but if the 
> larger clang community thinks that is a bad idea and wants to explicitly 
> disable the intrinsics, we could live with that.
> 
> Thanks,
> Schwieb
> 
> -Original Message-
> From: Erik Schwiebert
> Sent: Friday, June 16, 2017 8:49 AM
> To: 'Bruno Cardoso Lopes'  >; Brian Kelley  >; Tomasz Kukielka  >
> Cc: dexonsm...@apple.com ; Reid Kleckner 
> >; cfe-commits 
> >
> Subject: RE: r284060 - Implement MS _BitScan intrinsics
> 
> Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK intrinsics 
> headers. I'm not sure which method we'd prefer, so I'll walk down the hall 
> and ask them. Tomasz is our header maestro (because we play crazy 
> #include_next games so we can use both Windows and macOS SDKs!)
> 
> We'll get back to you ASAP.
> 
> Schwieb
> 
> -Original Message-
> From: Bruno Cardoso Lopes [mailto:bruno.card...@gmail.com 
> ]
> Sent: Thursday, June 15, 2017 4:41 PM
> To: Erik Schwiebert >
> Cc: dexonsm...@apple.com ; Reid Kleckner 
> >; cfe-commits 
> >
> Subject: Re: r284060 - Implement MS _BitScan intrinsics
> 
> On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
> > wrote:
> > On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
> > > wrote:
> >> SGTM too. Regarding Duncan's last question -- I can't think of any such 
> >> customer. :) If you all think the right thing for clang to do is to infer 
> >> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!
> 
> Thinking more about this; what if we mark such builtins as unsupported
> for "LP64 (Darwin) + ms_extensions" and then you provide the
> definitions via intrin.h (we can generate a compiler macro for this
> scenario and conditionalize the include_next as we do for _MSC_VER)?
> Do you use this header at all? Are there any other MS related flags
> that get passed to the compiler?
> 
> > SGTM as well!
> >
> >>
> >> Thanks all!
> >> Schwieb
> >>
> >> -Original Message-
> >> From: dexonsm...@apple.com  
> >> [mailto:dexonsm...@apple.com ]
> >> Sent: Monday, June 12, 2017 1:55 PM
> >> To: Reid Kleckner >
> >> Cc: Saleem Abdulrasool  >> >; Albert Gutowski  >> >; David Majnemer  >> >; cfe-commits 
> >> >; Erik 
> >> Schwiebert >
> >> Subject: Re: r284060 - Implement MS _BitScan intrinsics
> >>
> >>
> >>> On Jun 12, 2017, at 12:44, Reid Kleckner  >>> 

[PATCH] D34249: [libc++] Don't use UTIME_OMIT to detect utimensat on Apple

2017-06-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: src/experimental/filesystem/operations.cpp:23-28
+// We can use the presence of UTIME_OMIT to detect platforms that do not
+// provide utimensat, with some exceptions on OS X.
+#if !defined(UTIME_OMIT) || \
+   (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && 
__MAC_OS_X_VERSION_MIN_REQUIRED < 1030)
+#define _LIBCPP_HAS_NO_UTIMENSAT
+#endif

dexonsmith wrote:
> dexonsmith wrote:
> > EricWF wrote:
> > > dexonsmith wrote:
> > > > Sadly this isn't quite sufficient.  As per Jack's suggested SDK patch 
> > > > in the PR, we need to enumerate the platforms :/.  I think this should 
> > > > be the right logic for the four Darwin platforms:
> > > > 
> > > > (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && 
> > > > __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0) || \
> > > > (defined(__WATCH_OS_VERSION_MIN_REQUIRED) &&  
> > > > __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_4_0)  || \
> > > > (defined(__TV_OS_VERSION_MIN_REQUIRED) && 
> > > > __TV_OS_VERSION_MIN_REQUIRED < __TVOS_11_0)   || \
> > > > (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && 
> > > > __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13)
> > > > 
> > > Do we have to do the below dance for all of those macros?
> > > 
> > > ```
> > > #if !defined(__FOO_VERSION_MIN_REQUIRED) && 
> > > defined(__ENVIROMENT_FOO_VERSION_MIN_REQUIRED)
> > > #define __FOO_VERSION_MIN_REQUIRED __ENVIROMENT_FOO_VERSION_REQUIRED
> > > #endif
> > > ```
> > Nope.  I just advised you to use the wrong ones.  Use the `__ENVIRONMENT` 
> > versions pre-defined by Clang.
> Specifically:
> 
> ```
> clang/lib/Basic/Targets.cpp:183:  
> Builder.defineMacro("__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__", Str);
> clang/lib/Basic/Targets.cpp:185:  
> Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__",
> clang/lib/Basic/Targets.cpp:197:
> Builder.defineMacro("__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__", Str);
> clang/lib/Basic/Targets.cpp:221:
> Builder.defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", Str);
> ```
Ack, I'll switch to using those.



Comment at: src/experimental/filesystem/operations.cpp:22-24
+#if defined(__APPLE__)
+#include 
+#endif

dexonsmith wrote:
> EricWF wrote:
> > dexonsmith wrote:
> > > I only just noticed you were including Availability.h.  That shouldn't be 
> > > necessary, since the macros should be defined by the compiler.
> > __MAC_10_13 et al are defined in `Availability.h`, and 
> > `AvailabilityInternal.h` seems to do the `__ENV` dance described above. Are 
> > you sure it's not needed?
> I don't think the dance is necessary, since libcxx won't be overriding those 
> macros.
> 
> Also, we can skip the `__MAC_10_13` macros, ala src/chrono.cpp.
Using the `__MAC_10_13` seems preferable, and since this is in a source file, 
and not a header, we lose nothing by including ``. 



https://reviews.llvm.org/D34249



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


[PATCH] D34264: Introduce -Wunguarded-availability-new, which is like -Wunguarded-availability, except that it's enabled by default for new deployment targets

2017-06-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 102902.
arphaman marked an inline comment as done.
arphaman added a comment.

Swap the checking operators and bring back the accidentally deleted code.


Repository:
  rL LLVM

https://reviews.llvm.org/D34264

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/unguarded-availability-new.m

Index: test/SemaObjC/unguarded-availability-new.m
===
--- /dev/null
+++ test/SemaObjC/unguarded-availability-new.m
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability-new -DNO_WARNING -fblocks -fsyntax-only -verify %s
+
+// unguarded-availability implies unguarded-availability-new:
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -Wno-unguarded-availability-new -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -DNO_WARNING  -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-ios11 -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.12 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios10.3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos10 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+#ifdef MAC
+#define PLATFORM macos
+#define NEXT 10.14
+
+#define AVAILABLE_PREV __attribute__((availability(macos, introduced = 10.12)))
+#define AVAILABLE_CURRENT __attribute__((availability(macos, introduced = 10.13)))
+#define AVAILABLE_NEXT __attribute__((availability(macos, introduced = 10.14)))
+#endif
+
+#ifdef IOS
+#define PLATFORM ios
+#define NEXT 12
+
+#define AVAILABLE_PREV __attribute__((availability(ios, introduced = 10)))
+#define AVAILABLE_CURRENT __attribute__((availability(ios, introduced = 11)))
+#define AVAILABLE_NEXT __attribute__((availability(ios, introduced = 12)))
+#endif
+
+#ifdef TVOS
+#define PLATFORM tvos
+#define NEXT 13
+
+#define AVAILABLE_PREV __attribute__((availability(tvos, introduced = 10)))
+#define AVAILABLE_CURRENT __attribute__((availability(tvos, introduced = 11)))
+#define AVAILABLE_NEXT __attribute__((availability(tvos, introduced = 13)))
+#endif
+
+#ifdef WATCHOS
+#define PLATFORM watchos
+#define NEXT 5
+
+#define AVAILABLE_PREV __attribute__((availability(watchos, introduced = 3)))
+#define AVAILABLE_CURRENT __attribute__((availability(watchos, introduced = 4)))
+#define AVAILABLE_NEXT __attribute__((availability(watchos, introduced = 5)))
+#endif
+
+void previouslyAvailable() AVAILABLE_PREV;
+void currentlyAvailable() AVAILABLE_CURRENT;
+#ifdef WARN_CURRENT
+  // expected-note@-2 {{'currentlyAvailable' has been explicitly marked partial here}}
+#endif
+void willBeAvailabile() AVAILABLE_NEXT;
+#ifndef NO_WARNING
+  // expected-note@-2 {{'willBeAvailabile' has been explicitly marked partial here}}

[PATCH] D34301: [Sema] Make sure the definition of a referenced virtual function is emitted when it is final

2017-06-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
Herald added a subscriber: Prazek.

The test case I added used to fail because of a linker error.

Linkage failed because Sema::MarkDeclRefReferenced would prevent the virtual 
method definition from being emitted by setting OdrUse=false and then code-gen 
would devirtualized the virtual call because its class is marked final.

This patch fixes the bug.

rdar://problem/27455779


https://reviews.llvm.org/D34301

Files:
  lib/Sema/SemaExpr.cpp
  test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp


Index: test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
===
--- test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -241,3 +241,40 @@
 return static_cast(b)->f();
   }
 }
+
+namespace Test11 {
+  // Check that the definition of Derived::operator() is emitted.
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN6Test111SIiE4foo1Ev(
+  // CHECK: call void @_ZN6Test111SIiE7DerivedclEv(
+  // CHECK: define linkonce_odr void @_ZN6Test111SIiE7DerivedclEv(
+  class Base {
+  public:
+virtual void operator()() {
+}
+  };
+
+  template
+  struct S {
+class Derived final : public Base {
+public:
+  void operator()() override {
+  }
+};
+
+Derived *ptr = nullptr;
+
+void foo1() {
+  if (ptr) {
+// This call gets devirtualized. If the definition of
+// Derived::operator() is not emitted, there will be a linker error.
+(*ptr)();
+  }
+}
+  };
+
+  void foo2() {
+S *s = new S;
+s->foo1();
+  }
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14711,7 +14711,8 @@
   // if it's a qualified reference.
   bool OdrUse = true;
   if (CXXMethodDecl *Method = dyn_cast(E->getDecl()))
-if (Method->isVirtual())
+if (Method->isVirtual() && !(Method->hasAttr() ||
+ Method->getParent()->hasAttr()))
   OdrUse = false;
   MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E, OdrUse);
 }


Index: test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
===
--- test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -241,3 +241,40 @@
 return static_cast(b)->f();
   }
 }
+
+namespace Test11 {
+  // Check that the definition of Derived::operator() is emitted.
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN6Test111SIiE4foo1Ev(
+  // CHECK: call void @_ZN6Test111SIiE7DerivedclEv(
+  // CHECK: define linkonce_odr void @_ZN6Test111SIiE7DerivedclEv(
+  class Base {
+  public:
+virtual void operator()() {
+}
+  };
+
+  template
+  struct S {
+class Derived final : public Base {
+public:
+  void operator()() override {
+  }
+};
+
+Derived *ptr = nullptr;
+
+void foo1() {
+  if (ptr) {
+// This call gets devirtualized. If the definition of
+// Derived::operator() is not emitted, there will be a linker error.
+(*ptr)();
+  }
+}
+  };
+
+  void foo2() {
+S *s = new S;
+s->foo1();
+  }
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14711,7 +14711,8 @@
   // if it's a qualified reference.
   bool OdrUse = true;
   if (CXXMethodDecl *Method = dyn_cast(E->getDecl()))
-if (Method->isVirtual())
+if (Method->isVirtual() && !(Method->hasAttr() ||
+ Method->getParent()->hasAttr()))
   OdrUse = false;
   MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E, OdrUse);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34264: Introduce -Wunguarded-availability-new, which is like -Wunguarded-availability, except that it's enabled by default for new deployment targets

2017-06-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:6944
-diag = !ObjCPropertyAccess ? diag::err_unavailable
-   : diag::err_property_method_unavailable;
-diag_message = diag::err_unavailable_message;

erik.pilkington wrote:
> Why did you remove the AR_Unavailable checking?
Ooops, that was a mistake


Repository:
  rL LLVM

https://reviews.llvm.org/D34264



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


[PATCH] D34264: Introduce -Wunguarded-availability-new, which is like -Wunguarded-availability, except that it's enabled by default for new deployment targets

2017-06-16 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:6944
-diag = !ObjCPropertyAccess ? diag::err_unavailable
-   : diag::err_property_method_unavailable;
-diag_message = diag::err_unavailable_message;

Why did you remove the AR_Unavailable checking?



Comment at: lib/Sema/SemaDeclAttr.cpp:7021
+bool NewWarning =
+!S.Diags.isIgnored(diag::warn_unguarded_availability_new, Loc) &&
+shouldDiagnoseAvailabilityByDefault(

I think checking Diags::isIgnored is fairly expensive, maybe we should swap the 
operands to the '&&' so that it is only done if necessary?


Repository:
  rL LLVM

https://reviews.llvm.org/D34264



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


[PATCH] D34294: Rework libcxx strerror_r handling.

2017-06-16 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

In https://reviews.llvm.org/D34294#782856, @jyknight wrote:

> In https://reviews.llvm.org/D34294#782806, @krytarowski wrote:
>
> > New one is harder to comprehend and less portable (usage of `__atribute__`).
>
>
> I can't disagree more strongly.  This is fundamentally portable C++ code -- 
> __attribute__((unused)) is simply warning suppression.
>  I used it directly, because I saw other .cpp files in libcxx already did so. 
> If it needs to be conditioned, it could be.


OK with me.


https://reviews.llvm.org/D34294



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


[PATCH] D34212: docs: Document binary compatibility issue due to bug in gcc

2017-06-16 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Could you add links to this document in index.rst and UsersManual.rst?




Comment at: docs/BinaryCompatibilityWithOtherCompilers.rst:39
+
+https://llvm.org/PR33161

This link is still showing up as 'insecure'. Mind using this?: 
https://bugs.llvm.org/show_bug.cgi?id=33161


https://reviews.llvm.org/D34212



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


Re: r305600 - [Driver] Do a PATH lookup if needed when using -no-canonical-prefixes

2017-06-16 Thread Joerg Sonnenberger via cfe-commits
On Fri, Jun 16, 2017 at 10:40:18PM -, Petr Hosek via cfe-commits wrote:
> @@ -53,8 +53,15 @@ using namespace clang::driver;
>  using namespace llvm::opt;
>  
>  std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
> -  if (!CanonicalPrefixes)
> -return Argv0;
> +  if (!CanonicalPrefixes) {
> +SmallString<128> ExecutablePath(Argv0);
> +// Do a PATH lookup if Argv0 isn't a valid path.
> +if (!llvm::sys::fs::exists(ExecutablePath))
> +  if (llvm::ErrorOr P =
> +  llvm::sys::findProgramByName(ExecutablePath))
> +ExecutablePath = *P;
> +return ExecutablePath.str();
> +  }
>  
>// This just needs to be some symbol in the binary; C++ doesn't
>// allow taking the address of ::main however.

This will fail if the current directory contains a file with the name of
the program, won't it? I think the correct order here would be to check
if ExecutablePath contains a path separator and if it doesn't, call
findProgramByName.

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


[PATCH] D34290: [Driver] Do a PATH lookup when using only program name with -no-canonical-prefixes

2017-06-16 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305600: [Driver] Do a PATH lookup if needed when using 
-no-canonical-prefixes (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D34290?vs=102881=102894#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34290

Files:
  cfe/trunk/tools/driver/driver.cpp


Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -53,8 +53,15 @@
 using namespace llvm::opt;
 
 std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
-  if (!CanonicalPrefixes)
-return Argv0;
+  if (!CanonicalPrefixes) {
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup if Argv0 isn't a valid path.
+if (!llvm::sys::fs::exists(ExecutablePath))
+  if (llvm::ErrorOr P =
+  llvm::sys::findProgramByName(ExecutablePath))
+ExecutablePath = *P;
+return ExecutablePath.str();
+  }
 
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.


Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -53,8 +53,15 @@
 using namespace llvm::opt;
 
 std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
-  if (!CanonicalPrefixes)
-return Argv0;
+  if (!CanonicalPrefixes) {
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup if Argv0 isn't a valid path.
+if (!llvm::sys::fs::exists(ExecutablePath))
+  if (llvm::ErrorOr P =
+  llvm::sys::findProgramByName(ExecutablePath))
+ExecutablePath = *P;
+return ExecutablePath.str();
+  }
 
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305600 - [Driver] Do a PATH lookup if needed when using -no-canonical-prefixes

2017-06-16 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Jun 16 17:40:18 2017
New Revision: 305600

URL: http://llvm.org/viewvc/llvm-project?rev=305600=rev
Log:
[Driver] Do a PATH lookup if needed when using -no-canonical-prefixes

When -no-canonical-prefixes option is used and argv0 contains only
a program name, we need to do a PATH lookup to get an executable path,
otherwise the return value won't be a valid path and any subsequent
uses of it (e.g. when invoking -cc1) will fail with an error.

This patch fixes PR9576.

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

Modified:
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=305600=305599=305600=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Fri Jun 16 17:40:18 2017
@@ -53,8 +53,15 @@ using namespace clang::driver;
 using namespace llvm::opt;
 
 std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
-  if (!CanonicalPrefixes)
-return Argv0;
+  if (!CanonicalPrefixes) {
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup if Argv0 isn't a valid path.
+if (!llvm::sys::fs::exists(ExecutablePath))
+  if (llvm::ErrorOr P =
+  llvm::sys::findProgramByName(ExecutablePath))
+ExecutablePath = *P;
+return ExecutablePath.str();
+  }
 
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.


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


[PATCH] D34294: Rework libcxx strerror_r handling.

2017-06-16 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In https://reviews.llvm.org/D34294#782806, @krytarowski wrote:

> New one is harder to comprehend and less portable (usage of `__atribute__`).


I can't disagree more strongly.  This is fundamentally portable C++ code -- 
__attribute__((unused)) is simply warning suppression.
I used it directly, because I saw other .cpp files in libcxx already did so. If 
it needs to be conditioned, it could be.

> Or better:



> #elif __GLIBC__ || (__ANDROID_API__ - 0) >= 23
>  If I understand correctly, Android adopted GNU version.

No, we can't use that conditional, because android and glibc aren't the only 
ones to have adopted the GNU variant. As I mentioned, newlib uses it also.

We *may* be able to use a different conditional than what's there or what you 
suggested, but solving the problem once and for all by using the function type 
is certainly a better solution.


https://reviews.llvm.org/D34294



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


[PATCH] D34264: Introduce -Wunguarded-availability-new, which is like -Wunguarded-availability, except that it's enabled by default for new deployment targets

2017-06-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 102891.
arphaman marked 2 inline comments as done.
arphaman added a comment.

Remove the assert and support the other partial availability warnings.


Repository:
  rL LLVM

https://reviews.llvm.org/D34264

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/unguarded-availability-new.m

Index: test/SemaObjC/unguarded-availability-new.m
===
--- /dev/null
+++ test/SemaObjC/unguarded-availability-new.m
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability-new -DNO_WARNING -fblocks -fsyntax-only -verify %s
+
+// unguarded-availability implies unguarded-availability-new:
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -Wno-unguarded-availability-new -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -DNO_WARNING  -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-ios11 -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.12 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios10.3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos10 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
+
+#ifdef MAC
+#define PLATFORM macos
+#define NEXT 10.14
+
+#define AVAILABLE_PREV __attribute__((availability(macos, introduced = 10.12)))
+#define AVAILABLE_CURRENT __attribute__((availability(macos, introduced = 10.13)))
+#define AVAILABLE_NEXT __attribute__((availability(macos, introduced = 10.14)))
+#endif
+
+#ifdef IOS
+#define PLATFORM ios
+#define NEXT 12
+
+#define AVAILABLE_PREV __attribute__((availability(ios, introduced = 10)))
+#define AVAILABLE_CURRENT __attribute__((availability(ios, introduced = 11)))
+#define AVAILABLE_NEXT __attribute__((availability(ios, introduced = 12)))
+#endif
+
+#ifdef TVOS
+#define PLATFORM tvos
+#define NEXT 13
+
+#define AVAILABLE_PREV __attribute__((availability(tvos, introduced = 10)))
+#define AVAILABLE_CURRENT __attribute__((availability(tvos, introduced = 11)))
+#define AVAILABLE_NEXT __attribute__((availability(tvos, introduced = 13)))
+#endif
+
+#ifdef WATCHOS
+#define PLATFORM watchos
+#define NEXT 5
+
+#define AVAILABLE_PREV __attribute__((availability(watchos, introduced = 3)))
+#define AVAILABLE_CURRENT __attribute__((availability(watchos, introduced = 4)))
+#define AVAILABLE_NEXT __attribute__((availability(watchos, introduced = 5)))
+#endif
+
+void previouslyAvailable() AVAILABLE_PREV;
+void currentlyAvailable() AVAILABLE_CURRENT;
+#ifdef WARN_CURRENT
+  // expected-note@-2 {{'currentlyAvailable' has been explicitly marked partial here}}
+#endif
+void willBeAvailabile() AVAILABLE_NEXT;
+#ifndef NO_WARNING
+  // expected-note@-2 {{'willBeAvailabile' has been explicitly marked partial here}}

[PATCH] D34299: [ubsan] Improve diagnostics for return value checks (clang)

2017-06-16 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

This patch makes ubsan's nonnull return value diagnostics more precise,
which makes the diagnostics more useful when there are multiple return
statements in a function. Example:

  1 |__attribute__((returns_nonnull)) char *foo() {
  2 |  if (...) {
  3 |return expr_which_might_evaluate_to_null();
  4 |  } else {
  5 |return another_expr_which_might_evaluate_to_null();
  6 |  }
  7 |} // <- The current diagnostic always points here!
  
  runtime error: Null returned from Line 7, Column 2!

With this patch, the diagnostic would point to either Line 3, Column 5
or Line 5, Column 5.

This is done by emitting source location metadata for each return
statement in a sanitized function. The runtime is passed a pointer to
the appropriate metadata so that it can prepare and deduplicate reports.

Compiler-rt patch (with more tests): https://reviews.llvm.org/D34298


https://reviews.llvm.org/D34299

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenObjC/ubsan-nonnull-and-nullability.m
  test/CodeGenObjC/ubsan-nullability.m

Index: test/CodeGenObjC/ubsan-nullability.m
===
--- test/CodeGenObjC/ubsan-nullability.m
+++ test/CodeGenObjC/ubsan-nullability.m
@@ -2,15 +2,15 @@
 // RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=nullability-arg,nullability-assign,nullability-return -w %s -o - | FileCheck %s
 // RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=nullability-arg,nullability-assign,nullability-return -w %s -o - | FileCheck %s
 
-// CHECK: [[NONNULL_RV_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 109, i32 1 {{.*}} i32 100, i32 6
+// CHECK: [[NONNULL_RV_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 100, i32 6
 // CHECK: [[NONNULL_ARG_LOC:@.*]] = private unnamed_addr global {{.*}} i32 204, i32 15 {{.*}} i32 190, i32 23
 // CHECK: [[NONNULL_ASSIGN1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 305, i32 9
 // CHECK: [[NONNULL_ASSIGN2_LOC:@.*]] = private unnamed_addr global {{.*}} i32 405, i32 10
 // CHECK: [[NONNULL_ASSIGN3_LOC:@.*]] = private unnamed_addr global {{.*}} i32 506, i32 10
 // CHECK: [[NONNULL_INIT1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 604, i32 25
 // CHECK: [[NONNULL_INIT2_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 707, i32 26
 // CHECK: [[NONNULL_INIT2_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 707, i32 29
-// CHECK: [[NONNULL_RV_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 817, i32 1 {{.*}} i32 800, i32 6
+// CHECK: [[NONNULL_RV_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 800, i32 6
 
 #define NULL ((void *)0)
 #define INULL ((int *)NULL)
@@ -22,7 +22,7 @@
   // CHECK: br i1 true, label %[[NULL:.*]], label %[[NONULL:.*]], !nosanitize
   // CHECK: [[NULL]]:
   // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize
-  // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_nullability_return{{.*}}[[NONNULL_RV_LOC1]]
   return p;
   // CHECK: [[NONULL]]:
@@ -111,7 +111,7 @@
   // CHECK: br i1 [[DO_RV_CHECK_2]], label %[[NULL:.*]], label %[[NONULL:.*]], !nosanitize
   // CHECK: [[NULL]]:
   // CHECK-NEXT: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize
-  // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_nullability_return{{.*}}[[NONNULL_RV_LOC2]]
   return arg1;
   // CHECK: [[NONULL]]:
@@ -132,7 +132,7 @@
   // CHECK: br i1 [[DO_RV_CHECK]], label %[[NULL:.*]], label %[[NONULL:.*]], !nosanitize
   // CHECK: [[NULL]]:
   // CHECK-NEXT: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize
-  // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_nullability_return{{.*}}
   return arg1;
   // CHECK: [[NONULL]]:
@@ -146,7 +146,7 @@
   // CHECK: br i1 [[DO_RV_CHECK]], label %[[NULL:.*]], label %[[NONULL:.*]], !nosanitize
   // CHECK: [[NULL]]:
   // CHECK-NEXT: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize
-  // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_nullability_return{{.*}}
   return arg1;
   // CHECK: [[NONULL]]:
Index: test/CodeGenObjC/ubsan-nonnull-and-nullability.m
===
--- test/CodeGenObjC/ubsan-nonnull-and-nullability.m
+++ test/CodeGenObjC/ubsan-nonnull-and-nullability.m
@@ -8,12 +8,16 @@
 __attribute__((returns_nonnull)) int *_Nonnull f1(int *_Nonnull p) {
   // CHECK: entry:
   // CHECK-NEXT: [[ADDR:%.*]] = alloca i32*
+  // CHECK-NEXT: [[SLOC_PTR:%.*]] = alloca i8*
+  // CHECK-NEXT: store i8* null, i8** [[SLOC_PTR]]
   // CHECK-NEXT: store 

[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros

2017-06-16 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi updated this revision to Diff 102885.
akyrtzi added a comment.

Improving doc comment.


https://reviews.llvm.org/D34263

Files:
  include/clang/Lex/Preprocessor.h
  include/clang/Lex/PreprocessorOptions.h
  lib/Lex/PPDirectives.cpp
  lib/Lex/PPExpressions.cpp
  test/Index/singe-file-parse.m

Index: test/Index/singe-file-parse.m
===
--- test/Index/singe-file-parse.m
+++ test/Index/singe-file-parse.m
@@ -9,3 +9,103 @@
 // CHECK: [[@LINE+1]]:8: ObjCInstanceMethodDecl=some_meth
 -(void)some_meth;
 @end
+
+#if 1
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test1
+@interface Test1 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test2 @end
+#endif
+
+#if 0
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test3 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test4
+@interface Test4 @end
+#endif
+
+#if SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test5
+@interface Test5 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test6
+@interface Test6 @end
+#endif
+
+#define SOMETHING_DEFINED 1
+#if SOMETHING_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test7
+@interface Test7 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test8 @end
+#endif
+
+#if defined(SOMETHING_NOT_DEFINED)
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test9
+@interface Test9 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test10
+@interface Test10 @end
+#endif
+
+#if defined(SOMETHING_DEFINED)
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test11
+@interface Test11 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test12 @end
+#endif
+
+#if SOMETHING_NOT_DEFINED1
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test13
+@interface Test13 @end
+#elif SOMETHING_NOT_DEFINED2
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test14
+@interface Test14 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test15
+@interface Test15 @end
+#endif
+
+#ifdef SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test19
+@interface Test19 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test20
+@interface Test20 @end
+#endif
+
+#ifdef SOMETHING_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test21
+@interface Test21 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test22 @end
+#endif
+
+#ifndef SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test23
+@interface Test23 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test24
+@interface Test24 @end
+#endif
+
+#ifndef SOMETHING_DEFINED
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test25 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test26
+@interface Test26 @end
+#endif
+
+#if 1 < SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test27
+@interface Test27 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test28
+@interface Test28 @end
+#endif
Index: lib/Lex/PPExpressions.cpp
===
--- lib/Lex/PPExpressions.cpp
+++ lib/Lex/PPExpressions.cpp
@@ -73,6 +73,7 @@
 
 static bool EvaluateDirectiveSubExpr(PPValue , unsigned MinPrec,
  Token , bool ValueLive,
+ bool ,
  Preprocessor );
 
 /// DefinedTracker - This struct is used while parsing expressions to keep track
@@ -93,6 +94,7 @@
   /// TheMacro - When the state is DefinedMacro or NotDefinedMacro, this
   /// indicates the macro that was checked.
   IdentifierInfo *TheMacro;
+  bool IncludedUndefinedIds = false;
 };
 
 /// EvaluateDefined - Process a 'defined(sym)' expression.
@@ -128,6 +130,7 @@
   MacroDefinition Macro = PP.getMacroDefinition(II);
   Result.Val = !!Macro;
   Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
+  DT.IncludedUndefinedIds = !Macro;
 
   // If there is a macro, mark it used.
   if (Result.Val != 0 && ValueLive)
@@ -255,6 +258,8 @@
 Result.Val.setIsUnsigned(false);  // "0" is signed intmax_t 0.
 Result.setIdentifier(II);
 Result.setRange(PeekTok.getLocation());
+DT.IncludedUndefinedIds = (II->getTokenID() != tok::kw_true &&
+   II->getTokenID() != tok::kw_false);
 PP.LexNonComment(PeekTok);
 return false;
   }
@@ -400,7 +405,8 @@
   // Just use DT unmodified as our result.
 } else {
   // Otherwise, we have something like (x+y), and we consumed '(x'.
-  if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive, PP))
+  if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive,
+   DT.IncludedUndefinedIds, PP))
 return true;
 
   if (PeekTok.isNot(tok::r_paren)) {
@@ -532,6 +538,7 @@
 /// evaluation, such as division by zero warnings.
 static bool EvaluateDirectiveSubExpr(PPValue , unsigned MinPrec,
  Token , bool ValueLive,
+ bool ,

[PATCH] D34294: Rework libcxx strerror_r handling.

2017-06-16 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

Or better:

  #elif __GLIBC__ || (__ANDROID_API__ - 0) >= 23

If I understand correctly, Android adopted GNU version.


https://reviews.llvm.org/D34294



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


[PATCH] D34294: Rework libcxx strerror_r handling.

2017-06-16 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

New one is harder to comprehend and less portable (usage of `__atribute__`).

Can we just replace

  #elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) &&
 \
  (!defined(__ANDROID__) || __ANDROID_API__ >= 23)

with `#elif __GLIBC__`?


https://reviews.llvm.org/D34294



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


[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros

2017-06-16 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

Thanks, this looks good to me.  I'd appreciate if @klimek could take a quick 
look though.




Comment at: include/clang/Lex/PreprocessorOptions.h:102
+  /// in preprocessor directive conditions it causes all blocks to be parsed so
+  /// that the client can get the max amount of info from the parser.
   bool SingleFileParseMode = false;

nitpick: should use the full words "maximum" and probably also "information" 
here


https://reviews.llvm.org/D34263



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


[PATCH] D34290: [Driver] Do a PATH lookup when using only program name with -no-canonical-prefixes

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

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D34290



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


[PATCH] D34290: [Driver] Do a PATH lookup when using only program name with -no-canonical-prefixes

2017-06-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 102881.
phosek marked an inline comment as done.
phosek edited the summary of this revision.

Repository:
  rL LLVM

https://reviews.llvm.org/D34290

Files:
  tools/driver/driver.cpp


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -53,8 +53,15 @@
 using namespace llvm::opt;
 
 std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
-  if (!CanonicalPrefixes)
-return Argv0;
+  if (!CanonicalPrefixes) {
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup if Argv0 isn't a valid path.
+if (!llvm::sys::fs::exists(ExecutablePath))
+  if (llvm::ErrorOr P =
+  llvm::sys::findProgramByName(ExecutablePath))
+ExecutablePath = *P;
+return ExecutablePath.str();
+  }
 
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -53,8 +53,15 @@
 using namespace llvm::opt;
 
 std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
-  if (!CanonicalPrefixes)
-return Argv0;
+  if (!CanonicalPrefixes) {
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup if Argv0 isn't a valid path.
+if (!llvm::sys::fs::exists(ExecutablePath))
+  if (llvm::ErrorOr P =
+  llvm::sys::findProgramByName(ExecutablePath))
+ExecutablePath = *P;
+return ExecutablePath.str();
+  }
 
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34290: [Driver] Do a PATH lookup when using only program name with -no-canonical-prefixes

2017-06-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: tools/driver/driver.cpp:58
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup, if there are no directory components.
+if (llvm::sys::path::filename(ExecutablePath) == ExecutablePath)

hans wrote:
> What if "clang" is in the current directory? Presumably that should then be 
> preferred over PATH.. will we get that right with this patch?
> 
> Another way would be to check access() on Argv0, which is what we do when 
> trying to execute anyway. Is there any downside to that?
I don't think there should be any downside to that approach.


Repository:
  rL LLVM

https://reviews.llvm.org/D34290



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


[PATCH] D34267: do more processing in clang-fuzzer (use EmitAssemblyAction)

2017-06-16 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

ignore this for now. I've found how to make it even more interesting (by using 
llvm::InitializeAllTargets, etc), will send an update later.


https://reviews.llvm.org/D34267



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 102877.
jyu2 added a comment.

update patch


https://reviews.llvm.org/D3

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  test/CXX/except/except.spec/p11.cpp
  test/SemaCXX/warn-throw-out-noexcept-func.cpp

Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -279,6 +279,150 @@
 }
 
 //===--===//
+// Check for throw in a non-throwing function.
+//===--===//
+enum ThrowState {
+  FoundNoPathForThrow,
+  FoundPathForThrow,
+  FoundPathWithNoThrowOutFunction,
+};
+
+static bool isThrowCaught(const CXXThrowExpr *Throw,
+  const CXXCatchStmt *Catch) {
+  const Type *ThrowType = nullptr;
+  if (Throw->getSubExpr())
+ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  if (!ThrowType)
+return false;
+  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+  if (!CaughtType)
+return true;
+  if (ThrowType->isReferenceType())
+ThrowType = ThrowType->castAs()
+->getPointeeType()
+->getUnqualifiedDesugaredType();
+  if (CaughtType->isReferenceType())
+CaughtType = CaughtType->castAs()
+ ->getPointeeType()
+ ->getUnqualifiedDesugaredType();
+  if (CaughtType == ThrowType)
+return true;
+  const CXXRecordDecl *CaughtAsRecordType =
+  CaughtType->getPointeeCXXRecordDecl();
+  const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl();
+  if (CaughtAsRecordType && ThrowTypeAsRecordType)
+return ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType);
+  return false;
+}
+
+static bool isThrowCaughtByHandlers(const CXXThrowExpr *CE,
+const CXXTryStmt *TryStmt) {
+  for (unsigned H = 0, E = TryStmt->getNumHandlers(); H < E; ++H) {
+if (isThrowCaught(CE, TryStmt->getHandler(H)))
+  return true;
+  }
+  return false;
+}
+
+static bool doesThrowEscapePath(CFGBlock Block, SourceLocation ) {
+  for (const auto  : Block) {
+if (B.getKind() != CFGElement::Statement)
+  continue;
+const auto *CE = dyn_cast(B.getAs()->getStmt());
+if (!CE)
+  continue;
+
+OpLoc = CE->getThrowLoc();
+for (const auto  : Block.succs()) {
+  if (!I.isReachable())
+continue;
+  if (const auto *Terminator =
+  dyn_cast_or_null(I->getTerminator()))
+if (isThrowCaughtByHandlers(CE, Terminator))
+  return false;
+}
+return true;
+  }
+  return false;
+}
+
+static bool hasThrowOutNonThrowingFunc(SourceLocation , CFG *BodyCFG) {
+
+  unsigned ExitID = BodyCFG->getExit().getBlockID();
+
+  SmallVector States(BodyCFG->getNumBlockIDs(),
+ FoundNoPathForThrow);
+  States[BodyCFG->getEntry().getBlockID()] = FoundPathWithNoThrowOutFunction;
+
+  SmallVector Stack;
+  Stack.push_back(>getEntry());
+  while (!Stack.empty()) {
+CFGBlock *CurBlock = Stack.back();
+Stack.pop_back();
+
+unsigned ID = CurBlock->getBlockID();
+ThrowState CurState = States[ID];
+if (CurState == FoundPathWithNoThrowOutFunction) {
+  if (ExitID == ID)
+continue;
+
+  if (doesThrowEscapePath(*CurBlock, OpLoc))
+CurState = FoundPathForThrow;
+}
+
+// Loop over successor blocks and add them to the Stack if their state
+// changes.
+for (const auto  : CurBlock->succs())
+  if (I.isReachable()) {
+unsigned NextID = I->getBlockID();
+if (NextID == ExitID && CurState == FoundPathForThrow) {
+  States[NextID] = CurState;
+} else if (States[NextID] < CurState) {
+  States[NextID] = CurState;
+  Stack.push_back(I);
+}
+  }
+  }
+  // Return true if the exit node is reachable, and only reachable through
+  // a throw expression.
+  return States[ExitID] == FoundPathForThrow;
+}
+
+static void EmitDiagForCXXThrowInNonThrowingFunc(Sema , SourceLocation OpLoc,
+ const FunctionDecl *FD) {
+  if (!S.getSourceManager().isInSystemHeader(OpLoc)) {
+S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD;
+if (S.getLangOpts().CPlusPlus11 &&
+(isa(FD) ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete))
+  S.Diag(FD->getLocation(), diag::note_throw_in_dtor);
+else
+  S.Diag(FD->getLocation(), diag::note_throw_in_function);
+  }
+}
+
+static void checkThrowInNonThrowingFunc(Sema , const FunctionDecl *FD,
+AnalysisDeclContext ) {
+  CFG *BodyCFG = AC.getCFG();
+  if (!BodyCFG)
+

[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:27
+}
+
+struct N : A {

aaron.ballman wrote:
> jyu2 wrote:
> > aaron.ballman wrote:
> > > Can you add a test case like:
> > > ```
> > > struct Throws {
> > >   ~Throws() noexcept(false);
> > > };
> > > 
> > > struct ShouldDiagnose {
> > >   Throws T;
> > >   ~ShouldDiagnose() {}
> > > };
> > > ```
> > > I would expect `~ShouldDiagnose()` to be diagnosed as allowing exceptions 
> > > to escape because of the destructor for `Throws`.
> > In C++11, destructors are implicitly throw() unless any member or base of 
> > the type has a destructor with a different exception specification.
> > 
> > In the case of:
> > struct Throws {
> >   ~Throws() noexcept(false);
> > };
> > 
> > struct ShouldDiagnose {
> >   Throws T;
> >   ~ShouldDiagnose() {}
> > };
> > 
> > You should not see diagnose for   ~ShouldDiagnose() , since   
> > ShouldDiagnose has a member ofr Throws which has destructor with 
> > noexcept(false); therefor
> >   ~ShouldDiagnose has  noexcept(false).
> > 
> > But I add test case which remove (false) part.
> Good point! A test case with `noexcept(false)` would be handy as would one 
> where `~ShouldDiagnose()` is marked `noexcept(true)` explicitly rather than 
> picking up the `noexcept(false)` implicitly.
Okay I add two tests ShouldDiagnoes and ShouldNotDiagnoes. 


https://reviews.llvm.org/D3



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


[PATCH] D34294: Rework libcxx strerror_r handling.

2017-06-16 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
Herald added subscribers: krytarowski, srhines.

The set of #ifdefs used to handle the two incompatible variants of
strerror_r were not complete (they didn't handle newlib appropriately).

Rather than attempting to make the ifdefs more complex, make them
unnecessary by choosing which behavior to use dependent upon the
return type.


https://reviews.llvm.org/D34294

Files:
  src/system_error.cpp


Index: src/system_error.cpp
===
--- src/system_error.cpp
+++ src/system_error.cpp
@@ -73,39 +73,59 @@
   std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
   return string(buffer);
 }
-#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && 
\
-(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
-// GNU Extended version
-string do_strerror_r(int ev) {
-char buffer[strerror_buff_size];
-char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
-return string(ret);
-}
 #else
-// POSIX version
+
+// Only one of the two following functions will be used, depending on
+// the return type of strerror_r:
+
+// For the GNU variant, a char* return value:
+__attribute__((unused)) const char *
+handle_strerror_r_return(char *strerror_return, char *buffer) {
+  // GNU always returns a string pointer in its return value. The
+  // string might point to either the input buffer, or a static
+  // buffer, but we don't care which.
+  return strerror_return;
+}
+
+// For the POSIX variant: an int return value.
+__attribute__((unused)) const char *
+handle_strerror_r_return(int strerror_return, char *buffer) {
+  // The POSIX variant either:
+  // - fills in the provided buffer and returns 0
+  // - returns a positive error value, or
+  // - returns -1 and fills in errno with an error value.
+  if (strerror_return == 0)
+return buffer;
+
+  // Only handle EINVAL. Other errors abort.
+  int new_errno = strerror_return == -1 ? errno : strerror_return;
+  if (new_errno == EINVAL)
+return "";
+
+  _LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerror_r");
+  // FIXME maybe? 'strerror_buff_size' is likely to exceed the
+  // maximum error size so ERANGE shouldn't be returned.
+  std::abort();
+}
+
+// This function handles both GNU and POSIX variants, dispatching to
+// one of the two above functions.
 string do_strerror_r(int ev) {
 char buffer[strerror_buff_size];
+// Preserve errno around the call. (The C++ standard requires that
+// system_error functions not modify errno).
 const int old_errno = errno;
-int ret;
-if ((ret = ::strerror_r(ev, buffer, strerror_buff_size)) != 0) {
-// If `ret == -1` then the error is specified using `errno`, otherwise
-// `ret` represents the error.
-const int new_errno = ret == -1 ? errno : ret;
-errno = old_errno;
-if (new_errno == EINVAL) {
-std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
-return string(buffer);
-} else {
-_LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from 
::strerr_r");
-// FIXME maybe? 'strerror_buff_size' is likely to exceed the
-// maximum error size so ERANGE shouldn't be returned.
-std::abort();
-}
+const char *error_message = handle_strerror_r_return(
+::strerror_r(ev, buffer, strerror_buff_size), buffer);
+// If we didn't get any message, print one now.
+if (!error_message[0]) {
+  std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
+  error_message = buffer;
 }
-return string(buffer);
+errno = old_errno;
+return string(error_message);
 }
 #endif
-
 } // end namespace
 #endif
 


Index: src/system_error.cpp
===
--- src/system_error.cpp
+++ src/system_error.cpp
@@ -73,39 +73,59 @@
   std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
   return string(buffer);
 }
-#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && \
-(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
-// GNU Extended version
-string do_strerror_r(int ev) {
-char buffer[strerror_buff_size];
-char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
-return string(ret);
-}
 #else
-// POSIX version
+
+// Only one of the two following functions will be used, depending on
+// the return type of strerror_r:
+
+// For the GNU variant, a char* return value:
+__attribute__((unused)) const char *
+handle_strerror_r_return(char *strerror_return, char *buffer) {
+  // GNU always returns a string pointer in its return value. The
+  // string might point to either the input buffer, or a static
+  // buffer, but we don't care which.
+  return strerror_return;
+}
+
+// For the POSIX variant: an int return value.
+__attribute__((unused)) const char *
+handle_strerror_r_return(int strerror_return, char 

[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/Attr.td:2421
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];

Prazek wrote:
> rnk wrote:
> > davide wrote:
> > > Prazek wrote:
> > > > majnemer wrote:
> > > > > selectany should work on targets other than "x86", "x86_64", "arm", 
> > > > > "thumb", etc. I think it is only necessary to require that it be a 
> > > > > COFF or ELF target.
> > > > Should we allow other OSes than Win32 and Linux?
> > > I guess everything ELF should be allowed.
> > Why not use weak_odr / linkonce_odr on MachO? Microsoft builds Office for 
> > Mac and I suspect they use `__declspec(selectany)`.
> I think this is what would happen right now. The question is - should we warn 
> about using declspec on macho? Beause not using comdat looks like "not 
> supporting" it, but I am not sure about it.
I'm pretty sure weak_odr / linkonce_odr with ld64 on macho are the same as 
having a comdat. LLVM didn't always have comdats, but it's supported inline 
functions for a very long time. We should support selectany there.


https://reviews.llvm.org/D33852



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


[PATCH] D34286: [clang-tidy] Fix type names in modernize-use-unique/shared_ptr checks.

2017-06-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 102871.
hokein added a comment.

Update


https://reviews.llvm.org/D34286

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -49,6 +49,14 @@
 
 struct Empty {};
 
+namespace {
+class Foo {};
+} // namespace
+
+namespace bar {
+class Bar {};
+} // namespace bar
+
 template 
 using unique_ptr_ = std::unique_ptr;
 
@@ -239,6 +247,20 @@
   std::unique_ptr PEmpty = std::unique_ptr(new Empty{});
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = 
std::make_unique(Empty{});
+
+  std::unique_ptr FF = std::unique_ptr(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
+  // CHECK-FIXES: std::unique_ptr FF = std::make_unique();
+  FF.reset(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: FF = std::make_unique();
+
+  std::unique_ptr BB = std::unique_ptr(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  // CHECK-FIXES: std::unique_ptr BB = std::make_unique();
+  BB.reset(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: BB = std::make_unique();
 }
 
 void aliases() {
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -16,6 +16,17 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+StringRef GetNewExprName(const CXXNewExpr *NewExpr,
+ const SourceManager ,
+ const LangOptions ) {
+  return clang::Lexer::getSourceText(
+  clang::CharSourceRange::getTokenRange(
+  
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
+  SM, Lang);
+}
+} // namespace
+
 const char MakeSmartPtrCheck::PointerType[] = "pointerType";
 const char MakeSmartPtrCheck::ConstructorCall[] = "constructorCall";
 const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
@@ -87,7 +98,7 @@
   StringRef ExprStr = Lexer::getSourceText(
   CharSourceRange::getCharRange(
   ConstructCallStart, Construct->getParenOrBraceRange().getBegin()),
-  SM, LangOptions(), );
+  SM, getLangOpts(), );
   if (Invalid)
 return;
 
@@ -102,7 +113,8 @@
 // we have to add it back.
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
 Diag << FixItHint::CreateInsertion(
-ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">");
+ConstructCallEnd,
+"<" + GetNewExprName(New, SM, getLangOpts()).str() + ">");
   } else {
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
   }
@@ -144,7 +156,7 @@
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(OperatorLoc, ExprEnd),
   (llvm::Twine(" = ") + makeSmartPtrFunctionName + "<" +
-   New->getAllocatedType().getAsString(getLangOpts()) + ">")
+   GetNewExprName(New, SM, getLangOpts()) + ">")
   .str());
 
   if (Expr->isArrow())


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -49,6 +49,14 @@
 
 struct Empty {};
 
+namespace {
+class Foo {};
+} // namespace
+
+namespace bar {
+class Bar {};
+} // namespace bar
+
 template 
 using unique_ptr_ = std::unique_ptr;
 
@@ -239,6 +247,20 @@
   std::unique_ptr PEmpty = std::unique_ptr(new Empty{});
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = std::make_unique(Empty{});
+
+  std::unique_ptr FF = std::unique_ptr(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
+  // CHECK-FIXES: std::unique_ptr FF = std::make_unique();
+  FF.reset(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: FF = std::make_unique();
+
+  std::unique_ptr BB = std::unique_ptr(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  // CHECK-FIXES: std::unique_ptr BB = std::make_unique();
+  BB.reset(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: BB = std::make_unique();
 }
 
 void aliases() {
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -16,6 +16,17 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+StringRef GetNewExprName(const CXXNewExpr *NewExpr,
+ const SourceManager ,
+ const LangOptions ) {
+  return clang::Lexer::getSourceText(
+ 

[PATCH] D34114: [clang] A better format for unnecessary packed warning.

2017-06-16 Thread Yan Wang via Phabricator via cfe-commits
yawanng added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D34114



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


[PATCH] D33253: [index] Fix typo: inferface -> interface

2017-06-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Btw, you can usually commit typo fixes and other similar changes without 
pre-commit reviews


Repository:
  rL LLVM

https://reviews.llvm.org/D33253



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


r305588 - [index] Fix typo: inferface -> interface

2017-06-16 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Fri Jun 16 15:58:26 2017
New Revision: 305588

URL: http://llvm.org/viewvc/llvm-project?rev=305588=rev
Log:
[index] Fix typo: inferface -> interface

Reviewers: arphaman

Reviewed By: arphaman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang-c/CXCompilationDatabase.h
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/CXCompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/CXCompilationDatabase.h?rev=305588=305587=305588=diff
==
--- cfe/trunk/include/clang-c/CXCompilationDatabase.h (original)
+++ cfe/trunk/include/clang-c/CXCompilationDatabase.h Fri Jun 16 15:58:26 2017
@@ -7,7 +7,7 @@
 |*
*|
 
|*===--===*|
 |*
*|
-|* This header provides a public inferface to use CompilationDatabase without 
*|
+|* This header provides a public interface to use CompilationDatabase without 
*|
 |* the full Clang C++ API.
*|
 |*
*|
 
\*===--===*/

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=305588=305587=305588=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Jun 16 15:58:26 2017
@@ -7,7 +7,7 @@
 |*
*|
 
|*===--===*|
 |*
*|
-|* This header provides a public inferface to a Clang library for extracting  
*|
+|* This header provides a public interface to a Clang library for extracting  
*|
 |* high-level symbol information from source files without exposing the full  
*|
 |* Clang C++ API. 
*|
 |*
*|


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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:27
+}
+
+struct N : A {

jyu2 wrote:
> aaron.ballman wrote:
> > Can you add a test case like:
> > ```
> > struct Throws {
> >   ~Throws() noexcept(false);
> > };
> > 
> > struct ShouldDiagnose {
> >   Throws T;
> >   ~ShouldDiagnose() {}
> > };
> > ```
> > I would expect `~ShouldDiagnose()` to be diagnosed as allowing exceptions 
> > to escape because of the destructor for `Throws`.
> In C++11, destructors are implicitly throw() unless any member or base of the 
> type has a destructor with a different exception specification.
> 
> In the case of:
> struct Throws {
>   ~Throws() noexcept(false);
> };
> 
> struct ShouldDiagnose {
>   Throws T;
>   ~ShouldDiagnose() {}
> };
> 
> You should not see diagnose for   ~ShouldDiagnose() , since   ShouldDiagnose 
> has a member ofr Throws which has destructor with noexcept(false); therefor
>   ~ShouldDiagnose has  noexcept(false).
> 
> But I add test case which remove (false) part.
Good point! A test case with `noexcept(false)` would be handy as would one 
where `~ShouldDiagnose()` is marked `noexcept(true)` explicitly rather than 
picking up the `noexcept(false)` implicitly.


https://reviews.llvm.org/D3



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 102868.
jyu2 added a comment.

Update patch


https://reviews.llvm.org/D3

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  test/CXX/except/except.spec/p11.cpp
  test/SemaCXX/warn-throw-out-noexcept-func.cpp

Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -279,6 +279,150 @@
 }
 
 //===--===//
+// Check for throw in a non-throwing function.
+//===--===//
+enum ThrowState {
+  FoundNoPathForThrow,
+  FoundPathForThrow,
+  FoundPathWithNoThrowOutFunction,
+};
+
+static bool isThrowCaught(const CXXThrowExpr *Throw,
+  const CXXCatchStmt *Catch) {
+  const Type *ThrowType = nullptr;
+  if (Throw->getSubExpr())
+ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  if (!ThrowType)
+return false;
+  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+  if (!CaughtType)
+return true;
+  if (ThrowType->isReferenceType())
+ThrowType = ThrowType->castAs()
+->getPointeeType()
+->getUnqualifiedDesugaredType();
+  if (CaughtType->isReferenceType())
+CaughtType = CaughtType->castAs()
+ ->getPointeeType()
+ ->getUnqualifiedDesugaredType();
+  if (CaughtType == ThrowType)
+return true;
+  const CXXRecordDecl *CaughtAsRecordType =
+  CaughtType->getPointeeCXXRecordDecl();
+  const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl();
+  if (CaughtAsRecordType && ThrowTypeAsRecordType)
+return ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType);
+  return false;
+}
+
+static bool isThrowCaughtByHandlers(const CXXThrowExpr *CE,
+const CXXTryStmt *TryStmt) {
+  for (unsigned H = 0, E = TryStmt->getNumHandlers(); H < E; ++H) {
+if (isThrowCaught(CE, TryStmt->getHandler(H)))
+  return true;
+  }
+  return false;
+}
+
+static bool doesThrowEscapePath(CFGBlock Block, SourceLocation ) {
+  for (const auto  : Block) {
+if (B.getKind() != CFGElement::Statement)
+  continue;
+const auto *CE = dyn_cast(B.getAs()->getStmt());
+if (!CE)
+  continue;
+
+OpLoc = CE->getThrowLoc();
+for (const auto  : Block.succs()) {
+  if (!I.isReachable())
+continue;
+  if (const auto *Terminator =
+  dyn_cast_or_null(I->getTerminator()))
+if (isThrowCaughtByHandlers(CE, Terminator))
+  return false;
+}
+return true;
+  }
+  return false;
+}
+
+static bool hasThrowOutNonThrowingFunc(SourceLocation , CFG *BodyCFG) {
+
+  unsigned ExitID = BodyCFG->getExit().getBlockID();
+
+  SmallVector States(BodyCFG->getNumBlockIDs(),
+ FoundNoPathForThrow);
+  States[BodyCFG->getEntry().getBlockID()] = FoundPathWithNoThrowOutFunction;
+
+  SmallVector Stack;
+  Stack.push_back(>getEntry());
+  while (!Stack.empty()) {
+CFGBlock *CurBlock = Stack.back();
+Stack.pop_back();
+
+unsigned ID = CurBlock->getBlockID();
+ThrowState CurState = States[ID];
+if (CurState == FoundPathWithNoThrowOutFunction) {
+  if (ExitID == ID)
+continue;
+
+  if (doesThrowEscapePath(*CurBlock, OpLoc))
+CurState = FoundPathForThrow;
+}
+
+// Loop over successor blocks and add them to the Stack if their state
+// changes.
+for (const auto  : CurBlock->succs())
+  if (I.isReachable()) {
+unsigned NextID = I->getBlockID();
+if (NextID == ExitID && CurState == FoundPathForThrow) {
+  States[NextID] = CurState;
+} else if (States[NextID] < CurState) {
+  States[NextID] = CurState;
+  Stack.push_back(I);
+}
+  }
+  }
+  // Return true if the exit node is reachable, and only reachable through
+  // a throw expression.
+  return States[ExitID] == FoundPathForThrow;
+}
+
+static void EmitDiagForCXXThrowInNonThrowingFunc(Sema , SourceLocation OpLoc,
+ const FunctionDecl *FD) {
+  if (!S.getSourceManager().isInSystemHeader(OpLoc)) {
+S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD;
+if (S.getLangOpts().CPlusPlus11 &&
+(isa(FD) ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete))
+  S.Diag(FD->getLocation(), diag::note_throw_in_dtor);
+else
+  S.Diag(FD->getLocation(), diag::note_throw_in_function);
+  }
+}
+
+static void checkThrowInNonThrowingFunc(Sema , const FunctionDecl *FD,
+AnalysisDeclContext ) {
+  CFG *BodyCFG = AC.getCFG();
+  if (!BodyCFG)
+

[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:1
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fexceptions -fsyntax-only -Wexceptions -verify -std=c++11
+struct A {

aaron.ballman wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > Please drop the svn auto props.
> > This does not appear to be done.
> This file still has the svn auto props.
I am so sorry.  Remove it.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:1
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fexceptions -fsyntax-only -Wexceptions -verify -std=c++11
+struct A {

aaron.ballman wrote:
> rnk wrote:
> > aaron.ballman wrote:
> > > I believe you can drop the -fcxx-exceptions as it should be implied by 
> > > -fexceptions.
> > It isn't at the -cc1 level, you need -fcxx-exceptions there. -fexceptions 
> > controls landingpad cleanup emission.
> Ah, thank you Reid, I forgot about that.
I can remove -fexceptions, since I only care for syntax.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:27
+}
+
+struct N : A {

aaron.ballman wrote:
> Can you add a test case like:
> ```
> struct Throws {
>   ~Throws() noexcept(false);
> };
> 
> struct ShouldDiagnose {
>   Throws T;
>   ~ShouldDiagnose() {}
> };
> ```
> I would expect `~ShouldDiagnose()` to be diagnosed as allowing exceptions to 
> escape because of the destructor for `Throws`.
In C++11, destructors are implicitly throw() unless any member or base of the 
type has a destructor with a different exception specification.

In the case of:
struct Throws {
  ~Throws() noexcept(false);
};

struct ShouldDiagnose {
  Throws T;
  ~ShouldDiagnose() {}
};

You should not see diagnose for   ~ShouldDiagnose() , since   ShouldDiagnose 
has a member ofr Throws which has destructor with noexcept(false); therefor
  ~ShouldDiagnose has  noexcept(false).

But I add test case which remove (false) part.


https://reviews.llvm.org/D3



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


r305586 - Killing a tab and some other spurious whitespace; NFC.

2017-06-16 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Jun 16 15:52:59 2017
New Revision: 305586

URL: http://llvm.org/viewvc/llvm-project?rev=305586=rev
Log:
Killing a tab and some other spurious whitespace; NFC.

Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=305586=305585=305586=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Jun 16 15:52:59 2017
@@ -517,7 +517,7 @@ void PrintPreprocessedAction::ExecuteAct
 // file.  This is mostly a sanity check in case the file has no 
 // newlines whatsoever.
 if (end - cur > 256) end = cur + 256;
- 
+
 while (next < end) {
   if (*cur == 0x0D) {  // CR
 if (*next == 0x0A)  // CRLF


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


[PATCH] D33816: [Sema][ObjC] Don't allow -Wunguarded-availability to be silenced with redeclarations

2017-06-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I find the change to the diagnostic for enum constants a bit off putting, since 
the warning can refer to the enum itself when an enum constant is used. I'd 
rather we say something like `'EnumConstant' is deprecated` and keep the note 
that this patch uses (`'Enum' has been explicitly marked deprecated here`).




Comment at: lib/Sema/SemaDeclAttr.cpp:7077
   if (K == AR_NotYetIntroduced)
-S.Diag(Loc, diag::note_partial_availability_silence) << D;
+if (NamedDecl *Enclosing = findEnclosingDeclToAnnotate(Ctx))
+  S.Diag(Enclosing->getLocStart(), diag::note_partial_availability_silence)

You can use `const auto *` here.



Comment at: lib/Sema/SemaExpr.cpp:115
 
-  if (const EnumConstantDecl *ECD = dyn_cast(D))
+  if (EnumConstantDecl *ECD = dyn_cast(D))
 if (Result == AR_Available) {

You can use `auto *` here.



Comment at: lib/Sema/SemaExpr.cpp:118
+  DeclContext *DC = ECD->getDeclContext();
+  if (EnumDecl *TheEnumDecl = dyn_cast(DC)) {
 Result = TheEnumDecl->getAvailability(Message);

You can use `auto *` here as well.


https://reviews.llvm.org/D33816



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


[PATCH] D34290: [Driver] Do a PATH lookup when using only program name with -no-canonical-prefixes

2017-06-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Thanks!

Please add to the description that this is for PR9576.




Comment at: tools/driver/driver.cpp:58
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup, if there are no directory components.
+if (llvm::sys::path::filename(ExecutablePath) == ExecutablePath)

What if "clang" is in the current directory? Presumably that should then be 
preferred over PATH.. will we get that right with this patch?

Another way would be to check access() on Argv0, which is what we do when 
trying to execute anyway. Is there any downside to that?


Repository:
  rL LLVM

https://reviews.llvm.org/D34290



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:1
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fexceptions -fsyntax-only -Wexceptions -verify -std=c++11
+struct A {

rnk wrote:
> aaron.ballman wrote:
> > I believe you can drop the -fcxx-exceptions as it should be implied by 
> > -fexceptions.
> It isn't at the -cc1 level, you need -fcxx-exceptions there. -fexceptions 
> controls landingpad cleanup emission.
Ah, thank you Reid, I forgot about that.


https://reviews.llvm.org/D3



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:1
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fexceptions -fsyntax-only -Wexceptions -verify -std=c++11
+struct A {

aaron.ballman wrote:
> I believe you can drop the -fcxx-exceptions as it should be implied by 
> -fexceptions.
It isn't at the -cc1 level, you need -fcxx-exceptions there. -fexceptions 
controls landingpad cleanup emission.


https://reviews.llvm.org/D3



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


[PATCH] D34277: [analyzer] Bump default performance thresholds?

2017-06-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This was an mixture of internal apple projects (user apps, drivers, deamons, 
whatever) with a relatively balanced selection of languages and levels of 
analyzer adoption. They amounted to ~16 hours of analysis CPU time (i.e. 4 
hours on a quad-core machine per run). I've also ran it on LLVM separately, and 
had similar observations. I'm totally welcoming the feedback from other 
codebases!

In https://reviews.llvm.org/D34277#782605, @zaks.anna wrote:

> > Maybe we should introduce another UMK_* for deeper analysis instead?
>
> The difference here is not substantial enough to warrant a new level. The 
> general motivation for bumping these numbers is that we've set the timeouts 
> many years ago and the hardware improved quite a bit since then.


Yeah, the point was mostly about default settings, for people who don't bother 
to tweak them, and adding more options essentially defeats the purpose.


https://reviews.llvm.org/D34277



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


[PATCH] D34256: [PR33394] Avoid lexing editor placeholders when running the preprocessor only

2017-06-16 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305576: [PR33394] Avoid lexing editor placeholders when 
Clang is used only (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D34256?vs=102764=102862#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34256

Files:
  cfe/trunk/include/clang/Lex/PreprocessorOptions.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/test/Frontend/pp-only-no-editor-placeholders.c

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2379,9 +2379,51 @@
   Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders);
 }
 
+static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
+  switch (Action) {
+  case frontend::ASTDeclList:
+  case frontend::ASTDump:
+  case frontend::ASTPrint:
+  case frontend::ASTView:
+  case frontend::EmitAssembly:
+  case frontend::EmitBC:
+  case frontend::EmitHTML:
+  case frontend::EmitLLVM:
+  case frontend::EmitLLVMOnly:
+  case frontend::EmitCodeGenOnly:
+  case frontend::EmitObj:
+  case frontend::FixIt:
+  case frontend::GenerateModule:
+  case frontend::GenerateModuleInterface:
+  case frontend::GeneratePCH:
+  case frontend::GeneratePTH:
+  case frontend::ParseSyntaxOnly:
+  case frontend::ModuleFileInfo:
+  case frontend::VerifyPCH:
+  case frontend::PluginAction:
+  case frontend::PrintDeclContext:
+  case frontend::RewriteObjC:
+  case frontend::RewriteTest:
+  case frontend::RunAnalysis:
+  case frontend::MigrateSource:
+return false;
+
+  case frontend::DumpRawTokens:
+  case frontend::DumpTokens:
+  case frontend::InitOnly:
+  case frontend::PrintPreamble:
+  case frontend::PrintPreprocessedInput:
+  case frontend::RewriteMacros:
+  case frontend::RunPreprocessorOnly:
+return true;
+  }
+  llvm_unreachable("invalid frontend action");
+}
+
 static void ParsePreprocessorArgs(PreprocessorOptions , ArgList ,
   FileManager ,
-  DiagnosticsEngine ) {
+  DiagnosticsEngine ,
+  frontend::ActionKind Action) {
   using namespace options;
   Opts.ImplicitPCHInclude = Args.getLastArgValue(OPT_include_pch);
   Opts.ImplicitPTHInclude = Args.getLastArgValue(OPT_include_pth);
@@ -2454,52 +2496,23 @@
 else
   Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library;
   }
+
+  // Always avoid lexing editor placeholders when we're just running the
+  // preprocessor as we never want to emit the
+  // "editor placeholder in source file" error in PP only mode.
+  if (isStrictlyPreprocessorAction(Action))
+Opts.LexEditorPlaceholders = false;
 }
 
 static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions ,
 ArgList ,
 frontend::ActionKind Action) {
   using namespace options;
 
-  switch (Action) {
-  case frontend::ASTDeclList:
-  case frontend::ASTDump:
-  case frontend::ASTPrint:
-  case frontend::ASTView:
-  case frontend::EmitAssembly:
-  case frontend::EmitBC:
-  case frontend::EmitHTML:
-  case frontend::EmitLLVM:
-  case frontend::EmitLLVMOnly:
-  case frontend::EmitCodeGenOnly:
-  case frontend::EmitObj:
-  case frontend::FixIt:
-  case frontend::GenerateModule:
-  case frontend::GenerateModuleInterface:
-  case frontend::GeneratePCH:
-  case frontend::GeneratePTH:
-  case frontend::ParseSyntaxOnly:
-  case frontend::ModuleFileInfo:
-  case frontend::VerifyPCH:
-  case frontend::PluginAction:
-  case frontend::PrintDeclContext:
-  case frontend::RewriteObjC:
-  case frontend::RewriteTest:
-  case frontend::RunAnalysis:
-  case frontend::MigrateSource:
-Opts.ShowCPP = 0;
-break;
-
-  case frontend::DumpRawTokens:
-  case frontend::DumpTokens:
-  case frontend::InitOnly:
-  case frontend::PrintPreamble:
-  case frontend::PrintPreprocessedInput:
-  case frontend::RewriteMacros:
-  case frontend::RunPreprocessorOnly:
+  if (isStrictlyPreprocessorAction(Action))
 Opts.ShowCPP = !Args.hasArg(OPT_dM);
-break;
-  }
+  else
+Opts.ShowCPP = 0;
 
   Opts.ShowComments = Args.hasArg(OPT_C);
   Opts.ShowLineMarkers = !Args.hasArg(OPT_P);
@@ -2626,7 +2639,8 @@
   // ParsePreprocessorArgs and remove the FileManager
   // parameters from the function and the "FileManager.h" #include.
   FileManager FileMgr(Res.getFileSystemOpts());
-  ParsePreprocessorArgs(Res.getPreprocessorOpts(), Args, FileMgr, Diags);
+  ParsePreprocessorArgs(Res.getPreprocessorOpts(), Args, FileMgr, Diags,
+Res.getFrontendOpts().ProgramAction);
   ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), Args,
   Res.getFrontendOpts().ProgramAction);
 
Index: 

r305576 - [PR33394] Avoid lexing editor placeholders when Clang is used only

2017-06-16 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 16 15:13:39 2017
New Revision: 305576

URL: http://llvm.org/viewvc/llvm-project?rev=305576=rev
Log:
[PR33394] Avoid lexing editor placeholders when Clang is used only
for preprocessing

r300667 added support for editor placeholder to Clang. That commit didn’t take
into account that users who use Clang for preprocessing only (-E) will get the
"editor placeholder in source file" error when preprocessing their source
(PR33394). This commit ensures that Clang doesn't lex editor placeholders when
running a preprocessor only action.

rdar://32718000

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

Added:
cfe/trunk/test/Frontend/pp-only-no-editor-placeholders.c
Modified:
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=305576=305575=305576=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Fri Jun 16 15:13:39 2017
@@ -98,6 +98,9 @@ public:
   /// When enabled, preprocessor is in a mode for parsing a single file only.
   bool SingleFileParseMode = false;
 
+  /// When enabled, the preprocessor will construct editor placeholder tokens.
+  bool LexEditorPlaceholders = true;
+
   /// \brief True if the SourceManager should report the original file name for
   /// contents of files that were remapped to other files. Defaults to true.
   bool RemappedFilesKeepOriginalName;
@@ -185,6 +188,7 @@ public:
 ImplicitPTHInclude.clear();
 TokenCache.clear();
 SingleFileParseMode = false;
+LexEditorPlaceholders = true;
 RetainRemappedFileBuffers = true;
 PrecompiledPreambleBytes.first = 0;
 PrecompiledPreambleBytes.second = 0;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=305576=305575=305576=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Jun 16 15:13:39 2017
@@ -2379,9 +2379,51 @@ static void ParseLangArgs(LangOptions 
   Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders);
 }
 
+static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
+  switch (Action) {
+  case frontend::ASTDeclList:
+  case frontend::ASTDump:
+  case frontend::ASTPrint:
+  case frontend::ASTView:
+  case frontend::EmitAssembly:
+  case frontend::EmitBC:
+  case frontend::EmitHTML:
+  case frontend::EmitLLVM:
+  case frontend::EmitLLVMOnly:
+  case frontend::EmitCodeGenOnly:
+  case frontend::EmitObj:
+  case frontend::FixIt:
+  case frontend::GenerateModule:
+  case frontend::GenerateModuleInterface:
+  case frontend::GeneratePCH:
+  case frontend::GeneratePTH:
+  case frontend::ParseSyntaxOnly:
+  case frontend::ModuleFileInfo:
+  case frontend::VerifyPCH:
+  case frontend::PluginAction:
+  case frontend::PrintDeclContext:
+  case frontend::RewriteObjC:
+  case frontend::RewriteTest:
+  case frontend::RunAnalysis:
+  case frontend::MigrateSource:
+return false;
+
+  case frontend::DumpRawTokens:
+  case frontend::DumpTokens:
+  case frontend::InitOnly:
+  case frontend::PrintPreamble:
+  case frontend::PrintPreprocessedInput:
+  case frontend::RewriteMacros:
+  case frontend::RunPreprocessorOnly:
+return true;
+  }
+  llvm_unreachable("invalid frontend action");
+}
+
 static void ParsePreprocessorArgs(PreprocessorOptions , ArgList ,
   FileManager ,
-  DiagnosticsEngine ) {
+  DiagnosticsEngine ,
+  frontend::ActionKind Action) {
   using namespace options;
   Opts.ImplicitPCHInclude = Args.getLastArgValue(OPT_include_pch);
   Opts.ImplicitPTHInclude = Args.getLastArgValue(OPT_include_pth);
@@ -2454,6 +2496,12 @@ static void ParsePreprocessorArgs(Prepro
 else
   Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library;
   }
+
+  // Always avoid lexing editor placeholders when we're just running the
+  // preprocessor as we never want to emit the
+  // "editor placeholder in source file" error in PP only mode.
+  if (isStrictlyPreprocessorAction(Action))
+Opts.LexEditorPlaceholders = false;
 }
 
 static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions ,
@@ -2461,45 +2509,10 @@ static void ParsePreprocessorOutputArgs(
 frontend::ActionKind Action) {
   using namespace options;
 
-  switch (Action) {
-  case frontend::ASTDeclList:
-  case frontend::ASTDump:
-  case frontend::ASTPrint:
-  case 

[PATCH] D34290: [Driver] Do a PATH lookup when using only program name with -no-canonical-prefixes

2017-06-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.

When -no-canonical-prefixes option is used and argv0 contains only
a program name, we need to do a PATH lookup to get an executable path,
otherwise the return value won't be a valid path and any subsequent
uses of it (e.g. invoking -cc1) will fail with an error.


Repository:
  rL LLVM

https://reviews.llvm.org/D34290

Files:
  tools/driver/driver.cpp


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -53,8 +53,15 @@
 using namespace llvm::opt;
 
 std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
-  if (!CanonicalPrefixes)
-return Argv0;
+  if (!CanonicalPrefixes) {
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup, if there are no directory components.
+if (llvm::sys::path::filename(ExecutablePath) == ExecutablePath)
+  if (llvm::ErrorOr P =
+  llvm::sys::findProgramByName(ExecutablePath))
+ExecutablePath = *P;
+return ExecutablePath.str();
+  }
 
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -53,8 +53,15 @@
 using namespace llvm::opt;
 
 std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
-  if (!CanonicalPrefixes)
-return Argv0;
+  if (!CanonicalPrefixes) {
+SmallString<128> ExecutablePath(Argv0);
+// Do a PATH lookup, if there are no directory components.
+if (llvm::sys::path::filename(ExecutablePath) == ExecutablePath)
+  if (llvm::ErrorOr P =
+  llvm::sys::findProgramByName(ExecutablePath))
+ExecutablePath = *P;
+return ExecutablePath.str();
+  }
 
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

A few more nits, but this feels like it's getting close to ready (at least, to 
me).




Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:1
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fexceptions -fsyntax-only -Wexceptions -verify -std=c++11
+struct A {

aaron.ballman wrote:
> aaron.ballman wrote:
> > Please drop the svn auto props.
> This does not appear to be done.
This file still has the svn auto props.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:1
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fexceptions -fsyntax-only -Wexceptions -verify -std=c++11
+struct A {

I believe you can drop the -fcxx-exceptions as it should be implied by 
-fexceptions.



Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:27
+}
+
+struct N : A {

Can you add a test case like:
```
struct Throws {
  ~Throws() noexcept(false);
};

struct ShouldDiagnose {
  Throws T;
  ~ShouldDiagnose() {}
};
```
I would expect `~ShouldDiagnose()` to be diagnosed as allowing exceptions to 
escape because of the destructor for `Throws`.


https://reviews.llvm.org/D3



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


r305574 - Ignore return value in test.

2017-06-16 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Jun 16 14:29:20 2017
New Revision: 305574

URL: http://llvm.org/viewvc/llvm-project?rev=305574=rev
Log:
Ignore return value in test.

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

Modified: cfe/trunk/test/Driver/m_and_mm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/m_and_mm.c?rev=305574=305573=305574=diff
==
--- cfe/trunk/test/Driver/m_and_mm.c (original)
+++ cfe/trunk/test/Driver/m_and_mm.c Fri Jun 16 14:29:20 2017
@@ -5,7 +5,7 @@
 // RUN: %clang -M -MM %s 2> %t
 // RUN: not grep "warning" %t
 
-// RUN: %clang -MMD -MD %s 2> %t
+// RUN: %clang -MMD -MD %s 2> %t || true
 // RUN: grep "warning" %t
 
 #warning "This warning shouldn't show up with -M and -MM"


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


[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros

2017-06-16 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi updated this revision to Diff 102859.
akyrtzi added a comment.

Enhanced doc-comment for the preprocessor option, and fixed indentation on a 
couple of calls.


https://reviews.llvm.org/D34263

Files:
  include/clang/Lex/Preprocessor.h
  include/clang/Lex/PreprocessorOptions.h
  lib/Lex/PPDirectives.cpp
  lib/Lex/PPExpressions.cpp
  test/Index/singe-file-parse.m

Index: test/Index/singe-file-parse.m
===
--- test/Index/singe-file-parse.m
+++ test/Index/singe-file-parse.m
@@ -9,3 +9,103 @@
 // CHECK: [[@LINE+1]]:8: ObjCInstanceMethodDecl=some_meth
 -(void)some_meth;
 @end
+
+#if 1
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test1
+@interface Test1 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test2 @end
+#endif
+
+#if 0
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test3 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test4
+@interface Test4 @end
+#endif
+
+#if SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test5
+@interface Test5 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test6
+@interface Test6 @end
+#endif
+
+#define SOMETHING_DEFINED 1
+#if SOMETHING_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test7
+@interface Test7 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test8 @end
+#endif
+
+#if defined(SOMETHING_NOT_DEFINED)
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test9
+@interface Test9 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test10
+@interface Test10 @end
+#endif
+
+#if defined(SOMETHING_DEFINED)
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test11
+@interface Test11 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test12 @end
+#endif
+
+#if SOMETHING_NOT_DEFINED1
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test13
+@interface Test13 @end
+#elif SOMETHING_NOT_DEFINED2
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test14
+@interface Test14 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test15
+@interface Test15 @end
+#endif
+
+#ifdef SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test19
+@interface Test19 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test20
+@interface Test20 @end
+#endif
+
+#ifdef SOMETHING_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test21
+@interface Test21 @end
+#else
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test22 @end
+#endif
+
+#ifndef SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test23
+@interface Test23 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test24
+@interface Test24 @end
+#endif
+
+#ifndef SOMETHING_DEFINED
+// CHECK-NOT: [[@LINE+1]]:12:
+@interface Test25 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test26
+@interface Test26 @end
+#endif
+
+#if 1 < SOMETHING_NOT_DEFINED
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test27
+@interface Test27 @end
+#else
+// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test28
+@interface Test28 @end
+#endif
Index: lib/Lex/PPExpressions.cpp
===
--- lib/Lex/PPExpressions.cpp
+++ lib/Lex/PPExpressions.cpp
@@ -73,6 +73,7 @@
 
 static bool EvaluateDirectiveSubExpr(PPValue , unsigned MinPrec,
  Token , bool ValueLive,
+ bool ,
  Preprocessor );
 
 /// DefinedTracker - This struct is used while parsing expressions to keep track
@@ -93,6 +94,7 @@
   /// TheMacro - When the state is DefinedMacro or NotDefinedMacro, this
   /// indicates the macro that was checked.
   IdentifierInfo *TheMacro;
+  bool IncludedUndefinedIds = false;
 };
 
 /// EvaluateDefined - Process a 'defined(sym)' expression.
@@ -128,6 +130,7 @@
   MacroDefinition Macro = PP.getMacroDefinition(II);
   Result.Val = !!Macro;
   Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
+  DT.IncludedUndefinedIds = !Macro;
 
   // If there is a macro, mark it used.
   if (Result.Val != 0 && ValueLive)
@@ -255,6 +258,8 @@
 Result.Val.setIsUnsigned(false);  // "0" is signed intmax_t 0.
 Result.setIdentifier(II);
 Result.setRange(PeekTok.getLocation());
+DT.IncludedUndefinedIds = (II->getTokenID() != tok::kw_true &&
+   II->getTokenID() != tok::kw_false);
 PP.LexNonComment(PeekTok);
 return false;
   }
@@ -400,7 +405,8 @@
   // Just use DT unmodified as our result.
 } else {
   // Otherwise, we have something like (x+y), and we consumed '(x'.
-  if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive, PP))
+  if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive,
+   DT.IncludedUndefinedIds, PP))
 return true;
 
   if (PeekTok.isNot(tok::r_paren)) {
@@ -532,6 +538,7 @@
 /// evaluation, such as division by zero warnings.
 static bool EvaluateDirectiveSubExpr(PPValue , unsigned MinPrec,
  Token , bool 

[PATCH] D34277: [analyzer] Bump default performance thresholds?

2017-06-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Once Artem gives more details about the codebase he tested on, I think it would 
be fine to commit this. We can revert/address concerns later if @a.sidorin or 
anyone else raises concerns based on further testing on their codebases.  
@a.sidorin, would this work for you?


https://reviews.llvm.org/D34277



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


[PATCH] D34277: [analyzer] Bump default performance thresholds?

2017-06-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> Maybe we should introduce another UMK_* for deeper analysis instead?

The difference here is not substantial enough to warrant a new level. The 
general motivation for bumping these numbers is that we've set the timeouts 
many years ago and the hardware improved quite a bit since then.


https://reviews.llvm.org/D34277



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


r305568 - [ubsan] docs: Add a note about pointers to volatile

2017-06-16 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Jun 16 13:38:43 2017
New Revision: 305568

URL: http://llvm.org/viewvc/llvm-project?rev=305568=rev
Log:
[ubsan] docs: Add a note about pointers to volatile

Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=305568=305567=305568=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Fri Jun 16 13:38:43 2017
@@ -148,6 +148,12 @@ You can also use the following check gro
  nullability does not have undefined behavior, it is often unintentional,
  so UBSan offers to catch it.
 
+Volatile
+
+
+The ``null``, ``alignment``, ``object-size``, and ``vptr`` checks do not apply
+to pointers to types with the ``volatile`` qualifier.
+
 Stack traces and report symbolization
 =
 If you want UBSan to print symbolized stack trace for each error report, you


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


[PATCH] D34252: Add arbitrary file/path support to clang-format style file selection

2017-06-16 Thread Dan Ciliske via Phabricator via cfe-commits
dciliske added a comment.

So... how should I get something added? That patch has been sitting for a 
couple weeks.

Should I work on that patch? If so, how do I work on it? This is the first time 
I'm working on a large OSS project.


https://reviews.llvm.org/D34252



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


[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros

2017-06-16 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: lib/Lex/PPDirectives.cpp:2774
+// the directive blocks.
+CurPPLexer->pushConditionalLevel(CI.IfLoc, /*wasskip*/false,
+   /*foundnonskip*/true, /*foundelse*/true);

akyrtzi wrote:
> benlangmuir wrote:
> > Why is wasSkipping false here?
> For `#if` it sets `wasskip` to `true` to indicate later for 
> `HandleElseDirective` that the block should not be skipped.
> But here (inside `HandleElseDirective`) setting `wasskip` doesn't really 
> affect anything, the `HandleEndifDirective` doesn't check it. I chose to set 
> it to `false` as indication that the `#else` block does get parsed.
Thanks for explaining. That makes sense to me.


https://reviews.llvm.org/D34263



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


[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros

2017-06-16 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: lib/Lex/PPDirectives.cpp:2774
+// the directive blocks.
+CurPPLexer->pushConditionalLevel(CI.IfLoc, /*wasskip*/false,
+   /*foundnonskip*/true, /*foundelse*/true);

benlangmuir wrote:
> Why is wasSkipping false here?
For `#if` it sets `wasskip` to `true` to indicate later for 
`HandleElseDirective` that the block should not be skipped.
But here (inside `HandleElseDirective`) setting `wasskip` doesn't really affect 
anything, the `HandleEndifDirective` doesn't check it. I chose to set it to 
`false` as indication that the `#else` block does get parsed.


https://reviews.llvm.org/D34263



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


[PATCH] D34287: Moved code hanlding precompiled preamble out of the ASTUnit.

2017-06-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D34287

Files:
  include/clang/Frontend/ASTUnit.h
  include/clang/Frontend/PrecompiledPreamble.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CMakeLists.txt
  lib/Frontend/PrecompiledPreamble.cpp

Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- /dev/null
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -0,0 +1,573 @@
+//===--- PrecompiledPreamble.cpp - Build precompiled preambles --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Helper class to build precompiled preamble.
+//
+//===--===//
+
+#include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Serialization/ASTWriter.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/CrashRecoveryContext.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/MutexGuard.h"
+
+using namespace clang;
+
+namespace {
+
+/// Keeps a track of files to be deleted in destructor.
+class TemporaryFiles {
+public:
+  // A static instance to be used by
+  static TemporaryFiles ();
+
+private:
+  // Disallow constructing the class directly.
+  TemporaryFiles() = default;
+  // Disallow copy.
+  TemporaryFiles(const TemporaryFiles &) = delete;
+
+public:
+  ~TemporaryFiles();
+
+  /// Adds \p File to a set of tracked files.
+  void addFile(StringRef File);
+
+  /// Remove \p File from disk and from the set of tracked files.
+  void removeFile(StringRef File);
+
+private:
+  llvm::sys::SmartMutex Mutex;
+  llvm::StringSet<> Files;
+};
+
+TemporaryFiles ::getInstance() {
+  static TemporaryFiles Instance;
+  return Instance;
+}
+
+TemporaryFiles::~TemporaryFiles() {
+  llvm::MutexGuard Guard(Mutex);
+  for (const auto  : Files)
+llvm::sys::fs::remove(File.getKey());
+}
+
+void TemporaryFiles::addFile(StringRef File) {
+  llvm::MutexGuard Guard(Mutex);
+  auto IsInserted = Files.insert(File).second;
+  assert(IsInserted && "File has already been added");
+}
+
+void TemporaryFiles::removeFile(StringRef File) {
+  llvm::MutexGuard Guard(Mutex);
+  auto WasPresent = Files.erase(File);
+  assert(WasPresent && "File was not tracked");
+  llvm::sys::fs::remove(File);
+}
+
+class PreambleMacroCallbacks : public PPCallbacks {
+public:
+  PreambleMacroCallbacks(PreambleCallbacks ) : Callbacks(Callbacks) {}
+
+  void MacroDefined(const Token ,
+const MacroDirective *MD) override {
+Callbacks.HandleMacroDefined(MacroNameTok, MD);
+  }
+
+private:
+  PreambleCallbacks 
+};
+
+class PrecompilePreambleAction : public ASTFrontendAction {
+public:
+  PrecompilePreambleAction(PreambleCallbacks )
+  : Callbacks(Callbacks) {}
+
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef InFile) override;
+
+  bool hasEmittedPreamblePCH() const { return HasEmittedPreamblePCH; }
+
+  void setEmittedPreamblePCH(ASTWriter ) {
+this->HasEmittedPreamblePCH = true;
+Callbacks.AfterPCHEmitted(Writer);
+  }
+
+  bool shouldEraseOutputFiles() override { return !hasEmittedPreamblePCH(); }
+  bool hasCodeCompletionSupport() const override { return false; }
+  bool hasASTFileSupport() const override { return false; }
+  TranslationUnitKind getTranslationUnitKind() override { return TU_Prefix; }
+
+private:
+  friend class PrecompilePreambleConsumer;
+
+  bool HasEmittedPreamblePCH = false;
+  PreambleCallbacks 
+};
+
+class PrecompilePreambleConsumer : public PCHGenerator {
+public:
+  PrecompilePreambleConsumer(PrecompilePreambleAction ,
+ const Preprocessor , StringRef isysroot,
+ std::unique_ptr Out)
+  : PCHGenerator(PP, "", isysroot, std::make_shared(),
+ ArrayRef(),
+ /*AllowASTWithErrors=*/true),
+Action(Action), Out(std::move(Out)) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+Action.Callbacks.HandleTopLevelDecl(DG);
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext ) override {
+PCHGenerator::HandleTranslationUnit(Ctx);
+if (!hasEmittedPCH())
+  return;
+
+// Write the generated bitstream to "Out".
+*Out << getPCH();

[PATCH] D6550: ASTImporter: Fix missing SourceLoc imports

2017-06-16 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Thank you Sean, I'll try.


https://reviews.llvm.org/D6550



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


[PATCH] D34286: [clang-tidy] Fix type names in modernize-use-unique/shared_ptr checks.

2017-06-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: xazax.hun.

If the class being created in unique_ptr is in anonymous nampespace, the
anonymous namespace will be included in the apply-fixes. This patch fix
this.

  namespace {
  class Foo {};
  }
  std::unique_ptr f;
  f.reset(new Foo());
  // Before the change: f = std::make_unique<(annonymous namespace)::Foo>();
  // After the change: f = std::make_unique();


https://reviews.llvm.org/D34286

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -49,6 +49,14 @@
 
 struct Empty {};
 
+namespace {
+class Foo {};
+} // namespace
+
+namespace bar {
+class Bar {};
+} // namespace bar
+
 template 
 using unique_ptr_ = std::unique_ptr;
 
@@ -239,6 +247,20 @@
   std::unique_ptr PEmpty = std::unique_ptr(new Empty{});
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = 
std::make_unique(Empty{});
+
+  std::unique_ptr FF = std::unique_ptr(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
+  // CHECK-FIXES: std::unique_ptr FF = std::make_unique();
+  FF.reset(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: FF = std::make_unique();
+
+  std::unique_ptr BB = std::unique_ptr(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  // CHECK-FIXES: std::unique_ptr BB = std::make_unique();
+  BB.reset(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: BB = std::make_unique();
 }
 
 void aliases() {
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -16,6 +16,17 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+StringRef GetWrittenConstructorName(const CXXNewExpr* NewExpr,
+const SourceManager& SM,
+const LangOptions& Lang) {
+  return clang::Lexer::getSourceText(
+  clang::CharSourceRange::getTokenRange(
+  
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
+  SM, Lang);
+}
+} // namespace
+
 const char MakeSmartPtrCheck::PointerType[] = "pointerType";
 const char MakeSmartPtrCheck::ConstructorCall[] = "constructorCall";
 const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
@@ -87,7 +98,7 @@
   StringRef ExprStr = Lexer::getSourceText(
   CharSourceRange::getCharRange(
   ConstructCallStart, Construct->getParenOrBraceRange().getBegin()),
-  SM, LangOptions(), );
+  SM, getLangOpts(), );
   if (Invalid)
 return;
 
@@ -102,7 +113,8 @@
 // we have to add it back.
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
 Diag << FixItHint::CreateInsertion(
-ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">");
+ConstructCallEnd,
+"<" + GetWrittenConstructorName(New, SM, getLangOpts()).str() + ">");
   } else {
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
   }
@@ -144,7 +156,7 @@
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(OperatorLoc, ExprEnd),
   (llvm::Twine(" = ") + makeSmartPtrFunctionName + "<" +
-   New->getAllocatedType().getAsString(getLangOpts()) + ">")
+   GetWrittenConstructorName(New, SM, getLangOpts()) + ">")
   .str());
 
   if (Expr->isArrow())


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -49,6 +49,14 @@
 
 struct Empty {};
 
+namespace {
+class Foo {};
+} // namespace
+
+namespace bar {
+class Bar {};
+} // namespace bar
+
 template 
 using unique_ptr_ = std::unique_ptr;
 
@@ -239,6 +247,20 @@
   std::unique_ptr PEmpty = std::unique_ptr(new Empty{});
   // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
   // CHECK-FIXES: std::unique_ptr PEmpty = std::make_unique(Empty{});
+
+  std::unique_ptr FF = std::unique_ptr(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
+  // CHECK-FIXES: std::unique_ptr FF = std::make_unique();
+  FF.reset(new Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: FF = std::make_unique();
+
+  std::unique_ptr BB = std::unique_ptr(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  // CHECK-FIXES: std::unique_ptr BB = std::make_unique();
+  BB.reset(new bar::Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
+  // CHECK-FIXES: BB = std::make_unique();
 }
 
 void aliases() {
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp

[PATCH] D32332: Add support for transparent overloadable functions in clang

2017-06-16 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv updated this revision to Diff 102850.
george.burgess.iv marked 3 inline comments as done.
george.burgess.iv added a comment.

Addressed all feedback


https://reviews.llvm.org/D32332

Files:
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGen/mangle-ms.c
  test/CodeGen/mangle.c
  test/CodeGenCXX/mangle-ms.cpp
  test/PCH/attrs.c
  test/Sema/overloadable.c

Index: test/Sema/overloadable.c
===
--- test/Sema/overloadable.c
+++ test/Sema/overloadable.c
@@ -3,12 +3,15 @@
 int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}}
 void params(void) __attribute__((overloadable(12))); // expected-error {{'overloadable' attribute takes no arguments}}
 
-int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}}
-float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}
+int *f(int) __attribute__((overloadable)); // expected-note{{previous overload of function is here}}
+float *f(float);
 int *f(int); // expected-error{{redeclaration of 'f' must have the 'overloadable' attribute}} \
  // expected-note{{previous declaration is here}}
 double *f(double) __attribute__((overloadable)); // okay, new
 
+// Ensure we don't complain about overloadable on implicitly declared functions.
+int isdigit(int) __attribute__((overloadable));
+
 void test_f(int iv, float fv, double dv) {
   int *ip = f(iv);
   float *fp = f(fv);
@@ -71,19 +74,19 @@
   f1();
 }
 
-void before_local_1(int) __attribute__((overloadable)); // expected-note {{here}}
+void before_local_1(int) __attribute__((overloadable));
 void before_local_2(int); // expected-note {{here}}
 void before_local_3(int) __attribute__((overloadable));
 void local() {
-  void before_local_1(char); // expected-error {{must have the 'overloadable' attribute}}
-  void before_local_2(char) __attribute__((overloadable)); // expected-error {{conflicting types}}
+  void before_local_1(char);
+  void before_local_2(char); // expected-error {{conflicting types}}
   void before_local_3(char) __attribute__((overloadable));
-  void after_local_1(char); // expected-note {{here}}
-  void after_local_2(char) __attribute__((overloadable)); // expected-note {{here}}
+  void after_local_1(char);
+  void after_local_2(char) __attribute__((overloadable));
   void after_local_3(char) __attribute__((overloadable));
 }
-void after_local_1(int) __attribute__((overloadable)); // expected-error {{conflicting types}}
-void after_local_2(int); // expected-error {{must have the 'overloadable' attribute}}
+void after_local_1(int) __attribute__((overloadable));
+void after_local_2(int);
 void after_local_3(int) __attribute__((overloadable));
 
 // Make sure we allow C-specific conversions in C.
@@ -106,8 +109,8 @@
   void foo(char *c) __attribute__((overloadable));
   void (*ptr1)(void *) = 
   void (*ptr2)(char *) = 
-  void (*ambiguous)(int *) =  // expected-error{{initializing 'void (*)(int *)' with an expression of incompatible type ''}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
-  void *vp_ambiguous =  // expected-error{{initializing 'void *' with an expression of incompatible type ''}} expected-note@105{{candidate function}} expected-note@106{{candidate function}}
+  void (*ambiguous)(int *) =  // expected-error{{initializing 'void (*)(int *)' with an expression of incompatible type ''}} expected-note@-4{{candidate function}} expected-note@-3{{candidate function}}
+  void *vp_ambiguous =  // expected-error{{initializing 'void *' with an expression of incompatible type ''}} expected-note@-5{{candidate function}} expected-note@-4{{candidate function}}
 
   void (*specific1)(int *) = (void (*)(void *)) // expected-warning{{incompatible function pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}}
   void *specific2 = (void (*)(void *))
@@ -117,8 +120,8 @@
   void disabled(char *c) __attribute__((overloadable, enable_if(1, "The function name lies.")));
   // To be clear, these should all point to the last overload of 'disabled'
   void (*dptr1)(char *c) = 
-  void (*dptr2)(void *c) =  // expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type ''}} expected-note@115{{candidate function made ineligible by enable_if}} expected-note@116{{candidate function made ineligible by enable_if}} expected-note@117{{candidate function has type mismatch at 1st parameter (expected 'void *' but has 'char *')}}
-  void (*dptr3)(int *c) =  // expected-warning{{incompatible pointer types initializing 'void (*)(int *)' with an expression of type ''}} expected-note@115{{candidate function made ineligible by enable_if}} expected-note@116{{candidate 

[PATCH] D6550: ASTImporter: Fix missing SourceLoc imports

2017-06-16 Thread Sean Callanan via Phabricator via cfe-commits
spyffe added a comment.

Hmm, the transforming in place of `SelLocs` reads a little weirdly to me, but 
other than that the code seems fine.
Is your concern that you don't know how to write an Objective-C test that would 
cover this?  It looks to me like an Objective-C interface with a method:

  @interface MyClass { }
  -(int)addInt:(int)a toInt:(int)b moduloInt:(int)c;
  @end

might be enough for an ASTMerge test.  If you want to make `clang-import-test` 
use this code, then we might need to add one or two things into that tester to 
handle Objective-C method lookup.


https://reviews.llvm.org/D6550



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


RE: [llvm-dev] Llvm lab resent network issues are resolved

2017-06-16 Thread Quentin Neill via cfe-commits
> Hello everyone,
> There were network issues with our provider and LLVM buildmaster was 
> unavailable recently.
> Sorry for inconvenience.
> Thanks
> Galina

Hi Galina,
Thanks for the note.
Still no connectivity from the outside (using several down time checkers 
(upstrends.com, downforeveryoneorjustme.com) as of 12:45pm CDT



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


[PATCH] D6550: ASTImporter: Fix missing SourceLoc imports

2017-06-16 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Will anybody object if I commit this change without a test? This bug seems to 
be pretty obvious but, unfortunately, I'm not familiar with Objective C.


https://reviews.llvm.org/D6550



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


Re: r284060 - Implement MS _BitScan intrinsics

2017-06-16 Thread Reid Kleckner via cfe-commits
We should fix it. We just need a new character code in the builtin function
prototype encoding. Currently there is no encoding for a portable int32_t
that magically becomes "long" on 32-bit Windows. The closest thing we have
is 'W', which is used by Neon intrinsics to select between "long" and "long
long". It was added in r202004.

On Fri, Jun 16, 2017 at 10:28 AM, Erik Schwiebert 
wrote:

> We (Office developers for Apple platforms at Microsoft) would prefer to
> have the intrinsics work properly for LP64, as that will generate the most
> optimal and efficient code. That said, we understand that this may be odd
> to implement from the compiler's perspective and can work around it if the
> intrinsics are not supported for ms-extensions+LP64. At the end of the day
> we need the compiler to clearly adopt one of those two options, and not sit
> somewhere in the middle as it currently does. We don't turn on any flags
> other than -fms-extensions; we don’t attempt to define MSC_VER and we do
> conditionalize code based on __clang__ so the code is aware it is being
> compiled by clang vs MSVC.
>
> So I think we'd prefer what Duncan and Apple are offering to do, but if
> the larger clang community thinks that is a bad idea and wants to
> explicitly disable the intrinsics, we could live with that.
>
> Thanks,
> Schwieb
>
> -Original Message-
> From: Erik Schwiebert
> Sent: Friday, June 16, 2017 8:49 AM
> To: 'Bruno Cardoso Lopes' ; Brian Kelley <
> bkel...@microsoft.com>; Tomasz Kukielka 
> Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits <
> cfe-commits@lists.llvm.org>
> Subject: RE: r284060 - Implement MS _BitScan intrinsics
>
> Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK
> intrinsics headers. I'm not sure which method we'd prefer, so I'll walk
> down the hall and ask them. Tomasz is our header maestro (because we play
> crazy #include_next games so we can use both Windows and macOS SDKs!)
>
> We'll get back to you ASAP.
>
> Schwieb
>
> -Original Message-
> From: Bruno Cardoso Lopes [mailto:bruno.card...@gmail.com]
> Sent: Thursday, June 15, 2017 4:41 PM
> To: Erik Schwiebert 
> Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits <
> cfe-commits@lists.llvm.org>
> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>
> On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
>  wrote:
> > On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
> >  wrote:
> >> SGTM too. Regarding Duncan's last question -- I can't think of any such
> customer. :) If you all think the right thing for clang to do is to infer
> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!
>
> Thinking more about this; what if we mark such builtins as unsupported
> for "LP64 (Darwin) + ms_extensions" and then you provide the
> definitions via intrin.h (we can generate a compiler macro for this
> scenario and conditionalize the include_next as we do for _MSC_VER)?
> Do you use this header at all? Are there any other MS related flags
> that get passed to the compiler?
>
> > SGTM as well!
> >
> >>
> >> Thanks all!
> >> Schwieb
> >>
> >> -Original Message-
> >> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
> >> Sent: Monday, June 12, 2017 1:55 PM
> >> To: Reid Kleckner 
> >> Cc: Saleem Abdulrasool ; Albert Gutowski <
> agutow...@google.com>; David Majnemer ;
> cfe-commits ; Erik Schwiebert <
> eri...@microsoft.com>
> >> Subject: Re: r284060 - Implement MS _BitScan intrinsics
> >>
> >>
> >>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
> >>>
>  On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool <
> compn...@compnerd.org> wrote:
>  I'm worried about changing this signature all the time.  I suspect
> that it will cause the following to be emitted for valid code:
> 
>  warning: incompatible pointer types passing 'unsigned long *' to
> parameter of type 'unsigned int *' [-Wincompatible-pointer-types]
> 
>  Switching the signature on LP64 sounds much better to me.
> >>>
> >>> Right, we have to do this. It needs to be `long` on Windows.
> >>
> >> SGTM.  We'll go that way.
> >
> > +1 here!
> >
> >>> On Jun 8, 2017, at 12:21, Erik Schwiebert 
> wrote:
> >>>
> >>> It’s probably also better to not try to infer our weird desired
> behavior. It should probably be controlled by a specific driver directive,
> like “-fms-extensions-lp64-intrinsics” or something like that. Using a
> new directive means that nobody can accidentally get this behavior if they
> for some reason do want LLP64 behavior with Windows intrinsics.
> >>
> >> This seems overly complicated.  Is there a customer that:
> >> - is on LP64,
> >> - is using 

[PATCH] D33645: [analyzer] Add missing documentation for static analyzer checkers

2017-06-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: www/analyzer/alpha_checks.html:91
+(C, C++)
+Check for logical errors for function calls and Objective-C message 
+expressions (e.g., uninitialized arguments, null function pointers, 

szdominik wrote:
> zaks.anna wrote:
> > for function calls -> in function calls?
> > After briefly looking into this, the checker only reports the use of 
> > uninitialized arguments in calls, not the other issues (like null function 
> > pointers). Could you double check this?
> As I see here
> https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp#L341
>  
> there are checks for null pointers too. 
The file implements 2 checkers and only one of them is in alpha:
REGISTER_CHECKER(CallAndMessageUnInitRefArg)
REGISTER_CHECKER(CallAndMessageChecker)

You can search for "CallAndMessageUnInitRefArg" to see that it effects 
uninitialized parameters warnings.


https://reviews.llvm.org/D33645



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


[PATCH] D34277: [analyzer] Bump default performance thresholds?

2017-06-16 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Artem,

Could you tell what code bases did you use to collect your statistics? I'll try 
to check the patch on our code bases. I think we should be careful about 
default settings. Maybe we should introduce another UMK_* for deeper analysis 
instead?


https://reviews.llvm.org/D34277



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


[PATCH] D34096: [Sema][C++1z] Ensure structured binding's bindings in dependent foreach have non-null type

2017-06-16 Thread Benjamin Buch via Phabricator via cfe-commits
bebuch reopened this revision.
bebuch added a comment.
This revision is now accepted and ready to land.

I believe this patch is incomplete, I get a very odd warning:

  struct A{
  int x;
  };
  
  template < typename >
  struct B{
  A data_[1];
  
  void f(){
  for(auto [x]: data_){
  (void)x;
  }
  }
  };
  
  int main(){
B< int > v;
v.f();
  }



  $ clang++ -std=c++1z -Wall clang_fail.cpp 

   
  clang_fail.cpp:10:18: warning: unused variable '' [-Wunused-variable] 



  for(auto [x]: data_){ 



   ^



  clang_fail.cpp:18:4: note: in instantiation of member function 'B::f' 
requested here  

   
  v.f();



^   



  1 warning generated.

unused variable ''? An unnamed variable, that's odd ;-)

Nevertheless, thanks for what is already done! Great that I can use structured 
bindings without fear to crash now! :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D34096



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


[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros

2017-06-16 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

It would be nice if the doc comment for the single file parse mode flag was 
updated to include this new functionality.




Comment at: lib/Lex/PPDirectives.cpp:2709
+CurPPLexer->pushConditionalLevel(IfToken.getLocation(), /*wasskip*/true,
+   /*foundnonskip*/false, /*foundelse*/false);
+  } else if (ConditionalTrue) {

Nitpick: this is misaligned.  Same with many other calls to 
pushConditionalLevel in this patch.



Comment at: lib/Lex/PPDirectives.cpp:2774
+// the directive blocks.
+CurPPLexer->pushConditionalLevel(CI.IfLoc, /*wasskip*/false,
+   /*foundnonskip*/true, /*foundelse*/true);

Why is wasSkipping false here?


https://reviews.llvm.org/D34263



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


RE: r284060 - Implement MS _BitScan intrinsics

2017-06-16 Thread Erik Schwiebert via cfe-commits
We (Office developers for Apple platforms at Microsoft) would prefer to have 
the intrinsics work properly for LP64, as that will generate the most optimal 
and efficient code. That said, we understand that this may be odd to implement 
from the compiler's perspective and can work around it if the intrinsics are 
not supported for ms-extensions+LP64. At the end of the day we need the 
compiler to clearly adopt one of those two options, and not sit somewhere in 
the middle as it currently does. We don't turn on any flags other than 
-fms-extensions; we don’t attempt to define MSC_VER and we do conditionalize 
code based on __clang__ so the code is aware it is being compiled by clang vs 
MSVC.

So I think we'd prefer what Duncan and Apple are offering to do, but if the 
larger clang community thinks that is a bad idea and wants to explicitly 
disable the intrinsics, we could live with that.

Thanks,
Schwieb

-Original Message-
From: Erik Schwiebert 
Sent: Friday, June 16, 2017 8:49 AM
To: 'Bruno Cardoso Lopes' ; Brian Kelley 
; Tomasz Kukielka 
Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits 

Subject: RE: r284060 - Implement MS _BitScan intrinsics

Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK intrinsics 
headers. I'm not sure which method we'd prefer, so I'll walk down the hall and 
ask them. Tomasz is our header maestro (because we play crazy #include_next 
games so we can use both Windows and macOS SDKs!)

We'll get back to you ASAP.

Schwieb

-Original Message-
From: Bruno Cardoso Lopes [mailto:bruno.card...@gmail.com] 
Sent: Thursday, June 15, 2017 4:41 PM
To: Erik Schwiebert 
Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits 

Subject: Re: r284060 - Implement MS _BitScan intrinsics

On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
 wrote:
> On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
>  wrote:
>> SGTM too. Regarding Duncan's last question -- I can't think of any such 
>> customer. :) If you all think the right thing for clang to do is to infer 
>> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!

Thinking more about this; what if we mark such builtins as unsupported
for "LP64 (Darwin) + ms_extensions" and then you provide the
definitions via intrin.h (we can generate a compiler macro for this
scenario and conditionalize the include_next as we do for _MSC_VER)?
Do you use this header at all? Are there any other MS related flags
that get passed to the compiler?

> SGTM as well!
>
>>
>> Thanks all!
>> Schwieb
>>
>> -Original Message-
>> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
>> Sent: Monday, June 12, 2017 1:55 PM
>> To: Reid Kleckner 
>> Cc: Saleem Abdulrasool ; Albert Gutowski 
>> ; David Majnemer ; 
>> cfe-commits ; Erik Schwiebert 
>> 
>> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>>
>>
>>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>>>
 On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool  
 wrote:
 I'm worried about changing this signature all the time.  I suspect that it 
 will cause the following to be emitted for valid code:

 warning: incompatible pointer types passing 'unsigned long *' to parameter 
 of type 'unsigned int *' [-Wincompatible-pointer-types]

 Switching the signature on LP64 sounds much better to me.
>>>
>>> Right, we have to do this. It needs to be `long` on Windows.
>>
>> SGTM.  We'll go that way.
>
> +1 here!
>
>>> On Jun 8, 2017, at 12:21, Erik Schwiebert  wrote:
>>>
>>> It’s probably also better to not try to infer our weird desired behavior. 
>>> It should probably be controlled by a specific driver directive, like 
>>> “-fms-extensions-lp64-intrinsics” or something like that. Using a new 
>>> directive means that nobody can accidentally get this behavior if they for 
>>> some reason do want LLP64 behavior with Windows intrinsics.
>>
>> This seems overly complicated.  Is there a customer that:
>> - is on LP64,
>> - is using -fms-extensions,
>> - is using these intrinsics, and
>> - wants them to be 64-bit longs instead of 32-bit ints?
>> Put another way: who would use these intrinsics on LP64 and *not* want to 
>> mimic LLP64?
>>
>> If everyone using the intrinsics on LP64 is going to have to specify 
>> -fms-extensions-lp64-intrinsics, then we should just imply it.
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> 

[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude

2017-06-16 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In https://reviews.llvm.org/D34158#782467, @fedor.sergeev wrote:

> LGTM wrt your update to sources.
>  And sorry, I'm not that qualified to answer your question on failing tests.
>
> Probing existence of this header would make a sense, yet you are including it 
> w/o a full path, so how are you going to find it for this probe?


Yes, I'd have to change this patch to iterate through the system headers.  Once 
I found an instance I'd keep the full path name and -include it using full  
path name.  I'll go ahead and change the patch to do this.

The other thought I had is: don't check for gcc version -- just add this 
functionality for all gcc versions on Linux. The reason I'd do that is to avoid 
creating lit test failures when the lit tests are running with gcc versions 
less than gcc 4.8; thus far I've been able to fix the lit failures by adding 
"-nostdinc".   Adding "-nostdinc" to the tests would work regardless of gcc 
version.  But I'm concerned that I will need to update some of the lit tests by 
checking for different output. In that case the expected output would differ 
based on gcc version, and I don't know if it's possible to express "don't run 
this lit test for gcc< 4.8".


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


[PATCH] D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude

2017-06-16 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added a comment.

LGTM wrt your update to sources.
And sorry, I'm not that qualified to answer your question on failing tests.

Probing existence of this header would make a sense, yet you are including it 
w/o a full path, so how are you going to find it for this probe?


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


[PATCH] D34279: Fix release_40 build with MSVC (VS 2015)

2017-06-16 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

I also did not have any local patches applied - just checked out release_40 
branch for llvm and clang.
I believe I also don't have warnings as errors enabled. At least I've checked 
for the extra flags and did not find such. I'll search once again if I have /WX 
somewhere in my build config.
But this patch should not break anything in any case.


https://reviews.llvm.org/D34279



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


Llvm lab resent network issues are resolved

2017-06-16 Thread Galina Kistanova via cfe-commits
Hello everyone,

There were network issues with our provider and LLVM buildmaster was
unavailable recently.

Sorry for inconvenience.

Thanks

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


[PATCH] D34256: [PR33394] Avoid lexing editor placeholders when running the preprocessor only

2017-06-16 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D34256



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


[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler

2017-06-16 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 102840.
xiangzhai added a comment.

Dear Raphael,

I updated my patch as you suggested, may I commit it? thanks!

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D31320

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/autogenerated_automoc.cpp
  test/Analysis/copypaste/dbus_autogenerated.cpp
  test/Analysis/copypaste/moc_autogenerated.cpp
  test/Analysis/copypaste/not-autogenerated.cpp
  test/Analysis/copypaste/ui_autogenerated.cpp

Index: test/Analysis/copypaste/ui_autogenerated.cpp
===
--- test/Analysis/copypaste/ui_autogenerated.cpp
+++ test/Analysis/copypaste/ui_autogenerated.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|ui_|.*_automoc" -verify %s
+
+// Because files that have `ui_' in their names are most likely autogenerated,
+// we suppress copy-paste warnings here.
+
+// expected-no-diagnostics
+
+void f1() {
+  int *p1 = new int[1];
+  int *p2 = new int[1];
+  if (p1) {
+delete [] p1;
+p1 = nullptr;
+  }
+  if (p2) {
+delete [] p1; // no-warning
+p2 = nullptr;
+  }
+}
Index: test/Analysis/copypaste/not-autogenerated.cpp
===
--- test/Analysis/copypaste/not-autogenerated.cpp
+++ test/Analysis/copypaste/not-autogenerated.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|ui_|dbus_|.*_automoc" -verify %s
+
+void f1() {
+  int *p1 = new int[1];
+  int *p2 = new int[1];
+  if (p1) {
+delete [] p1; // expected-note{{Similar code using 'p1' here}}
+p1 = nullptr;
+  }
+  if (p2) {
+delete [] p1; // expected-warning{{Potential copy-paste error; did you really mean to use 'p1' here?}}
+p2 = nullptr;
+  }
+}
Index: test/Analysis/copypaste/moc_autogenerated.cpp
===
--- test/Analysis/copypaste/moc_autogenerated.cpp
+++ test/Analysis/copypaste/moc_autogenerated.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|.*_automoc" -verify %s
+
+// Because files that have `moc_' in their names are most likely autogenerated,
+// we suppress copy-paste warnings here.
+
+// expected-no-diagnostics
+
+void f1() {
+  int *p1 = new int[1];
+  int *p2 = new int[1];
+  if (p1) {
+delete [] p1;
+p1 = nullptr;
+  }
+  if (p2) {
+delete [] p1; // no-warning
+p2 = nullptr;
+  }
+}
Index: test/Analysis/copypaste/dbus_autogenerated.cpp
===
--- test/Analysis/copypaste/dbus_autogenerated.cpp
+++ test/Analysis/copypaste/dbus_autogenerated.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|dbus_|.*_automoc" -verify %s
+
+// Because files that have `dbus_' in their names are most likely autogenerated,
+// we suppress copy-paste warnings here.
+
+// expected-no-diagnostics
+
+void f1() {
+  int *p1 = new int[1];
+  int *p2 = new int[1];
+  if (p1) {
+delete [] p1;
+p1 = nullptr;
+  }
+  if (p2) {
+delete [] p1; // no-warning
+p2 = nullptr;
+  }
+}
Index: test/Analysis/copypaste/autogenerated_automoc.cpp
===
--- test/Analysis/copypaste/autogenerated_automoc.cpp
+++ test/Analysis/copypaste/autogenerated_automoc.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:IgnoredFilesPattern="moc_|.*_automoc.cpp" -verify %s
+
+// Because files that have `_automoc.' in their names are most likely autogenerated,
+// we suppress copy-paste warnings here.
+
+// expected-no-diagnostics
+
+void f1() {
+  int *p1 = new int[1];
+  int *p2 = new int[1];
+  if (p1) {
+delete [] p1;
+p1 = nullptr;
+  }
+  if (p2) {
+delete [] p1; // no-warning
+p2 = nullptr;
+  }
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CloneChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -73,12 +73,17 @@
   bool ReportNormalClones = Mgr.getAnalyzerOptions().getBooleanOption(
   "ReportNormalClones", true, this);
 
+  StringRef IgnoredFilesPattern = Mgr.getAnalyzerOptions().getOptionAsString(
+  "IgnoredFilesPattern", "", this);
+
   // Let the CloneDetector create a list of clones from all the analyzed
   // statements. We don't 

[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-06-16 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 102838.
vlad.tsyrklevich marked an inline comment as done.
vlad.tsyrklevich added a comment.

After reviewing this patch again last night I:

1. Updated some "%clang_cc1 -analyze" calls with  "%clang_analyze_cc1" due to 
2cfd901321423a96edd8513afc7c7c2bb0d18b2e
2. Isolated HTML generation into a separate function to simplify 
`HTMLDiagnostics::ReportDiag` even further


https://reviews.llvm.org/D30406

Files:
  include/clang/StaticAnalyzer/Core/Analyses.def
  lib/Rewrite/HTMLRewrite.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  test/Analysis/diagnostics/diag-cross-file-boundaries.c
  test/Analysis/diagnostics/diag-cross-file-boundaries.h
  test/Analysis/html-diag-singlefile.c
  test/Analysis/html-diag-singlefile.h
  test/Analysis/html-diags-analyze-headers.c
  test/Analysis/html-diags-analyze-headers.h
  test/Analysis/html-diags-multifile.c
  test/Analysis/html-diags.c
  test/Coverage/html-diagnostics.c
  test/Coverage/html-multifile-diagnostics.c
  test/Coverage/html-multifile-diagnostics.h
  www/analyzer/open_projects.html

Index: www/analyzer/open_projects.html
===
--- www/analyzer/open_projects.html
+++ www/analyzer/open_projects.html
@@ -107,13 +107,6 @@
 
   Bug Reporting 
   
-Add support for displaying cross-file diagnostic paths in HTML output
-(used by scan-build).
-Currently scan-build output does not display reports that span 
-multiple files. The main problem is that we do not have a good format to
-display such paths in HTML output. (Difficulty: Medium) 
-
-
 Refactor path diagnostic generation in http://clang.llvm.org/doxygen/BugReporter_8cpp_source.html;>BugReporter.cpp.
 It would be great to have more code reuse between "Minimal" and 
 "Extensive" PathDiagnostic generation algorithms. One idea is to create an 
Index: test/Coverage/html-multifile-diagnostics.h
===
--- /dev/null
+++ test/Coverage/html-multifile-diagnostics.h
@@ -0,0 +1,3 @@
+void f1(int *ptr) {
+  *ptr = 0;
+}
Index: test/Coverage/html-multifile-diagnostics.c
===
--- /dev/null
+++ test/Coverage/html-multifile-diagnostics.c
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
+// RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
+
+// REQUIRES: staticanalyzer
+
+// CHECK: Annotated Source Code
+
+// Make sure it's generated as multi-file HTML output
+// CHECK: {{.*}}html-multifile-diagnostics.c
+// CHECK: {{.*}}html-multifile-diagnostics.h
+
+// Without tweaking expr, the expr would hit to the line below
+// emitted to the output as comment.
+// CHECK: {{[D]ereference of null pointer}}
+
+#include "html-multifile-diagnostics.h"
+
+void f0() {
+  f1((int*)0);
+}
Index: test/Coverage/html-diagnostics.c
===
--- test/Coverage/html-diagnostics.c
+++ test/Coverage/html-diagnostics.c
@@ -1,11 +1,18 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
 // RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
+//
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -analyze -analyzer-output=html-single-file -analyzer-checker=core -o %t %s
+// RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
 
 // REQUIRES: staticanalyzer
 
 // CHECK: Annotated Source Code
 
+// Make sure it's not generated as a multi-file HTML output
+// CHECK-NOT: {{.*}}
+
 // Without tweaking expr, the expr would hit to the line below
 // emitted to the output as comment.
 // CHECK: {{[D]ereference of null pointer}}
Index: test/Analysis/html-diags.c
===
--- test/Analysis/html-diags.c
+++ test/Analysis/html-diags.c
@@ -3,6 +3,12 @@
 // RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o %T/dir %s
 // RUN: ls %T/dir | grep report
 
+// D30406: Test new html-single-file output
+// RUN: rm -fR %T/dir
+// RUN: mkdir %T/dir
+// RUN: %clang_analyze_cc1 -analyzer-output=html-single-file -analyzer-checker=core -o %T/dir %s
+// RUN: ls %T/dir | grep report
+
 // PR16547: Test relative paths
 // RUN: cd %T/dir
 // RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o testrelative %s
Index: test/Analysis/html-diags-multifile.c
===
--- test/Analysis/html-diags-multifile.c
+++ test/Analysis/html-diags-multifile.c
@@ -1,10 +1,9 @@
 // RUN: mkdir -p %t.dir
 // RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o %t.dir %s
-// RUN: ls %t.dir | not grep report
+// RUN: ls %t.dir | grep report
 // RUN: rm -fR %t.dir
 
-// This tests that we do not currently emit HTML diagnostics for reports that
-// cross file boundaries.
+// 

[PATCH] D33383: [GSoC] Flag value completion for clang

2017-06-16 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2198
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
-  HelpText<"C++ standard library to use">;
+  HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;

ruiu wrote:
> v.g.vassilev wrote:
> > `Values` seems too generic, can we use `ArgValues` instead?
> I'd keep it as `Values`, as everything is essentially related to command line 
> arguments, and `Args` seems redundant. For example, we didn't name `ArgFlags` 
> but just `Flags`, and `HelpText` instead of `ArgHelpText`, etc.
My reasoning for asking this is that I wanted to hint about the relationship 
between the values (as this is a very broad term) and arguments. I'd read 
`ArgValues` as possible values for an argument without having to dig into 
context.

That said, I don't think switching back to `Values` is a significant issue, if 
@ruiu feels strongly about it , please follow his suggestion and land the patch.



Comment at: clang/lib/Driver/Driver.cpp:1226
+// So spilit them with "," in order to make list of flags.
+PassedFlags.split(ListOfPassedFlags, ",", -1, false);
+std::vector SuggestedCompletions = 
Opts->findByPrefix(ListOfPassedFlags[0]);

ruiu wrote:
> You are using `PassedFlags` only once. Do you want to replace it with 
> `StringRef(A->getValue()).split(...)`?
`PassedFlags` looks more readable to casual readers like me ;)


https://reviews.llvm.org/D33383



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


[PATCH] D32341: Fix a bug that warnings generated with -M or -MM flags

2017-06-16 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi closed this revision.
yamaguchi added a comment.

Landed in r305561.


https://reviews.llvm.org/D32341



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


r305561 - Fix a bug that warnings generated with -M or -MM flags

2017-06-16 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Fri Jun 16 11:01:13 2017
New Revision: 305561

URL: http://llvm.org/viewvc/llvm-project?rev=305561=rev
Log:
Fix a bug that warnings generated with -M or -MM flags

This is a patch for bug: https://bugs.llvm.org/show_bug.cgi?id=6817

Warnings should not be emitted with -M and -MM flags, because this mode
is only used for generate MakeFiles.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/m_and_mm.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=305561=305560=305561=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Jun 16 11:01:13 2017
@@ -980,6 +980,9 @@ void Clang::AddPreprocessingOptions(Comp
 DepTarget = Args.MakeArgString(llvm::sys::path::filename(P));
   }
 
+  if (!A->getOption().matches(options::OPT_MD) && 
!A->getOption().matches(options::OPT_MMD)) {
+CmdArgs.push_back("-w");
+  }
   CmdArgs.push_back("-MT");
   SmallString<128> Quoted;
   QuoteTarget(DepTarget, Quoted);

Modified: cfe/trunk/test/Driver/m_and_mm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/m_and_mm.c?rev=305561=305560=305561=diff
==
--- cfe/trunk/test/Driver/m_and_mm.c (original)
+++ cfe/trunk/test/Driver/m_and_mm.c Fri Jun 16 11:01:13 2017
@@ -1,3 +1,15 @@
 // RUN: %clang -### \
 // RUN:   -M -MM %s 2> %t
 // RUN: not grep '"-sys-header-deps"' %t
+
+// RUN: %clang -M -MM %s 2> %t
+// RUN: not grep "warning" %t
+
+// RUN: %clang -MMD -MD %s 2> %t
+// RUN: grep "warning" %t
+
+#warning "This warning shouldn't show up with -M and -MM"
+int main (void)
+{
+return 0;
+}


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


[PATCH] D34279: Fix release_40 build with MSVC (VS 2015)

2017-06-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a subscriber: tstellar.
hans added a comment.

That's strange. I build the llvm 4.0 branch (and trunk too, which has the same 
code) with Visual Studio 2015 without problems. (I don't build with warnings as 
errors though, so if this is a warning maybe I missed it.) Do you have any 
local patches that might cause this problem?

In any case, I don't think Tom is taking more patches for the 4.0.1 release.


https://reviews.llvm.org/D34279



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


[PATCH] D34206: [clang-tidy] Add "MakeSmartPtrFunction" option to modernize-make-shared/unique checks.

2017-06-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 102833.
hokein added a comment.

More improvements.


https://reviews.llvm.org/D34206

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  docs/clang-tidy/checks/modernize-make-shared.rst
  docs/clang-tidy/checks/modernize-make-unique.rst
  test/clang-tidy/Inputs/modernize-smart-ptr/shared_ptr.h
  test/clang-tidy/Inputs/modernize-smart-ptr/unique_ptr.h
  test/clang-tidy/modernize-make-shared-header.cpp
  test/clang-tidy/modernize-make-shared.cpp
  test/clang-tidy/modernize-make-unique-header.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -1,31 +1,8 @@
+// RUN: cp %S/Inputs/modernize-smart-ptr/unique_ptr.h %T/unique_ptr.h
 // RUN: %check_clang_tidy %s modernize-make-unique %t
 
-namespace std {
-
-template 
-class default_delete {};
-
-template >
-class unique_ptr {
-public:
-  unique_ptr();
-  unique_ptr(type *ptr);
-  unique_ptr(const unique_ptr ) = delete;
-  unique_ptr(unique_ptr &);
-  ~unique_ptr();
-  type *() { return *ptr; }
-  type *operator->() { return ptr; }
-  type *release();
-  void reset();
-  void reset(type *pt);
-  unique_ptr =(unique_ptr &&);
-  template 
-  unique_ptr =(unique_ptr &&);
-
-private:
-  type *ptr;
-};
-}
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
 
 struct Base {
   Base();
Index: test/clang-tidy/modernize-make-unique-header.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-header.cpp
@@ -0,0 +1,18 @@
+// RUN: cp %S/Inputs/modernize-smart-ptr/unique_ptr.h %T/unique_ptr.h
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: modernize-make-unique.MakeSmartPtrFunction, \
+// RUN:   value: 'my::MakeUnique'}, \
+// RUN:  {key: modernize-make-unique.MakeSmartPtrFunctionHeader, \
+// RUN:   value: 'make_unique_util.h'} \
+// RUN: ]}" \
+// RUN:   -- -std=c++11
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include "make_unique_util.h"
+
+void f() {
+  std::unique_ptr P1 = std::unique_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use my::MakeUnique instead
+  // CHECK-FIXES: std::unique_ptr P1 = my::MakeUnique();
+}
Index: test/clang-tidy/modernize-make-shared.cpp
===
--- test/clang-tidy/modernize-make-shared.cpp
+++ test/clang-tidy/modernize-make-shared.cpp
@@ -1,28 +1,8 @@
+// RUN: cp %S/Inputs/modernize-smart-ptr/shared_ptr.h %T/shared_ptr.h
 // RUN: %check_clang_tidy %s modernize-make-shared %t
 
-namespace std {
-
-template 
-class shared_ptr {
-public:
-  shared_ptr();
-  shared_ptr(type *ptr);
-  shared_ptr(const shared_ptr ) {}
-  shared_ptr(shared_ptr &) {}
-  ~shared_ptr();
-  type *() { return *ptr; }
-  type *operator->() { return ptr; }
-  type *release();
-  void reset();
-  void reset(type *pt);
-  shared_ptr =(shared_ptr &&);
-  template 
-  shared_ptr =(shared_ptr &&);
-
-private:
-  type *ptr;
-};
-}
+#include "shared_ptr.h"
+// CHECK-FIXES: #include 
 
 struct Base {
   Base();
Index: test/clang-tidy/modernize-make-shared-header.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-shared-header.cpp
@@ -0,0 +1,18 @@
+// RUN: cp %S/Inputs/modernize-smart-ptr/shared_ptr.h %T/shared_ptr.h
+// RUN: %check_clang_tidy %s modernize-make-shared %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: modernize-make-shared.MakeSmartPtrFunction, \
+// RUN:   value: 'my::MakeShared'}, \
+// RUN:  {key: modernize-make-shared.MakeSmartPtrFunctionHeader, \
+// RUN:   value: 'make_shared_util.h'} \
+// RUN: ]}" \
+// RUN:   -- -std=c++11
+
+#include "shared_ptr.h"
+// CHECK-FIXES: #include "make_shared_util.h"
+
+void f() {
+  std::shared_ptr P1 = std::shared_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use my::MakeShared instead
+  // CHECK-FIXES: std::shared_ptr P1 = my::MakeShared();
+}
Index: test/clang-tidy/Inputs/modernize-smart-ptr/unique_ptr.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/modernize-smart-ptr/unique_ptr.h
@@ -0,0 +1,27 @@
+namespace std {
+
+template 
+class default_delete {};
+
+template >
+class unique_ptr {
+public:
+  unique_ptr();
+  unique_ptr(type *ptr);
+  unique_ptr(const unique_ptr ) = delete;
+  unique_ptr(unique_ptr &);
+  ~unique_ptr();
+  type *() { return *ptr; }
+  type *operator->() { return ptr; }
+  type *release();
+  void reset();
+  void reset(type *pt);
+  unique_ptr =(unique_ptr &&);
+  template 
+  unique_ptr =(unique_ptr &&);
+
+private:
+  type *ptr;
+};
+
+}  // namespace std
Index: 

RE: r284060 - Implement MS _BitScan intrinsics

2017-06-16 Thread Erik Schwiebert via cfe-commits
Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK intrinsics 
headers. I'm not sure which method we'd prefer, so I'll walk down the hall and 
ask them. Tomasz is our header maestro (because we play crazy #include_next 
games so we can use both Windows and macOS SDKs!)

We'll get back to you ASAP.

Schwieb

-Original Message-
From: Bruno Cardoso Lopes [mailto:bruno.card...@gmail.com] 
Sent: Thursday, June 15, 2017 4:41 PM
To: Erik Schwiebert 
Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits 

Subject: Re: r284060 - Implement MS _BitScan intrinsics

On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
 wrote:
> On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
>  wrote:
>> SGTM too. Regarding Duncan's last question -- I can't think of any such 
>> customer. :) If you all think the right thing for clang to do is to infer 
>> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!

Thinking more about this; what if we mark such builtins as unsupported
for "LP64 (Darwin) + ms_extensions" and then you provide the
definitions via intrin.h (we can generate a compiler macro for this
scenario and conditionalize the include_next as we do for _MSC_VER)?
Do you use this header at all? Are there any other MS related flags
that get passed to the compiler?

> SGTM as well!
>
>>
>> Thanks all!
>> Schwieb
>>
>> -Original Message-
>> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
>> Sent: Monday, June 12, 2017 1:55 PM
>> To: Reid Kleckner 
>> Cc: Saleem Abdulrasool ; Albert Gutowski 
>> ; David Majnemer ; 
>> cfe-commits ; Erik Schwiebert 
>> 
>> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>>
>>
>>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>>>
 On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool  
 wrote:
 I'm worried about changing this signature all the time.  I suspect that it 
 will cause the following to be emitted for valid code:

 warning: incompatible pointer types passing 'unsigned long *' to parameter 
 of type 'unsigned int *' [-Wincompatible-pointer-types]

 Switching the signature on LP64 sounds much better to me.
>>>
>>> Right, we have to do this. It needs to be `long` on Windows.
>>
>> SGTM.  We'll go that way.
>
> +1 here!
>
>>> On Jun 8, 2017, at 12:21, Erik Schwiebert  wrote:
>>>
>>> It’s probably also better to not try to infer our weird desired behavior. 
>>> It should probably be controlled by a specific driver directive, like 
>>> “-fms-extensions-lp64-intrinsics” or something like that. Using a new 
>>> directive means that nobody can accidentally get this behavior if they for 
>>> some reason do want LLP64 behavior with Windows intrinsics.
>>
>> This seems overly complicated.  Is there a customer that:
>> - is on LP64,
>> - is using -fms-extensions,
>> - is using these intrinsics, and
>> - wants them to be 64-bit longs instead of 32-bit ints?
>> Put another way: who would use these intrinsics on LP64 and *not* want to 
>> mimic LLP64?
>>
>> If everyone using the intrinsics on LP64 is going to have to specify 
>> -fms-extensions-lp64-intrinsics, then we should just imply it.
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fcfe-commits=02%7C01%7Ceriksc%40microsoft.com%7Cba4835eb4a1b438793d508d4b4481355%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636331669036098946=iWTF3jpX71tU%2B6aq%2BEpv8VD8IFfeDKMHvZd40%2FK64aE%3D=0
>
>
>
> --
> Bruno Cardoso Lopes
> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.brunocardoso.cc=02%7C01%7Ceriksc%40microsoft.com%7Cba4835eb4a1b438793d508d4b4481355%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636331669036098946=O01DYn4W3JN54%2B6wwAgCLAkq63PUtUBy4mQ9RMN833s%3D=0



-- 
Bruno Cardoso Lopes
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.brunocardoso.cc=02%7C01%7Ceriksc%40microsoft.com%7Cba4835eb4a1b438793d508d4b4481355%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636331669036098946=O01DYn4W3JN54%2B6wwAgCLAkq63PUtUBy4mQ9RMN833s%3D=0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros

2017-06-16 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Hey Vladimir, what you are proposing is orthogonal to this patch. You are 
proposing for "the client to provide the value for an undefined identifier", 
and the patch is about the client not knowing what the value should be so it 
fallbacks to parsing all tokens to get the max amount of info. Note that both 
of the techniques can be combined well, if the client provides the value, the 
preprocessor will take it into account, otherwise if it is stays unresolved it 
will fallback to lexing all tokens.
But what you are proposing is not a replacement for what the patch is doing.


https://reviews.llvm.org/D34263



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


[PATCH] D34102: [analyzer] Add portability package for the checkers.

2017-06-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 102829.
NoQ added a comment.

Whoops, forgot to actually attach the patch. Here.


https://reviews.llvm.org/D34102

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  test/Analysis/malloc-overflow2.c
  test/Analysis/unix-fns.c

Index: test/Analysis/unix-fns.c
===
--- test/Analysis/unix-fns.c
+++ test/Analysis/unix-fns.c
@@ -1,7 +1,7 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,unix.API,osx.API %s -analyzer-store=region -analyzer-output=plist -analyzer-eagerly-assume -analyzer-config faux-bodies=true -analyzer-config path-diagnostics-alternate=false -fblocks -verify -o %t.plist
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,unix.API,osx.API,optin.portability %s -analyzer-store=region -analyzer-output=plist -analyzer-eagerly-assume -analyzer-config faux-bodies=true -analyzer-config path-diagnostics-alternate=false -fblocks -verify -o %t.plist
 // RUN: FileCheck --input-file=%t.plist %s
 // RUN: mkdir -p %t.dir
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API,osx.API -analyzer-output=html -analyzer-config faux-bodies=true -fblocks -o %t.dir %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API,osx.API,optin.portability -analyzer-output=html -analyzer-config faux-bodies=true -fblocks -o %t.dir %s
 // RUN: rm -fR %t.dir
 struct _opaque_pthread_once_t {
   long __sig;
Index: test/Analysis/malloc-overflow2.c
===
--- test/Analysis/malloc-overflow2.c
+++ test/Analysis/malloc-overflow2.c
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -analyzer-checker=alpha.security.MallocOverflow,unix -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -analyzer-checker=alpha.security.MallocOverflow,unix,optin.portability -DPORTABILITY -verify %s
 
 typedef __typeof__(sizeof(int)) size_t;
 extern void *malloc(size_t);
@@ -32,5 +33,8 @@
 }
 
 void *f(int n) {
-  return malloc(n * 0 * sizeof(int)); // expected-warning {{Call to 'malloc' has an allocation size of 0 bytes}}
+  return malloc(n * 0 * sizeof(int));
+#ifdef PORTABILITY
+  // expected-warning@-2{{Call to 'malloc' has an allocation size of 0 bytes}}
+#endif
 }
Index: lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -45,6 +45,8 @@
   mutable Optional Val_O_CREAT;
 
 public:
+  DefaultBool CheckMisuse, CheckPortability;
+
   void checkPreStmt(const CallExpr *CE, CheckerContext ) const;
 
   void CheckOpen(CheckerContext , const CallExpr *CE) const;
@@ -437,29 +439,42 @@
   if (FName.empty())
 return;
 
-  SubChecker SC =
-llvm::StringSwitch(FName)
-  .Case("open", ::CheckOpen)
-  .Case("openat", ::CheckOpenAt)
-  .Case("pthread_once", ::CheckPthreadOnce)
-  .Case("calloc", ::CheckCallocZero)
-  .Case("malloc", ::CheckMallocZero)
-  .Case("realloc", ::CheckReallocZero)
-  .Case("reallocf", ::CheckReallocfZero)
-  .Cases("alloca", "__builtin_alloca", ::CheckAllocaZero)
-  .Case("__builtin_alloca_with_align",
-::CheckAllocaWithAlignZero)
-  .Case("valloc", ::CheckVallocZero)
-  .Default(nullptr);
-
-  if (SC)
-(this->*SC)(C, CE);
+  if (CheckMisuse) {
+if (SubChecker SC =
+llvm::StringSwitch(FName)
+.Case("open", ::CheckOpen)
+.Case("openat", ::CheckOpenAt)
+.Case("pthread_once", ::CheckPthreadOnce)
+.Default(nullptr)) {
+  (this->*SC)(C, CE);
+}
+  }
+  if (CheckPortability) {
+if (SubChecker SC =
+llvm::StringSwitch(FName)
+.Case("calloc", ::CheckCallocZero)
+.Case("malloc", ::CheckMallocZero)
+.Case("realloc", ::CheckReallocZero)
+.Case("reallocf", ::CheckReallocfZero)
+.Cases("alloca", "__builtin_alloca",
+   ::CheckAllocaZero)
+.Case("__builtin_alloca_with_align",
+  ::CheckAllocaWithAlignZero)
+.Case("valloc", ::CheckVallocZero)
+.Default(nullptr)) {
+  (this->*SC)(C, CE);
+}
+  }
 }
 
 //===--===//
 // Registration.
 //===--===//
 
-void ento::registerUnixAPIChecker(CheckerManager ) {
-  mgr.registerChecker();
-}
+#define REGISTER_CHECKER(Name) \
+  void ento::registerUnixAPI##Name##Checker(CheckerManager ) { \
+mgr.registerChecker()->Check##Name = true; \
+  }
+
+REGISTER_CHECKER(Misuse)

[PATCH] D34102: [analyzer] Add portability package for the checkers.

2017-06-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Here's a version of the patch without `.unix`. I'd still hate it to re-add the 
subpackages if we decide to turn some portability checkers on and off depending 
on language/platform (eg. checkers for portability across linux/bsd should be 
off on windows by default, checkers for non-portable C++ APIs should be off in 
plain C code, etc.).


https://reviews.llvm.org/D34102



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 102828.
jyu2 added a comment.

Thanks Aaron!!!   I just upload new patch to address your comments.  I now 
understand your point on when I can use auto.


https://reviews.llvm.org/D3

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  test/CXX/except/except.spec/p11.cpp
  test/SemaCXX/warn-throw-out-noexcept-func.cpp

Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -279,6 +279,150 @@
 }
 
 //===--===//
+// Check for throw in a non-throwing function.
+//===--===//
+enum ThrowState {
+  FoundNoPathForThrow,
+  FoundPathForThrow,
+  FoundPathWithNoThrowOutFunction,
+};
+
+static bool isThrowCaught(const CXXThrowExpr *Throw,
+  const CXXCatchStmt *Catch) {
+  const Type *ThrowType = nullptr;
+  if (Throw->getSubExpr())
+ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  if (!ThrowType)
+return false;
+  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+  if (!CaughtType)
+return true;
+  if (ThrowType->isReferenceType())
+ThrowType = ThrowType->castAs()
+->getPointeeType()
+->getUnqualifiedDesugaredType();
+  if (CaughtType->isReferenceType())
+CaughtType = CaughtType->castAs()
+ ->getPointeeType()
+ ->getUnqualifiedDesugaredType();
+  if (CaughtType == ThrowType)
+return true;
+  const CXXRecordDecl *CaughtAsRecordType =
+  CaughtType->getPointeeCXXRecordDecl();
+  const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl();
+  if (CaughtAsRecordType && ThrowTypeAsRecordType)
+return ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType);
+  return false;
+}
+
+static bool isThrowCaughtByHandlers(const CXXThrowExpr *CE,
+const CXXTryStmt *TryStmt) {
+  for (unsigned H = 0, E = TryStmt->getNumHandlers(); H < E; ++H) {
+if (isThrowCaught(CE, TryStmt->getHandler(H)))
+  return true;
+  }
+  return false;
+}
+
+static bool doesThrowEscapePath(CFGBlock Block, SourceLocation ) {
+  for (const auto  : Block) {
+if (B.getKind() != CFGElement::Statement)
+  continue;
+const auto *CE = dyn_cast(B.getAs()->getStmt());
+if (!CE)
+  continue;
+
+OpLoc = CE->getThrowLoc();
+for (const auto  : Block.succs()) {
+  if (!I.isReachable())
+continue;
+  if (const auto *Terminator =
+  dyn_cast_or_null(I->getTerminator()))
+if (isThrowCaughtByHandlers(CE, Terminator))
+  return false;
+}
+return true;
+  }
+  return false;
+}
+
+static bool hasThrowOutNonThrowingFunc(SourceLocation , CFG *BodyCFG) {
+
+  unsigned ExitID = BodyCFG->getExit().getBlockID();
+
+  SmallVector States(BodyCFG->getNumBlockIDs(),
+ FoundNoPathForThrow);
+  States[BodyCFG->getEntry().getBlockID()] = FoundPathWithNoThrowOutFunction;
+
+  SmallVector Stack;
+  Stack.push_back(>getEntry());
+  while (!Stack.empty()) {
+CFGBlock *CurBlock = Stack.back();
+Stack.pop_back();
+
+unsigned ID = CurBlock->getBlockID();
+ThrowState CurState = States[ID];
+if (CurState == FoundPathWithNoThrowOutFunction) {
+  if (ExitID == ID)
+continue;
+
+  if (doesThrowEscapePath(*CurBlock, OpLoc))
+CurState = FoundPathForThrow;
+}
+
+// Loop over successor blocks and add them to the Stack if their state
+// changes.
+for (const auto  : CurBlock->succs())
+  if (I.isReachable()) {
+unsigned NextID = I->getBlockID();
+if (NextID == ExitID && CurState == FoundPathForThrow) {
+  States[NextID] = CurState;
+} else if (States[NextID] < CurState) {
+  States[NextID] = CurState;
+  Stack.push_back(I);
+}
+  }
+  }
+  // Return true if the exit node is reachable, and only reachable through
+  // a throw expression.
+  return States[ExitID] == FoundPathForThrow;
+}
+
+static void EmitDiagForCXXThrowInNonThrowingFunc(Sema , SourceLocation OpLoc,
+ const FunctionDecl *FD) {
+  if (!S.getSourceManager().isInSystemHeader(OpLoc)) {
+S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD;
+if (S.getLangOpts().CPlusPlus11 &&
+(isa(FD) ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete))
+  S.Diag(FD->getLocation(), diag::note_throw_in_dtor);
+else
+  S.Diag(FD->getLocation(), diag::note_throw_in_function);
+  }
+}
+
+static void checkThrowInNonThrowingFunc(Sema , const FunctionDecl *FD,
+ 

[PATCH] D34279: Fix release_40 build with MSVC (VS 2015)

2017-06-16 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

error list 



https://reviews.llvm.org/D34279



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


[PATCH] D34279: Fix release_40 build with MSVC (VS 2015)

2017-06-16 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.

I currently have narrowing conversion error without that fix.
I try building with 64 and 32 bit compilers - both reproduce that error.


https://reviews.llvm.org/D34279

Files:
  include/llvm/Target/TargetOpcodes.h


Index: include/llvm/Target/TargetOpcodes.h
===
--- include/llvm/Target/TargetOpcodes.h
+++ include/llvm/Target/TargetOpcodes.h
@@ -19,7 +19,7 @@
 /// Invariant opcodes: All instruction sets have these as their low opcodes.
 ///
 namespace TargetOpcode {
-enum {
+enum : unsigned {
 #define HANDLE_TARGET_OPCODE(OPC) OPC,
 #define HANDLE_TARGET_OPCODE_MARKER(IDENT, OPC) IDENT = OPC,
 #include "llvm/Target/TargetOpcodes.def"


Index: include/llvm/Target/TargetOpcodes.h
===
--- include/llvm/Target/TargetOpcodes.h
+++ include/llvm/Target/TargetOpcodes.h
@@ -19,7 +19,7 @@
 /// Invariant opcodes: All instruction sets have these as their low opcodes.
 ///
 namespace TargetOpcode {
-enum {
+enum : unsigned {
 #define HANDLE_TARGET_OPCODE(OPC) OPC,
 #define HANDLE_TARGET_OPCODE_MARKER(IDENT, OPC) IDENT = OPC,
 #include "llvm/Target/TargetOpcodes.def"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32332: Add support for transparent overloadable functions in clang

2017-06-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This is generally looking good to me, with a few small nits. @rsmith, do you 
have thought on this?




Comment at: lib/Sema/SemaDecl.cpp:2875-2876
 /// Returns true if there was an error, false otherwise.
-bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *,
- Scope *S, bool MergeTypeWithOld) {
+bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S,
+ bool MergeTypeWithOld) {
   // Verify the old decl was also a function.

Seems to be a formatting-only change that's unrelated to the patch; can be 
reverted.



Comment at: lib/Sema/SemaDecl.cpp:9225
+/*NewIsUsingDecl=*/false)) {
+  case Sema::Ovl_Match:
+  case Sema::Ovl_NonFunction:

Why add `Sema::` to these?



Comment at: lib/Sema/SemaDecl.cpp:9383
+
+auto OtherUnmarkedIter = llvm::find_if(Previous, [&](const NamedDecl *ND) {
+  const auto *FD = dyn_cast(ND);

Why does this need a capture?


https://reviews.llvm.org/D32332



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


[PATCH] D34277: [analyzer] Bump default performance thresholds?

2017-06-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.

Because we now have faster CPUs and more RAM and stuff, should we now skew the 
balance to finding more bugs?

We could probably make a few rounds of such changes, observing any delayed 
feedback from users who use default settings and aren't watching phabricator, 
and rolling back in case we degrade dramatically on specific smaller projects.

As the first step, i've recently tested the following changes to default 
`-analyzer-option`s:

- `max-nodes`: 15 -> 225000 (+50%) - the limit on the size of the exploded 
graph.
- `max-inlinable-size`: 50 -> 100 (+100%) - the limit on the number of CFG 
blocks in inlined functions.

Totally, this gives 10% performance degradation and finds 5% more bugs on a 
large-ish codebase. `max-inlinable-size` change skews the analyzer to find more 
IPA-based bugs than before (+/-5% added/lost), and also overally slightly 
improves the number of bugs found; `max-nodes` increase brings back some of 
these positives.

Generally, it would also be good to make the analyzer work in a more obvious 
manner in terms of why does or doesn't it cover certain paths, inline certain 
functions, etc.- currently this is a mess of unobvious heuristics, and if we 
could make it less obvious by lifting some of these heuristics, it may be an 
additional benefit of this work as well.


https://reviews.llvm.org/D34277

Files:
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp


Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -293,7 +293,7 @@
 DefaultValue = 4;
 break;
   case UMK_Deep:
-DefaultValue = 50;
+DefaultValue = 100;
 break;
 }
 
@@ -332,7 +332,7 @@
 DefaultValue = 75000;
 break;
   case UMK_Deep:
-DefaultValue = 15;
+DefaultValue = 225000;
 break;
 }
 MaxNodesPerTopLevelFunction = getOptionAsInteger("max-nodes", 
DefaultValue);


Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -293,7 +293,7 @@
 DefaultValue = 4;
 break;
   case UMK_Deep:
-DefaultValue = 50;
+DefaultValue = 100;
 break;
 }
 
@@ -332,7 +332,7 @@
 DefaultValue = 75000;
 break;
   case UMK_Deep:
-DefaultValue = 15;
+DefaultValue = 225000;
 break;
 }
 MaxNodesPerTopLevelFunction = getOptionAsInteger("max-nodes", DefaultValue);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-06-16 Thread wangxin via Phabricator via cfe-commits
wangxindsb created this revision.

This implement a path-sensitive checker that warns if virtual calls are made 
from constructors and destructors.

The checker use the GDM (generic data map) to store three integers in the 
program state for constructors, destructors and objects. Once enter one of 
these is entered, increase the corresponding integer, once leave, decrease the 
corresponding integer. In a PreCall callback, the checker first check if a 
virtual method is called and the GDM meets the conditions, if yes, a warning 
will be issued.

The checker also  include a bug reporter visitor to add an extra note when the 
last constructor/destructor was called before the call to the virtual function.


https://reviews.llvm.org/D34275

Files:
  VirtualCallChecker.cpp

Index: VirtualCallChecker.cpp
===
--- VirtualCallChecker.cpp
+++ VirtualCallChecker.cpp
@@ -14,279 +14,269 @@
 
 #include "ClangSACheckers.h"
 #include "clang/AST/DeclCXX.h"
-#include "clang/AST/StmtVisitor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/SaveAndRestore.h"
-#include "llvm/Support/raw_ostream.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
 
 using namespace clang;
 using namespace ento;
 
 namespace {
 
-class WalkAST : public StmtVisitor {
-  const CheckerBase *Checker;
-  BugReporter 
-  AnalysisDeclContext *AC;
-
-  /// The root constructor or destructor whose callees are being analyzed.
-  const CXXMethodDecl *RootMethod = nullptr;
-
-  /// Whether the checker should walk into bodies of called functions.
-  /// Controlled by the "Interprocedural" analyzer-config option.
-  bool IsInterprocedural = false;
-
-  /// Whether the checker should only warn for calls to pure virtual functions
-  /// (which is undefined behavior) or for all virtual functions (which may
-  /// may result in unexpected behavior).
-  bool ReportPureOnly = false;
-
-  typedef const CallExpr * WorkListUnit;
-  typedef SmallVector DFSWorkList;
-
-  /// A vector representing the worklist which has a chain of CallExprs.
-  DFSWorkList WList;
-
-  // PreVisited : A CallExpr to this FunctionDecl is in the worklist, but the
-  // body has not been visited yet.
-  // PostVisited : A CallExpr to this FunctionDecl is in the worklist, and the
-  // body has been visited.
-  enum Kind { NotVisited,
-  PreVisited,  /**< A CallExpr to this FunctionDecl is in the
-worklist, but the body has not yet been
-visited. */
-  PostVisited  /**< A CallExpr to this FunctionDecl is in the
-worklist, and the body has been visited. */
-  };
+class VirtualCallChecker: public Checker {
+  mutable std::unique_ptr BT_CT;
+  mutable std::unique_ptr BT_DT;
 
-  /// A DenseMap that records visited states of FunctionDecls.
-  llvm::DenseMap VisitedFunctions;
+public:
+  void checkPreCall(const CallEvent , CheckerContext ) const;
+  void checkPostCall(const CallEvent , CheckerContext ) const;
 
-  /// The CallExpr whose body is currently being visited.  This is used for
-  /// generating bug reports.  This is null while visiting the body of a
-  /// constructor or destructor.
-  const CallExpr *visitingCallExpr;
+private:
+  bool isVirtualCall(const CallExpr *CE) const;
+  Optional getThisSVal(const StackFrameContext *SFC,
+ const ProgramStateRef State) const;
+  class VirtualBugVisitor : public BugReporterVisitorImpl {
+  private:
+const unsigned Flag;
+bool Found;
+
+  public:
+VirtualBugVisitor(const unsigned Flag) : Flag(Flag), Found(false) {}
+void Profile(llvm::FoldingSetNodeID ) const override{
+  static int x = 0;
+  ID.AddPointer();
+  ID.AddPointer();
+}
+std::shared_ptr VisitNode(const ExplodedNode *N,
+   const ExplodedNode *PrevN,
+   BugReporterContext ,
+   BugReport ) override;
+  };
+};
+} // end anonymous namespace
 
-public:
-  WalkAST(const CheckerBase *checker, BugReporter , AnalysisDeclContext *ac,
-  const CXXMethodDecl *rootMethod, bool isInterprocedural,
-  bool reportPureOnly)
-  : Checker(checker), BR(br), AC(ac), RootMethod(rootMethod),
-IsInterprocedural(isInterprocedural), ReportPureOnly(reportPureOnly),
-

[PATCH] D33563: Track whether a unary operation can overflow

2017-06-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Ping


https://reviews.llvm.org/D33563



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:304
+  ->getUnqualifiedDesugaredType();
+  if (CaughtType == nullptr || CaughtType == ThrowType)
+return true;

aaron.ballman wrote:
> The check for a null `CaughtType` can be hoisted above the if statements, 
> which can then be simplified.
This can still be hoisted higher in the function.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:297
+
+  if (ThrowType == nullptr)
+return false;

nit: `!ThrowType`



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:299
+return false;
+  if (ThrowType && ThrowType->isReferenceType())
+ThrowType = ThrowType->castAs()

No need for testing `ThrowType` for null here.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:305
+return true;
+  if (CaughtType && CaughtType->isReferenceType())
+CaughtType = CaughtType->castAs()

No need for testing `CaughtType` for null here.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:332
+  continue;
+const CXXThrowExpr *CE =
+dyn_cast(B.getAs()->getStmt());

`const auto *`



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:341
+continue;
+  if (const CXXTryStmt *Terminator =
+  dyn_cast_or_null(I->getTerminator()))

Oops, I should have suggested `const auto *` here with my original comment 
(sorry about that).



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:393
+
+static void EmitDiagForCXXThrowInNonThrowingFunc(SourceLocation OpLoc, Sema ,
+ const FunctionDecl *FD) {

For consistency with other code in the compiler, can you move the `Sema` param 
to be the first parameter?


https://reviews.llvm.org/D3



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


[PATCH] D34202: [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305554: [clang-tidy] readability-function-size: fix nesting 
level calculation (authored by lebedevri).

Changed prior to commit:
  https://reviews.llvm.org/D34202?vs=102548=102813#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34202

Files:
  clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp

Index: clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
@@ -36,15 +36,8 @@
 case Stmt::ForStmtClass:
 case Stmt::SwitchStmtClass:
   ++Info.Branches;
-// fallthrough
+  LLVM_FALLTHROUGH;
 case Stmt::CompoundStmtClass:
-  // If this new compound statement is located in a compound statement,
-  // which is already nested NestingThreshold levels deep, record the start
-  // location of this new compound statement
-  if (CurrentNestingLevel == Info.NestingThreshold)
-Info.NestingThresholders.push_back(Node->getLocStart());
-
-  ++CurrentNestingLevel;
   TrackedParent.push_back(true);
   break;
 default:
@@ -54,13 +47,25 @@
 
 Base::TraverseStmt(Node);
 
-if (TrackedParent.back())
-  --CurrentNestingLevel;
 TrackedParent.pop_back();
 
 return true;
   }
 
+  bool TraverseCompoundStmt(CompoundStmt *Node) {
+// If this new compound statement is located in a compound statement, which
+// is already nested NestingThreshold levels deep, record the start location
+// of this new compound statement.
+if (CurrentNestingLevel == Info.NestingThreshold)
+  Info.NestingThresholders.push_back(Node->getLocStart());
+
+++CurrentNestingLevel;
+Base::TraverseCompoundStmt(Node);
+--CurrentNestingLevel;
+
+return true;
+  }
+
   bool TraverseDecl(Decl *Node) {
 TrackedParent.push_back(false);
 Base::TraverseDecl(Node);
Index: clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp
@@ -63,8 +63,9 @@
 #define macro() {int x; {int y; {int z;}}}
 
 void baz0() { // 1
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 9 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
 int b;
@@ -87,5 +88,55 @@
   }
   macro()
 // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
-// CHECK-MESSAGES: :[[@LINE-27]]:25: note: expanded from macro 'macro'
+// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+}
+
+// check that nested if's are not reported. this was broken initially
+void nesting_if() { // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
+  if (true) { // 2
+ int j;
+  } else if (true) { // 2
+ int j;
+ if (true) { // 3
+   // CHECK-MESSAGES: :[[@LINE-1]]:16: note: nesting level 3 starts here (threshold 2)
+   int j;
+ }
+  } else if (true) { // 2
+ int j;
+ if (true) { // 3
+   // CHECK-MESSAGES: :[[@LINE-1]]:16: note: nesting level 3 starts here (threshold 2)
+   int j;
+ }
+  } else if (true) { // 2
+ int j;
+  }
+}
+
+// however this should warn
+void bad_if_nesting() { // 1
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
+// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
+  if (true) {// 2
+int j;
+  } else { // 2
+if (true) { // 3
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: note: nesting level 3 starts here (threshold 2)
+  int j;
+} else { // 3
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: note: nesting level 3 starts here (threshold 2)
+  if (true) { // 4
+int j;
+  } else { // 4
+if (true) { // 5
+  int j;
+}
+  }
+}
+  }
 }

[clang-tools-extra] r305554 - [clang-tidy] readability-function-size: fix nesting level calculation

2017-06-16 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jun 16 08:07:47 2017
New Revision: 305554

URL: http://llvm.org/viewvc/llvm-project?rev=305554=rev
Log:
[clang-tidy] readability-function-size: fix nesting level calculation

Summary:
A followup for D32942.

Malcolm Parsons has provided a valid testcase that the initial version of the 
check complained about nested `if`'s.
As it turns out, the culprit is the **partially** un-intentional `switch` 
fallthrough.
So rewrite the NestingThreshold logic without ab-using+mis-using that switch 
with fallthrough, and add testcases with nested `if`' where there should be a 
warning and shouldn't be a warning. This results in a cleaner, simpler code, 
too.

I guess, now it would be actually possible to pick some reasonable default for 
`NestingThreshold` setting.

Fixes PR33454.

Reviewers: malcolm.parsons, alexfh

Reviewed By: malcolm.parsons

Subscribers: sbenza, xazax.hun, cfe-commits, aaron.ballman

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp

Modified: clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp?rev=305554=305553=305554=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp Fri 
Jun 16 08:07:47 2017
@@ -36,15 +36,8 @@ public:
 case Stmt::ForStmtClass:
 case Stmt::SwitchStmtClass:
   ++Info.Branches;
-// fallthrough
+  LLVM_FALLTHROUGH;
 case Stmt::CompoundStmtClass:
-  // If this new compound statement is located in a compound statement,
-  // which is already nested NestingThreshold levels deep, record the start
-  // location of this new compound statement
-  if (CurrentNestingLevel == Info.NestingThreshold)
-Info.NestingThresholders.push_back(Node->getLocStart());
-
-  ++CurrentNestingLevel;
   TrackedParent.push_back(true);
   break;
 default:
@@ -54,12 +47,24 @@ public:
 
 Base::TraverseStmt(Node);
 
-if (TrackedParent.back())
-  --CurrentNestingLevel;
 TrackedParent.pop_back();
 
 return true;
   }
+
+  bool TraverseCompoundStmt(CompoundStmt *Node) {
+// If this new compound statement is located in a compound statement, which
+// is already nested NestingThreshold levels deep, record the start 
location
+// of this new compound statement.
+if (CurrentNestingLevel == Info.NestingThreshold)
+  Info.NestingThresholders.push_back(Node->getLocStart());
+
+++CurrentNestingLevel;
+Base::TraverseCompoundStmt(Node);
+--CurrentNestingLevel;
+
+return true;
+  }
 
   bool TraverseDecl(Decl *Node) {
 TrackedParent.push_back(false);

Modified: clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp?rev=305554=305553=305554=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp Fri 
Jun 16 08:07:47 2017
@@ -63,8 +63,9 @@ void bar2() { class A { void barx() {;;}
 #define macro() {int x; {int y; {int z;}}}
 
 void baz0() { // 1
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds 
recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 9 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds 
recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and 
comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
 int b;
@@ -87,5 +88,55 @@ void baz0() { // 1
   }
   macro()
 // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here 
(threshold 2)
-// CHECK-MESSAGES: :[[@LINE-27]]:25: note: expanded from macro 'macro'
+// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+}
+
+// check that nested if's are not reported. this was broken initially
+void nesting_if() { // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds 
recommended size/complexity
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and 
comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
+  if (true) { // 2
+ int j;
+  } else if (true) { // 2
+ int j;
+ if (true) { // 3
+   // CHECK-MESSAGES: :[[@LINE-1]]:16: note: 

Re: [libcxx] r276238 - Implement std::string_view as described in http://wg21.link/P0254R1. Reviewed as https://reviews.llvm.org/D21459

2017-06-16 Thread Duncan Exon Smith via cfe-commits

> On Jun 15, 2017, at 22:22, Eric Fiselier  wrote:
> 
> 
> 
>> On Thu, Jun 15, 2017 at 11:00 PM, Duncan P. N. Exon Smith 
>>  wrote:
>> Your suggestion is essentially to replace experimental/string_view with 
>> something like:
>> 
>> namespace std { inline namespace __1 { namespace experimental {
>>   template 
>>   using basic_string_view = _VSTD::basic_string_view;
>> }}}
>> 
>> That breaks:
>> 1. User compiles 1.cpp with older toolchain.  1.cpp implements 
>> foo(std::experimental::string_view).
>> 2. User compiles 2.cpp with newer toolchain.  2.cpp calls 
>> foo(std::experimental::string_view).
>> 3. User links 1.o with 2.o.
>> 
>> I'm not sure if this matters.
> 
> It can't matter.  are allowed to break both their API and 
> ABI as needed.
> 
> Also I was suggesting 
> 
>namespace std { namespace experimental {
>  using std::basic_string_view;
>  using std::string_view;
>   }}
>  
> This approach will break code that expects experimental::string_view and 
> std::string_view are different types:
> Example:
> 
>   void foo(std::string_view);
>   void foo(std::experimental::string_view);
>   foo(std::string_view{}); // ambiguous
> 
>> 
>>> On Jun 15, 2017, at 21:55, Eric Fiselier  wrote:
>>> 
>>> I would also want to do serious performance analysis on this patch. Does 
>>> removing the string_view overloads cause less optimal overloads to be 
>>> chosen? Perhaps allocating ones?
>>> That would be really unfortunate, and I'm not sure that's in the best 
>>> interest of our users at large.
>> 
>> Less optimal compared to what?  C++17 code?
> 
> Not sure yet, I'm trying to figure out what types the `const Tp&` overloads
> are attempting to soak up. Is it only string_view? 

The type trait restricts it to things convertible to string_view that are not 
const char *.

> 
>  
>> 
>>> /Eric
>>> 
 On Thu, Jun 15, 2017 at 10:51 PM, Duncan P. N. Exon Smith 
  wrote:
 
> On Jun 15, 2017, at 19:42, Eric Fiselier  wrote:
> 
> 
> 
> On Thu, Jun 15, 2017 at 8:38 PM, Duncan P. N. Exon Smith 
>  wrote:
>> I just started working on a patch to add #if guards, and the first 
>> interesting thing I found was the basic_string constructor:
>> 
>>> template 
>>> template 
>>> basic_string<_CharT, _Traits, _Allocator>::basic_string(
>>>  const _Tp& __t, size_type __pos, size_type __n, const 
>>> allocator_type& __a,
>>>  typename 
>>> enable_if<__can_be_converted_to_string_view<_CharT, _Traits, 
>>> _Tp>::value, void>::type *)
>>> : __r_(__second_tag(), __a)
>>> {
>>> __self_view __sv = __self_view(__t).substr(__pos, __n);
>>> __init(__sv.data(), __sv.size());
>>> #if _LIBCPP_DEBUG_LEVEL >= 2
>>> __get_db()->__insert_c(this);
>>> #endif
>>> }
>> 
> 
> That constructor was added in C++17, so removing it along with 
> string_view should be OK.
> Assuming we don't use it to implement older constructors using a single 
> template.
> 
>  
>> I suppose the decision was made so that std::string could take advantage 
>> of it.
>> 
>> Is it a conforming extension?
> 
> No, because it can change the meaning of otherwise well defined code, as 
> you pointed out initially. 
 
 Let me know if this patch is along the right lines.  If so, I'll finish it 
 up and put it on phab.
 
 experimental/filesystem/path.cpp doesn't compile, since 
 experimental/filesystem uses things like operator+=(string, string_view) 
 extensively.  But I'd like an early opinion on the approach before I dig 
 in.
 
 In string, the only function that needed to be rewritten was 
 string::compare(size, size, string, size, size).  I'm nervous that 
 filesystem will be a bigger job.
 
 
 
>  
>> 
>>> On Jun 15, 2017, at 18:35, Eric Fiselier  wrote:
>>> 
>>> It *shouldn't* include , that's a given.
>>> 
>>> IIRC, and Marshall would know better, I believe it was untenable to
>>> maintain a version of  that didn't depend on  
>>> after making
>>> the changes required for C++17.
>>> 
>>> However inspecting  now it does seem possible that the 
>>> entanglement
>>> is avoidable.Though it's also likely I'm just not seeing the whole 
>>> picture. 
>>> 
>>> /Eric
>>> 
>>> On Thu, Jun 15, 2017 at 6:42 PM, Duncan P. N. Exon Smith 
>>> wrote:
 
 > On Jul 20, 2016, at 22:31, Marshall Clow via cfe-commits 
 >  wrote:
 >
 > Modified: libcxx/trunk/include/string
 > URL: 
 > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=276238=276237=276238=diff

  1   2   >