As suggested in the post-commit review for D50531,
change from the templatized TrailingObjects friend declaration
to a version referring to the base.
llvm-svn: 339382
ParsedAttr is using a hand-rolled trailing-objects
implementation that gets cleaned up quite a bit by
just using llvm::TrailingObjects. This is a large
TrailingObjects list, but most things are length '0'.
Differential Revision: https://reviews.llvm.org/D50531
llvm-svn: 339380
As a part of attempting to clean up the way attributes are
printed, this patch adds an operator << to the diagnostics/
partialdiagnostics so that ParsedAttr can be sent directly.
This patch also rewrites a large amount* of the times when
ParsedAttr was printed using its IdentifierInfo object instead
of being printed itself.
*"a large amount" == "All I could find".
llvm-svn: 339344
gcc defines an intrinsic called __builtin_clrsb which counts the number of extra sign bits on a number. This is equivalent to counting the number of leading zeros on a positive number or the number of leading ones on a negative number and subtracting one from the result. Since we can't count leading ones we need to invert negative numbers to count zeros.
This patch will cause the builtin to be expanded inline while gcc uses a call to a function like clrsbdi2 that is implemented in libgcc. But this is similar to what we already do for popcnt. And I don't think compiler-rt supports clrsbdi2.
Differential Revision: https://reviews.llvm.org/D50168
llvm-svn: 339282
Summary:
When checking a class or function the described class or function template
is checked too.
Split StructuralEquivalenceContext::Finish into multiple functions.
Improved test with symmetric check, added new tests.
Reviewers: martong, a.sidorin, a_sidorin, bruno
Reviewed By: martong, a.sidorin
Subscribers: rnkovacs, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D49223
llvm-svn: 339256
Summary:
At equality check of fields without name the index of fields is compared.
At determining the index of a field all fields of the parent context
should be loaded from external source to find the field at all.
Reviewers: a.sidorin, a_sidorin, r.stahl
Reviewed By: a.sidorin
Subscribers: martong, cfe-commits
Differential Revision: https://reviews.llvm.org/D49796
llvm-svn: 339226
declare target.
According to OpenMP 5.0, variables captured in lambdas in declare target
regions must be considered as implicitly declare target.
llvm-svn: 339152
It now actually produces a signed APSInt when the QualType passed into it is
signed, which is what any caller would expect.
Fixes a couple of crashes.
Differential Revision: https://reviews.llvm.org/D50363
llvm-svn: 339088
The change in the AST in r338135 caused us to accidentally support
inlining constructors of operator implicit arguments. Previously they were
hard to support because they were treated as arguments in expressions
but not in declarations, but now they can be transparently treated as
simple temporaries.
Add tests and comments to explain how it now works.
Differential Revision: https://reviews.llvm.org/D49627
llvm-svn: 339087
Some checkers require ASTContext. Having it in the constructor saves a
lot of boilerplate of having to pass it around.
Differential Revision: https://reviews.llvm.org/D50111
llvm-svn: 339079
DeclarationNameTable currently hold 3 "void *" to
FoldingSet<CXXSpecialName>, FoldingSet<CXXLiteralOperatorIdName>
and FoldingSet<CXXDeductionGuideNameExtra>.
CXXSpecialName, CXXLiteralOperatorIdName and
CXXDeductionGuideNameExtra are private classes holding extra
information about a "special" declaration name and are in
AST/DeclarationName.cpp. The original intent seems to have
been to keep these classes private and only expose
DeclarationNameExtra and DeclarationName (the code dates from
2008 and has not been significantly changed since).
However this make the code less straightforward than necessary
because of the need to have "void *" in DeclarationNameTable
(with 1 of 3 comments wrong) and to manually allocate/deallocate
the FoldingSets.
Moreover removing the extra indirections reduce the run-time of
an fsyntax-only on all of Boost by 2.3% which is not totally
unexpected given how frequently this data structure is used
(especially for C++).
A concern raised by erichkeane during the review was that
including Type.h would increase the compile time unreasonably.
However test builds (both clean and incremental) showed that
this patch did not result in any compile time increase.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D50261
llvm-svn: 339030
This patch proposes an abstract type that represents fixed point numbers, similar to APInt or APSInt that was discussed in https://reviews.llvm.org/D48456#inline-425585. This type holds a value, scale, and saturation and is meant to perform intermediate calculations on constant fixed point values.
Currently this class is used as a way for handling the conversions between fixed point numbers with different sizes and radixes. For example, if I'm casting from a signed _Accum to a saturated unsigned short _Accum, I will need to check the value of the signed _Accum to see if it fits into the short _Accum which involves getting and comparing against the max/min values of the short _Accum. The FixedPointNumber class currently handles the radix shifting and extension when converting to a signed _Accum.
Differential Revision: https://reviews.llvm.org/D48661
llvm-svn: 339028
- Print negative numbers correctly
- Handle APInts of different sizes
- Add formal unit tests for FixedPointValueToString
- Add tests for checking correct printing when padding is set
- Restrict to printing in radix 10 since that's all we need for now
Differential Revision: https://reviews.llvm.org/D49945
llvm-svn: 339026
Move the enum { ObjCMethodFamilyBitWidth = 4 } to the top of
the class. For some dark reason having the enum between the
bitfields breaks the packing with gcc version 7.3-win32 20180312.
Reported by: Abramo Bagnara (by email)
llvm-svn: 339017
These forward declarations for various classes in the Type
hierarchy are not needed since they are all forward declared
systematically a few lines below.
llvm-svn: 338966
__builtin_memmove (in non-type-punning cases).
This is intended to permit libc++ to make std::copy etc constexpr
without sacrificing the optimization that uses memcpy on
trivially-copyable types.
__builtin_strcpy and __builtin_wcscpy are not handled by this change.
They'd be straightforward to add, but we haven't encountered a need for
them just yet.
This reinstates r338455, reverted in r338602, with a fix to avoid trying
to constant-evaluate a memcpy call if either pointer operand has an
invalid designator.
llvm-svn: 338941
Libc++ needs to know when aligned allocation is supported by clang, but is
otherwise unavailable at link time. Otherwise, libc++ will incorrectly end up
generating calls to `__builtin_operator_new`/`__builtin_operator_delete` with
alignment arguments.
This patch implements the following changes:
* The `__cpp_aligned_new` feature test macro to no longer be defined when
aligned allocation is otherwise enabled but unavailable.
* The Darwin driver no longer passes `-faligned-alloc-unavailable` when the
user manually specifies `-faligned-allocation` or `-fno-aligned-allocation`.
* Instead of a warning Clang now generates a hard error when an aligned
allocation or deallocation function is referenced but unavailable.
Patch by Eric Fiselier.
Reviewers: rsmith, vsapsai, erik.pilkington, ahatanak, dexonsmith
Reviewed By: rsmith
Subscribers: Quuxplusone, cfe-commits
Differential Revision: https://reviews.llvm.org/D45015
llvm-svn: 338934
Clang format got the best of me... it introduced spaces around something
in a table-genned file, so it was interpreted as an array and not a
code block.
llvm-svn: 338889
Add a comment in ObjCMethodDecl and ObjCContainerDecl stating that
we store some bits in ObjCMethodDeclBits and ObjCContainerDeclBits.
This was missed by the recent move in
r338641 : [AST][4/4] Move the bit-fields from ObjCMethodDecl
and ObCContainerDecl into DeclContext
llvm-svn: 338888
Factored out from https://reviews.llvm.org/D49729
following @erichkeane comments.
* Add missing classes in the list of classes
deriving directly from DeclContext.
* Move the friend declarations together and
add a comment for why they are required.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D49790
llvm-svn: 338887
Summary:
This adds support to libclang for reading the flag_enum attribute.
This also bumps CINDEX_VERSION_MINOR for this patch series.
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49635
llvm-svn: 338820
Summary: This allows libclang to access the actual names of property setters and getters without needing to go through the indexer API. Usually default names are used, but the property can specify a different name.
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49634
llvm-svn: 338816
Summary:
Having access to implicit attributes is sometimes useful so users of libclang don't have to duplicate some of the logic in sema.
This depends on D49081 since it also adds a CXTranslationUnit flag.
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49631
llvm-svn: 338815
Summary:
This adds support to libclang for identifying ObjC related attributes that don't take arguments.
All attributes but NSObject and NSConsumed are tested.
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49127
llvm-svn: 338813
Summary:
This patch adds a clang-c API for querying the nullability of an AttributedType.
The test here also tests D49081
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49082
llvm-svn: 338809
Summary:
This patch adds support to the libclang API for identifying AttributedTypes in CXTypes and reading the modified type that the type points to. Currently AttributedTypes are skipped. This patch continues to skip AttributedTypes by default, but adds a parsing option to CXTranslationUnit to include AttributedTypes.
This patch depends on D49066 since it also adds a CXType.
Testing will be added in another patch which depends on this one.
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49081
llvm-svn: 338808
Summary:
This patch adds support to the libclang API for identifying ObjCTypeParams in CXTypes.
This patch depends on D49063 since both patches add new values to CXTypeKind.
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49066
llvm-svn: 338807
Summary: This patch adds support to the clang-c API for identifying ObjCObjects in CXTypes, enumerating type args and protocols on ObjCObjectTypes, and retrieving the base type of ObjCObjectTypes. Currently only ObjCInterfaceTypes are exposed, which do not have type args or protocols.
Reviewers: yvvan, jbcoe
Reviewed By: yvvan
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49063
llvm-svn: 338804
Recommit of r335084 after revert in r335516.
... instead of prepending it at the beginning (the original behavior
since implemented in r122535 2010-12-23). This builds up an
AttributeList in the the order in which the attributes appear in the
source.
The reverse order caused nodes for attributes in the AST (e.g. LoopHint)
to be in the reverse order, and therefore printed in the wrong order in
-ast-dump. Some TODO comments mention this. The order was explicitly
reversed for enable_if attribute overload resolution and name mangling,
which is not necessary anymore with this patch.
The change unfortunately has some secondary effect, especially on
diagnostic output. In the simplest cases, the CHECK lines or expected
diagnostic were changed to the the new output. If the kind of
error/warning changed, the attributes' order was changed instead.
This unfortunately causes some 'previous occurrence here' hints to be
textually after the main marker. This typically happens when attributes
are merged, but are incompatible to each other. Interchanging the role
of the the main and note SourceLocation will also cause the case where
two different declaration's attributes (in contrast to multiple
attributes of the same declaration) are merged to be reverse. There is
no easy fix because sometimes previous attributes are merged into a new
declaration's attribute list, sometimes new attributes are added to a
previous declaration's attribute list. Since 'previous occurrence here'
pointing to locations after the main marker is not rare, I left the
markers as-is; it is only relevant when the attributes are declared in
the same declaration anyway.
Differential Revision: https://reviews.llvm.org/D48100
llvm-svn: 338800
We can't read a deduced return type until we are sure that the types referred
to by it are not in the middle of being loaded. So defer all reading of such
deduced return types until the end of the recursive deserialization step.
Also, when we load a function type that has a deduced return type, update all
other redeclarations of the function to have that deduced return type.
llvm-svn: 338798
The way address space declarations for builtins currently work
is nearly useless. The code assumes the address spaces used for
builtins is a confusingly named "target address space" from user
code using __attribute__((address_space(N))) that matches
the builtin declaration. There's no way to use this to declare
a builtin that returns a language specific address space.
The terminology used is highly cofusing since it has nothing
to do with the the address space selected by the target to use
for a language address space.
This feature is essentially unused as-is. AMDGPU and NVPTX
are the only in-tree targets attempting to use this. The AMDGPU
builtins certainly do not behave as intended (i.e. all of the
builtins returning pointers can never compile because the numbered
address space never matches the expected named address space).
The NVPTX builtins are missing tests for some, and the others
seem to rely on an implicit addrspacecast.
Change the used address space for builtins based on a target
hook to allow using a language address space for a builtin.
This allows the same builtin declaration to be used for multiple
languages with similarly purposed address spaces (e.g. the same
AMDGPU builtin can be used in OpenCL and CUDA even though the
constant address spaces are arbitarily different).
This breaks the possibility of using arbitrary numbered
address spaces alongside the named address spaces for builtins.
If this is an issue we probably need to introduce another builtin
declaration character to distinguish language address spaces from
so-called "target address spaces".
llvm-svn: 338707