]> granicus.if.org Git - clang/log
clang
6 years ago[Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Thu, 5 Apr 2018 21:09:03 +0000 (21:09 +0000)]
[Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329346 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR36992: do not store beyond the dsize of a class object unless we know
Richard Smith [Thu, 5 Apr 2018 20:52:58 +0000 (20:52 +0000)]
PR36992: do not store beyond the dsize of a class object unless we know
the tail padding is not reused.

We track on the AggValueSlot (and through a couple of other
initialization actions) whether we're dealing with an object that might
share its tail padding with some other object, so that we can avoid
emitting stores into the tail padding if that's the case. We still
widen stores into tail padding when we can do so.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329342 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standard
Richard Smith [Thu, 5 Apr 2018 18:55:37 +0000 (18:55 +0000)]
DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standard
layout" rules.

The new rules say that a standard-layout struct has its first non-static
data member and all base classes at offset 0, and consider a class to
not be standard-layout if that would result in multiple subobjects of a
single type having the same address.

We track "is C++11 standard-layout class" separately from "is
standard-layout class" so that the ABIs that need this information can
still use it.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329332 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove the temporary availability checking workaround for
Alex Lorenz [Thu, 5 Apr 2018 18:12:06 +0000 (18:12 +0000)]
Remove the temporary availability checking workaround for
the nested declarations in @interface.

rdar://28825862

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329324 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix typo in comment -fmath-errno=0 -> -fno-math-errno
Sam Clegg [Thu, 5 Apr 2018 17:44:08 +0000 (17:44 +0000)]
Fix typo in comment -fmath-errno=0 -> -fno-math-errno

The former is not a valid clang argument

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329323 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTImporter] Fix for importing unnamed structs
Aleksei Sidorin [Thu, 5 Apr 2018 15:31:49 +0000 (15:31 +0000)]
[ASTImporter] Fix for importing unnamed structs

Patch by Peter Szecsi!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329301 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDisable -fmerge-all-constants as default.
Manoj Gupta [Thu, 5 Apr 2018 15:29:52 +0000 (15:29 +0000)]
Disable -fmerge-all-constants as default.

Summary:
"-fmerge-all-constants" is a non-conforming optimization and should not
be the default. It is also causing miscompiles when building Linux
Kernel (https://lkml.org/lkml/2018/3/20/872).

Fixes PR18538.

Reviewers: rjmccall, rsmith, chandlerc

Reviewed By: rsmith, chandlerc

Subscribers: srhines, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329300 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Support lightweight Objective-C generics
Ben Hamilton [Thu, 5 Apr 2018 15:26:25 +0000 (15:26 +0000)]
[clang-format] Support lightweight Objective-C generics

Summary:
Previously, `clang-format` didn't understand lightweight
Objective-C generics, which have the form:

```
@interface Foo <KeyType,
                ValueTypeWithConstraint : Foo,
AnotherValueTypeWithGenericConstraint: Bar<Baz>, ... > ...
```

The lightweight generic specifier list appears before the base
class, if present, but because it starts with < like the protocol
specifier list, `UnwrappedLineParser` was getting confused and
failed to parse interfaces with both generics and protocol lists:

```
@interface Foo <KeyType> : NSObject <NSCopying>
```

Since the parsed line would be incomplete, the format result
would be very confused (e.g., https://bugs.llvm.org/show_bug.cgi?id=24381).

This fixes the issue by explicitly parsing the ObjC lightweight
generic conformance list, so the line is fully parsed.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=24381
Test Plan: New tests added. Ran tests with:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329298 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Ensure ObjC selectors with 0 args are annotated correctly
Ben Hamilton [Thu, 5 Apr 2018 15:26:23 +0000 (15:26 +0000)]
[clang-format] Ensure ObjC selectors with 0 args are annotated correctly

Summary:
Previously, clang-format would incorrectly annotate 0-argument
Objective-C selector names as TT_TrailingAnnotation:

```
% echo "-(void)foo;" > /tmp/test.m
% ./bin/clang-format -debug /tmp/test.m
Language: Objective-C
----
Line(0, FSC=0): minus[T=68, OC=0] l_paren[T=68, OC=1] void[T=68, OC=2]
r_paren[T=68, OC=6] identifier[T=68, OC=7] semi[T=68, OC=10]
Line(0, FSC=0): eof[T=68, OC=0]
Run 0...
AnnotatedTokens(L=0):
 M=0 C=0 T=ObjCMethodSpecifier S=1 B=0 BK=0 P=0 Name=minus L=1 PPK=2
 FakeLParens= FakeRParens=0 Text='-'
 M=0 C=1 T=Unknown S=1 B=0 BK=0 P=33 Name=l_paren L=3 PPK=2
 FakeLParens= FakeRParens=0 Text='('
 M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=void L=7 PPK=2 FakeLParens=
 FakeRParens=0 Text='void'
 M=0 C=0 T=CastRParen S=0 B=0 BK=0 P=43 Name=r_paren L=8 PPK=2
 FakeLParens= FakeRParens=0 Text=')'
 M=0 C=1 T=TrailingAnnotation S=0 B=0 BK=0 P=120 Name=identifier L=11
 PPK=2 FakeLParens= FakeRParens=0 Text='foo'
 M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=semi L=12 PPK=2 FakeLParens=
 FakeRParens=0 Text=';'
```

This caused us to incorrectly indent 0-argument wrapped selectors
when Style.IndentWrappedFunctionNames was false, as we thought
the 0-argument ObjC selector name was actually a trailing
annotation (which is always indented).

This diff fixes the issue and adds tests.

Test Plan: New tests added. Confirmed tests failed before diff.
  After diff, tests passed. Ran tests with:
  % make -j12 FormatTests &&
  ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: djasper, jolesiak

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329297 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ObjC] Make C++ triviality type traits available to non-trivial C
Akira Hatanaka [Thu, 5 Apr 2018 14:39:57 +0000 (14:39 +0000)]
[ObjC] Make C++ triviality type traits available to non-trivial C
structs.

r326307 and r327870 made changes that allowed using non-trivial C
structs with fields qualified with __strong or __weak. This commit makes
the following C++ triviality type traits available to non-trivial C
structs:

__has_trivial_assign
__has_trivial_move_assign
__has_trivial_copy
__has_trivial_move_constructor
__has_trivial_constructor
__has_trivial_destructor

This reapplies r328680. This commit fixes a bug where the copy/move
__has_trivial_* traits would return false when a volatile type was being
passed. Thanks to Richard Smith for pointing out the mistake.

rdar://problem/33599681

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329289 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[PATCH] [RISCV] Extend getTargetDefines for RISCVTargetInfo
Shiva Chen [Thu, 5 Apr 2018 12:54:00 +0000 (12:54 +0000)]
[PATCH] [RISCV] Extend getTargetDefines for RISCVTargetInfo

Summary:
This patch extend getTargetDefines and implement handleTargetFeatures
and hasFeature. and define corresponding marco for those features.

Reviewers: asb, apazos, eli.friedman

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

Patch by Kito Cheng.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329278 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Preserve spaces before a percent in (text) protos
Krasimir Georgiev [Thu, 5 Apr 2018 09:33:03 +0000 (09:33 +0000)]
[clang-format] Preserve spaces before a percent in (text) protos

This makes sure that we do not change the meaning of pieces of text with
format specifiers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329263 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r328680 ("[ObjC] Make C++ triviality type traits available to non-trivial...
Richard Smith [Thu, 5 Apr 2018 00:34:54 +0000 (00:34 +0000)]
Revert r328680 ("[ObjC] Make C++ triviality type traits available to non-trivial C structs.")

It unintentionally caused the values of the __has_* type traits to change in
C++ for trivially-copyable classes with volatile members.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329247 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Don't track lambda captures when checking a potential constant expression.
Erik Pilkington [Thu, 5 Apr 2018 00:12:05 +0000 (00:12 +0000)]
[AST] Don't track lambda captures when checking a potential constant expression.

Fixes PR36054.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329244 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoEnable msan unconditionally on Linux.
Evgeniy Stepanov [Wed, 4 Apr 2018 23:48:06 +0000 (23:48 +0000)]
Enable msan unconditionally on Linux.

Memory sanitizer compatibility are already done in
MemorySanitizer::doInitialization. It verifies whether the necessary offsets
exist and bails out if not. For this reason it is no good to duplicate two
checks in two projects. This patch removes clang check and postpones msan
compatibility validation till MemorySanitizer::doInitialization.

Another reason for this patch is to allow using msan with any CPU (given
compatible runtime) and custom mapping provided via the arguments added by
https://reviews.llvm.org/D44926.

Patch by vit9696.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329241 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAArch64: Implement support for the shadowcallstack attribute.
Peter Collingbourne [Wed, 4 Apr 2018 21:55:44 +0000 (21:55 +0000)]
AArch64: Implement support for the shadowcallstack attribute.

The implementation of shadow call stack on aarch64 is quite different to
the implementation on x86_64. Instead of reserving a segment register for
the shadow call stack, we reserve the platform register, x18. Any function
that spills lr to sp also spills it to the shadow call stack, a pointer to
which is stored in x18.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329236 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Include the Android multiarch includes.
Dan Albert [Wed, 4 Apr 2018 21:28:34 +0000 (21:28 +0000)]
[Driver] Include the Android multiarch includes.

Summary:
Most Android headers live in a single directory, but a small handful
live in multiarch directories.

Reviewers: srhines

Reviewed By: srhines

Subscribers: javed.absar, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329234 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Add amdgpu sub archs
Yaxun Liu [Wed, 4 Apr 2018 21:19:27 +0000 (21:19 +0000)]
[CUDA] Add amdgpu sub archs

Patch by Greg Rodgers.
Revised and lit tests added by Yaxun Liu.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329232 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] In tests, expected code should be format-stable
Mark Zeren [Wed, 4 Apr 2018 21:09:00 +0000 (21:09 +0000)]
[clang-format] In tests, expected code should be format-stable

Summary: Extend various verifyFormat helper functions to check that the
expected text is "stable". This provides some protection against bugs
where formatting results are ocilating between two forms, or continually
change in some other way.

Testing Done:

* Ran unit tests.

* Reproduced a known instability in preprocessor indentation which was
  caught by this new check.

Reviewers: krasimir

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329231 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[CUDA] Check initializers of instantiated template variables."
Artem Belevich [Wed, 4 Apr 2018 20:48:42 +0000 (20:48 +0000)]
Revert "[CUDA] Check initializers of instantiated template variables."

This (temporarily) reverts commit r329127 due to the problems
it exposed in TensorFlow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329229 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer][test] Set C++14 as language standard for test depending on new
Jan Korous [Wed, 4 Apr 2018 19:58:48 +0000 (19:58 +0000)]
[analyzer][test] Set C++14 as language standard for test depending on new
features

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329225 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFixes errors with FS iterators caused by https://reviews.llvm.org/D44960
Max Moroz [Wed, 4 Apr 2018 19:47:25 +0000 (19:47 +0000)]
Fixes errors with FS iterators caused by https://reviews.llvm.org/D44960

Summary:
In https://reviews.llvm.org/D44960, file status check is executed every
time a real file system directory iterator is constructed or
incremented, and emits an error code. This change list fixes the errors
in VirtualFileSystem caused by https://reviews.llvm.org/D44960.

Patch by Yuke Liao (@liaoyuke).

Reviewers: vsk, pcc, zturner, liaoyuke

Reviewed By: vsk

Subscribers: mgrang, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329223 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[XRay][clang] Allow clang to build XRay instrumented binaries in OpenBSD
Dean Michael Berris [Wed, 4 Apr 2018 12:47:49 +0000 (12:47 +0000)]
[XRay][clang] Allow clang to build XRay instrumented binaries in OpenBSD

Summary:
This patch was originally reviewed in D45126. It enables clang to add
the XRay runtime and the link-time dependencies for XRay instrumentation
in OpenBSD.

Landing for devnexen.

Reviewers: brad, dberris

Subscribers: dberris, krytarowski, cfe-commits

Author: devnexen

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329183 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMake helpers static. NFC.
Benjamin Kramer [Wed, 4 Apr 2018 11:45:11 +0000 (11:45 +0000)]
Make helpers static. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329170 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAs we don't use minor version anymore, let's remove it from the release notes too
Sylvestre Ledru [Wed, 4 Apr 2018 09:38:22 +0000 (09:38 +0000)]
As we don't use minor version anymore, let's remove it from the release notes too

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329161 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix typo in ASTStructuralEquivalence.cpp for UnaryTransform types.
Eric Fiselier [Wed, 4 Apr 2018 06:31:21 +0000 (06:31 +0000)]
Fix typo in ASTStructuralEquivalence.cpp for UnaryTransform types.

Previously UnaryTransformType nodes were comparing the same node
for structural equivalence. This was due to a typo where T1 was
on both sides of the comparison. This patch corrects that typo.

Unfortunately I couldn't find a way to test this change. It seems
that currently UnaryTransform nodes are never actually checked
for equivalence, only their canonical types are.

None the less, this correction seemed appropriate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329151 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSplit test/Driver/darwin-sdkroot.c into two tests
Alex Lorenz [Wed, 4 Apr 2018 02:11:20 +0000 (02:11 +0000)]
Split test/Driver/darwin-sdkroot.c into two tests

The test additions in r329110 are Darwin-specific, as they rely
on a code path that is reachabled when driver is invoked without
-target. Instead of making the old test checks Darwin-specific too,
let's simply split it into two files to ensure that the old
checks are still platform-agnostic. Thanks Chandler for
suggesting this!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329141 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ObjC] Use the name specified by objc_runtime_name instead of the class
Akira Hatanaka [Tue, 3 Apr 2018 22:50:16 +0000 (22:50 +0000)]
[ObjC] Use the name specified by objc_runtime_name instead of the class
identifier.

This patch fixes a few places in CGObjCMac.cpp where the class
identifier was used instead of the name specified by objc_runtime_name.

rdar://problem/37910822

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329128 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Check initializers of instantiated template variables.
Artem Belevich [Tue, 3 Apr 2018 22:41:06 +0000 (22:41 +0000)]
[CUDA] Check initializers of instantiated template variables.

We were already performing checks on non-template variables,
but the checks on templated ones were missing.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329127 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd the -fsanitize=shadow-call-stack flag
Vlad Tsyrklevich [Tue, 3 Apr 2018 22:33:53 +0000 (22:33 +0000)]
Add the -fsanitize=shadow-call-stack flag

Summary:
Add support for the -fsanitize=shadow-call-stack flag which causes clang
to add ShadowCallStack attribute to functions compiled with that flag
enabled.

Reviewers: pcc, kcc

Reviewed By: pcc, kcc

Subscribers: cryptoad, cfe-commits, kcc

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329122 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Tue, 3 Apr 2018 21:31:50 +0000 (21:31 +0000)]
[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329115 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd REQUIRES: darwin-system to test/Driver/darwin-sdkroot.c
Alex Lorenz [Tue, 3 Apr 2018 21:10:26 +0000 (21:10 +0000)]
Add REQUIRES: darwin-system to test/Driver/darwin-sdkroot.c

The test from r329110 is for Darwin only

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329113 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[driver][darwin] Do not infer -simulator environment for non-simulator SDKs
Alex Lorenz [Tue, 3 Apr 2018 20:50:05 +0000 (20:50 +0000)]
[driver][darwin] Do not infer -simulator environment for non-simulator SDKs

rdar://36369832

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329110 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix diagnostics in callees of interesting callees.
Artem Dergachev [Tue, 3 Apr 2018 18:52:30 +0000 (18:52 +0000)]
[analyzer] Fix diagnostics in callees of interesting callees.

removeUnneededCalls() is responsible for removing path diagnostic pieces within
functions that don't contain "interesting" events. It makes bug reports
much tidier.

When a stack frame is known to be interesting, the function doesn't descend
into it to prune anything within it, even other callees that are totally boring.

Fix the function to prune boring callees in interesting stack frames.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329102 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "Set calling convention for CUDA kernel"
Artem Belevich [Tue, 3 Apr 2018 18:29:31 +0000 (18:29 +0000)]
Revert "Set calling convention for CUDA kernel"

This reverts r328795 which introduced an issue with referencing __global__
function templates. More details in the original review D44747.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329099 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse Clang when referring to the project and clang when referring to the binary.
Richard Smith [Tue, 3 Apr 2018 18:28:13 +0000 (18:28 +0000)]
Use Clang when referring to the project and clang when referring to the binary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329098 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRestrict a test using named file descriptors to using the system shell
David Blaikie [Tue, 3 Apr 2018 18:22:14 +0000 (18:22 +0000)]
Restrict a test using named file descriptors to using the system shell

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329097 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Hexagon] Remove -mhvx-double and the corresponding subtarget feature
Krzysztof Parzyszek [Tue, 3 Apr 2018 15:59:10 +0000 (15:59 +0000)]
[Hexagon] Remove -mhvx-double and the corresponding subtarget feature

Specifying the HVX vector length should be done via the -mhvx-length
option.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329077 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format/ObjC] Do not detect "[]" as ObjC method expression
Ben Hamilton [Tue, 3 Apr 2018 14:07:11 +0000 (14:07 +0000)]
[clang-format/ObjC] Do not detect "[]" as ObjC method expression

Summary:
The following C++ code was being detected by
`guessLanguage()` as Objective-C:

  #define FOO(...) auto bar = [] __VA_ARGS__;

This was because `[] __VA_ARGS__` is not currently detected as a C++
lambda expression (it has no parens or braces), so
`TokenAnnotator::parseSquare()` incorrectly treats the opening square
as an ObjC method expression.

We have two options to fix this:

1. Parse `[] __VA_ARGS__` explicitly as a C++ lambda
2. Make it so `[]` is never parsed as an Objective-C method expression

This diff implements option 2, which causes the `[` to be parsed
as `TT_ArraySubscriptLSquare` instead of `TT_ObjCMethodExpr`.

Note that when I fixed this, it caused one change in formatting
behavior, where the following was implicitly relying on the `[`
being parsed as `TT_ObjCMethodExpr`:

  A<int * []> a;

becomes:

  A<int *[]> a;

with `Style.PointerAlignment = Middle`.

I don't really know what the desired format is for this syntax; the
test was added by Janusz Sobczak and integrated by @djasper in
https://github.com/llvm-mirror/clang/commit/b511fe9818829d7ece0cc0b2ce1fbe04a1f0739a
.

I went ahead and changed the test for now.

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Fixes: https://bugs.llvm.org/show_bug.cgi?id=36248
Reviewers: djasper, jolesiak

Reviewed By: djasper

Subscribers: klimek, cfe-commits, djasper

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329070 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format/ObjC] Do not insert space after opening brace of ObjC dict literal
Ben Hamilton [Tue, 3 Apr 2018 14:07:09 +0000 (14:07 +0000)]
[clang-format/ObjC] Do not insert space after opening brace of ObjC dict literal

Summary:
D44816 attempted to fix a few cases where `clang-format` incorrectly
inserted a space before the closing brace of an Objective-C dictionary
literal.

This revealed there were still a few cases where we inserted a space
after the opening brace of an Objective-C dictionary literal.

This fixes the formatting to be consistent and adds more tests.

Test Plan: New tests added. Confirmed tests failed before
  diff and passed after diff.
  Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak, krasimir

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329069 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUsersManual.rst: update text for /GX- to match r328708
Hans Wennborg [Tue, 3 Apr 2018 09:28:21 +0000 (09:28 +0000)]
UsersManual.rst: update text for /GX- to match r328708

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329052 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
Eugene Zelenko [Tue, 3 Apr 2018 00:11:50 +0000 (00:11 +0000)]
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329036 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Wire up the -f[no-]rtlib-add-rpath flag and tests
Petr Hosek [Mon, 2 Apr 2018 23:36:14 +0000 (23:36 +0000)]
[Driver] Wire up the -f[no-]rtlib-add-rpath flag and tests

D30700 added the -f[no-]rtlib-add-rpath flag, but that flag was never
wired up in the driver and tests were updated to check whether it
actually does anything. This patch wires up the flag and updates test.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329032 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCodeGenCXX: support PreserveMostCC in MS ABI
Saleem Abdulrasool [Mon, 2 Apr 2018 22:25:50 +0000 (22:25 +0000)]
CodeGenCXX: support PreserveMostCC in MS ABI

Microsoft has reserved 'U' for the PreserveMostCC which is used in the
swift runtime.  Add support for this.  This allows the swift runtime to
be built for Windows again.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329025 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MS] Emit vftable thunks for functions with incomplete prototypes
Reid Kleckner [Mon, 2 Apr 2018 20:20:33 +0000 (20:20 +0000)]
[MS] Emit vftable thunks for functions with incomplete prototypes

Summary:
The following class hierarchy requires that we be able to emit a
this-adjusting thunk for B::foo in C's vftable:

  struct Incomplete;
  struct A {
    virtual A* foo(Incomplete p) = 0;
  };
  struct B : virtual A {
    void foo(Incomplete p) override;
  };
  struct C : B { int c; };

This TU is valid, but lacks a definition of 'Incomplete', which makes it
hard to build a thunk for the final overrider, B::foo.

Before this change, Clang gives up attempting to emit the thunk, because
it assumes that if the parameter types are incomplete, it must be
emitting the thunk for optimization purposes. This is untrue for the MS
ABI, where the implementation of B::foo has no idea what thunks C's
vftable may require. Clang needs to emit the thunk without necessarily
having access to the complete prototype of foo.

This change makes Clang emit a musttail variadic call when it needs such
a thunk. I call these "unprototyped" thunks, because they only prototype
the "this" parameter, which must always come first in the MS C++ ABI.

These thunks work, but they create ugly LLVM IR. If the call to the
thunk is devirtualized, it will be a call to a bitcast of a function
pointer. Today, LLVM cannot inline through such a call, but I want to
address that soon, because we also use this pattern for virtual member
pointer thunks.

This change also implements an old FIXME in the code about reusing the
thunk's computed CGFunctionInfo as much as possible. Now we don't end up
computing the thunk's mangled name and arranging it's prototype up to
around three times.

Fixes PR25641

Reviewers: rjmccall, rsmith, hans

Subscribers: Prazek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329009 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix some DenseMap use-after-rehash bugs and hoist MethodVFTableLocation
Reid Kleckner [Mon, 2 Apr 2018 20:00:39 +0000 (20:00 +0000)]
Fix some DenseMap use-after-rehash bugs and hoist MethodVFTableLocation

This re-lands r328845 with fixes for crbug.com/827810.

The initial motiviation was to hoist MethodVFTableLocation to global
scope so it could be forward declared.

In this patch, I noticed that MicrosoftVTableContext uses some risky
patterns. It has methods that return references to data stored in
DenseMaps. I've made some of them return by value for trivial structs
and I've moved some things into separate allocations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329007 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Attr] [NFC] Revert accidental change from r327405
Joel E. Denny [Mon, 2 Apr 2018 19:43:34 +0000 (19:43 +0000)]
[Attr] [NFC] Revert accidental change from r327405

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329005 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTemporarily revert r328404:
Eric Christopher [Mon, 2 Apr 2018 18:33:47 +0000 (18:33 +0000)]
Temporarily revert r328404:

commit 519b97132a4c960e8dedbfe4290d86970d92e995
Author: Richard Trieu <rtrieu@google.com>
Date:   Sat Mar 24 00:52:44 2018 +0000

    [ODRHash] Support pointer and reference types.

    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328404 91177308-0d34-0410-b5e6-96231b3b80d8

As it's breaking some tests. I've communicated with Richard offline about testcases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329001 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd -fclang-abi-compat=6 flag for upcoming ABI changes.
Richard Smith [Mon, 2 Apr 2018 18:29:44 +0000 (18:29 +0000)]
Add -fclang-abi-compat=6 flag for upcoming ABI changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329000 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd helper to determine if a field is a zero-length bitfield.
Richard Smith [Mon, 2 Apr 2018 18:29:43 +0000 (18:29 +0000)]
Add helper to determine if a field is a zero-length bitfield.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328999 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Let device-side shared variables be initialized with undef
Yaxun Liu [Mon, 2 Apr 2018 17:38:24 +0000 (17:38 +0000)]
[CUDA] Let device-side shared variables be initialized with undef

CUDA shared variable should be initialized with undef.

Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328994 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[coroutines] Add __builtin_coro_noop => llvm.coro.noop
Gor Nishanov [Mon, 2 Apr 2018 17:35:37 +0000 (17:35 +0000)]
[coroutines] Add __builtin_coro_noop => llvm.coro.noop

A recent addition to Coroutines TS (https://wg21.link/p0913) adds a pre-defined
coroutine noop_coroutine that does nothing. To implement this feature, we implemented
an llvm.coro.noop intrinsic that returns a coroutine handle to a coroutine that
does nothing when resumed or destroyed.

This patch adds a builtin __builtin_coro_noop() that maps to llvm.coro.noop intrinsic.

Related llvm change: https://reviews.llvm.org/D45114

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328993 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix unused variable warning introduced at revision 328910.
Andrea Di Biagio [Mon, 2 Apr 2018 12:04:37 +0000 (12:04 +0000)]
Fix unused variable warning introduced at revision 328910.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328968 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Coroutines] Schedule coro-split before asan
Brian Gesiak [Sun, 1 Apr 2018 23:55:21 +0000 (23:55 +0000)]
[Coroutines] Schedule coro-split before asan

Summary:
The docs for the LLVM coroutines intrinsic `@llvm.coro.id` state that
"The second argument, if not null, designates a particular alloca instruction
to be a coroutine promise."

However, if the address sanitizer pass is run before the `@llvm.coro.id`
intrinsic is lowered, the `alloca` instruction passed to the intrinsic as its
second argument is converted, as per the
https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm docs, to
an `inttoptr` instruction that accesses the address of the promise.

On optimization levels `-O1` and above, the `-asan` pass is run after
`-coro-early`, `-coro-split`, and `-coro-elide`, and before
`-coro-cleanup`, and so there is no issue. At `-O0`, however, `-asan`
is run in between `-coro-early` and `-coro-split`, which causes an
assertion to be hit when the `inttoptr` instruction is forcibly cast to
an `alloca`.

Rearrange the passes such that the coroutine passes are registered
before the sanitizer passes.

Test Plan:
Compile a simple C++ program that uses coroutines in `-O0` with
`-fsanitize-address`, and confirm no assertion is hit:
`clang++ coro-example.cpp -fcoroutines-ts -g -fsanitize=address -fno-omit-frame-pointer`.

Reviewers: GorNishanov, lewissbaker, EricWF

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328951 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Coroutines] Find custom allocators in class scope
Brian Gesiak [Sun, 1 Apr 2018 22:59:22 +0000 (22:59 +0000)]
[Coroutines] Find custom allocators in class scope

Summary:
https://reviews.llvm.org/rL325291 implemented Coroutines TS N4723
section [dcl.fct.def.coroutine]/7, but it performed lookup of allocator
functions within both the global and class scope, whereas the specified
behavior is to perform lookup for custom allocators within just the
class scope.

To fix, add parameters to the `Sema::FindAllocationFunctions` function
such that it can be used to lookup allocators in global scope,
class scope, or both (instead of just being able to look up in just global
scope or in both global and class scope). Then, use those parameters
from within the coroutine Sema.

This incorrect behavior had the unfortunate side-effect of causing the
bug https://bugs.llvm.org/show_bug.cgi?id=36578 (or at least the reports
of that bug in C++ programs). That bug would occur for any C++ user with
a coroutine frame that took a single pointer argument, since it would
then find the global placement form `operator new`, described in the
C++ standard 18.6.1.3.1. This patch prevents Clang from generating code
that triggers the LLVM assert described in that bug report.

Test Plan: `check-clang`

Reviewers: GorNishanov, eric_niebler, lewissbaker

Reviewed By: GorNishanov

Subscribers: EricWF, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328949 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix a major swiftcall ABI bug with trivial C++ class types.
John McCall [Sun, 1 Apr 2018 21:04:30 +0000 (21:04 +0000)]
Fix a major swiftcall ABI bug with trivial C++ class types.

The problem with the previous logic was that there might not be any
explicit copy/move constructor declarations, e.g. if the type is
trivial and we've never type-checked a copy of it.  Relying on Sema's
computation seems much more reliable.

Also, I believe Richard's recommendation is exactly the rule we use
now on the Itanium ABI, modulo the trivial_abi attribute (which this
change of course fixes our handling of in Swift).

This does mean that we have a less portable rule for deciding
indirectness for swiftcall.  I would prefer it if we just applied the
Itanium rule universally under swiftcall, but in the meantime, I need
to fix this bug.

This only arises when defining functions with class-type arguments
in C++, as we do in the Swift runtime.  It doesn't affect normal Swift
operation because we don't import code as C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328942 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd missing include to ContinuousRangeMap.h
Eric Fiselier [Sun, 1 Apr 2018 00:33:51 +0000 (00:33 +0000)]
Add missing include to ContinuousRangeMap.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328924 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd missing include to Visibility.h
Eric Fiselier [Sun, 1 Apr 2018 00:31:14 +0000 (00:31 +0000)]
Add missing include to Visibility.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328923 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r328845, it caused crbug.com/827810.
Nico Weber [Sat, 31 Mar 2018 18:26:25 +0000 (18:26 +0000)]
Revert r328845, it caused crbug.com/827810.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328922 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Unroll the loop when it has a unsigned counter.
Henry Wong [Sat, 31 Mar 2018 12:46:46 +0000 (12:46 +0000)]
[analyzer] Unroll the loop when it has a unsigned counter.

Summary:
The original implementation in the `LoopUnrolling.cpp` didn't consider the case where the counter is unsigned. This case is only handled in `simpleCondition()`, but this is not enough, we also need to deal with the unsinged counter with the counter initialization.

Since `IntegerLiteral` is `signed`, there is a `ImplicitCastExpr<IntegralCast>` in `unsigned counter = IntergerLiteral`. This patch add the `ignoringParenImpCasts()` in the `IntegerLiteral` matcher.

Reviewers: szepet, a.sidorin, NoQ, george.karpenkov

Reviewed By: szepet, george.karpenkov

Subscribers: xazax.hun, rnkovacs, cfe-commits, MTC

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328919 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Hopefully fix the ARM buildbot.
George Karpenkov [Sat, 31 Mar 2018 02:17:15 +0000 (02:17 +0000)]
[analyzer] Hopefully fix the ARM buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328913 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix assertion crash in CStringChecker
George Karpenkov [Sat, 31 Mar 2018 01:20:08 +0000 (01:20 +0000)]
[analyzer] Fix assertion crash in CStringChecker

An offset might be unknown.

rdar://39054939

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328912 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Cache offset computation for MemRegion
George Karpenkov [Sat, 31 Mar 2018 01:20:07 +0000 (01:20 +0000)]
[analyzer] Cache offset computation for MemRegion

Achieves almost a 200% speedup on the example where the performance of
visitors was problematic.

Performance on sqlite3 is unaffected.

rdar://38818362

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328911 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix liveness calculation for C++17 structured bindings
George Karpenkov [Sat, 31 Mar 2018 01:20:06 +0000 (01:20 +0000)]
[analyzer] Fix liveness calculation for C++17 structured bindings

C++ structured bindings for non-tuple-types are defined in a peculiar
way, where the resulting declaration is not a VarDecl, but a
BindingDecl.
That means a lot of existing machinery stops working.

rdar://36912381

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328910 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTImporter] Add test helper Fixture
Peter Szecsi [Fri, 30 Mar 2018 22:03:29 +0000 (22:03 +0000)]
[ASTImporter] Add test helper Fixture

Add a helper test Fixture, so we can add tests which can check internal
attributes of AST nodes like getPreviousDecl(), isVirtual(), etc.
This enables us to check if a redeclaration chain is correctly built during
import, if the virtual flag is preserved during import, etc. We cannot check
such attributes with the existing testImport.
Also, this fixture makes it possible to import from several "From" contexts.

We also added several test cases here, some of them are disabled.
We plan to pass the disabled tests in other patches.

Patch by Gabor Marton!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328906 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix test triple in missing-bind-temporary.cpp.
Artem Dergachev [Fri, 30 Mar 2018 21:22:35 +0000 (21:22 +0000)]
[analyzer] Fix test triple in missing-bind-temporary.cpp.

Otherwise the default triple for x86-windows-msvc2015 auto-inserts
__attribute__((thiscall)) to some calls.

Fixes the respective buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328903 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Track null or undef values through pointer arithmetic.
Artem Dergachev [Fri, 30 Mar 2018 19:27:42 +0000 (19:27 +0000)]
[analyzer] Track null or undef values through pointer arithmetic.

Pointer arithmetic on null or undefined pointers results in null or undefined
pointers. This is obvious for undefined pointers; for null pointers it follows
from our incorrect-but-somehow-working approach that declares that 0 (Loc)
doesn't necessarily represent a pointer of numeric address value 0, but instead
it represents any pointer that will cause a valid "null pointer dereference"
issue when dereferenced.

For now we've been seeing through pointer arithmetic at the original dereference
expression, i.e. in bugreporter::getDerefExpr(), but not during further
investigation of the value's origins in bugreporter::trackNullOrUndefValue().
The patch fixes it.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328896 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CFG] [analyzer] Work around a disappearing CXXBindTemporaryExpr.
Artem Dergachev [Fri, 30 Mar 2018 19:25:39 +0000 (19:25 +0000)]
[CFG] [analyzer] Work around a disappearing CXXBindTemporaryExpr.

Sometimes template instantiation causes CXXBindTemporaryExpr to be missing in
its usual spot. In CFG, temporary destructors work by relying on
CXXBindTemporaryExprs, so they won't work in this case.

Avoid the crash and notify the clients that we've encountered an unsupported AST
by failing to provide the ill-formed construction context for the temporary.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328895 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CFG] [analyzer] Avoid modeling C++17 constructors that aren't fully supported.
Artem Dergachev [Fri, 30 Mar 2018 19:21:18 +0000 (19:21 +0000)]
[CFG] [analyzer] Avoid modeling C++17 constructors that aren't fully supported.

Not enough work has been done so far to ensure correctness of construction
contexts in the CFG when C++17 copy elision is in effect, so for now we
should drop construction contexts in the CFG and in the analyzer when
they seem different from what we support anyway.

This includes initializations with conditional operators and return values
across multiple stack frames.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328893 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove unused CHECK lines leftover from r306928.
Eli Friedman [Fri, 30 Mar 2018 18:39:28 +0000 (18:39 +0000)]
Remove unused CHECK lines leftover from r306928.

The RUN lines were removed, but the corresponding CHECK lines never
went away.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328891 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Added emission of offloading data sections for declare target
Alexey Bataev [Fri, 30 Mar 2018 18:31:07 +0000 (18:31 +0000)]
[OPENMP] Added emission of offloading data sections for declare target
variables.

Added emission of the offloading data sections for the variables within
declare target regions + fixes emission of the declare target variables
marked as declare target not within the declare target region.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328888 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Ensure wrapped ObjC selectors with 1 arg obey IndentWrappedFunctionNames
Ben Hamilton [Fri, 30 Mar 2018 15:38:45 +0000 (15:38 +0000)]
[clang-format] Ensure wrapped ObjC selectors with 1 arg obey IndentWrappedFunctionNames

Summary:
In D43121, @Typz introduced logic to avoid indenting 2-or-more
argument ObjC selectors too far to the right if the first component
of the selector was longer than the others.

This had a small side effect of causing wrapped ObjC selectors with
exactly 1 argument to not obey IndentWrappedFunctionNames:

```
- (aaaaaaaaaa)
aaaaaaaaaa;
```

This diff fixes the issue by ensuring we align wrapped 1-argument
ObjC selectors correctly:

```
- (aaaaaaaaaa)
    aaaaaaaaaa;
```

Test Plan: New tests added. Test failed before change, passed
  after change. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, klimek, Typz, jolesiak

Reviewed By: djasper, jolesiak

Subscribers: cfe-commits, Typz

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328871 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Remove the unused method declaration in `ValistChecker.cpp`.
Henry Wong [Fri, 30 Mar 2018 13:37:50 +0000 (13:37 +0000)]
[analyzer] Remove the unused method declaration in `ValistChecker.cpp`.

Summary: `getVariableNameFromRegion()` seems useless.

Reviewers: xazax.hun, george.karpenkov

Reviewed By: xazax.hun

Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits, MTC

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328860 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Modules] Improve fixit for framework private module maps
Bruno Cardoso Lopes [Fri, 30 Mar 2018 05:17:58 +0000 (05:17 +0000)]
[Modules] Improve fixit for framework private module maps

The wrong source range was being provided in some case, fix that to get
a better fixit.

rdar://problem/38520199

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328857 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdding UNSUPPORTED: system-windows at George's request until the problem can be debugged.
Douglas Yung [Fri, 30 Mar 2018 01:29:07 +0000 (01:29 +0000)]
Adding UNSUPPORTED: system-windows at George's request until the problem can be debugged.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328853 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoHoist MethodVFTableLocation out of MicrosoftVTableContext, NFC
Reid Kleckner [Thu, 29 Mar 2018 22:42:24 +0000 (22:42 +0000)]
Hoist MethodVFTableLocation out of MicrosoftVTableContext, NFC

This allows forward declaring it so that we can add it to
MicrosoftMangleContext::mangleVirtualMemPtrThunk without including
VTableBuilder.h. That saves a hashtable lookup when emitting virtual
member pointer functions.

It also shortens a really long type name. This struct has "VFtable" in
the name, so it seems pretty unlikely that someone will assume it is
generally useful for non-MS C++ ABI stuff.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328845 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix target triple for autorelease-write-checker test
George Karpenkov [Thu, 29 Mar 2018 22:28:04 +0000 (22:28 +0000)]
[analyzer] Fix target triple for autorelease-write-checker test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328837 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSet dso_local on cfi_slowpath.
Rafael Espindola [Thu, 29 Mar 2018 22:08:01 +0000 (22:08 +0000)]
Set dso_local on cfi_slowpath.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328836 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Better pretty-printing of regions in exploded graph
George Karpenkov [Thu, 29 Mar 2018 22:07:58 +0000 (22:07 +0000)]
[analyzer] Better pretty-printing of regions in exploded graph

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328835 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AArch64]: Add support for parsing rN registers.
Manoj Gupta [Thu, 29 Mar 2018 21:11:15 +0000 (21:11 +0000)]
[AArch64]: Add support for parsing rN registers.

Summary:
Allow rN registers to be simply parsed as correspoing xN registers.
The "register ... asm("rN")" is an command to the
compiler's register allocator, not an operand to any individual assembly
instruction. GCC documents this syntax as "...the name of the register
that should be used."

This is needed to support the changes in Linux kernel (see
https://lkml.org/lkml/2018/3/1/268 )

Note: This will add support only for the limited use case of
register ... asm("rN"). Any other uses that make rN leak into assembly
are not supported.

Reviewers: kristof.beyls, rengolin, peter.smith, t.p.northover

Reviewed By: peter.smith

Subscribers: javed.absar, eraman, cfe-commits, srhines

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328829 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Path-insensitive checker for writes into an auto-releasing pointer
George Karpenkov [Thu, 29 Mar 2018 20:55:34 +0000 (20:55 +0000)]
[analyzer] Path-insensitive checker for writes into an auto-releasing pointer

from the wrong auto-releasing pool, as such writes may crash.

rdar://25301111

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328827 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
Eugene Zelenko [Thu, 29 Mar 2018 20:51:59 +0000 (20:51 +0000)]
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328826 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMark __cfi_check as dso_local.
Rafael Espindola [Thu, 29 Mar 2018 20:51:30 +0000 (20:51 +0000)]
Mark __cfi_check as dso_local.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328825 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoGeneralize NRVO to cover C structs.
Akira Hatanaka [Thu, 29 Mar 2018 17:56:24 +0000 (17:56 +0000)]
Generalize NRVO to cover C structs.

This commit generalizes NRVO to cover C structs (both trivial and
non-trivial structs).

rdar://problem/33599681

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328809 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.
Volodymyr Sapsai [Thu, 29 Mar 2018 17:34:09 +0000 (17:34 +0000)]
[Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.

Deprecation replacement can be any text but if it looks like a name of
ObjC method and has the same number of arguments as original method,
replace all slot names so after applying a fix-it you have valid code.

rdar://problem/36660853

Reviewers: aaron.ballman, erik.pilkington, rsmith

Reviewed By: erik.pilkington

Subscribers: cfe-commits, jkorous-apple

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328807 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSet dso_local when clearing dllimport.
Rafael Espindola [Thu, 29 Mar 2018 16:45:18 +0000 (16:45 +0000)]
Set dso_local when clearing dllimport.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328801 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd a dllimport test.
Rafael Espindola [Thu, 29 Mar 2018 16:35:52 +0000 (16:35 +0000)]
Add a dllimport test.

Thanks to rnk for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328800 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[test] Fix an XRay test on FreeBSD
Zhihao Yuan [Thu, 29 Mar 2018 15:50:44 +0000 (15:50 +0000)]
[test] Fix an XRay test on FreeBSD

Summary: Fixing clang-test on FreeBSD as a follow-up of https://reviews.llvm.org/D43378 to handle the revert happened in r325749.

Reviewers: devnexen, krytarowski, dberris

Subscribers: emaste, dberris, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328797 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSet calling convention for CUDA kernel
Yaxun Liu [Thu, 29 Mar 2018 15:02:08 +0000 (15:02 +0000)]
Set calling convention for CUDA kernel

This patch sets target specific calling convention for CUDA kernels in IR.

Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328795 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDisable emitting static extern C aliases for amdgcn target for CUDA
Yaxun Liu [Thu, 29 Mar 2018 14:50:00 +0000 (14:50 +0000)]
Disable emitting static extern C aliases for amdgcn target for CUDA

Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328793 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix typo
Matt Arsenault [Thu, 29 Mar 2018 14:31:59 +0000 (14:31 +0000)]
Fix typo

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328791 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Hexagon] Aid bit-reverse load intrinsics lowering with bitcode
Krzysztof Parzyszek [Thu, 29 Mar 2018 13:54:31 +0000 (13:54 +0000)]
[Hexagon] Aid bit-reverse load intrinsics lowering with bitcode

The conversion of operatios to bitcode helps to eliminate an additional
store in certain cases. We used to lower these load intrinsics in DAG to
DAG conversion by which time, the "Dead Store Elimination" pass is
already run. There is an associated LLVM patch.

Patch by Sumanth Gundapaneni.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328776 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRename clang link from clang-X.Y to clang-X
Sylvestre Ledru [Thu, 29 Mar 2018 10:05:46 +0000 (10:05 +0000)]
Rename clang link from clang-X.Y to clang-X

Summary:
As we are only doing X.0.Z releases (not using the minor version), there is no need to keep -X.Y in the version.
So, instead, I propose the following:
Instead of having clang-7.0 in bin/, we will have clang-7

Since also matches was gcc is doing.

Reviewers: tstellar, dlj, dim, hans

Reviewed By: dim, hans

Subscribers: dim, mgorny, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328769 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRefactor some code for a warning. NFC.
Richard Trieu [Thu, 29 Mar 2018 05:14:17 +0000 (05:14 +0000)]
Refactor some code for a warning.  NFC.

Use range-based for-loops instead of iterators to walk over vectors.
Switch the key of the DenseMap so a custom key handler is no longer needed.
Remove unncessary adds to the DenseMap.
Use unique_ptr instead of manual memory management.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328763 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[astmatchers] Fix linking issue
George Karpenkov [Thu, 29 Mar 2018 02:47:28 +0000 (02:47 +0000)]
[astmatchers] Fix linking issue

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328754 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] [testing] Be less verbose by default in integration testing.
George Karpenkov [Thu, 29 Mar 2018 01:23:54 +0000 (01:23 +0000)]
[analyzer] [testing] Be less verbose by default in integration testing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328752 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[astmatchers] Move a matcher out of internal namespace: blind debugging of MSVC issues
George Karpenkov [Thu, 29 Mar 2018 01:15:05 +0000 (01:15 +0000)]
[astmatchers] Move a matcher out of internal namespace: blind debugging of MSVC issues

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328750 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ in templ...
George Karpenkov [Thu, 29 Mar 2018 00:56:24 +0000 (00:56 +0000)]
[ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ in templatized code under ARC

The AST for the fragment

```
@interface I
@end

template <typename>
void decode(I *p) {
  for (I *k in p) {}
}

void decode(I *p) {
  decode<int>(p);
}
```

differs heavily when templatized and non-templatized:

```
|-FunctionTemplateDecl 0x7fbfe0863940 <line:4:1, line:7:1> line:5:6 decode
| |-TemplateTypeParmDecl 0x7fbfe0863690 <line:4:11> col:11 typename depth 0 index 0
| |-FunctionDecl 0x7fbfe08638a0 <line:5:1, line:7:1> line:5:6 decode 'void (I *__strong)'
| | |-ParmVarDecl 0x7fbfe08637a0 <col:13, col:16> col:16 referenced p 'I *__strong'
| | `-CompoundStmt 0x7fbfe0863b88 <col:19, line:7:1>
| |   `-ObjCForCollectionStmt 0x7fbfe0863b50 <line:6:3, col:20>
| |     |-DeclStmt 0x7fbfe0863a50 <col:8, col:13>
| |     | `-VarDecl 0x7fbfe08639f0 <col:8, col:11> col:11 k 'I *const __strong'
| |     |-ImplicitCastExpr 0x7fbfe0863a90 <col:16> 'I *' <LValueToRValue>
| |     | `-DeclRefExpr 0x7fbfe0863a68 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe08637a0 'p' 'I *__strong'
| |     `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20>
| `-FunctionDecl 0x7fbfe0863f80 <line:5:1, line:7:1> line:5:6 used decode 'void (I *__strong)'
|   |-TemplateArgument type 'int'
|   |-ParmVarDecl 0x7fbfe0863ef8 <col:13, col:16> col:16 used p 'I *__strong'
|   `-CompoundStmt 0x7fbfe0890cf0 <col:19, line:7:1>
|     `-ObjCForCollectionStmt 0x7fbfe0890cc8 <line:6:3, col:20>
|       |-DeclStmt 0x7fbfe0890c70 <col:8, col:13>
|       | `-VarDecl 0x7fbfe0890c00 <col:8, col:11> col:11 k 'I *__strong' callinit
|       |   `-ImplicitValueInitExpr 0x7fbfe0890c60 <<invalid sloc>> 'I *__strong'
|       |-ImplicitCastExpr 0x7fbfe0890cb0 <col:16> 'I *' <LValueToRValue>
|       | `-DeclRefExpr 0x7fbfe0890c88 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe0863ef8 'p' 'I *__strong'
|       `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20>
```

Note how in the instantiated version ImplicitValueInitExpr unexpectedly appears.

While objects are auto-initialized under ARC, it does not make sense to
have an initializer for a for-loop variable, and it makes even less
sense to have such a different AST for instantiated and non-instantiated
version.

Digging deeper, I have found that there are two separate Sema* files for
dealing with templates and for dealing with non-templatized code.
In a non-templatized version, an initialization was performed only for
variables which are not loop variables for an Objective-C loop and not
variables for a C++ for-in loop:

```
  if (FRI && (Tok.is(tok::colon) || isTokIdentifier_in())) {
    bool IsForRangeLoop = false;
    if (TryConsumeToken(tok::colon, FRI->ColonLoc)) {
      IsForRangeLoop = true;
      if (Tok.is(tok::l_brace))
        FRI->RangeExpr = ParseBraceInitializer();
      else
        FRI->RangeExpr = ParseExpression();
    }

    Decl *ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
    if (IsForRangeLoop)
      Actions.ActOnCXXForRangeDecl(ThisDecl);
    Actions.FinalizeDeclaration(ThisDecl);
    D.complete(ThisDecl);
    return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, ThisDecl);
  }

  SmallVector<Decl *, 8> DeclsInGroup;
  Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(
      D, ParsedTemplateInfo(), FRI);
```

However the code in SemaTemplateInstantiateDecl was inconsistent,
guarding only against C++ for-in loops.

rdar://38391075

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328749 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTMatchers] Introduce a matcher for matching any given Objective-C selector
George Karpenkov [Thu, 29 Mar 2018 00:51:12 +0000 (00:51 +0000)]
[ASTMatchers] Introduce a matcher for matching any given Objective-C selector

Incudes a tiny related refactoring.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328747 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective...
George Karpenkov [Thu, 29 Mar 2018 00:51:11 +0000 (00:51 +0000)]
[ASTMatchers] Extend hasParameter and hasAnyParameter matches to handle Objective-C methods

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328746 91177308-0d34-0410-b5e6-96231b3b80d8