summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r241620 and follow-up commits while investigating linux buildbot ↵Adrian Prantl2015-07-071-1/+2
| | | | | | failures. llvm-svn: 241642
* Wrap clang modules and pch files in an object file container.Adrian Prantl2015-07-071-2/+1
| | | | | | | | | | | | | This patch adds ObjectFilePCHContainerOperations uses the LLVM backend to put the contents of a PCH into a __clangast section inside a COFF, ELF, or Mach-O object file container. This is done to facilitate module debugging by makeing it possible to store the debug info for the types defined by a module alongside the AST. rdar://problem/20091852 llvm-svn: 241620
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-072-0/+4
| | | | | | | | | | | | | | | Introduce co- and contra-variance for Objective-C type parameters, which allows us to express that (for example) an NSArray is covariant in its type parameter. This means that NSArray<NSMutableString *> * is a subtype of NSArray<NSString *> *, which is expected of the immutable Foundation collections. Type parameters can be annotated with __covariant or __contravariant to make them co- or contra-variant, respectively. This feature can be detected by __has_feature(objc_generics_variance). Implements rdar://problem/20217490. llvm-svn: 241549
* Implement the Objective-C __kindof type qualifier.Douglas Gregor2015-07-072-1/+3
| | | | | | | | | | The __kindof type qualifier can be applied to Objective-C object (pointer) types to indicate id-like behavior, which includes implicit "downcasting" of __kindof types to subclasses and id-like message-send behavior. __kindof types provide better type bounds for substitutions into unspecified generic types, which preserves more type information. llvm-svn: 241548
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-073-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When messaging a method that was defined in an Objective-C class (or category or extension thereof) that has type parameters, substitute the type arguments for those type parameters. Similarly, substitute into property accesses, instance variables, and other references. This includes general infrastructure for substituting the type arguments associated with an ObjCObject(Pointer)Type into a type referenced within a particular context, handling all of the substitutions required to deal with (e.g.) inheritance involving parameterized classes. In cases where no type arguments are available (e.g., because we're messaging via some unspecialized type, id, etc.), we substitute in the type bounds for the type parameters instead. Example: @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying> - (T)firstObject; @end void f(NSSet<NSString *> *stringSet, NSSet *anySet) { [stringSet firstObject]; // produces NSString* [anySet firstObject]; // produces id<NSCopying> (the bound) } When substituting for the type parameters given an unspecialized context (i.e., no specific type arguments were given), substituting the type bounds unconditionally produces type signatures that are too strong compared to the pre-generics signatures. Instead, use the following rule: - In covariant positions, such as method return types, replace type parameters with “id” or “Class” (the latter only when the type parameter bound is “Class” or qualified class, e.g, “Class<NSCopying>”) - In other positions (e.g., parameter types), replace type parameters with their type bounds. - When a specialized Objective-C object or object pointer type contains a type parameter in its type arguments (e.g., NSArray<T>*, but not NSArray<NSString *> *), replace the entire object/object pointer type with its unspecialized version (e.g., NSArray *). llvm-svn: 241543
* Handle Objective-C type arguments.Douglas Gregor2015-07-074-9/+22
| | | | | | | | | | | | | | | | | | | | | Objective-C type arguments can be provided in angle brackets following an Objective-C interface type. Syntactically, this is the same position as one would provide protocol qualifiers (e.g., id<NSCopying>), so parse both together and let Sema sort out the ambiguous cases. This applies both when parsing types and when parsing the superclass of an Objective-C class, which can now be a specialized type (e.g., NSMutableArray<T> inherits from NSArray<T>). Check Objective-C type arguments against the type parameters of the corresponding class. Verify the length of the type argument list and that each type argument satisfies the corresponding bound. Specializations of parameterized Objective-C classes are represented in the type system as distinct types. Both specialized types (e.g., NSArray<NSString *> *) and unspecialized types (NSArray *) are represented, separately. llvm-svn: 241542
* Parsing, semantic analysis, and AST for Objective-C type parameters.Douglas Gregor2015-07-073-1/+63
| | | | | | | | | | | | | | | | | | | | Produce type parameter declarations for Objective-C type parameters, and attach lists of type parameters to Objective-C classes, categories, forward declarations, and extensions as appropriate. Perform semantic analysis of type bounds for type parameters, both in isolation and across classes/categories/extensions to ensure consistency. Also handle (de-)serialization of Objective-C type parameter lists, along with sundry other things one must do to add a new declaration to Clang. Note that Objective-C type parameters are typedef name declarations, like typedefs and C++11 type aliases, in support of type erasure. Part of rdar://problem/6294649. llvm-svn: 241541
* [OPENMP 4.0] Initial support for 'omp cancel' construct.Alexey Bataev2015-07-022-0/+17
| | | | | | Implemented parsing/sema analysis + (de)serialization. llvm-svn: 241253
* [modules] Merging support for specializations of a function template. This veryRichard Smith2015-07-011-5/+5
| | | | | | | rarely matters, but can affect whether two dependent types are canonically equivalent. llvm-svn: 241207
* [modules] Remove some out-of-date (fixed) FIXMEs.Richard Smith2015-07-011-9/+0
| | | | llvm-svn: 241205
* [OPENMP 4.0] Initial support for 'omp cancellation point' construct.Alexey Bataev2015-07-012-0/+19
| | | | | | Add parsing and sema analysis for 'omp cancellation point' directive. llvm-svn: 241145
* Add a function to ExternalASTSource that returns a descriptor thatAdrian Prantl2015-06-301-0/+32
| | | | | | | abstracts the commonalities between modules and PCH files that are needed to emit debug info for a module or precompiled header. llvm-svn: 241083
* Remove unnecessary include.Adrian Prantl2015-06-291-1/+0
| | | | llvm-svn: 240963
* [ObjC] Add NSValue support for objc_boxed_expressionsAlex Denisov2015-06-263-2/+23
| | | | | | | | | | | | | Patch extends ObjCBoxedExpr to accept records (structs and unions): typedef struct __attribute__((objc_boxable)) _Color { int r, g, b; } Color; Color color; NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)]; llvm-svn: 240761
* [modules] Properly merge visibility of class definitions that got merged whileRichard Smith2015-06-251-5/+7
| | | | | | parsing then merged again when the module was loaded. llvm-svn: 240700
* Use AddString/ReadString instead of doing it manually NFCBen Langmuir2015-06-232-8/+3
| | | | llvm-svn: 240434
* [Modules] Consider -fmodule-feature in module hash and when loadingBen Langmuir2015-06-232-0/+13
| | | | | | | Any extra features from -fmodule-feature are part of the module hash and need to get validated on load. Also print them with -module-file-info. llvm-svn: 240433
* [OPENMP] Initial support for 'depend' clause (4.0).Alexey Bataev2015-06-232-0/+26
| | | | | | Parsing and sema analysis (without support for array sections in arguments) for 'depend' clause (used in 'task' directive, OpenMP 4.0). llvm-svn: 240409
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-229-32/+31
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-229-31/+32
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* ASTReader: Treat InputFileOffsets as unaligned to avoid UBJustin Bogner2015-06-211-1/+2
| | | | | | | | | | This is a better approach to fixing the undefined behaviour I tried to fix in r240228. This data doesn't necessarily have suitable alignment for uint64_t, so use unaligned_uint64_t instead. This fixes 225 test failures when clang is built with ubsan. llvm-svn: 240247
* Revert "ASTReader: Copy input file offset data to avoid unaligned accesses"Justin Bogner2015-06-211-10/+2
| | | | | | | | | We can do this better by changing the type to unaligned_uint64_t and paying the cost on use instead of up front. This reverts r240228 llvm-svn: 240246
* ASTReader: Copy input file offset data to avoid unaligned accessesJustin Bogner2015-06-201-2/+10
| | | | | | | | | | We interpret Blob as an array of uint64_t here, but there's no reason to think that it has suitable alignment. Instead, read the data in in an alignment-safe way and store it in a std::vector. This fixes 225 test failures when clang is built with ubsan. llvm-svn: 240228
* Introduce a PCHContainerOperations interface (NFC).Adrian Prantl2015-06-204-60/+59
| | | | | | | | | | | | | | | | A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
* [modules] When determining whether a definition of a class is visible, check ↵Richard Smith2015-06-201-0/+3
| | | | | | all modules even if we've already found a definition that's not visible. llvm-svn: 240204
* [modules] Refactor and slightly simplify class definition merging.Richard Smith2015-06-201-48/+26
| | | | llvm-svn: 240200
* Extend type nullability qualifiers for Objective-C.Douglas Gregor2015-06-192-2/+5
| | | | | | | | | | | | | | | Introduce context-sensitive, non-underscored nullability specifiers (nonnull, nullable, null_unspecified) for Objective-C method return types, method parameter types, and properties. Introduce Objective-C-specific semantics, including computation of the nullability of the result of a message send, merging of nullability information from the @interface of a class into its @implementation, etc . This is the Objective-C part of rdar://problem/18868820. llvm-svn: 240154
* [modules] Merging support for enums with a local definition prior to the firstRichard Smith2015-06-181-43/+54
| | | | | | imported definition. llvm-svn: 240068
* [OPENMP] Support for '#pragma omp taskgroup' directive.Alexey Bataev2015-06-182-0/+15
| | | | | | | | | | | | | Added parsing, sema analysis and codegen for '#pragma omp taskgroup' directive (OpenMP 4.0). The code for directive is generated the following way: #pragma omp taskgroup <body> void __kmpc_taskgroup(<loc>, thread_id); <body> void __kmpc_end_taskgroup(<loc>, thread_id); llvm-svn: 240011
* [modules] Ensure that if we merge the definitions of two enumerations, thatRichard Smith2015-06-171-17/+23
| | | | | | making either of them visible makes the merged definition visible. llvm-svn: 239969
* [modules] Fix typo in default argument merging.Richard Smith2015-06-171-3/+3
| | | | llvm-svn: 239954
* [OPENMP] Remove last iteration separation for loop-based constructs.Alexey Bataev2015-06-162-5/+2
| | | | | | Previously the last iteration for simd loop-based OpenMP constructs were generated as a separate code. This feature is not required and codegen is simplified. llvm-svn: 239810
* [modules] Better support for redefinitions of an entity from the same module.Richard Smith2015-06-151-3/+0
| | | | | | | Support this across module save/reload and extend the 'missing import' diagnostics with a list of providing modules. llvm-svn: 239750
* push_back() loop -> append() for random access iterators.Benjamin Kramer2015-06-121-2/+1
| | | | | | | append will resize the vector to the optimal size. No functional change intended. llvm-svn: 239607
* [modules] Track all default template arguments for a given parameter acrossRichard Smith2015-06-101-2/+1
| | | | | | | modules, and allow use of a default template argument if any of the parameters providing it is visible. llvm-svn: 239485
* [modules] Reconstruct template default argument inheritance on reload ratherRichard Smith2015-06-102-29/+57
| | | | | | than wasting storage and triggering eager deserializations by serializing it. llvm-svn: 239454
* Refactor storage of default template arguments.Richard Smith2015-06-102-18/+37
| | | | | | | This is just a preparatory step towards fixing visibility for default template arguments in modules builds. llvm-svn: 239447
* Implementing C99 partial re-initialization behavior (DR-253)Yunzhong Gao2015-06-103-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | Based on previous discussion on the mailing list, clang currently lacks support for C99 partial re-initialization behavior: Reference: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-April/029188.html Reference: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_253.htm This patch attempts to fix this problem. Given the following code snippet, struct P1 { char x[6]; }; struct LP1 { struct P1 p1; }; struct LP1 l = { .p1 = { "foo" }, .p1.x[2] = 'x' }; // this example is adapted from the example for "struct fred x[]" in DR-253; // currently clang produces in l: { "\0\0x" }, // whereas gcc 4.8 produces { "fox" }; // with this fix, clang will also produce: { "fox" }; Differential Review: http://reviews.llvm.org/D5789 llvm-svn: 239446
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-291-4/+3
| | | | | | | | | | | | | | | | | | | | If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
* Refactor MacroInfo so macro arguments can be iterated with range-based for ↵Daniel Marjamaki2015-05-291-3/+2
| | | | | | | | | | loops. No functional change intended. Patch by Sebastian Edman! llvm-svn: 238547
* Rename a helper template function to 'bytes' to avoid a C++17 STL conflictReid Kleckner2015-05-211-15/+15
| | | | | | | | | MSVC 2015 includes the std::data() template function added to C++17. ADL causes both cl.exe and clang-cl to prefer std::data over our static helper here, and we get errors about converting int64_t* to StringRef. Renaming it to bytes avoids the ambiguity. llvm-svn: 237863
* Allow skipping imports in the module visitor.Manuel Klimek2015-05-203-35/+99
| | | | | | | Skip imports when we know that we do not need to visit any imports because we've already deserialized the redecls from a module. llvm-svn: 237782
* [AST] Put VarDeclBitfields on a dietDavid Majnemer2015-05-192-21/+18
| | | | | | | | VarDeclBitfields contained bits which are never present in parameters. Split these out so that ParmVarDeclBitfields wouldn't grow past 32-bits if another field was added. llvm-svn: 237648
* Detect uses of mismatching forms of 'new' and 'delete'Ismail Pazarbasi2015-05-182-1/+45
| | | | | | | | | | | | | | | | | Emit warning when operand to `delete` is allocated with `new[]` or operand to `delete[]` is allocated with `new`. rev 2 update: `getNewExprFromInitListOrExpr` should return `dyn_cast_or_null` instead of `dyn_cast`, since `E` might be null. Reviewers: rtrieu, jordan_rose, rsmith Subscribers: majnemer, cfe-commits Differential Revision: http://reviews.llvm.org/D4661 llvm-svn: 237608
* [modules] Retain the name as written for umbrella headers and directories, ↵Richard Smith2015-05-162-12/+15
| | | | | | rather than converting to an absolute path. No observable change expected, but this allows us to correctly compute the module for an umbrella header, which later changes will require. llvm-svn: 237508
* [modules] Add local submodule visibility support for declarations.Richard Smith2015-05-153-17/+39
| | | | | | | | | | | | With this change, enabling -fmodules-local-submodule-visibility results in name visibility rules being applied to submodules of the current module in addition to imported modules (that is, names no longer "leak" between submodules of the same top-level module). This also makes it much safer to textually include a non-modular library into a module: each submodule that textually includes that library will get its own "copy" of that library, and so the library becomes visible no matter which including submodule you import. llvm-svn: 237473
* Refactor: when exposing a definition in some module, provide listeners with theRichard Smith2015-05-151-4/+3
| | | | | | module rather than requiring them to work it out themselves. llvm-svn: 237416
* Revert "Detect uses of mismatching forms of 'new' and 'delete'"Diego Novillo2015-05-142-45/+1
| | | | | | | | | This reverts commit 742dc9b6c9686ab52860b7da39c3a126d8a97fbc. This is generating multiple segfaults in our internal builds. Test case coming up shortly. llvm-svn: 237391
* Detect uses of mismatching forms of 'new' and 'delete'Ismail Pazarbasi2015-05-142-1/+45
| | | | | | | | | | | | | Emit warning when operand to `delete` is allocated with `new[]` or operand to `delete[]` is allocated with `new`. Reviewers: rtrieu, jordan_rose, rsmith Subscribers: majnemer, cfe-commits Differential Revision: http://reviews.llvm.org/D4661 llvm-svn: 237368
* [modules] Fix a #include cycle when building a module for our builtin headers.Richard Smith2015-05-141-5/+9
| | | | | | | | | | xmmintrin.h includes emmintrin.h and vice versa if SSE2 is enabled. We break this cycle for a modules build, and instead make the xmmintrin.h module re-export the immintrin.h module. Also included is a fix for an assert in the serialization code if a module exports another module that was declared later in the same module map. llvm-svn: 237321
OpenPOWER on IntegriCloud