summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-137-23/+33
| | | | | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Note: This recommits the previously reverted patch, but now it is commited together with a fix for lldb. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 349019
* [AST] Store "UsesADL" information in CallExpr.Eric Fiselier2018-12-123-8/+18
| | | | | | | | | | | | | | | | | | | | | Summary: Currently the Clang AST doesn't store information about how the callee of a CallExpr was found. Specifically if it was found using ADL. However, this information is invaluable to tooling. Consider a tool which renames usages of a function. If the originally CallExpr was formed using ADL, then the tooling may need to additionally qualify the replacement. Without information about how the callee was found, the tooling is left scratching it's head. Additionally, we want to be able to match ADL calls as quickly as possible, which means avoiding computing the answer on the fly. This patch changes `CallExpr` to store whether it's callee was found using ADL. It does not change the size of any AST nodes. Reviewers: fowles, rsmith, klimek, shafik Reviewed By: rsmith Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits Differential Revision: https://reviews.llvm.org/D55534 llvm-svn: 348977
* [ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element ↵Hubert Tong2018-12-121-22/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | types Summary: `memchr` and `memcmp` operate upon the character units of the object representation; that is, the `size_t` parameter expresses the number of character units. The constant folding implementation is updated in this patch to account for multibyte element types in the arrays passed to `memchr`/`memcmp` and, in the case of `memcmp`, to account for the possibility that the arrays may have differing element types (even when they are byte-sized). Actual inspection of the object representation is not implemented. Comparisons are done only between elements with the same object size; that is, `memchr` will fail when inspecting at least one character unit of a multibyte element. The integer types are assumed to have two's complement representation with 0 for `false`, 1 for `true`, and no padding bits. `memcmp` on multibyte elements will only be able to fold in cases where enough elements are equal for the answer to be 0. Various tests are added to guard against incorrect folding for cases that miscompile on some system or other prior to this patch. At the same time, the unsigned 32-bit `wchar_t` testing in `test/SemaCXX/constexpr-string.cpp` is restored. Reviewers: rsmith, aaron.ballman, hfinkel Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55510 llvm-svn: 348938
* Revert "[OpenCL] Add generic AS to 'this' pointer"Mikael Nilsson2018-12-127-33/+23
| | | | | | Reverting because the patch broke lldb. llvm-svn: 348931
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-127-23/+33
| | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 348927
* [ASTImporter] Remove import of definition from GetAlreadyImportedOrNullGabor Marton2018-12-121-10/+8
| | | | | | | | | | | | Summary: a_sidorin Reviewers: a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53755 llvm-svn: 348923
* Replace Const-Member checking with non-recursive version.Erich Keane2018-12-111-7/+16
| | | | | | | | | | | | | | As reported in PR39946, these two implementations cause stack overflows to occur when a type recursively contains itself. While this only happens when an incomplete version of itself is used by membership (and thus an otherwise invalid program), the crashes might be surprising. The solution here is to replace the recursive implementation with one that uses a std::vector as a queue. Old values are kept around to prevent re-checking already checked types. Change-Id: I582bb27147104763d7daefcfee39d91f408b9fa8 llvm-svn: 348899
* Revert "Change InitListExpr dump to label and pointer"Stephen Kelly2018-12-101-5/+4
| | | | | | This reverts commit r348794. llvm-svn: 348799
* Fix nitsStephen Kelly2018-12-101-8/+7
| | | | llvm-svn: 348798
* Re-order content of template parameter dumpsStephen Kelly2018-12-101-17/+26
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55393 llvm-svn: 348797
* Re-order content in OMPDeclareReductionDecl dumpStephen Kelly2018-12-101-3/+7
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55395 llvm-svn: 348795
* Change InitListExpr dump to label and pointerStephen Kelly2018-12-101-4/+5
| | | | | | | | | | | | Summary: Don't add a child just for the label. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55495 llvm-svn: 348794
* [constexpr][c++2a] Try-catch blocks in constexpr functionsBruno Cardoso Lopes2018-12-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | Implement support for try-catch blocks in constexpr functions, as proposed in http://wg21.link/P1002 and voted in San Diego for c++20. The idea is that we can still never throw inside constexpr, so the catch block is never entered. A try-catch block like this: try { f(); } catch (...) { } is then morally equivalent to just { f(); } Same idea should apply for function/constructor try blocks. rdar://problem/45530773 Differential Revision: https://reviews.llvm.org/D55097 llvm-svn: 348789
* Misc typos fixes in ./lib folderRaphael Isemann2018-12-105-7/+7
| | | | | | | | | | | | | | Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned` Reviewers: teemperor Reviewed By: teemperor Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D55475 llvm-svn: 348755
* NFC: Rename TemplateDecl dump utilitiesStephen Kelly2018-12-091-18/+17
| | | | | | | | | | There is a clang::TemplateDecl AST type, so a method called VisitTemplateDecl looks like it should 'override' the method from the base visitor, but it does not because of the extra parameters it takes. In reality, these methods are utilities, so name them like utilities. llvm-svn: 348720
* NFC: Move dump of individual comment nodes to NodeDumperStephen Kelly2018-12-092-154/+148
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55190 llvm-svn: 348719
* Revert "Introduce optional labels to dumpStmt"Stephen Kelly2018-12-091-15/+6
| | | | | | This reverts commit 933402caa09963792058198578522a95f013c69c. llvm-svn: 348718
* Introduce optional labels to dumpStmtStephen Kelly2018-12-091-6/+15
| | | | | | | | If the label is present, it is added as a child, with the statement a child of the label. This preserves behavior of the InitListExpr dump output. llvm-svn: 348717
* Inline hasNodes into only callerStephen Kelly2018-12-091-13/+8
| | | | | | It is easier to refactor with fewer utility methods. llvm-svn: 348716
* Inline dumpFullComment into callersStephen Kelly2018-12-091-10/+7
| | | | | | | It causes confusion over whether it or dumpComment is the more important. It is easier to refactor with fewer utility methods. llvm-svn: 348715
* Re-order content from InitListExprStephen Kelly2018-12-091-4/+4
| | | | | | | | | | | | | | Summary: This causes no change in the output of ast-dump-stmt.cpp due to the way child nodes are printed with a delay. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55398 llvm-svn: 348714
* Revert "Multiversioning- Ensure all MV functions are emitted."Erich Keane2018-12-071-4/+0
| | | | | | | | | This reverts commit 65df29f9318ac13a633c0ce13b2b0bccf06e79ca. AS suggested by @rsmith here: https://reviews.llvm.org/rL345839 I'm reverting this and solving the initial problem in a different way. llvm-svn: 348595
* NFC: Move VisitExpr code to dumpStmtStephen Kelly2018-12-061-89/+38
| | | | | | | | | | | | | | | | Summary: The call is duplicated in the handlers of all Expr subclasses. This change makes it easy to split statement handling out to TextNodeDumper. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55339 llvm-svn: 348546
* NFC: Move VisitStmt code to dumpStmtStephen Kelly2018-12-061-23/+6
| | | | | | | | | | | | Summary: This call is duplicated in Visits of all direct subclasses of Stmt. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55338 llvm-svn: 348545
* [Sema/Attribute] Check for noderef attributeLeonard Chan2018-12-061-0/+3
| | | | | | | | | | This patch adds the noderef attribute in clang and checks for dereferences of types that have this attribute. This attribute is currently used by sparse and would like to be ported to clang. Differential Revision: https://reviews.llvm.org/D49511 llvm-svn: 348442
* NFC: Extract TextNodeDumper classStephen Kelly2018-12-053-253/+261
| | | | | | | | | | | | | | | Summary: Start by moving some utilities to it. It will eventually house dumping of individual nodes (after indentation etc has already been accounted for). Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55189 llvm-svn: 348412
* NFC: Extract TextTreeStructure classStephen Kelly2018-12-051-145/+6
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55188 llvm-svn: 348410
* NFC: Inline handling of DependentSizedArrayTypeStephen Kelly2018-12-051-1/+7
| | | | | | | | | | | | | | | | Summary: Re-order handling of getElementType and getBracketsRange. It is necessary to perform all printing before any traversal to child nodes. This causes no change in the output of ast-dump-array.cpp due to the way child nodes are printed with a delay. This new order of the code is also the order that produces the expected output anyway. Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55257 llvm-svn: 348409
* Honor -fdebug-prefix-map when creating function names for the debug info.Adrian Prantl2018-12-051-3/+7
| | | | | | | | | | | | | This adds a callback to PrintingPolicy to allow CGDebugInfo to remap file paths according to -fdebug-prefix-map. Otherwise the debug info (particularly function names for C++ lambdas) may contain paths that should have been remapped in the debug info. <rdar://problem/46128056> Differential Revision: https://reviews.llvm.org/D55137 llvm-svn: 348397
* Revert: Honor -fdebug-prefix-map when creating function names for the debug ↵Renato Golin2018-12-051-7/+3
| | | | | | | | | info. This commit reverts r348060 and r348062 due to it breaking the AArch64 Full buildbot: https://bugs.llvm.org/show_bug.cgi?id=39892 llvm-svn: 348364
* [Sema] Remove some conditions of a failing assertErik Pilkington2018-12-051-2/+0
| | | | | | | | | | We should have been checking that this state is consistent, but its possible for it to be filled later, so it isn't really sound to check it here anyways. Fixes llvm.org/PR39742 llvm-svn: 348325
* [AST] Assert that no type class is polymorphicBruno Ricci2018-12-041-0/+8
| | | | | | | | | | | Add a static_assert checking that no type class is polymorphic. People should use LLVM style RTTI instead. Differential Revision: https://reviews.llvm.org/D55225 Reviewed By: aaron.ballman llvm-svn: 348281
* [AST] Assert that no statement/expression class is polymorphicBruno Ricci2018-12-041-0/+8
| | | | | | | | | | | Add a static_assert checking that no statement/expression class is polymorphic. People should use LLVM style RTTI instead. Differential Revision: https://reviews.llvm.org/D55222 Reviewed By: aaron.ballman llvm-svn: 348278
* [AST][NFC] Make ArrayTypeTraitExpr non polymorphicBruno Ricci2018-12-041-2/+0
| | | | | | | | | | | ArrayTypeTraitExpr is the only expression class which is polymorphic. As far as I can tell this is completely pointless. Differential Revision: https://reviews.llvm.org/D55221 Reviewed By: aaron.ballman llvm-svn: 348276
* [WIP][Sema] Improve static_assert diagnostics for type traits.Clement Courbet2018-12-041-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In our codebase, `static_assert(std::some_type_trait<Ts...>::value, "msg")` (where `some_type_trait` is an std type_trait and `Ts...` is the appropriate template parameters) account for 11.2% of the `static_assert`s. In these cases, the `Ts` are typically not spelled out explicitly, e.g. `static_assert(std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value, "message");` The diagnostic when the assert fails is typically not very useful, e.g. `static_assert failed due to requirement 'std::is_same<SomeT::TypeT, typename SomeDependentT::value_type>::value' "message"` This change makes the diagnostic spell out the types explicitly , e.g. `static_assert failed due to requirement 'std::is_same<int, float>::value' "message"` See tests for more examples. After this is submitted, I intend to handle `static_assert(!std::some_type_trait<Ts...>::value, "msg")`, which is another 6.6% of static_asserts. Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54903 llvm-svn: 348239
* [AST] [analyzer] NFC: Reuse code in stable ID dumping methods.Artem Dergachev2018-12-033-13/+4
| | | | | | | | Use the new fancy method introduced in r348197 to simplify some code. Differential Revision: https://reviews.llvm.org/D54488 llvm-svn: 348199
* [AST] Generate unique identifiers for CXXCtorInitializer objects.Artem Dergachev2018-12-031-0/+8
| | | | | | | | | This continues the work started in r342309 and r342315 to provide identifiers to AST objects that are shorter and easier to read and remember than pointers. Differential Revision: https://reviews.llvm.org/D54457 llvm-svn: 348198
* NFC: Simplify dumpStmt child handlingStephen Kelly2018-12-031-8/+3
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55068 llvm-svn: 348189
* [AST][Sema] Remove CallExpr::setNumArgsBruno Ricci2018-12-031-48/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CallExpr::setNumArgs is the only thing that prevents storing the arguments in a trailing array. There is only 3 places in Sema where setNumArgs is called. D54900 dealt with one of them. This patch remove the other two calls to setNumArgs in ConvertArgumentsForCall. To do this we do the following changes: 1.) Replace the first call to setNumArgs by an assertion since we are moving the responsability to allocate enough space for the arguments from Sema::ConvertArgumentsForCall to its callers (which are Sema::BuildCallToMemberFunction, and Sema::BuildResolvedCallExpr). 2.) Add a new member function CallExpr::shrinkNumArgs, which can only be used to drop arguments and then replace the second call to setNumArgs by shrinkNumArgs. 3.) Add a new defaulted parameter MinNumArgs to CallExpr and its derived classes which specifies a minimum number of argument slots to allocate. The actual number of arguments slots allocated will be max(number of args, MinNumArgs) with the extra args nulled. Note that after the creation of the call expression all of the arguments will be non-null. It is just during the creation of the call expression that some of the last arguments can be temporarily null, until filled by default arguments. 4.) Update Sema::BuildCallToMemberFunction by passing the number of parameters in the function prototype to the constructor of CXXMemberCallExpr. Here the change is pretty straightforward. 5.) Update Sema::BuildResolvedCallExpr. Here the change is more complicated since the type-checking for the function type was done after the creation of the call expression. We need to move this before the creation of the call expression, and then pass the number of parameters in the function prototype (if any) to the constructor of the call expression. 6.) Update the deserialization of CallExpr and its derived classes. Differential Revision: https://reviews.llvm.org/D54902 Reviewed By: aaron.ballman llvm-svn: 348145
* [AST] Fix an uninitialized bug in the bits of FunctionDeclBruno Ricci2018-12-031-21/+23
| | | | | | | FunctionDeclBits.IsCopyDeductionCandidate was not initialized. This caused a warning with valgrind. llvm-svn: 348131
* Replace FullComment member being visited with parameterStephen Kelly2018-12-021-37/+49
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55070 llvm-svn: 348101
* Remove unecessary methodsStephen Kelly2018-12-021-10/+0
| | | | | | The base class calls VisitExpr llvm-svn: 348099
* OpenCL: Improve vector printf warningsMatt Arsenault2018-12-013-19/+77
| | | | | | | | | | | | The vector modifier is considered separate, so don't treat it as a conversion specifier. This is still not warning on some cases, like using a type that isn't a valid vector element. Fixes bug 39652 llvm-svn: 348084
* Specify constant context in constant emitterBill Wendling2018-12-011-0/+1
| | | | | | | The constant emitter may need to evaluate the expression in a constant context. For exasmple, global initializer lists. llvm-svn: 348070
* Honor -fdebug-prefix-map when creating function names for the debug info.Adrian Prantl2018-12-011-3/+7
| | | | | | | | | | | | | This adds a callback to PrintingPolicy to allow CGDebugInfo to remap file paths according to -fdebug-prefix-map. Otherwise the debug info (particularly function names for C++ lambdas) may contain paths that should have been remapped in the debug info. <rdar://problem/46128056> Differential Revision: https://reviews.llvm.org/D55137 llvm-svn: 348060
* Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures.""Fangrui Song2018-11-303-54/+117
| | | | | | | | | It seems the two failing tests can be simply fixed after r348037 Fix 3 cases in Analysis/builtin-functions.cpp Delete the bad CodeGen/builtin-constant-p.c for now llvm-svn: 348053
* Revert r347417 "Re-Reinstate 347294 with a fix for the failures."Fangrui Song2018-11-303-117/+54
| | | | | | | | | | Kept the "indirect_builtin_constant_p" test case in test/SemaCXX/constant-expression-cxx1y.cpp while we are investigating why the following snippet fails: extern char extern_var; struct { int a; } a = {__builtin_constant_p(extern_var)}; llvm-svn: 348039
* [ExprConstant] Try fixing __builtin_constant_p after D54355 (rC347417)Fangrui Song2018-11-301-1/+0
| | | | | | | | | | | Summary: Reinstate the original behavior (Success(false, E)) before D54355 when this branch is taken. This fixes spurious error of the following snippet: extern char extern_var; struct { int a; } a = {__builtin_constant_p(extern_var)}; llvm-svn: 348037
* Revert "NFC: Fix case of CommentVisitor::Visit methods"Stephen Kelly2018-11-291-21/+21
| | | | | | This reverts commit 0859c80137ac5fb3c86e7802cb8c5ef56f921cce. llvm-svn: 347905
* NFC: Fix case of CommentVisitor::Visit methodsStephen Kelly2018-11-291-21/+21
| | | | | | | This difference is very visible because it is used with other Visitor classes together. llvm-svn: 347901
OpenPOWER on IntegriCloud