Commit Graph

6899 Commits

Author SHA1 Message Date
Richard Trieu 0255227a58 [ODRHash] Add support for array and decayed types, and parameter names and types.
llvm-svn: 301989
2017-05-02 23:58:52 +00:00
Daniel Jasper ffdee09350 Revert r301822 (and dependent r301825), which tried to improve the
handling of constexprs with unknown bounds.

This triggers a corner case of the language where it's not yet clear
whether this should be an error:

  struct A {
    static void *const a[];
    static void *const b[];
  };
  constexpr void *A::a[] = {&b[0]};
  constexpr void *A::b[] = {&a[0]};

When discovering the initializer for A::a, the bounds of A::b aren't known yet.
It is unclear whether warning about errors should be deferred until the end of
the translation unit, possibly resolving errors that can be resolved. In
practice, the compiler can know the bounds of all arrays in this example.

Credits for reproducers and explanation go to Richard Smith. Richard, please
add more info in case my explanation is wrong.

llvm-svn: 301963
2017-05-02 19:21:42 +00:00
Nick Lewycky c190f96b7d Revert r301785 (and r301787) because they caused PR32864.
The fix is that ExprEvaluatorBase::VisitInitListExpr should handle transparent exprs instead of exprs with one element. Fixing that uncovers one testcase failure because the AST for "constexpr _Complex float test2 = {1};" is wrong (the _Complex prvalue should not be const-qualified), and a number of test failures in test/OpenMP where the captured stmt contains an InitListExpr that is in syntactic form.

llvm-svn: 301891
2017-05-02 01:06:16 +00:00
Benjamin Kramer 5699969912 Silence unused variable warning. NFC.
llvm-svn: 301825
2017-05-01 20:00:23 +00:00
Richard Smith eec904f849 Improve handling of arrays of unknown bound in constant expressions.
Do not spuriously reject constexpr functions that access elements of an array
of unknown bound; this may later become valid once the bound is known. Permit
array-to-pointer decay on such arrays, but disallow pointer arithmetic (since
we do not know whether it will have defined behavior).

The standard is not clear on how this should work, but this seems to be a
decent answer.

Patch by Robert Haberlach!

llvm-svn: 301822
2017-05-01 18:49:04 +00:00
Nick Lewycky 499968f8a5 Handle expressions with non-literal types like ignored expressions if we are supposed to continue evaluating them.
Also fix a crash casting a derived nullptr to a virtual base.

llvm-svn: 301785
2017-05-01 02:03:23 +00:00
Nick Lewycky e7d6fbdfb7 Remove Sema::CheckForIntOverflow, and instead check all full-expressions.
CheckForIntOverflow used to implement a whitelist of top-level expressions to
send to the constant expression evaluator, which handled many more expressions
than the CheckForIntOverflow whitelist did.

llvm-svn: 301742
2017-04-29 09:33:46 +00:00
Nick Lewycky 19ae6dc853 ObjCBoxedExpr can't be evaluated by the constant expression evaluator.
A boxed expression evaluates its subexpr and then calls an objc method to transform it into another value with pointer type. The objc method can never be constexpr and therefore this expression can never be evaluated. Fixes a miscompile boxing expressions with side-effects.

Also make ObjCBoxedExpr handling a normal part of the expression evaluator instead of being the only case besides full-expression where we check for integer overflow.

llvm-svn: 301721
2017-04-29 00:07:27 +00:00
Bruno Cardoso Lopes 95ff11b7d1 [ASTImporter] Move structural equivalence context to its own file. NFCI
Create a header and impl file for the structural equivalence context.
This is to allow other users outside clang importer. NFCI

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

rdar://problem/30167717

llvm-svn: 301604
2017-04-28 00:31:30 +00:00
Oren Ben Simhon 318a6eae06 [X86] Support of no_caller_saved_registers attribute
Implements the Clang part for no_caller_saved_registers attribute as appears here: 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be.

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

llvm-svn: 301535
2017-04-27 12:01:00 +00:00
Alex Lorenz a8a372d85e [ObjC] Disallow vector parameters and return values in Objective-C methods
for iOS < 9 and OS X < 10.11 X86 targets

This commit adds a new error that disallows methods that have parameters/return
values with a vector type for some older X86 targets. This diagnostic is
needed because objc_msgSend doesn't support SIMD vector registers/return values
on X86 in iOS < 9 and OS X < 10.11. Note that we don't necessarily know if the
vector argument/return value will use a SIMD register, so instead we chose to
be conservative and prohibit all vector types.

rdar://21662309

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

llvm-svn: 301532
2017-04-27 10:43:48 +00:00
Nick Lewycky ad8886896e In the expression evaluator, visit the index of an ArraySubscriptExpr even if we can't evaluate the base, if the evaluation mode tells us to continue evaluation.
llvm-svn: 301522
2017-04-27 07:27:36 +00:00
Nick Lewycky 20edee6a3e In the expression evaluator, descend into both the true and false expressions of a ConditionalOperator when the condition can't be evaluated and we're in an evaluation mode that says we should continue evaluating.
llvm-svn: 301520
2017-04-27 07:11:09 +00:00
Alex Lorenz 00353a0bf9 -Wdocumentation should not check the @returns command for Objective-C
function/block pointer properties

The commit r300981 allowed @param/@return commands for function/block
pointer property declarations. This meant that -Wdocumentation started warning
about @return that was used to document properties whose function/block type
returned void. However, prior to that commit, we allowed @return for all
property declarations, because it can be used to document the value that's
returned by the property getter. This commit restores the previous behaviour:
now the @return command can be used to document all properties without warnings.

rdar://24978538

llvm-svn: 301402
2017-04-26 13:09:28 +00:00
Alex Lorenz 6246cc6c0e [AST] Look through attribute type locs when searching for function type
loc

Prior to this commit -Wdocumentation crashed when checking the @returns command
for declarations whose function/block pointer type included an attribute like
_Nullable.

rdar://31818195

llvm-svn: 301400
2017-04-26 12:46:27 +00:00
Bruno Cardoso Lopes faaeae5d6e [Modules][ObjC] Check definition from canonical decl on designated initializers
Use definition from canonical decl when checking for designated
initializers. This is necessary since deserialization of a interface
might reuse the definition from the canonical one (see r281119).

rdar://problem/29360655

llvm-svn: 301382
2017-04-26 05:06:20 +00:00
Alex Lorenz 6b82a75df5 [PR32667] -Wdocumentation should allow @param/@returns for fields/variables
that have a function/block pointer type

This commit improves the -Wdocumentation warning by making sure that @param and
@returns commands won't trigger warnings when used for fields, variables,
or properties whose type is a function/block pointer type. The
function/block pointer type must be specified directly with the declaration,
and when a typedef is used the warning is still emitted.

In the future we might also want to handle the std::function type as well.

rdar://24978538

llvm-svn: 300981
2017-04-21 14:17:49 +00:00
Richard Smith 2195ec9ad4 [modules] Properly look up the owning module for an instantiation of a merged template.
When looking for the template instantiation pattern of a templated entity,
consistently select the definition of the pattern if there is one. This means
we'll pick the same owning module when we start instantiating a template that
we'll later pick when determining which modules are visible during that
instantiation.

This reinstates r300650, reverted in r300659, with a fix for a regression
reported by Chandler after commit.

llvm-svn: 300938
2017-04-21 01:15:13 +00:00
Carlo Bertolli ffafe10fac [OpenMP] Prepare sema to support combined constructs with omp distribute and omp for
https://reviews.llvm.org/D32237

This patch prepares sema with additional fields to support all those composite and combined constructs of OpenMP that include pragma 'distribute' and 'for', such as 'distribute parallel for'. It also extends the regression tests for 'distribute parallel for' and adds a new one.

llvm-svn: 300802
2017-04-20 00:39:39 +00:00
Erich Keane 4b87d81068 Corrrect warn_unused_result attribute
The original idea was that if the attribute on an operator, 
that the return-value unused-ness wouldn't matter. However, 
all of the operators except postfix inc/dec return 
references! References don't result in this warning 
anyway, so those are already excluded.

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

llvm-svn: 300764
2017-04-19 21:24:55 +00:00
Gabor Horvath 10a837a27e Remove unnecessary condition as suggested by clang-tidy. NFC
Patch by: Gergely Angeli!

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

llvm-svn: 300703
2017-04-19 15:11:10 +00:00
Roger Ferrer Ibanez cb89513bc7 Avoid assert when a non-static member function is qualified with __unaligned
Under -fms-extensions __unaligned is a type-qualifier that can be applied to a
non-static member function declaration.

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

This patch justs makes the minimal change to avoid the crash and avoid mangling
__unaligned, as it currently happens with non-member functions.

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

llvm-svn: 300686
2017-04-19 12:23:28 +00:00
Chandler Carruth bd186c0787 Revert r300653 and r300650. The underlying commit fixes one issue with
modules but exposes much more widespread issues. Example and more
information is on the review thread for r300650.

Original commit summary:
[modules] Properly look up the owning module for an instantiation of a merged template.

llvm-svn: 300659
2017-04-19 05:25:13 +00:00
Richard Smith eb86173f7b Fix member function call with null 'this' pointer.
llvm-svn: 300653
2017-04-19 02:19:21 +00:00
Richard Smith 5aacc4021b [modules] Properly look up the owning module for an instantiation of a merged template.
When looking for the template instantiation pattern of a templated entity,
consistently select the definition of the pattern if there is one. This means
we'll pick the same owning module when we start instantiating a template that
we'll later pick when determining which modules are visible during that
instantiation.

llvm-svn: 300650
2017-04-19 01:36:43 +00:00
Alex Lorenz 47fd10c3b5 [ASTPrinter] Print template parameter lists for out-of-line functions
llvm-svn: 300560
2017-04-18 15:12:34 +00:00
Benjamin Kramer dcb52b167a Revert "Address http://bugs.llvm.org/pr30994 so that a non-friend can properly replace a friend, and a visible friend can properly replace an invisible friend but not vice verse, and definitions are not replaced. This fixes the two FIXME in SemaTemplate/friend-template.cpp."
This reverts commit r300443. Breaks compiling libc++ with modules in
some configurations.

llvm-svn: 300497
2017-04-17 20:57:40 +00:00
David Blaikie 0a0c033295 Use default ref capture to simplify local lambdas, use a template to avoid std::function overhead, other cleanup
llvm-svn: 300461
2017-04-17 17:16:19 +00:00
Yaron Keren 27e2ff964f Address http://bugs.llvm.org/pr30994 so that a non-friend can properly replace a friend, and a visible friend can properly replace an invisible friend but not vice verse, and definitions are not replaced. This fixes the two FIXME in SemaTemplate/friend-template.cpp.
The code implements Richard Smith suggestion in comment 3 of the PR.

reviewer: Vassil Vassilev

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

llvm-svn: 300443
2017-04-17 08:51:20 +00:00
NAKAMURA Takumi 23ad196a22 ExternalASTMerger.cpp: Silence another warning. [-Wunused-lambda-capture]
llvm-svn: 300145
2017-04-13 00:17:28 +00:00
Hans Wennborg 227077613a Revert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"
It caused PR32640.

llvm-svn: 300074
2017-04-12 16:40:26 +00:00
Benjamin Kramer 4ecc848ebd Silence unused variable warning in release builds.
llvm-svn: 300006
2017-04-11 23:06:49 +00:00
Richard Trieu 304ef22e6e Revert r298824 & r298816, recommit r298742 & r298754
r299989 fixes the underlying issue by waiting long enough to late parsed
arguments to be processed before doing an calculating the hash.

r298742
[ODRHash] Add error messages for mismatched parameters in methods.

r298754
[ODRHash] Add support for array and decayed types.

llvm-svn: 300001
2017-04-11 22:32:03 +00:00
Richard Trieu fd1acbb9bb [ODRHash] Improve handling of hash values
Calculating the hash in Sema::ActOnTagFinishDefinition could happen before
all sub-Decls were parsed or processed, which would produce the wrong hash
value.  Change to calculating the hash on the first use and storing the value
instead.  Also, avoid using the macros that were only for Boolean fields and
use an explicit checker during the DefintionData merge.  No functional change,
but was this blocking other ODRHash patches.

llvm-svn: 299989
2017-04-11 21:31:00 +00:00
David Blaikie 1ac9c98e6c Modular Codegen: Support homing debug info for types in modular objects
Matching the function-homing support for modular codegen. Any type
implicitly (implicit template specializations) or explicitly defined in
a module is attached to that module's object file and omitted elsewhere
(only a declaration used if necessary for references).

llvm-svn: 299987
2017-04-11 21:13:37 +00:00
Sean Callanan f8edb1de32 [ExternalASTMerger] Removed a move constructor to address MSVC build failure
llvm-svn: 299983
2017-04-11 20:51:21 +00:00
David Blaikie e6b7c28d17 Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen
Some decls are created not where they are written, but in other module
files/users (implicit special members and function template implicit
specializations). To correctly identify them, use a bit next to the definition
to track the modular codegen property.

Discussed whether the module file bit could be omitted in favor of
reconstituting from the modular codegen decls list - best guess today is that
the efficiency improvement of not having to deserialize the whole list whenever
any function is queried by a module user is worth it for the small size
increase of this redundant (list + bit-on-def) representation.

Reviewers: rsmith

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

llvm-svn: 299982
2017-04-11 20:46:34 +00:00
Aaron Ballman 4c54fe0c7b Add const children() accessors to match the existing non-const children() accessors.
llvm-svn: 299981
2017-04-11 20:21:30 +00:00
Sean Callanan 4bb0d78c84 [ExternalASTMerger] Fix the MSVC build
llvm-svn: 299977
2017-04-11 19:50:37 +00:00
Sean Callanan b7160ca466 [clang-import-test] Lookup inside contexts
clang-import-test has until now been only able to report top-level Decls.
This is clearly insufficient; we should be able to look inside structs 
and namespaces also.  This patch adds new test cases for a variety of 
lookups inside existing ASTContexts, and adds the functionality necessar
to make most of these testcases work.  (One testcase is known to fail 
because of ASTImporter limitations when importing templates; I'll look 
into that separately.)

This patch also separates the core functionality out into 
ExternalASTMerger, an interface that allows clients like LLDB to make 
use of it.  clang-import-test now only has the machinery necessary to
set up the tests.

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

llvm-svn: 299976
2017-04-11 19:33:35 +00:00
Yaxun Liu b34ec829be [OpenCL] Map default address space to alloca address space
For OpenCL, the private address space qualifier is 0 in AST. Before this change, 0 address space qualifier
is always mapped to target address space 0. As now target private address space is specified by
alloca address space in data layout, address space qualifier 0 needs to be mapped to alloca addr space specified by the data layout.

This change has no impact on targets whose alloca addr space is 0.

With contributions from Matt Arsenault, Tony Tye and Wen-Heng (Jack) Chung

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

llvm-svn: 299965
2017-04-11 17:24:23 +00:00
Alex Lorenz a981c7d79e [ASTPrinter] Print nested name specifiers for out-of-line functions
rdar://31501863

llvm-svn: 299962
2017-04-11 16:46:03 +00:00
Gabor Horvath 3b392bb8d8 Revert r299355 "[ASTImporter] Fix for importing unnamed structs"
It breaks windows bots. 

llvm-svn: 299386
2017-04-03 21:06:45 +00:00
Eric Fiselier bee782bb92 [coroutines] Fix rebuilding of implicit and dependent coroutine statements.
Summary:
Certain implicitly generated coroutine statements, such as the calls to 'return_value()' or `return_void()` or `get_return_object_on_allocation_failure()`, cannot be built until the promise type is no longer dependent. This means they are not built until after the coroutine body statement has been transformed.

This patch fixes an issue where these statements would never be built for coroutine templates.

It also fixes a small issue where diagnostics about `get_return_object_on_allocation_failure()` were incorrectly suppressed. 

Reviewers: rsmith, majnemer, GorNishanov, aaron.ballman

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 299380
2017-04-03 19:21:00 +00:00
Gabor Horvath 3d2c10d941 [ASTImporter] Fix for importing unnamed structs
Patch by Peter Szecsi!

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

llvm-svn: 299355
2017-04-03 11:57:11 +00:00
Gabor Horvath 5558ba2d82 [ASTImporter] Lookup SearchName instead of Name
When the SearchName is already calculated we should use that for the lookup.

Patch by Peter Szecsi!

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

llvm-svn: 299354
2017-04-03 09:30:20 +00:00
Simon Pilgrim 2c51880a82 Spelling mistakes in comments. NFCI. (PR27635)
llvm-svn: 299083
2017-03-30 14:13:19 +00:00
Craig Topper c396c538f1 [APInt] Remove references to integerPartWidth and integerPart outside of APFloat implentation.
Turns out integerPartWidth only explicitly defines the width of the tc functions in the APInt class. Functions that aren't used by APInt implementation itself. Many places in the code base already assume APInt is made up of 64-bit pieces. Explicitly assuming 64-bit here doesn't make that situation much worse. A full audit would need to be done if it ever changes.

llvm-svn: 299058
2017-03-30 05:48:58 +00:00
Dean Michael Berris 835832d37a [XRay] Add -fxray-{always,never}-instrument= flags to clang
Summary:
The -fxray-always-instrument= and -fxray-never-instrument= flags take
filenames that are used to imbue the XRay instrumentation attributes
using a whitelist mechanism (similar to the sanitizer special cases
list). We use the same syntax and semantics as the sanitizer blacklists
files in the implementation.

As implemented, we respect the attributes that are already defined in
the source file (i.e. those that have the
[[clang::xray_{always,never}_instrument]] attributes) before applying
the always/never instrument lists.

Reviewers: rsmith, chandlerc

Subscribers: jfb, mgorny, cfe-commits

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

llvm-svn: 299041
2017-03-30 00:29:36 +00:00
Brian Kelley cafd9121cb [Objective-C] Fix "repeated use of weak" warning with -fobjc-weak
Summary: -Warc-repeated-use-of-weak should produce the same warnings with -fobjc-weak as it does with -objc-arc. Also check for ObjCWeak along with ObjCAutoRefCount when recording the use of an evaluated weak variable. Add a -fobjc-weak run to the existing arc-repeated-weak test case and adapt it slightly to work in both modes.

Reviewers: rsmith, doug.gregor, jordan_rose, rjmccall

Reviewed By: rjmccall

Subscribers: arphaman, rjmccall, cfe-commits

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

llvm-svn: 299011
2017-03-29 17:55:11 +00:00