summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith2016-06-251-2/+6
| | | | | | | variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
* Use more ArrayRefsDavid Majnemer2016-06-241-4/+4
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Add some std::move where the value is only read otherwise.Benjamin Kramer2016-06-121-1/+1
| | | | | | This mostly affects smart pointers. No functionality change intended. llvm-svn: 272520
* Revert "[ASTMatchers] New forEachOverriden matcher."Chandler Carruth2016-06-111-12/+9
| | | | | | | This reverts commit r272386. It doesn't compile with MSVC and those bots have been red the entire day as a consequence. llvm-svn: 272453
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-06-101-9/+12
| | | | | | Matches methods overridden by the given method. llvm-svn: 272386
* Support for MSVS default calling convention options (/Gd, /Gz, /Gv,Alexey Bataev2016-05-181-2/+19
| | | | | | | | | /Gr), by Alexander Makarov Patch for bug #27711 Differential Revision: http://reviews.llvm.org/D20171 llvm-svn: 269891
* Enable support for __float128 in Clang and enable it on pertinent platformsNemanja Ivanovic2016-05-091-13/+19
| | | | | | | | | | | | | | | | | | This patch corresponds to reviews: http://reviews.llvm.org/D15120 http://reviews.llvm.org/D19125 It adds support for the __float128 keyword, literals and target feature to enable it. Based on the latter of the two aforementioned reviews, this feature is enabled on Linux on i386/X86 as well as SystemZ. This is also the second attempt in commiting this feature. The first attempt did not enable it on required platforms which caused failures when compiling type_traits with -std=gnu++11. If you see failures with compiling this header on your platform after this commit, it is likely that your platform needs to have this feature enabled. llvm-svn: 268898
* ObjC kindof: set the type of a conditional expression when involving kindof.Manman Ren2016-05-061-4/+13
| | | | | | | | When either LHS or RHS is a kindof type, we return a kindof type. rdar://problem/20513780 llvm-svn: 268781
* [CUDA] Make sure device-side __global__ functions are always visible.Artem Belevich2016-05-021-6/+13
| | | | | | | | | | | | __global__ functions are a special case in CUDA. Even when the symbol would normally not be externally visible according to C++ rules, they still must be visible in CUDA GPU object so host-side stub can launch them. Differential Revision: http://reviews.llvm.org/D19748 llvm-svn: 268299
* [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as ↵Yaxun Liu2016-04-281-1/+1
| | | | | | | | | | different. When comparing unqualified types, canonical types should be used, otherwise equivalent types may be treated as different type. Differential Revision: http://reviews.llvm.org/D19662 llvm-svn: 267906
* Revert 266186 as it breaks anything that includes type_traits on some platformsNemanja Ivanovic2016-04-151-16/+9
| | | | | | | | | | Since this patch provided support for the __float128 type but disabled it on all platforms by default, some platforms can't compile type_traits with -std=gnu++11 since there is a specialization with __float128. This reverts the patch until D19125 is approved (i.e. we know which platforms need this support enabled). llvm-svn: 266460
* Enable support for __float128 in ClangNemanja Ivanovic2016-04-131-9/+16
| | | | | | | | | | | | | | | | This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
* [OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library.Alexey Bader2016-04-131-3/+3
| | | | | | | | | | Putting OpenCLImageTypes.def to clangAST library violates layering requirement: "It's not OK for a Basic/ header to include an AST/ header". This fixes the modules build. Differential revision: http://reviews.llvm.org/D18954 Reviewers: Richard Smith, Vassil Vassilev. llvm-svn: 266180
* PR19957: [OpenCL] Incorrectly accepts implicit address space conversion with ↵Yaxun Liu2016-04-121-0/+9
| | | | | | | | | | | | ternary operator. Generates addrspacecast instead of bitcast for ternary operator when necessary, and diagnose ternary operator with incompatible second and third operands. https://llvm.org/bugs/show_bug.cgi?id=19957 Differential Revision: http://reviews.llvm.org/D17412 llvm-svn: 266111
* [OpenCL] Complete image types support.Alexey Bader2016-04-081-38/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I. Current implementation of images is not conformant to spec in the following points: 1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine: void write_image(write_only image2d_t img); kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code which is disallowed according to s6.13.14. 2. It discards access qualifier on generated code, which leads to generated code for the above example: call void @write_image(%opencl.image2d_t* %img); In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images. Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently. 3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names. 4. Default access qualifier read_only is to be added if not provided explicitly. II. This patch corrects the above points as follows: 1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type. 2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers). 3. Improves testing of images in Clang. Author: Anastasia Stulova Reviewers: bader, mgrang. Subscribers: pxli168, pekka.jaaskelainen, yaxunl. Differential Revision: http://reviews.llvm.org/D17821 llvm-svn: 265783
* [OPENMP] Parsing and Sema support for 'omp declare target' directiveDmitry Polukhin2016-04-061-0/+3
| | | | | | | | | | | | | | | | | | | | Add parsing, sema analysis for 'declare target' construct for OpenMP 4.0 (4.5 support will be added in separate patch). The declare target directive specifies that variables, functions (C, C++ and Fortran), and subroutines (Fortran) are mapped to a device. The declare target directive is a declarative directive. In Clang declare target is implemented as implicit attribute for the declaration. The syntax of the declare target directive is as follows: #pragma omp declare target declarations-definition-seq #pragma omp end declare target Based on patch from Michael Wong http://reviews.llvm.org/D15321 llvm-svn: 265530
* Canonicalize UnaryTransformType types when they don't have a known ↵Vassil Vassilev2016-03-301-7/+29
| | | | | | | | | | underlying type. Fixes https://llvm.org/bugs/show_bug.cgi?id=26014 Reviewed by Richard Smith. llvm-svn: 264937
* [Clang][ARM] __va_list declaration is not saved in ASTContext causing ↵Oleg Ranevskyy2016-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | compilation error or crash Summary: When the code is compiled for arm32 and the builtin `__va_list` declaration is created by `CreateAAPCSABIBuiltinVaListDecl`, the declaration is not saved in the `ASTContext` which may lead to a compilation error or crash. Minimal reproducer I was able to find: **header.h** ``` #include <stdarg.h> typedef va_list va_list_1; ``` **test.cpp** ``` typedef __builtin_va_list va_list_2; void foo(const char* format, ...) { va_list args; va_start( args, format ); } ``` Steps to reproduce: ``` clang -x c++-header --target=armv7l-linux-eabihf header.h clang -c -include header.h --target=armv7l-linux-eabihf test.cpp ``` Compilation error: ``` error: non-const lvalue reference to type '__builtin_va_list' cannot bind to a value of unrelated type 'va_list' (aka '__builtin_va_list') ``` Compiling the same code as a C source leads to a crash: ``` clang --target=armv7l-linux-eabihf header.h clang -c -x c -include header.h --target=armv7l-linux-eabihf test.cpp ``` Reviewers: logan, rsmith Subscribers: cfe-commits, asl, aemerson, rengolin Differential Revision: http://reviews.llvm.org/D18557 llvm-svn: 264930
* [modules] Store mangling numbers in a deterministic order so they don't ↵Richard Smith2016-03-211-4/+2
| | | | | | cause the resulting .pcm files to be nondeterministic. llvm-svn: 263996
* [OPENMP 4.0] Codegen for 'declare reduction' construct.Alexey Bataev2016-03-041-1/+3
| | | | | | | Emit function for 'combiner' part of 'declare reduction' construct and 'initialilzer' part, if any. llvm-svn: 262699
* Serialize `#pragma detect_mismatch`.Nico Weber2016-03-021-0/+2
| | | | | | | This is like r262493, but for pragma detect_mismatch instead of pragma comment. The two pragmas have similar behavior, so use the same approach for both. llvm-svn: 262506
* Serialize `#pragma comment`.Nico Weber2016-03-021-1/+3
| | | | | | | | | | | | | | `#pragma comment` was handled by Sema calling a function on ASTConsumer, and CodeGen then implementing this function and writing things to its output. Instead, introduce a PragmaCommentDecl AST node and hang one off the TranslationUnitDecl for every `#pragma comment` line, and then use the regular serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's eagerly deserialized.) http://reviews.llvm.org/D17799 llvm-svn: 262493
* Generalize the consumed-parameter array on FunctionProtoTypeJohn McCall2016-03-011-32/+43
| | | | | | | | | to allow arbitrary data to be associated with a parameter. Also, fix a bug where we apparently haven't been serializing this information for the last N years. llvm-svn: 262278
* Add FieldNames to __NSConstantString_tagBen Langmuir2016-02-251-1/+7
| | | | | | | | Since consumers of the AST may expect fields to be named. Patch by Brad King! llvm-svn: 261887
* [X86] Fix stack alignment for MCU target (Clang part), by Anton Nadolskiy.Andrey Turetskiy2016-02-101-2/+2
| | | | | | | | This patch fixes stack alignments for MCU (should be aligned to 4 bytes). Differential Revision: http://reviews.llvm.org/D15647 llvm-svn: 260376
* Fix predefine for __NSConstantString struct typeBen Langmuir2016-02-041-18/+34
| | | | | | | | | | | | | | | | | Per review feedback the name was wrong and it can be used outside Objective-C. Unfortunately, making the internal struct visible broke some ASTMatchers tests that assumed that the first record decl would be from user code, rather than a builtin type. I'm worried that this will also affect users' code. So this patch adds a typedef to wrap the internal struct and only makes the typedef visible to namelookup. This is sufficient to allow the ASTReader to merge the decls we need without making the struct itself visible. rdar://problem/24425801 llvm-svn: 259734
* Reapply r259624, it is likely not the commit causing the bot failures.Quentin Colombet2016-02-031-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original message: Make CF constant string decl visible to name lookup to fix module errors The return type of the __builtin___*StringMakeConstantString functions is a pointer to a struct, so we need that struct to be visible to name lookup so that we will correctly merge multiple declarations of that type if they come from different modules. Incidentally, to make this visible to name lookup we need to rename the type to __NSConstantString, since the real NSConstantString is an Objective-C interface type. This shouldn't affect anyone outside the compiler since users of the constant string builtins cast the result immediately to CFStringRef. Since this struct type is otherwise implicitly created by the AST context and cannot access namelookup, we make this a predefined type and initialize it in Sema. Note: this issue of builtins that refer to types not visible to name lookup technically also affects other builtins (e.g. objc_msgSendSuper), but in all other cases the builtin is a library builtin and the issue goes away if you include the library that defines the types it uses, unlike for these constant string builtins. rdar://problem/24425801 llvm-svn: 259721
* Revert r259624 - Make CF constant string decl visible to name lookup to fix ↵Quentin Colombet2016-02-031-10/+4
| | | | | | | | | module errors. This breaks some internal bots in stage2: clang seg fault. Looking with Ben to see what is going on. llvm-svn: 259715
* Make CF constant string decl visible to name lookup to fix module errorsBen Langmuir2016-02-031-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | The return type of the __builtin___*StringMakeConstantString functions is a pointer to a struct, so we need that struct to be visible to name lookup so that we will correctly merge multiple declarations of that type if they come from different modules. Incidentally, to make this visible to name lookup we need to rename the type to __NSConstantString, since the real NSConstantString is an Objective-C interface type. This shouldn't affect anyone outside the compiler since users of the constant string builtins cast the result immediately to CFStringRef. Since this struct type is otherwise implicitly created by the AST context and cannot access namelookup, we make this a predefined type and initialize it in Sema. Note: this issue of builtins that refer to types not visible to name lookup technically also affects other builtins (e.g. objc_msgSendSuper), but in all other cases the builtin is a library builtin and the issue goes away if you include the library that defines the types it uses, unlike for these constant string builtins. rdar://problem/24425801 llvm-svn: 259624
* [libclang] Introduce APIs for evaluating a cursor and checking if a macro is ↵Argyrios Kyrtzidis2016-01-161-1/+1
| | | | | | | | builtin/function. rdar://24091595 llvm-svn: 257968
* Update for LLVM function name change.Rui Ueyama2016-01-141-3/+3
| | | | llvm-svn: 257802
* [OpenCL] Pipe type supportXiuli Pan2016-01-091-0/+53
| | | | | | | | | | | | | | | Summary: Support for OpenCL 2.0 pipe type. This is a bug-fix version for bader's patch reviews.llvm.org/D14441 Reviewers: pekka.jaaskelainen, Anastasia Subscribers: bader, Anastasia, cfe-commits Differential Revision: http://reviews.llvm.org/D15603 llvm-svn: 257254
* ArrayRef-ize a function. NFCCraig Topper2016-01-031-6/+4
| | | | llvm-svn: 256718
* [ptr-traits] Add #includes of headers rather than forward declarationsChandler Carruth2015-12-301-0/+1
| | | | | | | | | | | | | | for types which are used as pointees in PointerUnions, PointerIntPairs, and DenseMap pointer keys. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. I think this is the last patch for getting Clang clean here!!! llvm-svn: 256615
* [ptr-traits] Move methods manipulating PointerUnions, DenseMap pointerChandler Carruth2015-12-301-0/+15
| | | | | | | | | | | | | | | keys, and PointerIntPairs where the pointee types are incomplete out-of-line to where we have the complete type. This is the standard pattern used throughout the AST library to address the inherently mutually cross referenced nature of the AST. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. llvm-svn: 256612
* [ptr-traits] Switch from a really wasteful SmallDenseMap ofChandler Carruth2015-12-301-5/+3
| | | | | | | | | | | | | | | | | | | | | | SmallVector<.., 16> (16!!!!) objects to a simple SmallVector of pairs. This no longer de-duplicates the common function pointers used during deallocation, but this doesn't really seem worth the complexity and overhead of managing the map-of-vectors. Notably, there is no reason to assume that functions have the 4-byte alignment that DenseMap relies on, and indeed this prevents checking the alignment of the DenseMap keys because we can't even meaningfully query the alignment of functions using our existing alignment tools. Generally, function pointers don't seem like a great idea for keys in a DenseMap. =] I chatted with Richard Smith about this a bit as well and have written down a FIXME because this *does* waste some memory and in general seems a very clumsy memory management strategy. He would like to see a more fundamental fix eventually here that tries to build a better pattern. llvm-svn: 256610
* ArrayRef-ize TemplateParameterList. NFCDavid Majnemer2015-12-271-2/+1
| | | | llvm-svn: 256463
* Use data recursion in RecursiveASTVisitor when traversing Stmt and Expr nodes.Richard Smith2015-11-241-15/+16
| | | | | | | | | | | | | | | | | | When RAV traverses a Stmt or Expr node, if the corresponding Traverse* functions have not been overridden, it will now use data recursion to walk those nodes. We arrange this to be an unobservable optimization to RAV subclasses, and to gracefully degrade as parts of the visitation are overridden with functions that might observe the visitation. For instance, if an RAV subclass overrides TraverseUnaryNot, we will ensure that there are real recursive stack frames for those traversals, but we'll use data recursion for all other traversals. This removes the need for DataRecursiveASTVisitor, and for the 'shouldUseDataRecursionFor' extension point, both of which are removed by this change. llvm-svn: 253948
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* Fix some Clang-tidy modernize warnings, other minor fixes.Eugene Zelenko2015-11-041-8/+3
| | | | | | Differential revision: http://reviews.llvm.org/D14311 llvm-svn: 252081
* [Sema] Implement __make_integer_seqDavid Majnemer2015-11-041-1/+19
| | | | | | | | | | | | | | | | | | This new builtin template allows for incredibly fast instantiations of templates like std::integer_sequence. Performance numbers follow: My work station has 64 GB of ram + 20 Xeon Cores at 2.8 GHz. __make_integer_seq<std::integer_sequence, int, 90000> takes 0.25 seconds. std::make_integer_sequence<int, 90000> takes unbound time, it is still running. Clang is consuming gigabytes of memory. Differential Revision: http://reviews.llvm.org/D13786 llvm-svn: 252036
* Watch and TV OS: wire up basic ABI choicesTim Northover2015-10-301-0/+2
| | | | | | | This sets the mostly expected Darwin default ABI options for these two platforms. Active changes from these defaults for watchOS are in a later patch. llvm-svn: 251708
* [MSVC] Workaround for ICE in cl.exe when compiling ASTContext.cpp in Release ↵Will Wilson2015-10-271-1/+3
| | | | | | | | Win32 Microsoft connect bug: https://connect.microsoft.com/VisualStudio/feedback/details/1741530 llvm-svn: 251415
* [AST] Plug a memory leak when promoting a single ParentMap entry to a vector.Benjamin Kramer2015-10-231-1/+1
| | | | | | Found by asan! llvm-svn: 251110
* [AST] Re-add TypeLocs and NestedNameSpecifierLocs to the ParentMap.Benjamin Kramer2015-10-231-30/+80
| | | | | | | | | | | | | | | | | | | | This relands r250831 after some fixes to shrink the ParentMap overall with one addtional tweak: nodes with pointer identity (e.g. Decl* and friends) can be store more efficiently so I put them in a separate map. All other nodes (so far only TypeLoc and NNSLoc) go in a different map keyed on DynTypedNode. This further uglifies the code but significantly reduces memory overhead. Overall this change still make ParentMap significantly larger but it's nowhere as bad as before. I see about 25 MB over baseline (pre-r251008) on X86ISelLowering.cpp. If this becomes an issue we could consider splitting the maps further as DynTypedNode is still larger (32 bytes) than a single TypeLoc (16 bytes) but I didn't want to introduce even more complexity now. Differential Revision: http://reviews.llvm.org/D14011 llvm-svn: 251101
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-221-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
* [AST] Remove redundant template keywords.Benjamin Kramer2015-10-221-3/+3
| | | | | | GCC complains about them, clang does not. llvm-svn: 251009
* [AST] Store Decl* and Stmt* directly into the ParentMap.Benjamin Kramer2015-10-221-14/+29
| | | | | | | | | | | | | | | | | | These are by far the most common types to be parents in the AST so it makes sense to optimize for them. Put them directly into the value of the map. This currently saves 32 bytes per parent in the map and a pointer indirection at the cost of some additional complexity in the code. Sadly this means we cannot return an ArrayRef from getParents anymore, add a proxy class that can own a single DynTypedNode and otherwise behaves exactly the same as ArrayRef. For example on a random large file (X86ISelLowering.cpp) this reduces the size of the parent map by 24 MB. Differential Revision: http://reviews.llvm.org/D13976 llvm-svn: 251008
* Change SortAndUniqueProtocols to operate directly on a SmallVector rather ↵Craig Topper2015-10-221-16/+11
| | | | | | | | than taking a pointer and element count that it modifies. This paves the way to directly convert the small vector into an ArrayRef without needing to explicitly pass the modified size. No functional change intended. While there also use a range-based for loop and use append instead of insert to copy elements into the empty SmallVector." llvm-svn: 250971
* Revert "[AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap."Benjamin Kramer2015-10-211-32/+18
| | | | | | | | | | | | Putting DynTypedNode in the ParentMap bloats its memory foot print. Before the void* key had 8 bytes, now we're at 40 bytes per key which can mean multiple gigabytes increase for large ASTs and this count doesn't even include all the added TypeLoc nodes. Revert until I come up with a better data structure. This reverts commit r250831. llvm-svn: 250889
OpenPOWER on IntegriCloud