summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Re-commit r289252 and r289285, and fix PR31374Yaxun Liu2016-12-151-0/+10
| | | | llvm-svn: 289787
* [c++1z] Permit constant evaluation of a call through a function pointer whoseRichard Smith2016-12-151-0/+8
| | | | | | | type differs from the type of the actual function due to having a different exception specification. llvm-svn: 289754
* Revert 289252 (and follow-up 289285), it caused PR31374Nico Weber2016-12-141-10/+0
| | | | llvm-svn: 289713
* Add support for non-zero null pointer for C and OpenCLYaxun Liu2016-12-091-0/+10
| | | | | | | | | | | | | | | | | | In amdgcn target, null pointers in global, constant, and generic address space take value 0 but null pointers in private and local address space take value -1. Currently LLVM assumes all null pointers take value 0, which results in incorrectly translated IR. To workaround this issue, instead of emit null pointers in local and private address space, a null pointer in generic address space is emitted and casted to local and private address space. Tentative definition of global variables with non-zero initializer will have weak linkage instead of common linkage since common linkage requires zero initializer and does not have explicit section to hold the non-zero value. Virtual member functions getNullPointer and performAddrSpaceCast are added to TargetCodeGenInfo which by default returns ConstantPointerNull and emitting addrspacecast instruction. A virtual member function getNullPointerValue is added to TargetInfo which by default returns 0. Each target can override these virtual functions to get target specific null pointer and the null pointer value for specific address space, and perform specific translations for addrspacecast. Wrapper functions getNullPointer is added to CodegenModule and getTargetNullPointerValue is added to ASTContext to facilitate getting the target specific null pointers and their values. This change has no effect on other targets except amdgcn target. Other targets can provide support of non-zero null pointer in a similar way. This change only provides support for non-zero null pointer for C and OpenCL. Supporting for other languages will be added later incrementally. Differential Revision: https://reviews.llvm.org/D26196 llvm-svn: 289252
* [OpenCL] Refactor read_only/write_only pipes.Joey Gouly2016-12-011-45/+15
| | | | | | | | | | | This adds the access qualifier to the Pipe Type, rather than using a class hierarchy. It also fixes mergeTypes for Pipes, by disallowing merges. Only identical pipe types can be merged. The test case in invalid-pipes-cl2.0.cl is added to check that. llvm-svn: 288332
* getObjCEncodingForMethodDecl cannot fail. Simplify. NFC.John McCall2016-11-291-13/+15
| | | | llvm-svn: 288203
* Support constant expression evaluation for wchar_t versions of simple stringRichard Smith2016-11-291-0/+4
| | | | | | functions, in order to support constexpr std::char_traits<wchar_t>. llvm-svn: 288193
* Correct comment: we are creating a canonicla decltypetype.Yaron Keren2016-11-291-1/+1
| | | | llvm-svn: 288124
* Remove C++ default arg side table for MS ABI ctor closuresReid Kleckner2016-11-231-12/+0
| | | | | | | | | | | | | | | | | | | Summary: We don't need a side table in ASTContext to hold CXXDefaultArgExprs. The important part of building the CXXDefaultArgExprs was to ODR use the default argument expressions, not to make AST nodes. Refactor the code to only check the default argument, and remove the side table in ASTContext which wasn't being serialized. Fixes PR31121 Reviewers: thakis, rsmith, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27007 llvm-svn: 287774
* [OpenCL] Introduce ReadPipeType and WritePipeType.Joey Gouly2016-11-181-10/+35
| | | | | | | This allows Sema to diagnose passing a read_only pipe to a write_only pipe argument. llvm-svn: 287343
* Accept nullability qualifiers on array parameters.Jordan Rose2016-11-101-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since array parameters decay to pointers, '_Nullable' and friends should be available for use there as well. This is especially important for parameters that are typedefs of arrays. The unsugared syntax for this follows the syntax for 'static'-sized arrays in C: void test(int values[_Nullable]); This syntax was previously accepted but the '_Nullable' (and any other attributes) were silently discarded. However, applying '_Nullable' to a typedef was previously rejected and is now accepted; therefore, it may be necessary to test for the presence of this feature: #if __has_feature(nullability_on_arrays) One important change here is that DecayedTypes don't always immediately contain PointerTypes anymore; they may contain an AttributedType instead. This only affected one place in-tree, so I would guess it's not likely to cause problems elsewhere. This commit does not change -Wnullability-completeness just yet. I want to think about whether it's worth doing something special to avoid breaking existing clients that compile with -Werror. It also doesn't change '#pragma clang assume_nonnull' behavior, which currently treats the following two declarations as equivalent: #pragma clang assume_nonnull begin void test(void *pointers[]); #pragma clang assume_nonnull end void test(void * _Nonnull pointers[]); This is not the desired behavior, but changing it would break backwards-compatibility. Most likely the best answer is going to be adding a new warning. Part of rdar://problem/25846421 llvm-svn: 286519
* Fix use-after-scope in ASTContext.Benjamin Kramer2016-10-261-1/+1
| | | | | | | | | | | | Extend lifetime of ExceptionTypeStorage, as it is referenced by CanonicalEPI and used outside the block (ExceptionSpec.Exceptions is an ArrayRef) Patch by Sam McCall! Differential Revision: https://reviews.llvm.org/D25983 llvm-svn: 285192
* Implement name mangling proposal for exception specifications from ↵Richard Smith2016-10-261-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cxx-abi-dev 2016-10-11. This has the following ABI impact: 1) Functions whose parameter or return types are non-throwing function pointer types have different manglings in c++1z mode from prior modes. This is necessary because c++1z permits overloading on the noexceptness of function pointer parameter types. A warning is issued for cases that will change manglings in c++1z mode. 2) Functions whose parameter or return types contain instantiation-dependent exception specifications change manglings in all modes. This is necessary to support overloading on / SFINAE in these exception specifications, which a careful reading of the standard indicates has essentially always been permitted. Note that, in order to be affected by these changes, the code in question must specify an exception specification on a function pointer/reference type that is written syntactically within the declaration of another function. Such declarations are very rare, and I have so far been unable to find any code that would be affected by this. (Note that such things will probably become more common in C++17, since it's a lot easier to get a noexcept function type as a function parameter / return type there.) This change does not affect the set of symbols produced by a build of clang, libc++, or libc++abi. llvm-svn: 285150
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-6/+6
| | | | | | No functionality change intended. llvm-svn: 284730
* [c++1z] Fix corner case where we could create a function type whose ↵Richard Smith2016-10-181-8/+12
| | | | | | canonical type is not actually canonical. llvm-svn: 284528
* When two function types have equivalent (but distinct) noexcept ↵Richard Smith2016-10-181-24/+61
| | | | | | specifications, create separate type sugar nodes. This is necessary so that substitution into the exception specification will substitute into the correct expression. llvm-svn: 284519
* [c++1z] Include "noexcept" in builtin function types where appropriate. FixesRichard Smith2016-10-181-0/+3
| | | | | | | an assertion failure looking up a matching ::operator delete for __builtin_operator_delete. llvm-svn: 284458
* [c++1z] Use canonical expression equivalence to determine whether two differentRichard Smith2016-10-181-11/+11
| | | | | | | | | dependent noexcept specifications result in the same canonical function type. We still use non-canonical hashing when deduplicating type sugar so that diagnostics will point to the right place. llvm-svn: 284457
* Revert "Reinstate r281429, reverted in r281452, with a fix for its ↵Benjamin Kramer2016-10-171-60/+4
| | | | | | | | | mishandling of" This reverts commit r284176. It still marks some modules as invisible that should be visible. Will follow up with the author with a test case. llvm-svn: 284382
* P0012R1: Make exception specifications be part of the type system. ThisRichard Smith2016-10-161-4/+74
| | | | | | | implements the bulk of the change (modifying the type system to include exception specifications), but not all the details just yet. llvm-svn: 284337
* Fix bogus assert breaking modules self-host.Richard Smith2016-10-141-4/+6
| | | | llvm-svn: 284187
* Reinstate r281429, reverted in r281452, with a fix for its mishandling ofRichard Smith2016-10-131-4/+58
| | | | | | | | | compiles without -fmodules-local-submodule-visibility. Original commit message: [modules] When merging one definition into another, propagate the list of re-exporting modules from the discarded definition to the retained definition. llvm-svn: 284176
* Add and use isDiscardableGVALinkage function.Justin Lebar2016-10-131-9/+2
| | | | | | | | | | Reviewers: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25571 llvm-svn: 284159
* Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use ofRichard Smith2016-10-101-0/+24
| | | | | | | | | | | past-the-end iterator. Original commit message: P0035R4: Semantic analysis and code generation for C++17 overaligned allocation. llvm-svn: 283789
* [AST] Convert MangleNumberingContext to a unique_ptr.Justin Lebar2016-10-101-4/+3
| | | | | | | | | | | | Summary: It doesn't need to be refcounted anymore, either. Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25420 llvm-svn: 283768
* Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned ↵Daniel Jasper2016-10-101-24/+0
| | | | | | | | | | | | allocation." This reverts commit r283722. Breaks: Clang.SemaCUDA.device-var-init.cu Clang.CodeGenCUDA.device-var-init.cu http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/884/ llvm-svn: 283750
* P0035R4: Semantic analysis and code generation for C++17 overalignedRichard Smith2016-10-101-0/+24
| | | | | | allocation. llvm-svn: 283722
* Un-tabify source files, NFC.Yaron Keren2016-10-081-3/+2
| | | | llvm-svn: 283657
* Revert "[modules] When merging one definition into another, propagate the ↵Eric Liu2016-09-141-59/+4
| | | | | | | | list of re-exporting modules from the discarded definition to the retained definition." This reverts commit r281429. llvm-svn: 281452
* [modules] When merging one definition into another, propagate the list ofRichard Smith2016-09-141-4/+59
| | | | | | re-exporting modules from the discarded definition to the retained definition. llvm-svn: 281429
* ObjectiveC Generics: Start using ObjCTypeParamType.Manman Ren2016-09-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | For ObjC type parameter, we used to have TypedefType that is canonicalized to id or the bound type. We can't represent "T <protocol>" and thus will lose the type information in the following example: @interface MyMutableDictionary<KeyType, ObjectType> : NSObject - (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType <NSCopying>)key; @end MyMutableDictionary<NSString *, NSString *> *stringsByString; NSNumber *n1, *n2; stringsByString[n1] = n2; --> no warning on type mismatch of the key. To fix the problem, we introduce a new type ObjCTypeParamType that supports a list of protocol qualifiers. We create ObjCTypeParamType for ObjCTypeParamDecl when we create ObjCTypeParamDecl. We also substitute ObjCTypeParamType instead of TypedefType on an ObjCTypeParamDecl. rdar://24619481 rdar://25060179 Differential Revision: http://reviews.llvm.org/D23080 llvm-svn: 281358
* ObjectiveC generics: Add ObjCTypeParamType in the type system.Manman Ren2016-09-131-0/+38
| | | | | | | | | | | | | | | | | We also need to add ObjCTypeParamTypeLoc. ObjCTypeParamType supports the representation of "T <protocol>" where T is a type parameter. Before this, we use TypedefType to represent the type parameter for ObjC. ObjCTypeParamType has "ObjCTypeParamDecl *OTPDecl" and it extends from ObjCProtocolQualifiers. It is a non-canonical type and is canonicalized to the underlying type with the protocol qualifiers. rdar://24619481 rdar://25060179 Differential Revision: http://reviews.llvm.org/D23079 llvm-svn: 281355
* ObjectiveC: Refactor applyObjCProtocolQualifiers.Manman Ren2016-09-131-0/+70
| | | | | | | | | | | | | | To construct the canonical type of ObjCTypeParamType, we need to apply qualifiers on ObjCObjectPointerType. The updated applyObjCProtocolQualifiers handles this case by merging the protocol lists, constructing a new ObjCObjectType, then a new ObjCObjectPointerType. rdar://24619481 rdar://25060179 Differential Revision: http://reviews.llvm.org/D24059 llvm-svn: 281353
* Remove a pointless LLVM_CONSTEXPR. NFC.George Burgess IV2016-08-251-1/+1
| | | | llvm-svn: 279702
* [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl.Akira Hatanaka2016-08-171-12/+14
| | | | | | | | | | Check that ExpandStructures is true before visiting the list of ivars. rdar://problem/27135221 Differential revision: https://reviews.llvm.org/D22929 llvm-svn: 278956
* P0217R3: code generation support for decomposition declarations.Richard Smith2016-08-151-0/+8
| | | | llvm-svn: 278642
* [OpenCL] Fix size of image typeYaxun Liu2016-08-031-4/+8
| | | | | | | | | | The size of image type is reported incorrectly as size of a pointer to address space 0, which causes error when casting image type to pointers by __builtin_astype. The fix is to get image address space from TargetInfo then report the size accordingly. Differential Revision: https://reviews.llvm.org/D22927 llvm-svn: 277647
* Reapply r276069 with workaround for MSVC 2013Hubert Tong2016-07-301-1/+6
| | | | llvm-svn: 277286
* [OpenCL] Generate opaque type for sampler_t and function call for the ↵Yaxun Liu2016-07-281-4/+5
| | | | | | | | | | | | | | | | initializer Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type. This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer. Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions. This patch is partially based on Alexey Sotkin's work in Khronos Clang (https://github.com/KhronosGroup/SPIR/commit/3d4eec61623502fc306e8c67c9868be2b136e42b). Differential Revision: https://reviews.llvm.org/D21567 llvm-svn: 277024
* Fix memory leak introduced in r276159.Richard Smith2016-07-201-0/+3
| | | | llvm-svn: 276188
* [modules] Don't emit initializers for VarDecls within a module eagerly wheneverRichard Smith2016-07-201-0/+63
| | | | | | | | | | | | we first touch any part of that module. Instead, defer them until the first time that module is (transitively) imported. The initializer step for a module then recursively initializes modules that its own headers imported. For example, this avoids running the <iostream> global initializer in programs that don't actually use iostreams, but do use other parts of the standard library. llvm-svn: 276159
* Revert r276069: MSVC bots not happyHubert Tong2016-07-201-6/+1
| | | | llvm-svn: 276074
* Fix r276069: use LLVM_CONSTEXPRHubert Tong2016-07-201-1/+1
| | | | llvm-svn: 276071
* Concepts: Create space for requires-clause in TemplateParameterList; NFCHubert Tong2016-07-201-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Space for storing the //constraint-expression// of the //requires-clause// associated with a `TemplateParameterList` is arranged by taking a bit out of the `NumParams` field for the purpose of determining whether there is a //requires-clause// or not, and by adding to the trailing objects tied to the `TemplateParameterList`. An accessor is provided. An appropriate argument is supplied to `TemplateParameterList::Create` at the various call sites. Serialization changes will addressed as the Concepts implementation becomes more solid. Drive-by fix: This change also replaces the custom `FixedSizeTemplateParameterListStorage` implementation with one that follows the interface provided by `llvm::TrailingObjects`. Reviewers: aaron.ballman, faisalv, rsmith Subscribers: cfe-commits, nwilson Differential Revision: https://reviews.llvm.org/D19322 llvm-svn: 276069
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-071-37/+27
| | | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274732
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-061-3/+2
| | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274601
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-07-051-9/+12
| | | | | | Matches methods overridden by the given method. llvm-svn: 274531
* PR28394: For compatibility with c++11 and c++14, if a static constexpr dataRichard Smith2016-07-021-2/+35
| | | | | | | | member is redundantly redeclared outside the class definition in code built in c++17 mode, ensure we emit a non-discardable definition of the data member for c++11 and c++14 compilations to use. llvm-svn: 274416
* [Feature] Add a builtin for indexing into parameter packs. Patch by Louis ↵Eric Fiselier2016-07-011-2/+10
| | | | | | | | | | | | | Dionne. This patch adds a __nth_element builtin that allows fetching the n-th type of a parameter pack with very little compile-time overhead. The patch was inspired by r252036 and r252115 by David Majnemer, which add a similar __make_integer_seq builtin for efficiently creating a std::integer_sequence. Reviewed as D15421. http://reviews.llvm.org/D15421 llvm-svn: 274316
OpenPOWER on IntegriCloud