summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* [AST] Refine the condition for element-dependent array fillersIvan A. Kosarev2018-02-141-2/+23
| | | | | | | | | | | | This patch fixes clang to not consider braced initializers for aggregate elements of arrays to be potentially dependent on the indices of the initialized elements. Resolves bug 18978: initialize a large static array = clang oom? https://bugs.llvm.org/show_bug.cgi?id=18978 Differential Revision: https://reviews.llvm.org/D43187 llvm-svn: 325120
* Quick fix for 325116 buildbots: move template specialization into namespaceAleksei Sidorin2018-02-141-27/+29
| | | | llvm-svn: 325118
* [ASTImporter] Fix lexical DC for templated decls; support ↵Aleksei Sidorin2018-02-141-50/+109
| | | | | | | | | | VarTemplatePartialSpecDecl Also minor refactoring in related functions was done. Differential Revision: https://reviews.llvm.org/D43012 llvm-svn: 325116
* Fix a couple of places where we assumed that non-type template parameters ↵Richard Smith2018-02-141-1/+2
| | | | | | are always rvalues. llvm-svn: 325095
* Teach Wreturn-type, Wunreachable-code, and alpha.deadcode.UnreachableCode to ↵Nico Weber2018-02-131-0/+12
| | | | | | | | | treat __assume(0) like __builtin_unreachable. Fixes PR29134. https://reviews.llvm.org/D43221 llvm-svn: 325052
* Update StmtProfile.cpp to handle zero template arguments.Richard Trieu2018-02-131-2/+5
| | | | | | | Treat having no templates arguments differently than having zero template arguments when profiling. llvm-svn: 325040
* [Sema] Don't mark plain MS enums as fixedReid Kleckner2018-02-121-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a flaw in our AST: PR27098 MSVC always gives plain enums the underlying type 'int'. Clang does this as well, but we claim the enum is "fixed", as if the user actually wrote ': int'. It means we end up emitting spurious -Wsign-compare warnings on code like this: enum Vals { E1, E2, E3 }; bool f(unsigned v1, Vals v2) { return v1 == v2; } We think 'v2' can take on negative values because we think 'Vals' is fixed. This fixes that. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43110 llvm-svn: 324913
* AST: support ObjC lifetime qualifiers in MS ABISaleem Abdulrasool2018-02-091-5/+60
| | | | | | | | | | | | | | | Adjust the ObjC protocol conformance workaround to be more extensible. Use a synthetic type for the protocol (`struct Protocol`). Embed this within a reserved namespace to permit extending the extended pointer type qualifiers similarly for ObjC lifetime qualifiers. Introduce additional special handling for `__autoreleasing`, `__strong`, and `__weak` Objective C lifetime qualifiers. We decorate these by creating an artificial template type `Autoreleasing`, `Strong`, or `Weak` in the `__ObjC` namespace. These are only considered in the template type specialization and not the function parameter. llvm-svn: 324701
* AST: support SwiftCC on MS ABISaleem Abdulrasool2018-02-071-3/+3
| | | | | | | | Microsoft has reserved the identifier 'S' as the swift calling convention. Decorate the symbols appropriately. This enables swift on Windows. llvm-svn: 324439
* Add support for attribute 'trivial_abi'.Akira Hatanaka2018-02-053-5/+73
| | | | | | | | | | | | | | | | | | | | | | | | | The 'trivial_abi' attribute can be applied to a C++ class, struct, or union. It makes special functions of the annotated class (the destructor and copy/move constructors) to be trivial for the purpose of calls and, as a result, enables the annotated class or containing classes to be passed or returned using the C ABI for the underlying type. When a type that is considered trivial for the purpose of calls despite having a non-trivial destructor (which happens only when the class type or one of its subobjects is a 'trivial_abi' class) is passed to a function, the callee is responsible for destroying the object. For more background, see the discussions that took place on the mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-November/055955.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180101/thread.html#214043 rdar://problem/35204524 Differential Revision: https://reviews.llvm.org/D41039 llvm-svn: 324269
* Make __has_unique_object_representations reject empty union types.Eric Fiselier2018-02-021-1/+1
| | | | | | | | | | | | | | | | | Summary: Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`. @erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible. Reviewers: erichkeane, rsmith, aaron.ballman, majnemer Reviewed By: erichkeane Subscribers: cfe-commits, erichkeane Differential Revision: https://reviews.llvm.org/D42863 llvm-svn: 324134
* [AST] namespace ns { extern "C" { int X; }} prints as "ns::X", not as "X"Sam McCall2018-02-021-3/+4
| | | | llvm-svn: 324081
* PR36181: Teach CodeGen to properly ignore requests to emit dependent entities.Richard Smith2018-02-011-0/+13
| | | | | | | Previously, friend function definitions within class templates slipped through the gaps and caused the MS mangler to assert. llvm-svn: 323935
* [PR32482] Fix bitfield layout for -mms-bitfield and pragma packAlex Lorenz2018-01-311-3/+4
| | | | | | | | | | | The patch ensures that a new storage unit is created when the new bitfield's size is wider than the available bits. rdar://36343145 Differential Revision: https://reviews.llvm.org/D42660 llvm-svn: 323921
* [ASTImporter] Add support to import some AST nodes:Gabor Horvath2018-01-271-23/+108
| | | | | | | | | | | | | | | | * CXXOperatorCallExpr * SizeOfPackExpr * DependentTemplateSpecializationType * DependentSizedArray * CXXTypeidExpr * Fix importing CXXTemporaryObjectExpr Some of the changes are based on https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp Differential Revision: https://reviews.llvm.org/D42335 llvm-svn: 323589
* AST: support protocol conformances on id/class/interfaces in MS ABISaleem Abdulrasool2018-01-261-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | Add support for mangling ObjC protocol conformances in MS ABI as if they are COM interfaces. By diverging from the itanium mangling of `objc_protocol` prefixed names, this approach allows for a semi-reasonable, albeit of questionable sanity, undecoration via existing tooling. There is also the possibility of adding an extension and taking part of the namespace to add the conformance via the `L` and `Z` "modifiers", but the existing tooling would not be able to properly undecorated the symbol even though incidentally `undname` currently produces something legible while wine's implementation is not able to cope with the extension. This allows for the disambiguation of overloads where the parameter differs only in the protocol conformance of the ObjC type, e.g. ``` @protocol P; void f(std::vector<id>); void f(std::vector<id<P>>); ``` which clang would previously fail due to the mangling being identical as the protocol conformance was ignored. llvm-svn: 323547
* [AST] Use bit packing to reduce sizeof(TypedefNameDecl) from 88 to 80.Benjamin Kramer2018-01-261-3/+1
| | | | | | | | We can stash the cached transparent tag bit in existing pointer padding. Everything coming out of ASTContext is always aligned to a multiple of 8, so we have 8 spare bits. llvm-svn: 323528
* [ASTImporter] avoid warnings: unused var, switch coveredSam McCall2018-01-262-8/+6
| | | | llvm-svn: 323524
* [ASTImporter] Support LambdaExprs and improve template supportAleksei Sidorin2018-01-263-61/+334
| | | | | | | | | | | | | | Also, a number of style and bug fixes was done: * ASTImporterTest: added sanity check for source node * ExternalASTMerger: better lookup for template specializations * ASTImporter: don't add templated declarations into DeclContext * ASTImporter: introduce a helper, ImportTemplateArgumentListInfo getting SourceLocations * ASTImporter: proper set ParmVarDecls for imported FunctionProtoTypeLoc Differential Revision: https://reviews.llvm.org/D42301 llvm-svn: 323519
* AST: inline a single-use variable (NFC)Saleem Abdulrasool2018-01-251-2/+1
| | | | | | Inline the single use variable into the only use. NFC. llvm-svn: 323461
* AST: correct mangling for SEL on MS ABISaleem Abdulrasool2018-01-231-1/+0
| | | | | | | | We would previously treat `SEL` as a pointer-only type. This is not the case. It should be treated similarly to `id` and `Class`. Add some test cases to ensure that it will be properly handled as well. llvm-svn: 323257
* AST: adjust ObjC MS mangling to work with typedefsSaleem Abdulrasool2018-01-231-5/+0
| | | | | | | | | Rather than hardcode the pointerness of the `id` and `class` types, handle them generically. This allows for the template type specialization of `remove_pointer<id>` which would look through the `id` type and deal with the `objc_object` structure without the pointer. llvm-svn: 323241
* [CUDA] CUDA has no device-side library builtins.Artem Belevich2018-01-231-0/+7
| | | | | | | | | | We should (almost) never consider a device-side declaration to match a library builtin functio. Otherwise clang may ignore the implementation provided by the CUDA headers and emit clang's idea of the builtin. Differential Revision: https://reviews.llvm.org/D42319 llvm-svn: 323239
* Allow BlockDecl in CXXRecord scope to have no access specifier.Richard Trieu2018-01-191-0/+2
| | | | | | | | | Using a BlockDecl in a default member initializer causes it to be attached to CXXMethodDecl without its access specifier being set. This prevents a crash where getAccess is called on this BlockDecl, since that method expects any Decl in CXXRecord scope to have an access specifier. llvm-svn: 322984
* [DeclPrinter] Fix two cases that crash clang -ast-print.Artem Belevich2018-01-171-4/+5
| | | | | | | | | | | | | Both are related to handling anonymous structures. * clang didn't handle () around an anonymous struct variable. * clang also crashed on syntax errors that could lead to other syntactic constructs following the declaration of an anonymous struct. While the code is invalid, that's not a good reason to panic compiler. Differential Revision: https://reviews.llvm.org/D41788 llvm-svn: 322742
* Ensure code complete with !LoadExternal sees all local decls.Sam McCall2018-01-162-16/+18
| | | | | | | | | | | | | | | | | | | | | Summary: noload_lookups() was too lazy: in addition to avoiding external decls, it avoided populating the lazy lookup structure for internal decls. This is the right behavior for the existing callsite in ASTDumper, but I think it's not a very useful default, so we populate it by default. While here: - remove an unused test file accidentally added in r322371. - remove lookups_begin()/lookups_end() in favor of lookups().begin(), which is more common and more efficient. Reviewers: ilya-biryukov Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D42077 llvm-svn: 322548
* [OPENMP] Replace calls of getAssociatedStmt().Alexey Bataev2018-01-121-7/+3
| | | | | | | | | | | | | getAssociatedStmt() returns the outermost captured statement for the OpenMP directive. It may return incorrect region in case of combined constructs. Reworked the code to reduce the number of calls of getAssociatedStmt() and used getInnermostCapturedStmt() and getCapturedStmt() functions instead. In case of firstprivate variables it may lead to an extra allocas generation for private copies even if the variable is passed by value into outlined function and could be used directly as private copy. llvm-svn: 322393
* [ODRHash] Don't hash friend functions.Richard Trieu2018-01-121-0/+2
| | | | | | | | In certain combinations of templated classes and friend functions, the body of friend functions does not get propagated along with function signature. Exclude friend functions for hashing to avoid this case. llvm-svn: 322350
* [ASTImporter] Support importing CXXUnresolvedConstructExpr and ↵Aleksei Sidorin2018-01-091-0/+61
| | | | | | | | | | | | | UnresolvedLookupExpr * Note: This solution is based on https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp#L7605. Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38694 llvm-svn: 322091
* [ASTImporter] Fix missing SourceLoc import for ObjCMethodDecl selectorsAleksei Sidorin2018-01-091-1/+5
| | | | | | | | Patch by Nico Rieck, test case by Sean Callanan! Differential Revision: https://reviews.llvm.org/D6550 llvm-svn: 322079
* Track in the AST whether the operand to a UnaryOperator can overflow and ↵Aaron Ballman2018-01-093-60/+54
| | | | | | then use that logic when evaluating constant expressions and emitting codegen. llvm-svn: 322074
* Implement Attribute Target MultiVersioningErich Keane2018-01-081-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC's attribute 'target', in addition to being an optimization hint, also allows function multiversioning. We currently have the former implemented, this is the latter's implementation. This works by enabling functions with the same name/signature to coexist, so that they can all be emitted. Multiversion state is stored in the FunctionDecl itself, and SemaDecl manages the definitions. Note that it ends up having to permit redefinition of functions so that they can all be emitted. Additionally, all versions of the function must be emitted, so this also manages that. Note that this includes some additional rules that GCC does not, since defining something as a MultiVersion function after a usage has been made illegal. The only 'history rewriting' that happens is if a function is emitted before it has been converted to a multiversion'ed function, at which point its name needs to be changed. Function templates and virtual functions are NOT yet supported (not supported in GCC either). Additionally, constructors/destructors are disallowed, but the former is planned. llvm-svn: 322028
* Add support for a limited subset of TS 18661-3 math builtins.Benjamin Kramer2018-01-062-4/+12
| | | | | | | | | | | | | | | | | These just overloads for _Float128. They're supported by GCC 7 and used by glibc. APFloat support is already there so just add the overloads. __builtin_copysignf128 __builtin_fabsf128 __builtin_huge_valf128 __builtin_inff128 __builtin_nanf128 __builtin_nansf128 This is the same support that GCC has, according to the documentation, but limited to _Float128. llvm-svn: 321948
* Serialize the IDNS for a UsingShadowDecl rather than recomputing it.Richard Smith2018-01-061-2/+2
| | | | | | | | | Attempting to recompute it are doomed to fail because the IDNS of a declaration is not necessarily preserved across serialization and deserialization (in turn because whether a friend declaration is visible depends on whether some prior non-friend declaration exists). llvm-svn: 321921
* Add AST dumping support for _Generic expressions.Richard Smith2018-01-051-0/+32
| | | | llvm-svn: 321899
* No -fsanitize=function warning when calling noexcept function through ↵Stephan Bergmann2018-01-051-14/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | non-noexcept pointer in C++17 As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/ #!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non- noexcept pointer is undefined behavior?", such a call should not be UB. However, Clang currently warns about it. This change removes exception specifications from the function types recorded for -fsanitize=function, both in the functions themselves and at the call sites. That means that calling a non-noexcept function through a noexcept pointer will also not be flagged as UB. In the review of this change, that was deemed acceptable, at least for now. (See the "TODO" in compiler-rt test/ubsan/TestCases/TypeCheck/Function/function.cpp.) To remove exception specifications from types, the existing internal ASTContext::getFunctionTypeWithExceptionSpec was made public, and some places otherwise unrelated to this change have been adapted to call it, too. This is the cfe part of a patch covering both cfe and compiler-rt. Differential Revision: https://reviews.llvm.org/D40720 llvm-svn: 321859
* PR35697: look at the first declaration when determining whether a function orRichard Smith2018-01-031-3/+3
| | | | | | variable is extern "C" in linkage calculations. llvm-svn: 321686
* Again reverting an attempt to convert the DeclSpec enums into scoped enums.Faisal Vali2018-01-012-36/+24
| | | | | | | | | | | | - reverts r321622, r321625, and r321626. - the use of bit-fields is still resulting in warnings - even though we can use static-asserts to harden the code and ensure the bit-fields are wide enough. The bots still complain of warnings being seen. - to silence the warnings requires specifying the bit-fields with the underlying enum type (as opposed to the enum type itself), which then requires lots of unnecessary static casts of each enumerator within DeclSpec to the underlying-type, which even though could be seen as implementation details, it does hamper readability - and given the additional litterings, makes me question the value of the change. So in short - I give up (for now at least). Sorry about the noise. llvm-svn: 321628
* [NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & ↵Faisal Vali2018-01-012-24/+36
| | | | | | | | | | | | TypeSpecifierType into scoped enums with underlying types. - Since these enums are used as bit-fields - for the bit-fields to be interpreted as unsigned, the underlying type must be specified as unsigned. Previous failed attempt - wherein I did not specify an underlying type - was the sum of: https://reviews.llvm.org/rC321614 https://reviews.llvm.org/rC321615 llvm-svn: 321622
* Revert r321614 and r321615Faisal Vali2018-01-012-36/+24
| | | | | | | | - the enum changes to TypeSpecifierType are breaking some tests - and will require a more careful integration. Sorry about rushing these changes - thought I could sneak them in prior to heading out for new years ;) llvm-svn: 321616
* Add scope specifiers to updated scoped-enums (that I somehow missed in r321614)Faisal Vali2018-01-011-7/+7
| | | | llvm-svn: 321615
* [NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & ↵Faisal Vali2018-01-011-17/+29
| | | | | | | | TypeSpecifierType into scoped enums. llvm-svn: 321614
* [ASTImporter] Support importing FunctionTemplateDecl and ↵Aleksei Sidorin2017-12-271-0/+126
| | | | | | | | | | | | | | | CXXDependentScopeMemberExpr * Also introduces ImportTemplateArgumentListInfo facility (A. Sidorin) This re-commits r320942 after fixing the behaviour on '-fdelayed-template-parsing' option and adding additional checks. Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38692 llvm-svn: 321492
* Fix comment typo in r321312.Paul Robinson2017-12-261-1/+1
| | | | | | Post-commit review by Kim Grasman! llvm-svn: 321457
* [AST] Inline CompoundStmt contents into the parent allocation.Benjamin Kramer2017-12-242-21/+23
| | | | | | Saves a pointer on every CompoundStmt. llvm-svn: 321429
* [AST] Convert AttributedStmt to llvm::TrailingObjects.Benjamin Kramer2017-12-241-2/+2
| | | | | | No functionality change intended. llvm-svn: 321428
* Make helpers static. No functionality change.Benjamin Kramer2017-12-241-1/+1
| | | | llvm-svn: 321425
* [ODRHash] Disable hashing on methods.Richard Trieu2017-12-231-0/+3
| | | | | | | Turn off hashing for class methods, but leave it on for other functions. This should get the buildbot to green for the time being. llvm-svn: 321396
* [ODRHash] Support ODR violation detection in functions.Richard Trieu2017-12-232-0/+50
| | | | | | | Extend the hashing to functions, which allows detection of function definition mismatches across modules. This is a re-commit of r320230. llvm-svn: 321395
* [ODRHash] Canonicalize Decl's before processing.Richard Trieu2017-12-211-0/+1
| | | | | | | Canonicalizing the Decl before processing it as part of the hash should reduce issues with non-canonical types showing up as mismatches. llvm-svn: 321319
OpenPOWER on IntegriCloud