summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* Use unsigned instead of an enum for map keysGeorge Burgess IV2017-08-091-23/+12
| | | | | | | ubsan's enum sanitizer doesn't like the latter, and we had to have out-of-bounds values for DenseMapInfo's tombstone/empty keys. llvm-svn: 310523
* Revert "PR19668, PR23034: Fix handling of move constructors and deleted copy ↵Diana Picus2017-08-092-35/+4
| | | | | | | | | constructors when deciding whether classes should be passed indirectly." This reverts commit r310401 because it seems to have broken some ARM bot(s). llvm-svn: 310464
* [AST] Cache intermediate visibility/linkage resultsGeorge Burgess IV2017-08-093-6/+53
| | | | | | | | | | | | This is a follow-up to r310436 with actual functional changes. Please see that commit message for a description of why a cache is appearing here. Suggestions for less-bad ways of testing this are appreciated. :) This fixes PR29160. llvm-svn: 310437
* [AST] Move visibility computations into a class; NFCGeorge Burgess IV2017-08-093-143/+218
| | | | | | | | | | | | | | | | | | | | | This is patch 1 in a 2 patch series that aims to fix PR29160. Its goal is to cache decl visibility/linkage for the duration of each visibility+linkage query. The simplest way I can see to do this is to put the visibility calculation code that needs to (transitively) access this cache into a class, which is what this patch does. Actual caching will come in patch 2. (Another way would be to keep the cache in ASTContext + manually invalidate it or something, but that felt way too subtle to me.) Caching visibility results across multiple queries seems a bit tricky, since the user can add visibility attributes ~whenever they want, and these attributes can apparently have far-reaching effects (e.g. class visibility extends to its members, ...). Because a cache that's dropped at the end of each top-level query seems to work nearly as well and doesn't require any eviction logic, I opted for that design. llvm-svn: 310436
* PR19668, PR23034: Fix handling of move constructors and deleted copyRichard Smith2017-08-082-4/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | constructors when deciding whether classes should be passed indirectly. This fixes ABI differences between Clang and GCC: * Previously, Clang ignored the move constructor when making this determination. It now takes the move constructor into account, per https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may seem recent, but the ABI change was agreed on the Itanium C++ ABI list a long time ago). * Previously, Clang's behavior when the copy constructor was deleted was unstable -- depending on whether the lazy declaration of the copy constructor had been triggered, you might get different behavior. We now eagerly declare the copy constructor whenever its deletedness is unclear, and ignore deleted copy/move constructors when looking for a trivial such constructor. This also fixes an ABI difference between Clang and MSVC: * If the copy constructor would be implicitly deleted (but has not been lazily declared yet), for instance because the class has an rvalue reference member, we would pass it directly. We now pass such a class indirectly, matching MSVC. llvm-svn: 310401
* [Availability] Don't make an availability attribute imply default visibility ↵Erik Pilkington2017-08-081-8/+0
| | | | | | | | | | on macOS Fixes PR33796, rdar://33655115 Differential revision: https://reviews.llvm.org/D36191 llvm-svn: 310382
* Mark static variables static; NFC.George Burgess IV2017-08-071-2/+2
| | | | llvm-svn: 310299
* [ODRHash] Treat some non-templated classes as templated.Richard Trieu2017-08-051-2/+6
| | | | | | | | | | When using nested classes, if the inner class is not templated, but the outer class is templated, the inner class will not be templated, but may have some traits as if it were. This is particularly evident if the inner class refers to the outer class in some fashion. Treat any class that is in the context of a templated class as also a templated class. llvm-svn: 310158
* Add OpenCL 2.0 atomic builtin functions as Clang builtinYaxun Liu2017-08-043-8/+38
| | | | | | | | | | | | | | | | | | | | | OpenCL 2.0 atomic builtin functions have a scope argument which is ideally represented as synchronization scope argument in LLVM atomic instructions. Clang supports translating Clang atomic builtin functions to LLVM atomic instructions. However it currently does not support synchronization scope of LLVM atomic instructions. Without this, users have to use LLVM assembly code to implement OpenCL atomic builtin functions. This patch adds OpenCL 2.0 atomic builtin functions as Clang builtin functions, which supports generating LLVM atomic instructions with synchronization scope operand. Currently only constant memory scope argument is supported. Support of non-constant memory scope argument will be added later. Differential Revision: https://reviews.llvm.org/D28691 llvm-svn: 310082
* [clang] Change the condition of unnecessary packed warningYan Wang2017-08-011-13/+13
| | | | | | | | | | | | | | | | | | | | Summary: Change the condition of this unnecessary packed warning. The packed is unnecessary when 1. the alignment of the struct/class won't alter. 2. the size is unchanged. 3. the offset of each field is the same. Remove all field-level warning. Reviewers: chh, akyrtzi, rtrieu Reviewed By: chh Subscribers: rsmith, srhines, cfe-commits, xazax.hun Differential Revision: https://reviews.llvm.org/D34114 llvm-svn: 309750
* Improve readability of CXX method overrides listLenar Safin2017-07-291-2/+5
| | | | | | | | | | | | | | | Summary: Separate CXX method overrides list entries with commas. Reviewers: lhames Reviewed By: lhames Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35800 llvm-svn: 309496
* [OPENMP] Codegen for 'in_reduction' clause.Alexey Bataev2017-07-272-4/+18
| | | | | | | | | | | | | | | | | | Added codegen for task-based directive with in_reduction clause. ``` <body> ``` The next code is emitted: ``` void *td; ... td = call i8* @__kmpc_task_reduction_init(); ... <type> *priv = (<type> *)call i8* @__kmpc_task_reduction_get_th_data(i32 GTID, i8* td, i8* <orig>) ``` llvm-svn: 309270
* [CodeGen] Correctly model std::byte's aliasing propertiesDavid Majnemer2017-07-251-0/+9
| | | | | | | | | | | | std::byte, when defined as an enum, needs to be given special treatment with regards to its aliasing properties. An array of std::byte is allowed to be used as storage for other types. This fixes PR33916. Differential Revision: https://reviews.llvm.org/D35824 llvm-svn: 309058
* [ExternalASTMerger] Import Objective-C classesSean Callanan2017-07-251-1/+5
| | | | | | | | | | | | | This patch adds functionality and a test for importing Objective-C classes and their methods. It also adds a flag to clang-import-test to set the language used for parsing. This takes the same argument format as the -x option to the driver. Differential Revision: https://reviews.llvm.org/D35274 llvm-svn: 309014
* [coroutines] Add serialization/deserialization of coroutinesGor Nishanov2017-07-251-0/+14
| | | | | | | | | | | | Reviewers: rsmith Reviewed By: rsmith Subscribers: EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D35383 llvm-svn: 308996
* [OPENMP] Codegen for 'task_reduction' clause.Alexey Bataev2017-07-252-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added codegen for taskgroup directive with task_reduction clause. ``` <body> ``` The next code is emitted: ``` %struct.kmp_task_red_input_t red_init[n]; void *td; call void @__kmpc_taskgroup(%ident_t id, i32 gtid) ... red_init[i].shar = &<item>; red_init[i].size = sizeof(<item>); red_init[i].init = (void*)initializer_function; red_init[i].fini = (void*)destructor_function; red_init[i].comb = (void*)combiner_function; red_init[i].flags = flags; ... td = call i8* @__kmpc_task_reduction_init(i32 gtid, i32 n, i8* (void*)red_init); call void @__kmpc_end_taskgroup(%ident_t id, i32 gtid) void initializer_function(i8* priv) { *(<type>*)priv = <red_init>; ret void; } void destructor_function(i8* priv) { (<type>*)priv->~(); ret void; } void combiner_function(i8* inout, i8* in) { *(<type>*)inout = *(<type>*)inout <red_id> *(<type>*)in; ret void; } ``` llvm-svn: 308979
* Work around an MSVC2017 update 3 codegen bug.Nico Weber2017-07-241-0/+15
| | | | | | | | | | | C2017 update 3 produces a clang that crashes when compiling clang. Disabling optimizations for StmtProfiler::VisitCXXOperatorCallExpr() makes the crash go away. Patch from Bruce Dawson <brucedawson@chromium.org>! https://reviews.llvm.org/D35757 llvm-svn: 308897
* [OPENMP] Initial support for 'in_reduction' clause.Alexey Bataev2017-07-213-0/+103
| | | | | | | Parsing/sema analysis for 'in_reduction' clause for task-based directives. llvm-svn: 308768
* [OPENMP] Initial support for 'task_reduction' clause.Alexey Bataev2017-07-184-9/+118
| | | | | | Parsing/sema analysis of the 'task_reduction' clause. llvm-svn: 308352
* [AArch64] Add support for __builtin_ms_va_list on aarch64Martin Storsjo2017-07-174-4/+4
| | | | | | | | | | | Move builtins from the x86 specific scope into the global scope. Their use is still limited to x86_64 and aarch64 though. This allows wine on aarch64 to properly handle variadic functions. Differential Revision: https://reviews.llvm.org/D34475 llvm-svn: 308218
* Use ARC parsing rules for ns_returns_retained in MRC so that code canJohn McCall2017-07-152-28/+47
| | | | | | | | be shared without warnings. Build AttributedTypes to leave breadcrumbs for tools like the static analyzer. Warn about attempting to use the attribute with incompatible return types. llvm-svn: 308092
* [ODRHash] Revert r307743 which reverted r307720Richard Trieu2017-07-151-0/+2
| | | | | | | Reapply r307720 to allow processing of constructors and destructors. Reuse the diagnostics for CXXMethodDecl for them. llvm-svn: 308077
* [clang] Add getSignedSizeType methodAlexander Shaposhnikov2017-07-141-0/+6
| | | | | | | | | | | | | | | | | C11 standard refers to the signed counterpart of the type size_t in the paragraph 7.21.6.1 where it defines d, i, o, u, x, or x conversion specifiers (in printf format string). In Clang there is a FIXME (in lib/Analysis/PrintfFormatString.cpp) for this case (which is not handled correctly at the moment). This diff adds getSignedSizeType method to TargetInfo and exposes it in ASTContext similarly to how it is done for getSizeType. lib/Analysis/PrintfFormatString.cpp will be changed in a separate commit. Differential revision: https://reviews.llvm.org/D35378 Test plan: make check-all llvm-svn: 308037
* [ODRHash] Avoid taking the types of FunctionDecl'sRichard Trieu2017-07-141-1/+5
| | | | | | | | FunctionDecl already hashes most of the information in the function's type. Add hashing of the return type, and skip hashing the function's type to avoid redundancy and extra work when computing the hash. llvm-svn: 307986
* Use getNameAsString instead of getName to get method names when dumpingLang Hames2017-07-131-6/+2
| | | | | | | | overrides: getName can fail if the decl's name isn't a simple identifier. This is a more general replacement for the fix in r305860. llvm-svn: 307959
* [ObjC] Pick a 'readwrite' property when synthesizing ambiguousAlex Lorenz2017-07-131-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | property and check for incompatible attributes This commit changes the way ambiguous property synthesis (i.e. when synthesizing a property that's declared in multiple protocols) is performed. Previously, Clang synthesized the first property that was found. This lead to problems when the property was synthesized in a class that conformed to two protocols that declared that property and a second protocols had a 'readwrite' declaration - the setter was not synthesized so the class didn't really conform to the second protocol and user's code would crash at runtime when they would try to set the property. This commit ensures that a first readwrite property is selected. This is a semantic change that changes users code in this manner: ``` @protocol P @property(readonly) int p; @end @protocol P2 @property(readwrite) id p; @end @interface I <P2> @end @implementation I @syntesize p; // Users previously got a warning here, and Clang synthesized // readonly 'int p' here. Now Clang synthesizes readwrite 'id' p.. @end ``` To ensure that this change is safe, the warning about incompatible types is promoted to an error when this kind of readonly/readwrite ambiguity is detected in the @implementation. This will ensure that previous code that had this subtle bug and ignored the warning now will fail to compile with an error, and users should not get suprises at runtime once they resolve the error. The commit also extends the ambiguity checker, and now it can detect conflicts among the different property attributes. An error diagnostic is used for conflicting attributes, to ensure that the user won't get "suprises" at runtime. ProtocolPropertyMap is removed in favour of a a set + vector because the map's order of iteration is non-deterministic, so it couldn't be used to select the readwrite property. rdar://31579994 Differential Revision: https://reviews.llvm.org/D35268 llvm-svn: 307903
* [Sema] Mark a virtual CXXMethodDecl as used if a call to it can beAkira Hatanaka2017-07-131-0/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | devirtualized. The code to detect devirtualized calls is already in IRGen, so move the code to lib/AST and make it a shared utility between Sema and IRGen. This commit fixes a linkage error I was seeing when compiling the following code: $ cat test1.cpp struct Base { virtual void operator()() {} }; template<class T> struct Derived final : Base { void operator()() override {} }; Derived<int> *d; int main() { if (d) (*d)(); return 0; } rdar://problem/33195657 Differential Revision: https://reviews.llvm.org/D34301 llvm-svn: 307883
* [ODRHash] Revert r307720 to fix buildbot.Richard Trieu2017-07-121-2/+0
| | | | llvm-svn: 307743
* [ODRHash] Support more method types.Richard Trieu2017-07-111-0/+2
| | | | | | | Hash CXXConstructorDecl and CXXDestructorDecl. Extend the diagnostics from CXXMethodDecl to include constructors and destructors. llvm-svn: 307720
* clang-import-test had some dead code. I did the following to eliminate it:Sean Callanan2017-07-101-5/+0
| | | | | | | | | | | | | | - eliminated error handling for the indirect CompilerInstance, which should never generate an error as it is created; - added a new test for direct importation; and - removed an unused implementation of the CompleteType() API. This brings clang-import-test.cpp and ExternalASTMerge.cpp back to 100% coverage on all metrics measured by DLLVM_BUILD_INSTRUMENTED_COVERAGE. Differential Revision: https://reviews.llvm.org/D35220 llvm-svn: 307600
* IsSpecialLong was only ever set in release mode as all of the uses are in ↵Eric Christopher2017-07-101-1/+8
| | | | | | asserts. Wrap in ifndef NDEBUG. llvm-svn: 307594
* [ODRHash] Support FriendDeclRichard Trieu2017-07-081-0/+18
| | | | llvm-svn: 307458
* [MS] Don't statically initialize dllimport member function pointersReid Kleckner2017-07-071-0/+16
| | | | | | | | | | | | | | | | | | | | Summary: r306137 made dllimport pointers to member functions non-constant. This is correct because a load must be executed to resolve any dllimported data. However, r306137 did not account for the use of dllimport member function pointers used as template arguments. This change re-lands r306137 with a template instantiation fix. This fixes PR33570. Reviewers: rnk, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34714 llvm-svn: 307446
* [modules ts] Basic for module linkage.Richard Smith2017-07-071-14/+64
| | | | | | | | | | In addition to the formal linkage rules, the Modules TS includes cases where internal-linkage symbols within a module interface unit can be referenced from outside the module via exported inline functions / templates. We give such declarations "module-internal linkage", which is formally internal linkage, but results in an externally-visible symbol. llvm-svn: 307434
* [modules ts] Improve merging of module-private declarations.Richard Smith2017-07-051-2/+4
| | | | | | | | | | These cases occur frequently for declarations in the global module (above the module-declaration) in a Modules TS module interface. When we merge a definition from another module into such a module-private definition, ensure that we transitively make everything lexically within that definition visible to that translation unit. llvm-svn: 307129
* fix trivial typos in comments; NFCHiroshi Inoue2017-07-051-2/+2
| | | | llvm-svn: 307123
* [modules ts] Declarations from a module interface unit are only visible outsideRichard Smith2017-07-051-1/+1
| | | | | | the module if declared in an export block. llvm-svn: 307115
* [modules] Teach clang how to merge typedef over anonymous structs in C mode.Vassil Vassilev2017-07-011-2/+1
| | | | | | | | | | In C mode clang fails to merge the textually included definition with the one imported from a module. The C lookup rules fail to find the imported definition because its linkage is internal in non C++ mode. This patch reinstates some of the ODR merging rules for typedefs of anonymous tags for languages other than C++. Patch by Raphael Isemann and me (D34510). llvm-svn: 306964
* [ODRHash] Revert r305104 - Skip inline namespaces when hashing.Richard Trieu2017-07-012-19/+13
| | | | | | Test inline namespaces and handle them in the ODR hash again. llvm-svn: 306926
* [Modules] Implement ODR-like semantics for tag types in C/ObjCBruno Cardoso Lopes2017-07-011-10/+48
| | | | | | | | | | | | | | | | | | | | | | Allow ODR for ObjC/C in the sense that we won't keep more that one definition around (merge them). However, ensure the decl pass the structural compatibility check in C11 6.2.7/1, for that, reuse the structural equivalence checks used by the ASTImporter. Few other considerations: - Create error diagnostics for tag types mismatches and thread them into the structural equivalence checks. - Note that by doing this we only support redefinition between types that are considered "compatible types" by C. This is mixed approach of the suggestions discussed in http://lists.llvm.org/pipermail/cfe-dev/2017-March/053257.html Differential Revision: https://reviews.llvm.org/D31778 rdar://problem/31909368 llvm-svn: 306918
* Change enumerator default linkage type for CBruno Cardoso Lopes2017-07-011-1/+3
| | | | | | | | | | | | | | | Redeclaration lookup should never find hidden enumerators in C, because they do not have linkage (C11 6.2.2/6) The linkage of an enumerator should be VisibleNoLinkage, and isHiddenDeclarationVisible should be checking hasExternalFormalLinkage. This is was reviewed as part of D31778, but splitted into a different commit for clarity. rdar://problem/31909368 llvm-svn: 306917
* Fix PR 33189: Clang assertion on template destructor declarationHubert Tong2017-06-301-4/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch aims to fix the bug reported at https://bugs.llvm.org/show_bug.cgi?id=33189. Clang hits an assertion when a template destructor declaration is present. This is caused by later processing that does not expect to encounter a template when looking at a destructor. The resolution is to treat the destructor as being not declared when later processing is interested in the properties of the destructor of a class. Reviewers: rcraik, hubert.reinterpretcast, aaron.ballman, rsmith Reviewed By: rsmith Subscribers: rsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D33833 Patch by Kuang He! llvm-svn: 306905
* [ODRHash] Support Type TemplateArgumentRichard Trieu2017-06-301-0/+3
| | | | llvm-svn: 306904
* [ODRHash] Improve typedef handling.Richard Trieu2017-06-291-1/+14
| | | | | | | Follow typedef chains to find the root type when processing types, and also keep track of qualifiers. llvm-svn: 306753
* [Sema] Issue diagnostics if a new/delete expression generates a call toAkira Hatanaka2017-06-291-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | a c++17 aligned allocation/deallocation function that is unavailable in the standard library on Apple platforms. The aligned functions are implemented only in the following versions or later versions of the OSes, so clang issues diagnostics if the deployment target being targeted is older than these: macosx: 10.13 ios: 11.0 tvos: 11.0 watchos: 4.0 The diagnostics are issued whenever the aligned functions are selected except when the selected function has a definition in the same file. If there is a user-defined function available somewhere else, option -Wno-aligned-allocation-unavailable can be used to silence the diagnostics. rdar://problem/32664169 Differential Revision: https://reviews.llvm.org/D34574 llvm-svn: 306722
* Make CastExpr::getSubExprAsWritten look through implicit temporary under ↵Stephan Bergmann2017-06-271-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | CK_ConstructorConversion With struct S1 {}; struct S2 { operator S1(); }; S1 f(S2 s) { return static_cast<S1>(s); } the static_cast expr is CXXStaticCastExpr 0x... 'struct S1' static_cast<struct S1> <ConstructorConversion> `-CXXConstructExpr 0x... 'struct S1' 'void (struct S1 &&) noexcept' elidable `-MaterializeTemporaryExpr 0x... 'struct S1' xvalue `-ImplicitCastExpr 0x... 'struct S1' <UserDefinedConversion> `-CXXMemberCallExpr 0x... 'struct S1' `-MemberExpr 0x... '<bound member function type>' .operator S1 0x... `-DeclRefExpr 0x... 'struct S2' lvalue ParmVar 0x... 's' 'struct S2' getSubExprAsWritten used to return the MaterializeTemporaryExpr (of type S1) under the CXXConstructExpr, instead of unwinding further to the DeclRefExpr (of type S2) at the bottom. Differential Revision: https://reviews.llvm.org/D22128 llvm-svn: 306377
* [CodeGen][ObjC] Fix GNU's encoding of bit-field ivars.Akira Hatanaka2017-06-272-3/+48
| | | | | | | | | | | | | | | | | According to the documentation, when encoding a bit-field, GNU runtime needs its starting position in addition to its type and size. https://gcc.gnu.org/onlinedocs/gcc/Type-encoding.html Prior to r297702, the starting position information was not being encoded, which is incorrect, and after r297702, an assertion started to fail because an ObjCIvarDecl was being passed to a function expecting a FieldDecl. This commit moves LookupFieldBitOffset to ASTContext and uses the function to encode the starting position of bit-fields. llvm-svn: 306364
* AST: enhance mangling for blocks with MS ABISaleem Abdulrasool2017-06-261-10/+65
| | | | | | | | | | | | When generating the decorated name for a static variable inside a BlockDecl, construct a scope for the block invocation function that homes the parameter. This allows for arbitrary nesting of the blocks even if the variables are shadowed. Furthermore, using this for the name allows for undname to properly undecorated the name for us. It shows up as the synthetic __block_invocation function that the compiler emitted in the local scope. llvm-svn: 306347
* Revert r301742, which caused us to try to evaluate all full-expressions.Richard Smith2017-06-261-9/+4
| | | | | | | | | | | | | | Also add testcases for a bunch of expression forms that cause our evaluator to crash. See PR33140 and PR32864 for crashes that this was causing. This reverts r305287, which reverted r305239, which reverted r301742. The previous revert claimed that buildbots were broken, but did not add any testcases and the buildbots have lost all memory of what was wrong here. Changes to test/OpenMP are not reverted; another change has triggered those tests to change their output in the same way that r301742 did. llvm-svn: 306346
* Revert "[MS] Don't statically initialize dllimport member function pointers"Reid Kleckner2017-06-231-16/+0
| | | | | | | | | | | | | | | | | | | This reverts commit r306137. It has problems on code like this: struct __declspec(dllimport) Foo { int a; int get_a() { return a; } }; template <int (Foo::*Getter)()> struct HasValue { int operator()(Foo *p) { return (p->*Getter)(); } }; int main() { Foo f; f.a = 3; int x = HasValue<&Foo::get_a>()(&f); } llvm-svn: 306175
OpenPOWER on IntegriCloud