summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* [OpenCL] Add constant address space to __func__ in AST.Anastasia Stulova2018-05-092-1/+8
| | | | | | | | | | | | Added string literal helper function to obtain the type attributed by a constant address space. Also fixed predefind __func__ expr to use the helper to constract the string literal correctly. Differential Revision: https://reviews.llvm.org/D46049 llvm-svn: 331877
* _Atomic of empty struct shouldn't assertJF Bastien2018-05-091-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: An _Atomic of an empty struct is pretty silly. In general we just widen empty structs to hold a byte's worth of storage, and we represent size and alignment as 0 internally and let LLVM figure out what to do. For _Atomic it's a bit different: the memory model mandates concrete effects occur when atomic operations occur, so in most cases actual instructions need to get emitted. It's really not worth trying to optimize empty struct atomics by figuring out e.g. that a fence would do, even though sane compilers should do optimize atomics. Further, wg21.link/p0528 will fix C++20 atomics with padding bits so that cmpxchg on them works, which means that we'll likely need to do the zero-init song and dance for empty atomic structs anyways (and I think we shouldn't special-case this behavior to C++20 because prior standards are just broken). This patch therefore makes a minor change to r176658 "Promote atomic type sizes up to a power of two": if the width of the atomic's value type is 0, just use 1 byte for width and leave alignment as-is (since it should never be zero, and over-aligned zero-width structs are weird but fine). This fixes an assertion: (NumBits >= MIN_INT_BITS && "bitwidth too small"), function get, file ../lib/IR/Type.cpp, line 241. It seems like this has run into other assertions before (namely the unreachable Kind check in ImpCastExprToType), but I haven't reproduced that issue with tip-of-tree. <rdar://problem/39678063> Reviewers: arphaman, rjmccall Subscribers: aheejin, cfe-commits Differential Revision: https://reviews.llvm.org/D46613 llvm-svn: 331845
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-0929-167/+167
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [ASTImporter] Properly import SourceLocations of AttrsAleksei Sidorin2018-05-081-13/+12
| | | | | | | | Patch by Rafael Stahl! Differential Revision: https://reviews.llvm.org/D46115 llvm-svn: 331762
* Fix 'not all control paths return a value' MSVC warnings. NFCI.Simon Pilgrim2018-05-081-0/+1
| | | | llvm-svn: 331753
* [C++2a] Implement operator<=>: Address bugs and post-commit review comments ↵Eric Fiselier2018-05-081-35/+26
| | | | | | | | | | | | after r331677. This patch addresses some mostly trivial post-commit review comments received on r331677. Additionally, this patch fixes an assertion in `getNarrowingKind` caused by the use of an uninitialized value from `checkThreeWayNarrowingConversion`. llvm-svn: 331707
* PR37352: mangle numbering for decomposition declarations.Richard Smith2018-05-071-1/+59
| | | | | | | | | | In order to match our mangling scheme, use a different set of numbers for decomposition declarations, and consider all binding names when forming the numbering. This does not yet affect any mangled names we produce, because local decomposition declarations can't yet have linkage, but a C++ standard proposal to change that is currently being processed. llvm-svn: 331692
* [C++2a] Implement operator<=> CodeGen and ExprConstantEric Fiselier2018-05-075-272/+573
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch tackles long hanging fruit for the builtin operator<=> expressions. It is currently needs some cleanup before landing, but I want to get some initial feedback. The main changes are: * Lookup, build, and store the required standard library types and expressions in `ASTContext`. By storing them in ASTContext we don't need to store (and duplicate) the required expressions in the BinaryOperator AST nodes. * Implement [expr.spaceship] checking, including diagnosing narrowing conversions. * Implement `ExprConstant` for builtin spaceship operators. * Implement builitin operator<=> support in `CodeGenAgg`. Initially I emitted the required comparisons using `ScalarExprEmitter::VisitBinaryOperator`, but this caused the operand expressions to be emitted once for every required cmp. * Implement [builtin.over] with modifications to support the intent of P0946R0. See the note on `BuiltinOperatorOverloadBuilder::addThreeWayArithmeticOverloads` for more information about the workaround. Reviewers: rsmith, aaron.ballman, majnemer, rnk, compnerd, rjmccall Reviewed By: rjmccall Subscribers: rjmccall, rsmith, aaron.ballman, junbuml, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D45476 llvm-svn: 331677
* [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, ↵Peter Szecsi2018-05-071-1/+86
| | | | | | | | | | DependentScopeDeclRefExpr The visit callback implementations for the 3 C++ AST Node added to the ASTImporter. Differential Revision: https://reviews.llvm.org/D38845 llvm-svn: 331630
* Remove now-unnecessary check for non-zero nvsize in addition toRichard Smith2018-05-071-2/+2
| | | | | | emptyness in MS record layout. llvm-svn: 331621
* Non-zero-length bit-fields make a class non-empty.Richard Smith2018-05-071-9/+13
| | | | | | | | | | | | | | | | | | | | This implements the rule intended by the standard (see LWG 2358) and the rule intended by the Itanium C++ ABI (see https://github.com/itanium-cxx-abi/cxx-abi/pull/51), and makes Clang match the behavior of GCC, ICC, and MSVC. A pedantic reading of both the standard and the ABI indicate that Clang is currently technically correct, but that's not worth much when it's clear that the wording is wrong in both those places. This is an ABI break for classes that derive from a class that is empty other than one or more unnamed non-zero-length bit-fields. Such cases are expected to be rare, but -fclang-abi-compat=6 restores the old behavior just in case. Differential Revision: https://reviews.llvm.org/D45174 llvm-svn: 331620
* Fix a couple places that immediately called operator-> on the result of ↵Craig Topper2018-05-051-1/+1
| | | | | | | | dyn_cast. It looks like it safe to just use cast for both cases. llvm-svn: 331578
* Allow modifying the PrintingPolicy for fully qualified names.Sterling Augustine2018-05-041-5/+1
| | | | | Author: mikhail.ramalho@gmail.com llvm-svn: 331552
* Track the result of evaluating a computed noexcept specification on theRichard Smith2018-05-037-87/+54
| | | | | | | | | | | | | | FunctionProtoType. We previously re-evaluated the expression each time we wanted to know whether the type is noexcept or not. We now evaluate the expression exactly once. This is not quite "no functional change": it fixes a crasher bug during AST deserialization where we would try to evaluate the noexcept specification in a situation where we have not deserialized sufficient portions of the AST to permit such evaluation. llvm-svn: 331428
* [ObjC] Supress the 'implementing unavailable method' warning whenAlex Lorenz2018-05-031-3/+8
| | | | | | | | | | | | | the method declaration is unavailable for an app extension platform Rationale: Classes are often shared between an app extension code and non-app extension code. There's no way to remove the implementation using preprocessor when building the app extension, so we should not warn here. rdar://38150617 llvm-svn: 331421
* [ASTImporter] Fix isa cast assertPeter Szecsi2018-05-021-3/+7
| | | | | | | | | | | | | | | | | | | | | | | Do early return if we can't import the found decl for a member expr. This follows the pre-existing scheme, e.g with E->getMemberDecl(). E->getFoundDecl().getDecl() can be null when a member expression does not involve lookup. It may involve a lookup in case of a using directive which refers to a member function in a base class template. We faced this assert during the CTU analysis of google::protobuf v3.5.2. We tried hard to synthesize a minimal test example both by hand and by executing creduce on multiple files. Unfortunately, we were unable to reduce to such a minimal example, yet. Nevertheless, this fix solved the problem in protobuf. To reproduce the error one must execute the analyzer with -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true -Xclang -analyzer-config -Xclang ctu-dir=/path/to/ctu_dir Patch by Gabor Marton! Differential Revision: https://reviews.llvm.org/D46019 llvm-svn: 331344
* Fix bogus MSVC char8_t mangling.Richard Smith2018-05-011-1/+1
| | | | | | | This appears to have been caused by a bad automatic svn merge with r330225 attaching the 'case' label to the wrong block of code. :( llvm-svn: 331299
* Add Microsoft Mangling for OpenCL Half TypeErich Keane2018-05-011-2/+5
| | | | | | | | | | | | Half-type mangling is accomplished following the method introduced by Erich Keane for mangling _Float16. Updated the half.cl LIT test to cover this particular case. Patch By: vbridgers Differential Revision: https://reviews.llvm.org/D46131 llvm-svn: 331263
* Implement P0482R2, support for char8_t type.Richard Smith2018-05-017-0/+24
| | | | | | | | | | | | This is not yet part of any C++ working draft, and so is controlled by the flag -fchar8_t rather than a -std= flag. (The GCC implementation is controlled by a flag with the same name.) This implementation is experimental, and will be removed or revised substantially to match the proposal as it makes its way through the C++ committee. llvm-svn: 331244
* Fix printing of reference-to-reference types.Richard Smith2018-04-291-8/+20
| | | | | | Previously we would sometimes print these as 'T &&&' or even 'T &&&&'. llvm-svn: 331137
* PR37275 packed attribute should not apply to base classesRichard Smith2018-04-291-3/+8
| | | | | | | | | | | | | Clang incorrectly applied the packed attribute to base classes. Per GCC's documentation and as can be observed from its behavior, packed only applies to members, not base classes. This change is conditioned behind -fclang-abi-compat so that an ABI break can be avoided by users if desired. Differential Revision: https://reviews.llvm.org/D46218 llvm-svn: 331136
* [ItaniumMangle] Undeduced auto type shouldn't be substitutable.Erik Pilkington2018-04-281-11/+16
| | | | | | | | | We still support the old mangling if we're trying to be ABI-compatible with Clang 6.0, though. Differential revision: https://reviews.llvm.org/D45451 llvm-svn: 331098
* Revert rC330794 and some dependent tiny bug fixes Faisal Vali2018-04-263-29/+0
| | | | | | | | | | | | | | See Richard's humbling feedback here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html Wish I'd had the patience to solicit the feedback prior to committing :) Sorry for the noise guys. Thank you Richard for being the steward that clang deserves! llvm-svn: 330888
* [ASTImporter] FriendDecl importing improvementsPeter Szecsi2018-04-252-5/+92
| | | | | | | | | | There are only a few cases of importing a frienddecl which is currently supported. This patch aims to improve the friend import process. Set FriendObjectKind in case of decls, insert friend into the friend chain correctly, checks structurally equivalent in a more advanced manner. Test cases added as well. llvm-svn: 330847
* [c++2a] [concepts] Add rudimentary parsing support for template concept ↵Faisal Vali2018-04-253-0/+29
| | | | | | | | | | | | | | declarations This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly. See the test file to get a sense of the basic parsing that this patch supports. There is much more work to be done before concepts are usable... Thanks Changyu! llvm-svn: 330794
* [ODRHash] Hash template arguments of methods.Richard Trieu2018-04-251-0/+11
| | | | llvm-svn: 330789
* [Attr] Print enum attributes at correct positionJoel E. Denny2018-04-241-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: void fn() { enum __attribute__((deprecated)) T *p; } -ast-print produced: void fn() { enum T __attribute__((deprecated(""))) *p; } -ast-print on that produced: void fn() { enum T *p __attribute__((deprecated(""))); } The attribute is on enum T in the first case, but it's on p in the other cases. Details: Within enum declarations, enum attributes were always printed after the tag and any member list. When no member list was present but the enum was a type specifier in a variable declaration, the attribute then applied to the variable not the enum, changing the semantics. This patch fixes that by always printing attributes between the enum's keyword and tag, as clang already does for structs, unions, and classes. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D45456 llvm-svn: 330722
* [ASTImporter] Allow testing of import sequences; fix import of typedefs for ↵Aleksei Sidorin2018-04-241-23/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | anonymous decls This patch introduces the ability to test an arbitrary sequence of imports between a given set of virtual source files. This should finally allow us to write simple tests and fix annoying issues inside ASTImporter that cause failures in CSA CTU. This is done by refactoring ASTImporterTest functions and introducing `testImportSequence` facility. As a side effect, `testImport` facility was generalized a bit more. It should now allow import of non-decl AST nodes; however, there is still no test using this ability. As a "test for test", there is also a fix for import anonymous TagDecls referred by typedef. Before this patch, the setting of typedef for anonymous structure was delayed; however, this approach misses the corner case if an enum constant is imported directly. In this patch, typedefs for anonymous declarations are imported right after the anonymous declaration is imported, without any delay. Thanks to Adam Balogh for suggestions included into this patch. Differential Revision: https://reviews.llvm.org/D44079 llvm-svn: 330704
* [AST] strcmp/memcmp always compares unsigned chars.Benjamin Kramer2018-04-231-2/+12
| | | | | | | This makes it return the right result in a couple of edge cases. The wide versions always do the comparison on the underlying wchar_t type. llvm-svn: 330656
* [CXX] Templates specialization visibility can be wrongSteven Wu2018-04-191-3/+12
| | | | | | | | | | | | | | | | | | | | | Summary: Under some conditions, LinkageComputer can get the visibility for ClassTemplateSpecializationDecl wrong because it failed to find the Decl that has the explicit visibility. This fixes: llvm.org/bugs/pr36810 rdar://problem/38080953 Reviewers: rsmith, arphaman, doug.gregor Reviewed By: doug.gregor Subscribers: doug.gregor, cfe-commits Differential Revision: https://reviews.llvm.org/D44670 llvm-svn: 330338
* [OPENMP] Code cleanup and code improvements.Alexey Bataev2018-04-181-2/+2
| | | | llvm-svn: 330270
* Add Microsoft mangling for _Float16Erich Keane2018-04-171-0/+3
| | | | | | | | | | | | Enables _Float16 on Windows by creating a mangling mechanism in MicrosoftMangle. It accomplishes this by mangling as a structure type of __clang::_Float16, similar to how Complex works. Patch By: mibintc Differential Revision: https://reviews.llvm.org/D45738 llvm-svn: 330225
* Limit types of builtins that can be redeclared.Erich Keane2018-04-161-0/+4
| | | | | | | | | | | | | | | | | | As reported here: https://bugs.llvm.org/show_bug.cgi?id=37033 Any usage of a builtin function that uses a va_list by reference will cause an assertion when redeclaring it. After discussion in the review, it was concluded that the correct way of accomplishing this fix is to make attempts to redeclare certain builtins an error. Unfortunately, doing this limitation for all builtins is likely a breaking change, so this commit simply limits it to types with custom type checking and those that take a reference. Two tests needed to be updated to make this work. Differential Revision: https://reviews.llvm.org/D45383 llvm-svn: 330160
* Clean carriage returns from lib/ and include/. NFC.Malcolm Parsons2018-04-162-49/+49
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Clean carriage returns from lib/ and include/. NFC. (I have to make this change locally in order for `git diff` to show sane output after I edit a file, so I might as well ask for it to be committed. I don't have commit privs myself.) (Without this patch, `git rebase`ing any change involving SemaDeclCXX.cpp is a real nightmare. :( So while I have no right to ask for this to be committed, geez would it make my workflow easier if it were.) Here's the command I used to reformat things. (Requires bash and OSX/FreeBSD sed.) git grep -l $'\r' lib include | xargs sed -i -e $'s/\r//' find lib include -name '*-e' -delete Reviewers: malcolm.parsons Reviewed By: malcolm.parsons Subscribers: emaste, krytarowski, cfe-commits Differential Revision: https://reviews.llvm.org/D45591 Patch by Arthur O'Dwyer. llvm-svn: 330112
* [ODRHash] Support pointer and reference types.Richard Trieu2018-04-131-0/+18
| | | | | | | Recommit r328404 which was reverted in rL328404. r329869 fixed the issue that caused the revert. llvm-svn: 330074
* [ODRHash] Skip more types hashing TypedefTypeRichard Trieu2018-04-121-3/+13
| | | | | | To get the underlying type for TypedefType's, also skip ElaboratedType's. llvm-svn: 329869
* [AST] Fix some Clang-tidy modernize-use-auto and Include What You Use ↵Eugene Zelenko2018-04-104-137/+233
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 329766
* [ExprConstant] Use an AST node and a version number as a key to createAkira Hatanaka2018-04-102-75/+190
| | | | | | | | | | | | | | | an APValue and retrieve it from map Temporaries. The version number is needed when a single AST node is visited multiple times and is used to create APValues that are required to be distinct from each other (for example, MaterializeTemporaryExprs in default arguments and VarDecls in loops). rdar://problem/36505742 Differential Revision: https://reviews.llvm.org/D42776 llvm-svn: 329671
* [ObjC++] Never pass structs that transitively contain __weak fields inAkira Hatanaka2018-04-093-13/+9
| | | | | | | | | | | | | | | | | | | | registers. This patch fixes a bug in r328731 that caused structs transitively containing __weak fields to be passed in registers. The patch replaces the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates whether the struct or structs containing the struct are forced to be passed indirectly. This reapplies r329617. r329617 didn't specify the underlying type for enum ArgPassingKind, which caused regression tests to fail on a windows bot. rdar://problem/39194693 Differential Revision: https://reviews.llvm.org/D45384 llvm-svn: 329635
* [AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).Eugene Zelenko2018-04-093-270/+228
| | | | llvm-svn: 329630
* [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2018-04-091-407/+405
| | | | | | minor fixes (NFC). llvm-svn: 329628
* Revert "[ObjC++] Never pass structs that transitively contain __weak fields in"Akira Hatanaka2018-04-093-9/+13
| | | | | | | | This reverts commit r329617. It broke a windows bot. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16372/steps/test/logs/stdio llvm-svn: 329627
* [ObjC++] Never pass structs that transitively contain __weak fields inAkira Hatanaka2018-04-093-13/+9
| | | | | | | | | | | | | | registers. This patch fixes a bug in r328731 that caused structs transitively containing __weak fields to be passed in registers. The patch replaces the flag RecordDecl::CanPassInRegisters with a 2-bit enum that indicates whether the struct or structs containing the struct are forced to be passed indirectly. rdar://problem/39194693 llvm-svn: 329617
* [XRay][llvm+clang] Consolidate attribute list filesDean Michael Berris2018-04-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This change consolidates the always/never lists that may be provided to clang to externally control which functions should be XRay instrumented by imbuing attributes. The files follow the same format as defined in https://clang.llvm.org/docs/SanitizerSpecialCaseList.html for the sanitizer blacklist. We also deprecate the existing `-fxray-instrument-always=` and `-fxray-instrument-never=` flags, in favour of `-fxray-attr-list=`. This fixes http://llvm.org/PR34721. Reviewers: echristo, vlad.tsyrklevich, eugenis Reviewed By: vlad.tsyrklevich Subscribers: llvm-commits, cfe-commits Differential Revision: https://reviews.llvm.org/D45357 llvm-svn: 329543
* Fix typos in clangAlexander Kornienko2018-04-066-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standardRichard Smith2018-04-053-44/+181
| | | | | | | | | | | | | | | | | layout" rules. The new rules say that a standard-layout struct has its first non-static data member and all base classes at offset 0, and consider a class to not be standard-layout if that would result in multiple subobjects of a single type having the same address. We track "is C++11 standard-layout class" separately from "is standard-layout class" so that the ABIs that need this information can still use it. Differential Revision: https://reviews.llvm.org/D45176 llvm-svn: 329332
* [ASTImporter] Fix for importing unnamed structsAleksei Sidorin2018-04-052-3/+6
| | | | | | | | Patch by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D30876 llvm-svn: 329301
* Disable -fmerge-all-constants as default.Manoj Gupta2018-04-051-3/+0
| | | | | | | | | | | | | | | | | | | Summary: "-fmerge-all-constants" is a non-conforming optimization and should not be the default. It is also causing miscompiles when building Linux Kernel (https://lkml.org/lkml/2018/3/20/872). Fixes PR18538. Reviewers: rjmccall, rsmith, chandlerc Reviewed By: rsmith, chandlerc Subscribers: srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D45289 llvm-svn: 329300
* [AST] Don't track lambda captures when checking a potential constant expression.Erik Pilkington2018-04-051-6/+19
| | | | | | | | Fixes PR36054. Differential revision: https://reviews.llvm.org/D45194 llvm-svn: 329244
* Fix typo in ASTStructuralEquivalence.cpp for UnaryTransform types.Eric Fiselier2018-04-041-1/+1
| | | | | | | | | | | | | | Previously UnaryTransformType nodes were comparing the same node for structural equivalence. This was due to a typo where T1 was on both sides of the comparison. This patch corrects that typo. Unfortunately I couldn't find a way to test this change. It seems that currently UnaryTransform nodes are never actually checked for equivalence, only their canonical types are. None the less, this correction seemed appropriate. llvm-svn: 329151
OpenPOWER on IntegriCloud