summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-39/+34
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Added missing StandardConversionSequence initializationIsmail Pazarbasi2014-01-241-0/+1
| | | | | | | This is the second msan failure where UserDefinedConversion does not initialize its `Before` member as identity conversion. llvm-svn: 199997
* Initialize StandardConversionSequence correctlyIsmail Pazarbasi2014-01-241-1/+1
| | | | | | | | MSAN detected a path that leaves DeprecatedStringLiteralToCharPtr uninitialized. UserDefinedConversionSequence::First is a StandardConversionSequence that must be initialized with setAsIdentityConversion. llvm-svn: 199988
* Introduce and use Decl::getAsFunction() to simplify templated function checksAlp Toker2014-01-221-12/+3
| | | | | | | | | | | | | | Lift the getFunctionDecl() utility out of the parser into a general Decl::getAsFunction() and use it to simplify other parts of the implementation. Reduce isFunctionOrFunctionTemplate() to a simple type check that works the same was as the other is* functions and move unwrapping of shadowed decls to callers so it doesn't get run twice. Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer. There's no need to query when we already know the body can't be skipped. llvm-svn: 199794
* Simplify expression, made possible by r199702.Nick Lewycky2014-01-211-2/+2
| | | | llvm-svn: 199703
* Update FunctionTypeLoc and related names to match r199686Alp Toker2014-01-211-17/+17
| | | | llvm-svn: 199699
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-44/+45
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* Fix string-literal to char* conversion in overload resolution for C++11Ismail Pazarbasi2014-01-171-20/+50
| | | | | | | | String literal to char* conversion is deprecated in C++03, and is removed in C++11. We still accept this conversion in C++11 mode as an extension, if we find it in the best viable function. llvm-svn: 199513
* Rename language option MicrosoftMode to MSVCCompatAlp Toker2014-01-141-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
* Add a new attribute 'enable_if' which can be used to control overload ↵Nick Lewycky2014-01-111-13/+176
| | | | | | resolution based on the values of the function arguments at the call site. llvm-svn: 198996
* ObjectiveC. Further improvements of useFariborz Jahanian2013-12-161-1/+3
| | | | | | | | | | of objc_bridge_related attribute; eliminate unnecessary diagnostics which is issued elsewhere, fixit now produces a valid AST tree per convention. This results in some simplification in handling of this attribute as well. // rdar://15499111 llvm-svn: 197436
* Fix code typos spotted while working on type traitsAlp Toker2013-12-061-1/+1
| | | | llvm-svn: 196587
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* PR17533 and duplicates: don't compute the return type of an overloaded operatorRichard Smith2013-11-151-15/+15
| | | | | | | until after we've referenced the operator; otherwise, we might pick up a not-yet-deduced type. llvm-svn: 194775
* Rather than duplicating extension diagnostics to allow them to cause aRichard Smith2013-11-121-6/+2
| | | | | | | | | | substitution failure, allow a flag to be set on the Diagnostic object, to mark it as 'causes substitution failure'. Refactor Diagnostic.td and the tablegen to use an enum for SFINAE behavior rather than a bunch of flags. llvm-svn: 194444
* s/DebugPrint/dump/gDouglas Gregor2013-11-081-10/+10
| | | | llvm-svn: 194242
* Objective-C++ ARC: Improve the conversion to a const __unsafe_unretained ↵Douglas Gregor2013-11-081-2/+17
| | | | | | | | | | | | | reference. Under ARC++, a reference to a const Objective-C pointer is implicitly treated as __unsafe_unretained, and can be initialized with (e.g.) a __strong lvalue. Make sure this behavior does not break template argument deduction and (related) that partial ordering still prefers a 'T* const&' template over a 'T const&' template when this case kicks in. Fixes <rdar://problem/14467941>. llvm-svn: 194239
* Fix a bogus assert I introduced in r194224Douglas Gregor2013-11-081-1/+1
| | | | llvm-svn: 194237
* Re-instate contextual conversion to Objective-C pointers in message sends.Douglas Gregor2013-11-071-31/+91
| | | | | | | | | When performing an Objective-C message send to a value of class type, perform a contextual conversion to an Objective-C pointer type. We've had this for a long time, but it recently regressed. Fixes <rdar://problem/15234703>. llvm-svn: 194224
* Implement final resolution of DR1402: implicitly-declared move operators thatRichard Smith2013-11-041-1/+16
| | | | | | | | | | | would be deleted are still declared, but are ignored by overload resolution. Also, don't delete such members if a subobject has no corresponding move operation and a non-trivial copy. This causes us to implicitly declare move operations in more cases, but risks move-assigning virtual bases multiple times in some circumstances (a warning for that is to follow). llvm-svn: 193969
* Sema: Do not allow overloading between methods based on restrictDavid Majnemer2013-11-031-1/+6
| | | | | | | | | | | | | | | | If the sole distinction between two declarations is that one has a __restrict qualifier then we should not consider it to be an overload. Instead, we will consider it as an incompatible redeclaration which is similar to how MSVC, ICC and GCC would handle it. This fixes PR17786. N.B. We must not mangle in __restrict into method qualifiers becase we don't allow overloading between such declarations anymore. To do otherwise would be a violation of the Itanium ABI. llvm-svn: 193964
* Fix crash in cleanup attr handlingAlp Toker2013-10-201-0/+3
| | | | | | | | | | | ResolveSingleFunctionTemplateSpecialization() returns 0 and doesn't emit diags unless the expression has template-ids, so we must null check the result. Also add a better diag noting which overloads are causing the problem. Reviewed by Aaron Ballman. llvm-svn: 193055
* Sema: Cleanup redundant variable NumArgsToCheckBenjamin Kramer2013-10-051-4/+1
| | | | | | Patch by Daniel Marjamäki! llvm-svn: 192030
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-09-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - generic lambdas within template functions and nested within other generic lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware (Although I have gotten some useful feedback on my patches of the above and will be incorporating that as I submit those patches for commit) As an example of what compiles through this commit: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. This patch has been reviewed by Doug and Richard. Minor changes (non-functionality affecting) have been made since both of them formally looked at it, but the changes involve removal of supernumerary return type deduction changes (since they are now redundant, with richard having committed a recent patch to address return type deduction for C++11 lambdas using C++14 semantics). Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that SemaType.cpp::ConvertDeclSpecToType may use it to immediately generate a template-parameter-type when 'auto' is parsed in a generic lambda parameter context. (i.e we do NOT use AutoType deduced to a template parameter type - Richard seemed ok with this approach). We encode that this template type was generated from an auto by simply adding $auto to the name which can be used for better diagnostics if needed. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - various tests were added - but much more will be needed. There is obviously more work to be done, and both Richard (weakly) and Doug (strongly) have requested that LambdaExpr be removed form the CXXRecordDecl LambdaDefinitionaData in a future patch which is forthcoming. A greatful thanks to all reviewers including Eli Friedman, James Dennett, and especially the two gracious wizards (Richard Smith and Doug Gregor) who spent hours providing feedback (in person in Chicago and on the mailing lists). And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 191453
* Sema: Simplify code a bit, plug a potential leak.Benjamin Kramer2013-09-251-20/+12
| | | | | | No intended functionality change. llvm-svn: 191370
* Fix typo. Add missing whitespace. No functionality change.Nick Lewycky2013-09-221-2/+2
| | | | llvm-svn: 191169
* PR17295: Do not allow explicit conversion functions to be used in cases whereRichard Smith2013-09-211-0/+11
| | | | | | | | | | an additional conversion (other than a qualification conversion) would be required after the explicit conversion. Conversely, do allow explicit conversion functions to be used when initializing a temporary for a reference binding in direct-list-initialization. llvm-svn: 191150
* [-cxx-abi microsoft] Correctly identify Win32 entry pointsDavid Majnemer2013-09-161-0/+5
| | | | | | | | | | | | | | | | | | | Summary: This fixes several issues with the original implementation: - Win32 entry points cannot be in namespaces - A Win32 entry point cannot be a function template, diagnose if we it. - Win32 entry points cannot be overloaded. - Win32 entry points implicitly return, similar to main. Reviewers: rnk, rsmith, whunt, timurrrr Reviewed By: rnk CC: cfe-commits, nrieck Differential Revision: http://llvm-reviews.chandlerc.com/D1683 llvm-svn: 190818
* PR17075: When performing partial ordering of a member function against aRichard Smith2013-09-111-1/+2
| | | | | | | | | | | non-member function, the number of arguments in the two candidate calls will be different (the non-member call will have one extra argument). We used to get confused by this, and fail to compare the last argument when testing whether the member is better, resulting in us always thinking it is, even if the non-member is more specialized in the last argument. llvm-svn: 190470
* getMostSpecialized for function template sets is never used in the context of aRichard Smith2013-09-101-1/+1
| | | | | | | call; remove its 'number of explicit arguments' and 'what kind of call' parameters. llvm-svn: 190444
* Fix constructor-related typos.Benjamin Kramer2013-09-091-1/+1
| | | | | | Noticed by Roman Divacky. llvm-svn: 190311
* Remove error-prone 'list initialization' flag from an implicit conversionRichard Smith2013-09-061-22/+10
| | | | | | | sequence. All that matters here is whether we're doing the std::initializer_list special case thing. llvm-svn: 190213
* When creating an implicit conversion sequence for a reference of type T from anRichard Smith2013-09-061-5/+12
| | | | | | | | initializer list containing a single element of type T, be sure to mark the sequence as a list conversion sequence so that it is known to be worse than an implicit conversion sequence that initializes a std::initializer_list object. llvm-svn: 190115
* Improve error for assignment to incomplete class.Eli Friedman2013-08-281-0/+5
| | | | | | PR7681. llvm-svn: 189510
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-221-4/+0
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - nested lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware As an example of what compiles: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Augment AutoType's constructor (similar to how variadic template-type-parameters ala TemplateTypeParmDecl are implemented) to accept an IsParameterPack to encode a generic lambda parameter pack. - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that Sema::ActOnLambdaAutoParameter may use it to create the appropriate list of corresponding TemplateTypeParmDecl for each auto parameter identified within the generic lambda (also stored within the current LambdaScopeInfo). Additionally, a TemplateParameterList data-member was added to hold the invented TemplateParameterList AST node which will be much more useful once we teach TreeTransform how to transform generic lambdas. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - Teach Sema::ActOnStartOfLambdaDefinition to set the return type of a lambda without a trailing return type to 'auto' in C++1y mode, and teach the return type deduction machinery in SemaStmt.cpp to process either C++11 and C++14 lambda's correctly depending on the flag. - various tests were added - but much more will be needed. A greatful thanks to all reviewers including Eli Friedman, James Dennett and the ever illuminating Richard Smith. And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 188977
* Don't produce duplicate notes if we have deduction failure notes when resolvingRichard Smith2013-08-141-6/+16
| | | | | | the address of an overloaded function template. llvm-svn: 188334
* Fix for PR16570: when comparing two function pointers, discard qualifiers whenRichard Trieu2013-08-091-1/+2
| | | | | | | | | | comparing non-reference function parameters. The qualifiers don't matter for comparisons. This is a re-commit of r187769, which was accidentially reverted in r187770, with a simplification at the suggestion of Eli Friedman. llvm-svn: 188112
* Omit llvm:: before ArrayRef, as we have using llvm::ArrayRef in ↵Robert Wilhelm2013-08-091-5/+4
| | | | | | include/clang/Basic/LLVM.h. llvm-svn: 188089
* Fixing commit r187768: Moved diagnosis of forward declarations of variable ↵Larisse Voufo2013-08-061-11/+3
| | | | | | templates from Parser to Sema. llvm-svn: 187770
* Fix for PR16570: when comparing two function pointers, discard qualifiers whenRichard Trieu2013-08-061-3/+11
| | | | | | | comparing non-reference function parameters. The qualifiers don't matter for comparisons. llvm-svn: 187769
* Sema: Diagnose explicitly bound unresolved member expressions decaying into ↵David Majnemer2013-08-011-25/+42
| | | | | | | | | | | | | pointers to function type We would disallow the case where the overloaded member expression is coming from an address-of operator but we wouldn't issue any diagnostics when the overloaded member expression comes by way of a function to pointer decay cast. Clang's implementation of DR61 is now seemingly complete. llvm-svn: 187559
* Improve the diagnostic experience, including adding recovery, forKaelyn Uhrain2013-07-311-1/+8
| | | | | | changing '->' to '.' when there is no operator-> defined for a class. llvm-svn: 187504
* FIXME fix: improving diagnostics for template arguments deduction of class ↵Larisse Voufo2013-07-191-103/+257
| | | | | | | | templates and explicit specializations This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info. llvm-svn: 186730
* Revert "Use function overloading instead of template specialization for ↵Larisse Voufo2013-07-191-257/+103
| | | | | | | | diagnosis of bad template argument deductions." This reverts commit a730f548325756d050d4caaa28fcbffdae8dfe95. llvm-svn: 186729
* Use function overloading instead of template specialization for diagnosis of ↵Larisse Voufo2013-07-191-103/+257
| | | | | | bad template argument deductions. llvm-svn: 186727
* Move the "->" to "." fixit from r186128 into a separate note sinceKaelyn Uhrain2013-07-151-5/+3
| | | | | | | | recovery is not attempted with the fixit. Also move the associated test case from FixIt/fixit.cpp to SemaCXX/member-expr.cpp since the fixit is no longer automatically applied. llvm-svn: 186342
* Provide a fixit hint for changing '->' to '.' if there is no operator->Kaelyn Uhrain2013-07-111-4/+11
| | | | | | defined for a class. llvm-svn: 186128
* Make a couple of useful typo correction callbacks more widely available.Kaelyn Uhrain2013-07-081-62/+2
| | | | llvm-svn: 185880
* Put helper class in anonymous namespace.Craig Topper2013-07-011-0/+4
| | | | llvm-svn: 185305
OpenPOWER on IntegriCloud