summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix errored return value in CheckFunctionReturnType and add a fixit hintErich Keane2017-05-101-2/+3
| | | | | | | | | | | As discovered by ChenWJ and listed on cfe-dev, the error for Objective C return type ended up being wrong. This fixes that. Additionally, as a "while we're there", the other usages of this error and the usage of the FP above both use a FixItHint, so I'll add it here. Differential Revision: https://reviews.llvm.org/D32759 llvm-svn: 302720
* [Sema] Objective-C++ support for type trait __is_base_ofErik Pilkington2017-05-101-3/+17
| | | | | | | | rdar://24308607 Differential revision: https://reviews.llvm.org/D32891 llvm-svn: 302695
* [OpenCL] Handle OpenCL specific subelement typesEgor Churaev2017-05-101-1/+1
| | | | | | | | | | | | Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D32898 llvm-svn: 302633
* When we see a '<' operator, check whether it's a probable typo for a ↵Richard Smith2017-05-101-0/+79
| | | | | | | | | | | | | | | | | | | template-id. The heuristic that we use here is: * the left-hand side must be a simple identifier or a class member access * the right-hand side must be '<' followed by either a '>' or by a type-id that cannot be an expression (in particular, not followed by '(' or '{') * there is a '>' token matching the '<' token The second condition guarantees the expression would otherwise be ill-formed. If we're confident that the user intended the name before the '<' to be interpreted as a template, diagnose the fact that we didn't interpret it that way, rather than diagnosing that the template arguments are not valid expressions. llvm-svn: 302615
* When instantiating a friend function template, don't forget to inherit ↵Richard Smith2017-05-101-0/+13
| | | | | | default template arguments from other declarations. llvm-svn: 302603
* Don't mark a member as a member specialization until we know we're keeping ↵Richard Smith2017-05-092-51/+85
| | | | | | | | | | | | | | | | | | | | | | | | | the specialization. This improves our behavior in a few ways: * We now guarantee that if a member is marked as being a member specialization, there will actually be a member specialization declaration somewhere on its redeclaration chain. This fixes a crash in modules builds where we would try to check that there was a visible declaration of the member specialization and be surprised to not find any declaration of it at all. * We don't set the source location of the in-class declaration of the member specialization to the out-of-line declaration's location until we have actually finished merging them. This fixes some very silly looking diagnostics, where we'd point a "previous declaration is here" note at the same declaration we're complaining about. Ideally we wouldn't mess with the prior declaration's location at all, but too much code assumes that the first declaration of an entity is a reasonable thing to use as an indication of where it was declared, and that's not really true for a member specialization unless we fake it like this. llvm-svn: 302596
* [CodeCompletion] Complete platform names in @available expressionsAlex Lorenz2017-05-091-0/+17
| | | | | | rdar://32074504 llvm-svn: 302545
* Add support for pretty platform names to `@available`/Alex Lorenz2017-05-091-1/+3
| | | | | | | | | | | | | `__builtin_available` This commit allows us to use the macOS/iOS/tvOS/watchOS platform names in `@available`/`__builtin_available`. rdar://32067795 Differential Revision: https://reviews.llvm.org/D33000 llvm-svn: 302540
* Reland "Warn about unused static file scope function template declarations."Vassil Vassilev2017-05-092-10/+31
| | | | | | | This patch reinstates r299930, reverted in r299956, as a separate diagnostic option (-Wunused-template). llvm-svn: 302518
* Fix PR32638 : Make sure we switch Sema's CurContext to the substituted ↵Faisal Vali2017-05-091-0/+1
| | | | | | | | | | | | | | | | | | | FunctionDecl when instantiating the exception specification. This fixes the bug: https://bugs.llvm.org/show_bug.cgi?id=32638 int main() { [](auto x) noexcept(noexcept(x)) { } (0); } In the above code, prior to this patch, when substituting into the noexcept expression, i.e. transforming the DeclRefExpr that represents 'x' - clang attempts to capture 'x' because Sema's CurContext is still pointing to the pattern FunctionDecl (i.e. the templated-decl set in FinishTemplateArgumentDeduction) which does not match the substituted 'x's DeclContext, which leads to an attempt to capture and an assertion failure. We fix this by adjusting Sema's CurContext to point to the substituted FunctionDecl under which the noexcept specifier's argument should be transformed, and so the ParmVarDecl that 'x' refers to has the same declcontext and no capture is attempted. I briefly investigated whether the SwitchContext should occur right after VisitMethodDecl creates the new substituted FunctionDecl, instead of only during instantiating the exception specification - but seeing no other code that seemed to rely on that, I decided to leave it just for the duration of the exception specification instantiation. llvm-svn: 302507
* [Sema] Make typeof(OverloadedFunctionName) not a pointer.George Burgess IV2017-05-092-4/+5
| | | | | | | | | | | | | | | | We were sometimes doing a function->pointer conversion in Sema::CheckPlaceholderExpr, which isn't the job of CheckPlaceholderExpr. So, when we saw typeof(OverloadedFunctionName), where OverloadedFunctionName referenced a name with only one function that could have its address taken, we'd give back a function pointer type instead of a function type. This is incorrect. I kept the logic for doing the function pointer conversion in resolveAndFixAddressOfOnlyViableOverloadCandidate because it was more consistent with existing ResolveAndFix* methods. llvm-svn: 302506
* [Sema][ObjC] Clean up possible null dereference.Akira Hatanaka2017-05-091-2/+1
| | | | | | | | | | | | It appears that the code is actually dead since unbridged-cast placeholder types are created by calling CastOperation::complete and ImplicitCastExprs are never passed to it. Spotted by Vedant Kumar. rdar://problem/31542226 llvm-svn: 302503
* [Sema] Fix typos handling in an overloadable call.Anastasia Stulova2017-05-081-0/+3
| | | | | | | | | | | | | | | | In C typos in arguments in a call of an overloadable function lead to a failure of construction of CallExpr and following recovery does not handle created delayed typos. This causes an assertion fail in Sema::~Sema since Sema::DelayedTypos remains not empty. The patch fixes that behavior by handling a call with arguments having dependant types in the way that C++ does. Differential Revision: https://reviews.llvm.org/D31764 Patch by Dmitry Borisenkov! llvm-svn: 302435
* [OpenCL] Check that global samplers are constSven van Haastregt2017-05-081-6/+18
| | | | | | | | Patch by Simon Perretta. Differential Revision: https://reviews.llvm.org/D32856 llvm-svn: 302411
* Add support for building modules from preprocessed source.Richard Smith2017-05-051-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support this, an optional marker "#pragma clang module contents" is recognized in module map files, and the rest of the module map file from that point onwards is treated as the source of the module. Preprocessing a module map produces the input module followed by the marker and then the preprocessed contents of the module. Ignoring line markers, a preprocessed module might look like this: module A { header "a.h" } #pragma clang module contents #pragma clang module begin A // ... a.h ... #pragma clang module end The preprocessed output generates line markers, which are not accepted by the module map parser, so -x c++-module-map-cpp-output should be used to compile such outputs. A couple of major parts do not work yet: 1) The files that are listed in the module map must exist on disk, in order to build the on-disk header -> module lookup table in the PCM file. To fix this, we need the preprocessed output to track the file size and other stat information we might use to build the lookup table. 2) Declaration ownership semantics don't work properly yet, since mapping from a source location to a module relies on mapping from FileIDs to modules, which we can't do if module transitions can occur in the middle of a file. llvm-svn: 302309
* [ARM] Limit the diagnose when an ISR calls a regular functionWeiming Zhao2017-05-051-2/+4
| | | | | | | | | | | | | | | | Summary: When the function is compiled with soft-float or on CPU with no FPU, we don't need to diagnose for a call from an ISR to a regular function. Reviewers: jroelofs, eli.friedman Reviewed By: jroelofs Subscribers: aemerson, rengolin, javed.absar, cfe-commits Differential Revision: https://reviews.llvm.org/D32918 llvm-svn: 302274
* ANSIfy. No behavior change.Nico Weber2017-05-052-2/+2
| | | | llvm-svn: 302258
* Warn that the [] spelling of uuid(...) is deprecated.Nico Weber2017-05-051-0/+9
| | | | | | https://reviews.llvm.org/D32879 llvm-svn: 302255
* Add a fix-it for -Wunguarded-availabilityAlex Lorenz2017-05-051-3/+140
| | | | | | | | | | | | | This patch adds a fix-it for the -Wunguarded-availability warning. This fix-it is similar to the Swift one: it suggests that you wrap the statement in an `if (@available)` check. The produced fixits are indented (just like the Swift ones) to make them look nice in Xcode's fix-it preview. rdar://31680358 Differential Revision: https://reviews.llvm.org/D32424 llvm-svn: 302253
* [ObjC] Don't disallow vector parameters/return values in methodsAlex Lorenz2017-05-051-3/+1
| | | | | | | | | | | whose introduced version is lower than the allowed version. We should just rely on the target version as this introduced version can lead to false positives (e.g. deprecated declarations). rdar://31964333 llvm-svn: 302250
* Introduce Wzero-as-null-pointer-constant.Nico Weber2017-05-051-0/+14
| | | | | | | | | Add an opt-in warning that fires when 0 is used as a null pointer. gcc has this warning, and there's some demand for it. https://reviews.llvm.org/D32914 llvm-svn: 302247
* Fix bugs checking va_start in lambdas and erroneous contextsReid Kleckner2017-05-041-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: First, getCurFunction looks through blocks and lambdas, which is wrong. Inside a lambda, va_start should refer to the lambda call operator prototype. This fixes PR32737. Second, we shouldn't use any of the getCur* methods, because they look through contexts that we don't want to look through (EnumDecl, CapturedStmtDecl). We can use CurContext directly as the calling context. Finally, this code assumed that CallExprs would never appear outside of code contexts (block, function, obj-c method), which is wrong. Struct member initializers are an easy way to create and parse exprs in a non-code context. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D32761 llvm-svn: 302188
* [OpenCL] Add intel_reqd_sub_group_size attribute supportXiuli Pan2017-05-041-0/+28
| | | | | | | | | | | | | | | | Summary: Add intel_reqd_sub_group_size attribute support as intel extension cl_intel_required_subgroup_size from https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_required_subgroup_size.txt Reviewers: Anastasia, bader, hfinkel, pxli168 Reviewed By: Anastasia, bader, pxli168 Subscribers: cfe-commits, yaxunl Differential Revision: https://reviews.llvm.org/D30805 llvm-svn: 302125
* Reusing an existing attribute diagnosticOren Ben Simhon2017-05-031-1/+2
| | | | | | | | | In a previous patch, a new generic error diagnostic for inconsistent attributes was added. In this commit I reuse this diagnostic for ns_returns_retained attribute check. Differential Revision: https://reviews.llvm.org/D32697 llvm-svn: 302024
* Fix PR32831 (Try Again): 'this' capture while instantiating generic lambda ↵Faisal Vali2017-05-021-14/+39
| | | | | | | | | | | | | | | | | | | | | | | call operator specialization When computing the appropriate cv-qualifiers for the 'this' capture, we have to examine each enclosing lambda - but when using the FunctionScopeInfo stack we have to ensure that the lambda below (outer) is the decl-context of the closure-class of the current lambda. https://bugs.llvm.org/show_bug.cgi?id=32831 This patch was initially committed here: https://reviews.llvm.org/rL301735 Then reverted here: https://reviews.llvm.org/rL301916 The issue with the original patch was a failure to check that the closure type has been created within the LambdaScopeInfo before querying its DeclContext - instead of just assuming it has (silly!). A reduced example such as this highlights the problem: struct X { int data; auto foo() { return [] { return [] -> decltype(data) { return 0; }; }; } }; When 'data' within decltype(data) tries to determine the type of 'this', none of the LambdaScopeInfo's have their closure types created at that point. llvm-svn: 301972
* [Sema] Update function doc; NFCGeorge Burgess IV2017-05-021-1/+1
| | | | llvm-svn: 301970
* Simplify some va_start checking logicReid Kleckner2017-05-021-85/+82
| | | | | | | | | | | | | | | Combine the logic doing the ms_abi/sysv_abi checks into one function so that each check and its logical opposite are near each other. Now we don't need two Sema entry points for MS va_start and regular va_start. Refactor the code that checks if the va_start caller is a function, block, or obj-c method. We do this in three places, and they are all buggy for variadic lambdas (PR32737). After this change, I have one place to apply the functional fix. NFC llvm-svn: 301968
* Revert r301735 (and subsequent r301786).Daniel Jasper2017-05-021-37/+13
| | | | | | | | | | | | | | | It leads to clang crashing, e.g. on this short code fragment (added to test/SemaCXX/warn-thread-safety-parsing.cpp): class SomeClass { public: void foo() { auto l = [this] { auto l = [] EXCLUSIVE_LOCKS_REQUIRED(mu_) {}; }; } Mutex mu_; }; llvm-svn: 301916
* Remove Sema::CheckForIntOverflow, and instead check all full-expressions.Nick Lewycky2017-04-291-23/+1
| | | | | | | | CheckForIntOverflow used to implement a whitelist of top-level expressions to send to the constant expression evaluator, which handled many more expressions than the CheckForIntOverflow whitelist did. llvm-svn: 301742
* Fix PR32831: 'this capture while instantiating generic lambda call operator ↵Faisal Vali2017-04-291-13/+37
| | | | | | | | | | specialization When computing the appropriate cv-qualifiers for the 'this' capture, we have to examine each enclosing lambda - but when using the FunctionScopeInfo stack we have to ensure that the lambda below (outer) is the decl-context of the closure-class of the current lambda. https://bugs.llvm.org/show_bug.cgi?id=32831 llvm-svn: 301735
* ObjCBoxedExpr can't be evaluated by the constant expression evaluator.Nick Lewycky2017-04-292-1/+3
| | | | | | | | A boxed expression evaluates its subexpr and then calls an objc method to transform it into another value with pointer type. The objc method can never be constexpr and therefore this expression can never be evaluated. Fixes a miscompile boxing expressions with side-effects. Also make ObjCBoxedExpr handling a normal part of the expression evaluator instead of being the only case besides full-expression where we check for integer overflow. llvm-svn: 301721
* [Sema] Avoid an invalid redefinition error that was presented forAlex Lorenz2017-04-281-0/+11
| | | | | | | | | | of a function whose previous definition was typo-corrected rdar://28550928 Differential Revision: https://reviews.llvm.org/D25113 llvm-svn: 301643
* Use a consistent style. NFCGeorge Burgess IV2017-04-271-4/+3
| | | | llvm-svn: 301601
* [OPENMP] Add a check for iterator not reached the end of stack, NFC.Alexey Bataev2017-04-271-2/+2
| | | | | | | Add an extra check for the iterator during checks of the data-sharing attributes. llvm-svn: 301549
* [OPENMP] Improve performance of the hasDSA() function, NFC.Alexey Bataev2017-04-271-10/+5
| | | | | | | Remove some unneccesary code from the function after the fix for ASAN buildbots. llvm-svn: 301547
* Fix asan failures on OpenMP.Haojian Wu2017-04-271-0/+2
| | | | llvm-svn: 301536
* [X86] Support of no_caller_saved_registers attributeOren Ben Simhon2017-04-273-7/+64
| | | | | | | | | Implements the Clang part for no_caller_saved_registers attribute as appears here: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be. Differential Revision: https://reviews.llvm.org/D31871 llvm-svn: 301535
* [ObjC] Disallow vector parameters and return values in Objective-C methodsAlex Lorenz2017-04-271-0/+49
| | | | | | | | | | | | | | | | | for iOS < 9 and OS X < 10.11 X86 targets This commit adds a new error that disallows methods that have parameters/return values with a vector type for some older X86 targets. This diagnostic is needed because objc_msgSend doesn't support SIMD vector registers/return values on X86 in iOS < 9 and OS X < 10.11. Note that we don't necessarily know if the vector argument/return value will use a SIMD register, so instead we chose to be conservative and prohibit all vector types. rdar://21662309 Differential Revision: https://reviews.llvm.org/D28670 llvm-svn: 301532
* Fix comment. NFCGeorge Burgess IV2017-04-261-2/+1
| | | | llvm-svn: 301486
* [Modules] Fix a crash-on-invalid with overloaded functionsBruno Cardoso Lopes2017-04-261-0/+4
| | | | | | | | | | Do not add an overload if the function doesn't have a prototype; this can happen if, for instance, a misplaced/malformed call site is considered like a declaration for recovery purposes. rdar://problem/31306325 llvm-svn: 301453
* [Sema] Avoid using a null type pointer (fixes PR32750)Vedant Kumar2017-04-261-1/+1
| | | | | | | | | | isMicrosoftMissingTypename() uses a Type pointer without first checking that it's non-null. PR32750 reports a case where the pointer is in fact null. This patch adds in a defensive check and a regression test. Differential Revision: https://reviews.llvm.org/D32519 llvm-svn: 301420
* [OPENMP] Fix handling of OpenMP code during template instantiation.Alexey Bataev2017-04-262-95/+181
| | | | | | | | | If some function template is instantiated during handling of OpenMP code, currently it may cause crash of compiler because of trying of capturing variables in non-capturing function scopes. Patch fixes this bug. llvm-svn: 301416
* [OPENMP] Move handling of threadprivate vars from the stack, NFC.Alexey Bataev2017-04-261-69/+75
| | | | | | | Threadprivate variables do no need to be handled in the Stack of all directives, moving it out for better performance and memory. llvm-svn: 301410
* -Wunguarded-availability should support if (@available) checks in top-levelAlex Lorenz2017-04-262-3/+13
| | | | | | | | | | | | | blocks and lambdas Prior to this commit Clang emitted the old "partial availability" warning for expressions that referred to declarations that were not yet introduced in blocks and lambdas that were not in a function/method. This commit ensures that top-level blocks and lambdas use the new unguarded availability checks. rdar://31835952 llvm-svn: 301409
* [modules ts] Diagnose 'export' declarations outside of a module interface.Richard Smith2017-04-241-0/+6
| | | | llvm-svn: 301271
* P0629R0: Switch to latest proposal for distinguishing module interface from ↵Richard Smith2017-04-211-16/+27
| | | | | | | | | | | | implementation. This switches from the prototype syntax in P0273R0 ('module' and 'module implementation') to the consensus syntax 'export module' and 'module'. In passing, drop the "module declaration must be first" enforcement, since EWG seems to have changed its mind on that. llvm-svn: 301056
* [ms] Give -Wmicrosoft-enum-forward-reference a chance to fire in clang-cl, ↵Nico Weber2017-04-211-1/+2
| | | | | | | | | | | | | | | | | | PR32736 clang-cl sets MicrosoftCompat. In that mode, we always give enums a fixed underlying type, and for enums with fixed underlying type we never enter the block that tries to emit ext_ms_forward_ref_enum. Fix this by requiring an explicit underlying type when we're skipping this diagnostic. We had a test for this warning, but it only ran in C++98 mode. clang-cl always enables -std=c++14, so MicrosoftCompatibiliy-cxx98.cpp is a fairly useless test. Fold it into MicrosoftCompatibility.cpp -- that way, the test checks if -Wmicrosoft-enum-forward-reference can fire in clang-cl builds. https://reviews.llvm.org/D32369 llvm-svn: 301032
* [OpenCL] Fix semantic check of ndrange_t for device_side_enqueue.Anastasia Stulova2017-04-211-1/+1
| | | | | | | | | | | Check unqualified type for ndrange argument in device_side_enqueue so device_side_enqueue accept const and volatile qualified ndranges. Differential Revision: https://reviews.llvm.org/D31458 Patch by Dmitry Borisenkov! llvm-svn: 300988
* [modules] Properly look up the owning module for an instantiation of a ↵Richard Smith2017-04-211-11/+4
| | | | | | | | | | | | | | | merged template. When looking for the template instantiation pattern of a templated entity, consistently select the definition of the pattern if there is one. This means we'll pick the same owning module when we start instantiating a template that we'll later pick when determining which modules are visible during that instantiation. This reinstates r300650, reverted in r300659, with a fix for a regression reported by Chandler after commit. llvm-svn: 300938
* Sema: protect against ObjC++ typo-correction failureSaleem Abdulrasool2017-04-201-0/+3
| | | | | | | | | ObjC++ has two different types of "pointer" types (ObjCClassPointerType and PointerType). Both can be indirected through. However, the former is not a member expression. Ensure that we do not try to rebuild the MRE in that case. llvm-svn: 300909
OpenPOWER on IntegriCloud