summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang] New __attribute__((__clang_arm_mve_alias)).Simon Tatham2019-10-241-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows you to declare a function with a name of your choice (say `foo`), but have clang treat it as if it were a builtin function (say `__builtin_foo`), by writing static __inline__ __attribute__((__clang_arm_mve_alias(__builtin_foo))) int foo(args); I'm intending to use this for the ACLE intrinsics for MVE, which have to be polymorphic on their argument types and also need to be implemented by builtins. To avoid having to implement the polymorphism with several layers of nested _Generic and make error reporting hideous, I want to make all the user-facing intrinsics correspond directly to clang builtins, so that after clang resolves __attribute__((overloadable)) polymorphism it's already holding the right BuiltinID for the intrinsic it selected. However, this commit itself just introduces the new attribute, and doesn't use it for anything. To avoid unanticipated side effects if this attribute is used to make aliases to other builtins, there's a restriction mechanism: only (BuiltinID, alias) pairs that are approved by the function ArmMveAliasValid() will be permitted. At present, that function doesn't permit anything, because the Tablegen that will generate its list of valid pairs isn't yet implemented. So the only test of this facility is one that checks that an unapproved builtin _can't_ be aliased. Reviewers: dmgreen, miyuki, ostannard Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67159
* [c++2a] Allow comparison functions to be explicitly defaulted.Richard Smith2019-10-221-14/+9
| | | | | | This adds some initial syntactic checking that only the appropriate function signatures can be defaulted. No implicit definitions are generated yet.
* Revert r374202"[ObjC generics] Fix not inheriting type bounds in ↵Hans Wennborg2019-10-221-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | categories/extensions." This introduced new errors, see below. Reverting until that can be investigated properly. #import <AVFoundation/AVFoundation.h> void f(int width, int height) { FourCharCode best_fourcc = kCMPixelFormat_422YpCbCr8_yuvs; NSDictionary* videoSettingsDictionary = @{ (id)kCVPixelBufferPixelFormatTypeKey : @(best_fourcc), }; } $ clang++ -c /tmp/a.mm /tmp/a.mm:6:5: error: cannot initialize a parameter of type 'KeyType<NSCopying> _Nonnull const' (aka 'const id') with an rvalue of type 'id' (id)kCVPixelBufferPixelFormatTypeKey : @(best_fourcc), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. > When a category/extension doesn't repeat a type bound, corresponding > type parameter is substituted with `id` when used as a type argument. As > a result, in the added test case it was causing errors like > > > type argument 'T' (aka 'id') does not satisfy the bound ('id<NSCopying>') of type parameter 'T' > > We are already checking that type parameters should be consistent > everywhere (see `checkTypeParamListConsistency`) and update > `ObjCTypeParamDecl` to have correct underlying type. And when we use the > type parameter as a method return type or a method parameter type, it is > substituted to the bounded type. But when we use the type parameter as a > type argument, we check `ObjCTypeParamType` that ignores the updated > underlying type and remains `id`. > > Fix by desugaring `ObjCTypeParamType` to the underlying type, the same > way we are doing with `TypedefType`. > > rdar://problem/54329242 > > Reviewers: erik.pilkington, ahatanak > > Reviewed By: erik.pilkington > > Subscribers: jkorous, dexonsmith, ributzka, cfe-commits > > Differential Revision: https://reviews.llvm.org/D66696
* [hip][cuda] Fix the extended lambda name mangling issue.Michael Liao2019-10-192-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: - HIP/CUDA host side needs to use device kernel symbol name to match the device side binaries. Without a consistent naming between host- and device-side compilations, it's risky that wrong device binaries are executed. Consistent naming is usually not an issue until unnamed types are used, especially the lambda. In this patch, the consistent name mangling is addressed for the extended lambdas, i.e. the lambdas annotated with `__device__`. - In [Itanium C++ ABI][1], the mangling of the lambda is generally unspecified unless, in certain cases, ODR rule is required to ensure consisent naming cross TUs. The extended lambda is such a case as its name may be part of a device kernel function, e.g., the extended lambda is used as a template argument and etc. Thus, we need to force ODR for extended lambdas as they are referenced in both device- and host-side TUs. Furthermore, if a extended lambda is nested in other (extended or not) lambdas, those lambdas are required to follow ODR naming as well. This patch revises the current lambda mangle numbering to force ODR from an extended lambda to all its parent lambdas. - On the other side, the aforementioned ODR naming should not change those lambdas' original linkages, i.e., we cannot replace the original `internal` with `linkonce_odr`; otherwise, we may violate ODR in general. This patch introduces a new field `HasKnownInternalLinkage` in lambda data to decouple the current linkage calculation based on mangling number assigned. [1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html Reviewers: tra, rsmith, yaxunl, martong, shafik Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68818 llvm-svn: 375309
* [c++20] Add rewriting from comparison operators to <=> / ==.Richard Smith2019-10-191-2/+2
| | | | | | | | | | | | | | | | | This adds support for rewriting <, >, <=, and >= to a normal or reversed call to operator<=>, for rewriting != to a normal or reversed call to operator==, and for rewriting <=> and == to reversed forms of those same operators. Note that this is a breaking change for various C++17 code patterns, including some in use in LLVM. The most common patterns (where an operator== becomes ambiguous with a reversed form of itself) are still accepted under this patch, as an extension (with a warning). I'm hopeful that we can get the language rules fixed before C++20 ships, and the extension warning is aimed primarily at providing data to inform that decision. llvm-svn: 375306
* [c++20] Add CXXRewrittenBinaryOperator to represent a comparisonRichard Smith2019-10-197-0/+112
| | | | | | | | operator that is rewritten as a call to multiple other operators. No functionality change yet: nothing creates these expressions. llvm-svn: 375305
* DebugInfo: Render the canonical name of a class template specialization, ↵David Blaikie2019-10-181-1/+2
| | | | | | | | even when nested in another class template specialization Differential Revision: https://reviews.llvm.org/D63031 llvm-svn: 375304
* [OPENMP50]Add support for master taskloop simd.Alexey Bataev2019-10-183-0/+65
| | | | | | Added trsing/semantics/codegen for combined construct master taskloop simd. llvm-svn: 375255
* [ObjC] Diagnose implicit type coercion from ObjC 'Class' to objectJames Y Knight2019-10-171-9/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pointer types. For example, in Objective-C mode, the initialization of 'x' in: ``` @implementation MyType + (void)someClassMethod { MyType *x = self; } @end ``` is correctly diagnosed with an incompatible-pointer-types warning, but in Objective-C++ mode, it is not diagnosed at all -- even though incompatible pointer conversions generally become an error in C++. This patch fixes that oversight, allowing implicit conversions involving Class only to/from unqualified-id, and between qualified and unqualified Class, where the protocols are compatible. Note that this does change some behaviors in Objective-C, as well, as shown by the modified tests. Of particular note is that assignment from from 'Class<MyProtocol>' to 'id<MyProtocol>' now warns. (Despite appearances, those are not compatible types. 'Class<MyProtocol>' is not expected to have instance methods defined by 'MyProtocol', while 'id<MyProtocol>' is.) Differential Revision: https://reviews.llvm.org/D67983 llvm-svn: 375125
* [Concepts] ConceptSpecializationExprs manglingSaar Raz2019-10-171-3/+14
| | | | | | | | | Implement mangling for CSEs to match regular template-ids. Reviewed as part of D41569 <https://reviews.llvm.org/D41569>. Re-commit fixing failing test. llvm-svn: 375063
* [OPENMP]Allow priority clause in combined task-based directives.Alexey Bataev2019-10-162-1/+9
| | | | | | | The expression of the priority clause must be captured in the combined task-based directives, like 'parallel master taskloop' directive. llvm-svn: 375026
* Revert 374967 "[Concepts] ConceptSpecializationExprs mangling"Nico Weber2019-10-161-14/+3
| | | | | | | | | | | | | | | This reverts commit 5e34ad109ced8dbdea9500ee28180315b2aeba3d. The mangling test fails on Windows: http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15944 It also fails on ppc64le: http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/21092 Also revert follow-up 374971 "Fix failing mangle-concept.cpp test." (it did not help on Win/ppc64le). llvm-svn: 374985
* [Concepts] ConceptSpecializationExprs manglingSaar Raz2019-10-161-3/+14
| | | | | | | Implement mangling for CSEs to match regular template-ids. Reviewed as part of D41569. llvm-svn: 374967
* PR43674: fix incorrect constant evaluation of 'switch' where no caseRichard Smith2019-10-151-1/+1
| | | | | | label corresponds to the condition. llvm-svn: 374954
* [OPENMP]Allow final clause in combined task-based directives.Alexey Bataev2019-10-152-1/+9
| | | | | | | The condition of the final clause must be captured in the combined task-based directives, like 'parallel master taskloop' directive. llvm-svn: 374942
* [Concept] Associated Constraints InfrastructureSaar Raz2019-10-152-18/+39
| | | | | | | Add code to correctly calculate the associated constraints of a template (no enforcement yet). D41284 on Phabricator. llvm-svn: 374938
* Add more information to JSON AST dumping of source locations.Aaron Ballman2019-10-151-0/+24
| | | | | | This adds information about the offset within the source file to the given source location as well as information about the include file a location is from. These pieces of information allow for more efficient post-processing of JSON AST dumps. llvm-svn: 374921
* [Concepts] Remove unused and illegal Sema includes from ExprCXX.cppSaar Raz2019-10-151-4/+1
| | | | | | Fixing accidental includes introduced in 374903 llvm-svn: 374907
* [Concepts] Concept Specialization ExpressionsSaar Raz2019-10-157-0/+112
| | | | | | | | | | Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is refe$ D41217 on Phabricator. (recommit after fixing failing Parser test on windows) llvm-svn: 374903
* Revert 374882 "[Concepts] Concept Specialization Expressions"Nico Weber2019-10-157-109/+0
| | | | | | | | | | This reverts commit ec87b003823d63f3342cf648f55a134c1522e612. The test fails on Windows, see e.g. http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11533/steps/stage%201%20check/logs/stdio Also revert follow-up r374893. llvm-svn: 374899
* [AST] Remove unused Sema includes to fix a cyclic dependency from Sema to ASTBenjamin Kramer2019-10-151-4/+1
| | | | llvm-svn: 374893
* [Concepts] Concept Specialization ExpressionsSaar Raz2019-10-157-0/+112
| | | | | | Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is referenced with arguments, and tests thereof. llvm-svn: 374882
* Fix uninitialized variable warnings. NFCI.Simon Pilgrim2019-10-151-2/+2
| | | | llvm-svn: 374876
* [OPNEMP]Allow num_tasks clause in combined task-based directives.Alexey Bataev2019-10-142-1/+9
| | | | | | | The expression of the num_tasks clause must be captured in the combined task-based directives, like 'parallel master taskloop' directive. llvm-svn: 374819
* [OPNEMP]Allow grainsize clause in combined task-based directives.Alexey Bataev2019-10-142-1/+9
| | | | | | | The expression of the grainsize clause must be captured in the combined task-based directives, like 'parallel master taskloop' directive. llvm-svn: 374810
* [OPENMP50]Add support for 'parallel master taskloop' construct.Alexey Bataev2019-10-143-0/+66
| | | | | | | | | Added parsing/sema/codegen support for 'parallel master taskloop' constructs. Some of the clauses, like 'grainsize', 'num_tasks', 'final' and 'priority' are not supported in full, only constant expressions can be used currently in these clauses. llvm-svn: 374791
* [ObjC] Remove default parameter no caller was providing. NFC intended.Volodymyr Sapsai2019-10-111-12/+9
| | | | | | | | Currently there is no need to make ObjCTypeParamType have a canonical type different from the one in corresponding ObjCTypeParamDecl. So remove the corresponding unused API. llvm-svn: 374596
* [MS ABI]: Fix mangling function arguments for template types to be ↵Nico Weber2019-10-111-1/+1
| | | | | | | | | | | | | | | | | | | | | compatible with MSVC MS name mangling supports cache for first 10 distinct function arguments. The error was when non cached template type occurred twice (e.g. 11th and 12th). For such case in code there is another cache table TemplateArgStrings (for performance reasons). Then one '@' character at the end of the mangled name taken from this table was missing. For other cases the missing '@' character was added in the call to mangleSourceName(TemplateMangling) in the cache miss code, but the cache hit code didn't add it. This fixes a regression from r362560. Patch by Adam Folwarczny <adamf88@gmail.com>! Differential Revision: https://reviews.llvm.org/D68099 llvm-svn: 374543
* Include whether the destructor is constexpr in -ast-dump output for aRichard Smith2019-10-111-0/+1
| | | | | | clss. llvm-svn: 374488
* Move most CXXRecordDecl::DefinitionData bit-fields out into a separateRichard Smith2019-10-112-67/+7
| | | | | | | | | | | file. Reduces duplication and thereby reduces the risk that someone will forget to update one of these places, as I did when adding DefaultedDestructorIsConstexpr (though I've been unable to produce a testcase for which that matters so far). llvm-svn: 374484
* PR43629: Fix crash evaluating constexpr placement new on a subobject ofRichard Smith2019-10-101-1/+1
| | | | | | an out-of-lifetime object. llvm-svn: 374465
* [OPENMP50]Support for 'master taskloop' directive.Alexey Bataev2019-10-103-0/+63
| | | | | | Added full support for master taskloop directive. llvm-svn: 374437
* [clang] prevent crash for nonnull attribut in constant context (Bug 43601)Gauthier Harnisch2019-10-101-6/+6
| | | | | | | | | | | | | | | | | | Summary: bug : https://bugs.llvm.org/show_bug.cgi?id=43601 Reviewers: rnk Reviewed By: rnk Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68716 llvm-svn: 374285
* Re-land [mangle] Fix mangling where an extra mangle context is required.Reid Kleckner2019-10-101-0/+10
| | | | | | | | | | | This reverts r374268 (git commit c34385d07c7d59447bf836b740f032235391d121) I think I reverted this by mistake, so I'm relanding it. While my bisect found this revision, I think the crashes I'm seeing locally must be environmental. Maybe the version of clang I'm using miscompiles tot clang. llvm-svn: 374269
* Revert [mangle] Fix mangling where an extra mangle context is required.Reid Kleckner2019-10-101-10/+0
| | | | | | | | This reverts r374200 (git commit fd18e94697c987d5f24e25aa4e27adaffff3cce4) Causes crashes just compiling `int main() {}` on my machine. llvm-svn: 374268
* [ObjC generics] Fix not inheriting type bounds in categories/extensions.Volodymyr Sapsai2019-10-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a category/extension doesn't repeat a type bound, corresponding type parameter is substituted with `id` when used as a type argument. As a result, in the added test case it was causing errors like > type argument 'T' (aka 'id') does not satisfy the bound ('id<NSCopying>') of type parameter 'T' We are already checking that type parameters should be consistent everywhere (see `checkTypeParamListConsistency`) and update `ObjCTypeParamDecl` to have correct underlying type. And when we use the type parameter as a method return type or a method parameter type, it is substituted to the bounded type. But when we use the type parameter as a type argument, we check `ObjCTypeParamType` that ignores the updated underlying type and remains `id`. Fix by desugaring `ObjCTypeParamType` to the underlying type, the same way we are doing with `TypedefType`. rdar://problem/54329242 Reviewers: erik.pilkington, ahatanak Reviewed By: erik.pilkington Subscribers: jkorous, dexonsmith, ributzka, cfe-commits Differential Revision: https://reviews.llvm.org/D66696 llvm-svn: 374202
* [mangle] Fix mangling where an extra mangle context is required.Michael Liao2019-10-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: - [Itanium C++ ABI][1], for certain contexts like default parameter and etc., mangling numbering will be local to the particular argument in which it appears. - However, for these cases, the mangle numbering context is allocated per expression evaluation stack entry. That causes, for example, two lambdas defined/used understand the same default parameter are numbered as the same value and, in turn, one of them is not generated at all. - In this patch, an extra mangle numbering context map is maintained in the AST context to map taht extra declaration context to its numbering context. So that, 2 different lambdas defined/used in the same default parameter are numbered differently. [1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html Reviewers: rsmith, eli.friedman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68715 llvm-svn: 374200
* Revert r374006: Reland 'Add VFS support for sanitizers' blacklist'Ilya Biryukov2019-10-091-18/+1
| | | | | | | | | | | Also revert follow-up changes to the test. Reason: the patch breaks our internal clang-tidy integration. It's also unclear why we should use getRealPath instead of plumbing the VFS to SanitizerBlacklist, see original commit thread of cfe-commits for a discussion. llvm-svn: 374151
* Unify the two CRC implementationsHans Wennborg2019-10-091-2/+2
| | | | | | | | | | | | | | | | | | | | | David added the JamCRC implementation in r246590. More recently, Eugene added a CRC-32 implementation in r357901, which falls back to zlib's crc32 function if present. These checksums are essentially the same, so having multiple implementations seems unnecessary. This replaces the CRC-32 implementation with the simpler one from JamCRC, and implements the JamCRC interface in terms of CRC-32 since this means it can use zlib's implementation when available, saving a few bytes and potentially making it faster. JamCRC took an ArrayRef<char> argument, and CRC-32 took a StringRef. This patch changes it to ArrayRef<uint8_t> which I think is the best choice, and simplifies a few of the callers nicely. Differential revision: https://reviews.llvm.org/D68570 llvm-svn: 374148
* Factor out some duplication. NFC.Richard Smith2019-10-081-5/+3
| | | | llvm-svn: 374130
* Fix crash or wrong code bug if a lifetime-extended temporary contains aRichard Smith2019-10-081-2/+4
| | | | | | | | | | | | | | "non-constant" value. If the constant evaluator evaluates part of a variable initializer, including the initializer for some lifetime-extended temporary, but fails to fully evaluate the initializer, it can leave behind wrong values for temporaries encountered in that initialization. Don't try to emit those from CodeGen! Instead, look at the values that constant evaluation produced if (and only if) it actually succeeds and we're emitting the lifetime-extending declaration's initializer as a constant. llvm-svn: 374119
* [ItaniumMangle] Fix mangling of GNU __null in an expression to match GCCJames Clarke2019-10-081-2/+5
| | | | | | | | | | | | | | Reviewers: rsmith Reviewed By: rsmith Subscribers: erik.pilkington, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68368 llvm-svn: 374013
* Reland 'Add VFS support for sanitizers' blacklist'Jan Korous2019-10-081-1/+18
| | | | | | | | | | The original patch broke the test for Windows. Trying to fix as per Reid's suggestions outlined here: https://reviews.llvm.org/rC371663 Differential Revision: https://reviews.llvm.org/D67742 llvm-svn: 374006
* Revert "Add VFS support for sanitizers' blacklist"Jan Korous2019-10-081-18/+1
| | | | | | | | Fix tests on Windows for now. This reverts commit 96ac97a4213287003f08636d0c372b3f71e9cfca. llvm-svn: 373999
* Add VFS support for sanitizers' blacklistJan Korous2019-10-071-1/+18
| | | | | | Differential Revision: https://reviews.llvm.org/D67742 llvm-svn: 373977
* AST - silence static analyzer getAs<> null dereference warnings. NFCI.Simon Pilgrim2019-10-076-14/+11
| | | | | | The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 373904
* [c++20] Check for a class-specific operator delete when deleting anRichard Smith2019-10-071-0/+19
| | | | | | object of class type with a virtual destructor. llvm-svn: 373875
* [Sema] Split out -Wformat-type-confusion from -Wformat-pedanticErik Pilkington2019-10-041-1/+1
| | | | | | | | | The warnings now in -Wformat-type-confusion don't align with how we interpret 'pedantic' in clang, and don't belong in -pedantic. Differential revision: https://reviews.llvm.org/D67775 llvm-svn: 373774
* [lldb][modern-type-lookup] No longer import temporary declarations into the ↵Raphael Isemann2019-10-041-7/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | persistent AST Summary: As we figured out in D67803, importing declarations from a temporary ASTContext that were originally from a persistent ASTContext causes a bunch of duplicated declarations where we end up having declarations in the target AST that have no associated ASTImporter that can complete them. I haven't figured out how/if we can solve this in the current way we do things in LLDB, but in the modern-type-lookup this is solvable as we have a saner architecture with the ExternalASTMerger. As we can (hopefully) make modern-type-lookup the default mode in the future, I would say we try fixing this issue here. As we don't use the hack that was reinstated in D67803 during modern-type-lookup, the test case for this is essentially just printing any kind of container in `std::` as we would otherwise run into the issue that required a hack like D67803. What this patch is doing in essence is that instead of importing a declaration from a temporary ASTContext, we instead check if the declaration originally came from a persistent ASTContext (e.g. the debug information) and we directly import from there. The ExternalASTMerger is already connected with ASTImporters to these different sources, so this patch is essentially just two parts: 1. Mark our temporary ASTContext/ImporterSource as temporary when we import from the expression AST. 2. If the ExternalASTMerger sees we import from the expression AST, instead of trying to import these temporary declarations, check if we can instead import from the persistent ASTContext that is already connected. This ensures that all records from the persistent source actually come from the persistent source and are minimally imported in a way that allows them to be completed later on in the target AST. The next step is to run the ASTImporter for these temporary expressions with the MinimalImport mode disabled, but that's a follow up patch. This patch fixes most test failures with modern-type-lookup enabled by default (down to 73 failing tests, which includes the 22 import-std-module tests which need special treatment). Reviewers: shafik, martong Reviewed By: martong Subscribers: aprantl, rnkovacs, christof, abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68326 llvm-svn: 373711
* Properly handle instantiation-dependent array bounds.Richard Smith2019-10-044-35/+94
| | | | | | | | | We previously failed to treat an array with an instantiation-dependent but not value-dependent bound as being an instantiation-dependent type. We now track the array bound expression as part of a constant array type if it's an instantiation-dependent expression. llvm-svn: 373685
OpenPOWER on IntegriCloud