summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-49/+37
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-36/+36
| | | | | | takeAs to getAs. llvm-svn: 209800
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-96/+100
| | | | llvm-svn: 209613
* Add hasSameType overload to ASTContext for Type pointers. Switch a typeRichard Trieu2014-05-221-2/+1
| | | | | | comparison check to use this instead of calling Type::getCanonicalTypeInternal llvm-svn: 209378
* Fix diagnostic message for member function pointer mismatches where one of theRichard Trieu2014-05-201-1/+2
| | | | | | classes is a template argument. llvm-svn: 209190
* More fixes for isBetterOverloadCandidate not being a strict weak ordering. TheRichard Smith2014-05-171-19/+8
| | | | | | bug was obvious from inspection, figuring out a way to test it was... less so. llvm-svn: 209060
* Switch to a more efficient expression of this check.Richard Smith2014-05-171-20/+24
| | | | llvm-svn: 209055
* Correct incoherent function versus function template partial ordering for ↵Richard Smith2014-05-171-24/+30
| | | | | | conversion operators (the comparison could claim that two conversion operators are both better than each other). Actually implement DR495, rather than passing its test by chance because the declarations happened to be in the "lucky" order. llvm-svn: 209054
* Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.Benjamin Kramer2014-05-101-0/+1
| | | | | | | Required pulling LambdaExpr::Capture into its own header. No functionality change. llvm-svn: 208470
* Try harder to ensure a strict weak ordering of overload candidates thatKaelyn Takata2014-05-071-6/+11
| | | | | | have arity mismatches. llvm-svn: 208146
* Fix crash when one overload candidate is a template instead of a function. ↵Nick Lewycky2014-05-061-0/+1
| | | | | | | | | | Patch by Kaelyn Takata. Testcase coming out of creduce will land in a separate commit shortly. Also, it appears that this callback is used even in a SFINAE context where the results are never displayed. llvm-svn: 208062
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-2/+1
| | | | llvm-svn: 207896
* Use std::abs(int) portably.David Blaikie2014-05-011-2/+3
| | | | | | Code review feedback from Reid Kleckner on r207806. llvm-svn: 207811
* Fix some -Wabsolute-value warnings introduced in r207796.David Blaikie2014-05-011-2/+2
| | | | llvm-svn: 207806
* When sorting overload candidates, sort arity mismatches in ascendingKaelyn Takata2014-05-011-3/+16
| | | | | | | | order by the number of missing or extra parameters. This is useful if there are more than a few overload candidates with arity mismatches, particularly in the presence of -fshow-overloads=best. llvm-svn: 207796
* Implement [over.match.oper]p3 properly, by filtering the non-candidates outRichard Smith2014-04-171-22/+78
| | | | | | | when building the candidate set, rather than trying to contort name lookup into handling this. llvm-svn: 206436
* Try harder about not suggesting methods as corrections when theyKaelyn Takata2014-04-041-1/+2
| | | | | | | | obviously won't work. Specifically, don't suggest methods (static or not) from unrelated classes when the expression is a method call through a specific object. llvm-svn: 205653
* Add defensive check that argument may be null in call to ↵Ted Kremenek2014-04-011-1/+1
| | | | | | | | | | | compareConversionFunctions() on incorrect code. I'm looking into getting a reduced test case, but it's not immediately available. Fixes <rdar://problem/16344806> llvm-svn: 205285
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-1/+1
| | | | | | class. llvm-svn: 203640
* [C++11] Remove the remaining uses of OwningPtr.Ahmed Charles2014-03-091-1/+1
| | | | | | Replace OwningArrayPtr with std::unique_ptr<T[]>. llvm-svn: 203388
* [C++11] Replacing RecordDecl iterators field_begin() and field_end() with ↵Aaron Ballman2014-03-081-3/+1
| | | | | | iterator_range fields(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203355
* Don't suggest non-static methods as corrections when they obviouslyKaelyn Uhrain2014-02-281-1/+1
| | | | | | | won't work (i.e. when not doing a member lookup and not in a method from the same class or a descendant class). llvm-svn: 202520
* Fix crash with enable_if on constructors.Nick Lewycky2014-02-281-1/+2
| | | | llvm-svn: 202467
* Tighten lax vector-conversion rules and enforce them consistently.John McCall2014-02-041-6/+5
| | | | | | | | | | | | | | | | | | | | When a lax conversion featured a vector and a non-vector, we were only requiring the non-vector to be a scalar type, but really it needs to be a real type (i.e. integral or real floating); it is not reasonable to allow a pointer, member pointer, or complex type here. r198474 required lax conversions to match in "data size", i.e. element size * element count, forbidding matches that happen only because a vector is rounded up to the nearest power of two in size. Unfortunately, the erroneous logic was repeated in several different places; unify them to use the new condition, so that it triggers for arbitrary conversions and not just those performed as part of binary operator checking. rdar://15931426 llvm-svn: 200810
* [Sema] Follow-up on r200521 for the -Wnon-literal-null-conversion warning ↵Argyrios Kyrtzidis2014-02-021-15/+1
| | | | | | and revert its behavior for C++. llvm-svn: 200622
* [Sema] For -Wnon-literal-null-conversion warning, look through integer ↵Argyrios Kyrtzidis2014-01-311-1/+15
| | | | | | | | | | casts, which are used by some projects in their null macro. rdar://15925483 llvm-svn: 200521
* 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
OpenPOWER on IntegriCloud