Overload.h revision d97f558f48865aa96e7bdf9c1c9315790c3d77c9
1//===--- Overload.h - C++ Overloading ---------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the data structures and types used in C++ 11// overload resolution. 12// 13//===----------------------------------------------------------------------===// 14 15#ifndef LLVM_CLANG_SEMA_OVERLOAD_H 16#define LLVM_CLANG_SEMA_OVERLOAD_H 17 18#include "clang/AST/Decl.h" 19#include "clang/AST/DeclTemplate.h" 20#include "clang/AST/Expr.h" 21#include "clang/AST/TemplateBase.h" 22#include "clang/AST/Type.h" 23#include "clang/AST/UnresolvedSet.h" 24#include "llvm/ADT/SmallPtrSet.h" 25#include "llvm/ADT/SmallVector.h" 26 27namespace clang { 28 class ASTContext; 29 class CXXConstructorDecl; 30 class CXXConversionDecl; 31 class FunctionDecl; 32 class Sema; 33 34 /// OverloadingResult - Capture the result of performing overload 35 /// resolution. 36 enum OverloadingResult { 37 OR_Success, ///< Overload resolution succeeded. 38 OR_No_Viable_Function, ///< No viable function found. 39 OR_Ambiguous, ///< Ambiguous candidates found. 40 OR_Deleted ///< Succeeded, but refers to a deleted function. 41 }; 42 43 enum OverloadCandidateDisplayKind { 44 /// Requests that all candidates be shown. Viable candidates will 45 /// be printed first. 46 OCD_AllCandidates, 47 48 /// Requests that only viable candidates be shown. 49 OCD_ViableCandidates 50 }; 51 52 /// ImplicitConversionKind - The kind of implicit conversion used to 53 /// convert an argument to a parameter's type. The enumerator values 54 /// match with Table 9 of (C++ 13.3.3.1.1) and are listed such that 55 /// better conversion kinds have smaller values. 56 enum ImplicitConversionKind { 57 ICK_Identity = 0, ///< Identity conversion (no conversion) 58 ICK_Lvalue_To_Rvalue, ///< Lvalue-to-rvalue conversion (C++ 4.1) 59 ICK_Array_To_Pointer, ///< Array-to-pointer conversion (C++ 4.2) 60 ICK_Function_To_Pointer, ///< Function-to-pointer (C++ 4.3) 61 ICK_NoReturn_Adjustment, ///< Removal of noreturn from a type (Clang) 62 ICK_Qualification, ///< Qualification conversions (C++ 4.4) 63 ICK_Integral_Promotion, ///< Integral promotions (C++ 4.5) 64 ICK_Floating_Promotion, ///< Floating point promotions (C++ 4.6) 65 ICK_Complex_Promotion, ///< Complex promotions (Clang extension) 66 ICK_Integral_Conversion, ///< Integral conversions (C++ 4.7) 67 ICK_Floating_Conversion, ///< Floating point conversions (C++ 4.8) 68 ICK_Complex_Conversion, ///< Complex conversions (C99 6.3.1.6) 69 ICK_Floating_Integral, ///< Floating-integral conversions (C++ 4.9) 70 ICK_Pointer_Conversion, ///< Pointer conversions (C++ 4.10) 71 ICK_Pointer_Member, ///< Pointer-to-member conversions (C++ 4.11) 72 ICK_Boolean_Conversion, ///< Boolean conversions (C++ 4.12) 73 ICK_Compatible_Conversion, ///< Conversions between compatible types in C99 74 ICK_Derived_To_Base, ///< Derived-to-base (C++ [over.best.ics]) 75 ICK_Vector_Conversion, ///< Vector conversions 76 ICK_Vector_Splat, ///< A vector splat from an arithmetic type 77 ICK_Complex_Real, ///< Complex-real conversions (C99 6.3.1.7) 78 ICK_Block_Pointer_Conversion, ///< Block Pointer conversions 79 ICK_TransparentUnionConversion, /// Transparent Union Conversions 80 ICK_Num_Conversion_Kinds ///< The number of conversion kinds 81 }; 82 83 /// ImplicitConversionCategory - The category of an implicit 84 /// conversion kind. The enumerator values match with Table 9 of 85 /// (C++ 13.3.3.1.1) and are listed such that better conversion 86 /// categories have smaller values. 87 enum ImplicitConversionCategory { 88 ICC_Identity = 0, ///< Identity 89 ICC_Lvalue_Transformation, ///< Lvalue transformation 90 ICC_Qualification_Adjustment, ///< Qualification adjustment 91 ICC_Promotion, ///< Promotion 92 ICC_Conversion ///< Conversion 93 }; 94 95 ImplicitConversionCategory 96 GetConversionCategory(ImplicitConversionKind Kind); 97 98 /// ImplicitConversionRank - The rank of an implicit conversion 99 /// kind. The enumerator values match with Table 9 of (C++ 100 /// 13.3.3.1.1) and are listed such that better conversion ranks 101 /// have smaller values. 102 enum ImplicitConversionRank { 103 ICR_Exact_Match = 0, ///< Exact Match 104 ICR_Promotion, ///< Promotion 105 ICR_Conversion, ///< Conversion 106 ICR_Complex_Real_Conversion ///< Complex <-> Real conversion 107 }; 108 109 ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind); 110 111 /// StandardConversionSequence - represents a standard conversion 112 /// sequence (C++ 13.3.3.1.1). A standard conversion sequence 113 /// contains between zero and three conversions. If a particular 114 /// conversion is not needed, it will be set to the identity conversion 115 /// (ICK_Identity). Note that the three conversions are 116 /// specified as separate members (rather than in an array) so that 117 /// we can keep the size of a standard conversion sequence to a 118 /// single word. 119 class StandardConversionSequence { 120 public: 121 /// First -- The first conversion can be an lvalue-to-rvalue 122 /// conversion, array-to-pointer conversion, or 123 /// function-to-pointer conversion. 124 ImplicitConversionKind First : 8; 125 126 /// Second - The second conversion can be an integral promotion, 127 /// floating point promotion, integral conversion, floating point 128 /// conversion, floating-integral conversion, pointer conversion, 129 /// pointer-to-member conversion, or boolean conversion. 130 ImplicitConversionKind Second : 8; 131 132 /// Third - The third conversion can be a qualification conversion. 133 ImplicitConversionKind Third : 8; 134 135 /// \brief Whether this is the deprecated conversion of a 136 /// string literal to a pointer to non-const character data 137 /// (C++ 4.2p2). 138 unsigned DeprecatedStringLiteralToCharPtr : 1; 139 140 /// IncompatibleObjC - Whether this is an Objective-C conversion 141 /// that we should warn about (if we actually use it). 142 unsigned IncompatibleObjC : 1; 143 144 /// ReferenceBinding - True when this is a reference binding 145 /// (C++ [over.ics.ref]). 146 unsigned ReferenceBinding : 1; 147 148 /// DirectBinding - True when this is a reference binding that is a 149 /// direct binding (C++ [dcl.init.ref]). 150 unsigned DirectBinding : 1; 151 152 /// \brief Whether this is an lvalue reference binding (otherwise, it's 153 /// an rvalue reference binding). 154 unsigned IsLvalueReference : 1; 155 156 /// \brief Whether we're binding to a function lvalue. 157 unsigned BindsToFunctionLvalue : 1; 158 159 /// \brief Whether we're binding to an rvalue. 160 unsigned BindsToRvalue : 1; 161 162 /// \brief Whether this binds an implicit object argument to a 163 /// non-static member function without a ref-qualifier. 164 unsigned BindsImplicitObjectArgumentWithoutRefQualifier : 1; 165 166 /// FromType - The type that this conversion is converting 167 /// from. This is an opaque pointer that can be translated into a 168 /// QualType. 169 void *FromTypePtr; 170 171 /// ToType - The types that this conversion is converting to in 172 /// each step. This is an opaque pointer that can be translated 173 /// into a QualType. 174 void *ToTypePtrs[3]; 175 176 /// CopyConstructor - The copy constructor that is used to perform 177 /// this conversion, when the conversion is actually just the 178 /// initialization of an object via copy constructor. Such 179 /// conversions are either identity conversions or derived-to-base 180 /// conversions. 181 CXXConstructorDecl *CopyConstructor; 182 183 void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); } 184 void setToType(unsigned Idx, QualType T) { 185 assert(Idx < 3 && "To type index is out of range"); 186 ToTypePtrs[Idx] = T.getAsOpaquePtr(); 187 } 188 void setAllToTypes(QualType T) { 189 ToTypePtrs[0] = T.getAsOpaquePtr(); 190 ToTypePtrs[1] = ToTypePtrs[0]; 191 ToTypePtrs[2] = ToTypePtrs[0]; 192 } 193 194 QualType getFromType() const { 195 return QualType::getFromOpaquePtr(FromTypePtr); 196 } 197 QualType getToType(unsigned Idx) const { 198 assert(Idx < 3 && "To type index is out of range"); 199 return QualType::getFromOpaquePtr(ToTypePtrs[Idx]); 200 } 201 202 void setAsIdentityConversion(); 203 204 bool isIdentityConversion() const { 205 return First == ICK_Identity && Second == ICK_Identity && 206 Third == ICK_Identity; 207 } 208 209 ImplicitConversionRank getRank() const; 210 bool isPointerConversionToBool() const; 211 bool isPointerConversionToVoidPointer(ASTContext& Context) const; 212 void DebugPrint() const; 213 }; 214 215 /// UserDefinedConversionSequence - Represents a user-defined 216 /// conversion sequence (C++ 13.3.3.1.2). 217 struct UserDefinedConversionSequence { 218 /// Before - Represents the standard conversion that occurs before 219 /// the actual user-defined conversion. (C++ 13.3.3.1.2p1): 220 /// 221 /// If the user-defined conversion is specified by a constructor 222 /// (12.3.1), the initial standard conversion sequence converts 223 /// the source type to the type required by the argument of the 224 /// constructor. If the user-defined conversion is specified by 225 /// a conversion function (12.3.2), the initial standard 226 /// conversion sequence converts the source type to the implicit 227 /// object parameter of the conversion function. 228 StandardConversionSequence Before; 229 230 /// EllipsisConversion - When this is true, it means user-defined 231 /// conversion sequence starts with a ... (elipsis) conversion, instead of 232 /// a standard conversion. In this case, 'Before' field must be ignored. 233 // FIXME. I much rather put this as the first field. But there seems to be 234 // a gcc code gen. bug which causes a crash in a test. Putting it here seems 235 // to work around the crash. 236 bool EllipsisConversion : 1; 237 238 /// After - Represents the standard conversion that occurs after 239 /// the actual user-defined conversion. 240 StandardConversionSequence After; 241 242 /// ConversionFunction - The function that will perform the 243 /// user-defined conversion. 244 FunctionDecl* ConversionFunction; 245 246 /// \brief The declaration that we found via name lookup, which might be 247 /// the same as \c ConversionFunction or it might be a using declaration 248 /// that refers to \c ConversionFunction. 249 NamedDecl *FoundConversionFunction; 250 251 void DebugPrint() const; 252 }; 253 254 /// Represents an ambiguous user-defined conversion sequence. 255 struct AmbiguousConversionSequence { 256 typedef llvm::SmallVector<FunctionDecl*, 4> ConversionSet; 257 258 void *FromTypePtr; 259 void *ToTypePtr; 260 char Buffer[sizeof(ConversionSet)]; 261 262 QualType getFromType() const { 263 return QualType::getFromOpaquePtr(FromTypePtr); 264 } 265 QualType getToType() const { 266 return QualType::getFromOpaquePtr(ToTypePtr); 267 } 268 void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); } 269 void setToType(QualType T) { ToTypePtr = T.getAsOpaquePtr(); } 270 271 ConversionSet &conversions() { 272 return *reinterpret_cast<ConversionSet*>(Buffer); 273 } 274 275 const ConversionSet &conversions() const { 276 return *reinterpret_cast<const ConversionSet*>(Buffer); 277 } 278 279 void addConversion(FunctionDecl *D) { 280 conversions().push_back(D); 281 } 282 283 typedef ConversionSet::iterator iterator; 284 iterator begin() { return conversions().begin(); } 285 iterator end() { return conversions().end(); } 286 287 typedef ConversionSet::const_iterator const_iterator; 288 const_iterator begin() const { return conversions().begin(); } 289 const_iterator end() const { return conversions().end(); } 290 291 void construct(); 292 void destruct(); 293 void copyFrom(const AmbiguousConversionSequence &); 294 }; 295 296 /// BadConversionSequence - Records information about an invalid 297 /// conversion sequence. 298 struct BadConversionSequence { 299 enum FailureKind { 300 no_conversion, 301 unrelated_class, 302 suppressed_user, 303 bad_qualifiers, 304 lvalue_ref_to_rvalue, 305 rvalue_ref_to_lvalue 306 }; 307 308 // This can be null, e.g. for implicit object arguments. 309 Expr *FromExpr; 310 311 FailureKind Kind; 312 313 private: 314 // The type we're converting from (an opaque QualType). 315 void *FromTy; 316 317 // The type we're converting to (an opaque QualType). 318 void *ToTy; 319 320 public: 321 void init(FailureKind K, Expr *From, QualType To) { 322 init(K, From->getType(), To); 323 FromExpr = From; 324 } 325 void init(FailureKind K, QualType From, QualType To) { 326 Kind = K; 327 FromExpr = 0; 328 setFromType(From); 329 setToType(To); 330 } 331 332 QualType getFromType() const { return QualType::getFromOpaquePtr(FromTy); } 333 QualType getToType() const { return QualType::getFromOpaquePtr(ToTy); } 334 335 void setFromExpr(Expr *E) { 336 FromExpr = E; 337 setFromType(E->getType()); 338 } 339 void setFromType(QualType T) { FromTy = T.getAsOpaquePtr(); } 340 void setToType(QualType T) { ToTy = T.getAsOpaquePtr(); } 341 }; 342 343 /// ImplicitConversionSequence - Represents an implicit conversion 344 /// sequence, which may be a standard conversion sequence 345 /// (C++ 13.3.3.1.1), user-defined conversion sequence (C++ 13.3.3.1.2), 346 /// or an ellipsis conversion sequence (C++ 13.3.3.1.3). 347 class ImplicitConversionSequence { 348 public: 349 /// Kind - The kind of implicit conversion sequence. BadConversion 350 /// specifies that there is no conversion from the source type to 351 /// the target type. AmbiguousConversion represents the unique 352 /// ambiguous conversion (C++0x [over.best.ics]p10). 353 enum Kind { 354 StandardConversion = 0, 355 UserDefinedConversion, 356 AmbiguousConversion, 357 EllipsisConversion, 358 BadConversion 359 }; 360 361 private: 362 enum { 363 Uninitialized = BadConversion + 1 364 }; 365 366 /// ConversionKind - The kind of implicit conversion sequence. 367 unsigned ConversionKind; 368 369 void setKind(Kind K) { 370 destruct(); 371 ConversionKind = K; 372 } 373 374 void destruct() { 375 if (ConversionKind == AmbiguousConversion) Ambiguous.destruct(); 376 } 377 378 public: 379 union { 380 /// When ConversionKind == StandardConversion, provides the 381 /// details of the standard conversion sequence. 382 StandardConversionSequence Standard; 383 384 /// When ConversionKind == UserDefinedConversion, provides the 385 /// details of the user-defined conversion sequence. 386 UserDefinedConversionSequence UserDefined; 387 388 /// When ConversionKind == AmbiguousConversion, provides the 389 /// details of the ambiguous conversion. 390 AmbiguousConversionSequence Ambiguous; 391 392 /// When ConversionKind == BadConversion, provides the details 393 /// of the bad conversion. 394 BadConversionSequence Bad; 395 }; 396 397 ImplicitConversionSequence() : ConversionKind(Uninitialized) {} 398 ~ImplicitConversionSequence() { 399 destruct(); 400 } 401 ImplicitConversionSequence(const ImplicitConversionSequence &Other) 402 : ConversionKind(Other.ConversionKind) 403 { 404 switch (ConversionKind) { 405 case Uninitialized: break; 406 case StandardConversion: Standard = Other.Standard; break; 407 case UserDefinedConversion: UserDefined = Other.UserDefined; break; 408 case AmbiguousConversion: Ambiguous.copyFrom(Other.Ambiguous); break; 409 case EllipsisConversion: break; 410 case BadConversion: Bad = Other.Bad; break; 411 } 412 } 413 414 ImplicitConversionSequence & 415 operator=(const ImplicitConversionSequence &Other) { 416 destruct(); 417 new (this) ImplicitConversionSequence(Other); 418 return *this; 419 } 420 421 Kind getKind() const { 422 assert(isInitialized() && "querying uninitialized conversion"); 423 return Kind(ConversionKind); 424 } 425 426 /// \brief Return a ranking of the implicit conversion sequence 427 /// kind, where smaller ranks represent better conversion 428 /// sequences. 429 /// 430 /// In particular, this routine gives user-defined conversion 431 /// sequences and ambiguous conversion sequences the same rank, 432 /// per C++ [over.best.ics]p10. 433 unsigned getKindRank() const { 434 switch (getKind()) { 435 case StandardConversion: 436 return 0; 437 438 case UserDefinedConversion: 439 case AmbiguousConversion: 440 return 1; 441 442 case EllipsisConversion: 443 return 2; 444 445 case BadConversion: 446 return 3; 447 } 448 449 return 3; 450 } 451 452 bool isBad() const { return getKind() == BadConversion; } 453 bool isStandard() const { return getKind() == StandardConversion; } 454 bool isEllipsis() const { return getKind() == EllipsisConversion; } 455 bool isAmbiguous() const { return getKind() == AmbiguousConversion; } 456 bool isUserDefined() const { return getKind() == UserDefinedConversion; } 457 458 /// Determines whether this conversion sequence has been 459 /// initialized. Most operations should never need to query 460 /// uninitialized conversions and should assert as above. 461 bool isInitialized() const { return ConversionKind != Uninitialized; } 462 463 /// Sets this sequence as a bad conversion for an explicit argument. 464 void setBad(BadConversionSequence::FailureKind Failure, 465 Expr *FromExpr, QualType ToType) { 466 setKind(BadConversion); 467 Bad.init(Failure, FromExpr, ToType); 468 } 469 470 /// Sets this sequence as a bad conversion for an implicit argument. 471 void setBad(BadConversionSequence::FailureKind Failure, 472 QualType FromType, QualType ToType) { 473 setKind(BadConversion); 474 Bad.init(Failure, FromType, ToType); 475 } 476 477 void setStandard() { setKind(StandardConversion); } 478 void setEllipsis() { setKind(EllipsisConversion); } 479 void setUserDefined() { setKind(UserDefinedConversion); } 480 void setAmbiguous() { 481 if (ConversionKind == AmbiguousConversion) return; 482 ConversionKind = AmbiguousConversion; 483 Ambiguous.construct(); 484 } 485 486 // The result of a comparison between implicit conversion 487 // sequences. Use Sema::CompareImplicitConversionSequences to 488 // actually perform the comparison. 489 enum CompareKind { 490 Better = -1, 491 Indistinguishable = 0, 492 Worse = 1 493 }; 494 495 void DiagnoseAmbiguousConversion(Sema &S, 496 SourceLocation CaretLoc, 497 const PartialDiagnostic &PDiag) const; 498 499 void DebugPrint() const; 500 }; 501 502 enum OverloadFailureKind { 503 ovl_fail_too_many_arguments, 504 ovl_fail_too_few_arguments, 505 ovl_fail_bad_conversion, 506 ovl_fail_bad_deduction, 507 508 /// This conversion candidate was not considered because it 509 /// duplicates the work of a trivial or derived-to-base 510 /// conversion. 511 ovl_fail_trivial_conversion, 512 513 /// This conversion candidate is not viable because its result 514 /// type is not implicitly convertible to the desired type. 515 ovl_fail_bad_final_conversion, 516 517 /// This conversion function template specialization candidate is not 518 /// viable because the final conversion was not an exact match. 519 ovl_fail_final_conversion_not_exact 520 }; 521 522 /// OverloadCandidate - A single candidate in an overload set (C++ 13.3). 523 struct OverloadCandidate { 524 /// Function - The actual function that this candidate 525 /// represents. When NULL, this is a built-in candidate 526 /// (C++ [over.oper]) or a surrogate for a conversion to a 527 /// function pointer or reference (C++ [over.call.object]). 528 FunctionDecl *Function; 529 530 /// FoundDecl - The original declaration that was looked up / 531 /// invented / otherwise found, together with its access. 532 /// Might be a UsingShadowDecl or a FunctionTemplateDecl. 533 DeclAccessPair FoundDecl; 534 535 // BuiltinTypes - Provides the return and parameter types of a 536 // built-in overload candidate. Only valid when Function is NULL. 537 struct { 538 QualType ResultTy; 539 QualType ParamTypes[3]; 540 } BuiltinTypes; 541 542 /// Surrogate - The conversion function for which this candidate 543 /// is a surrogate, but only if IsSurrogate is true. 544 CXXConversionDecl *Surrogate; 545 546 /// Conversions - The conversion sequences used to convert the 547 /// function arguments to the function parameters. 548 llvm::SmallVector<ImplicitConversionSequence, 4> Conversions; 549 550 /// Viable - True to indicate that this overload candidate is viable. 551 bool Viable; 552 553 /// IsSurrogate - True to indicate that this candidate is a 554 /// surrogate for a conversion to a function pointer or reference 555 /// (C++ [over.call.object]). 556 bool IsSurrogate; 557 558 /// IgnoreObjectArgument - True to indicate that the first 559 /// argument's conversion, which for this function represents the 560 /// implicit object argument, should be ignored. This will be true 561 /// when the candidate is a static member function (where the 562 /// implicit object argument is just a placeholder) or a 563 /// non-static member function when the call doesn't have an 564 /// object argument. 565 bool IgnoreObjectArgument; 566 567 /// FailureKind - The reason why this candidate is not viable. 568 /// Actually an OverloadFailureKind. 569 unsigned char FailureKind; 570 571 /// \brief The number of call arguments that were explicitly provided, 572 /// to be used while performing partial ordering of function templates. 573 unsigned ExplicitCallArguments; 574 575 /// A structure used to record information about a failed 576 /// template argument deduction. 577 struct DeductionFailureInfo { 578 // A Sema::TemplateDeductionResult. 579 unsigned Result; 580 581 /// \brief Opaque pointer containing additional data about 582 /// this deduction failure. 583 void *Data; 584 585 /// \brief Retrieve the template parameter this deduction failure 586 /// refers to, if any. 587 TemplateParameter getTemplateParameter(); 588 589 /// \brief Retrieve the template argument list associated with this 590 /// deduction failure, if any. 591 TemplateArgumentList *getTemplateArgumentList(); 592 593 /// \brief Return the first template argument this deduction failure 594 /// refers to, if any. 595 const TemplateArgument *getFirstArg(); 596 597 /// \brief Return the second template argument this deduction failure 598 /// refers to, if any. 599 const TemplateArgument *getSecondArg(); 600 601 /// \brief Free any memory associated with this deduction failure. 602 void Destroy(); 603 }; 604 605 union { 606 DeductionFailureInfo DeductionFailure; 607 608 /// FinalConversion - For a conversion function (where Function is 609 /// a CXXConversionDecl), the standard conversion that occurs 610 /// after the call to the overload candidate to convert the result 611 /// of calling the conversion function to the required type. 612 StandardConversionSequence FinalConversion; 613 }; 614 615 /// hasAmbiguousConversion - Returns whether this overload 616 /// candidate requires an ambiguous conversion or not. 617 bool hasAmbiguousConversion() const { 618 for (llvm::SmallVectorImpl<ImplicitConversionSequence>::const_iterator 619 I = Conversions.begin(), E = Conversions.end(); I != E; ++I) { 620 if (!I->isInitialized()) return false; 621 if (I->isAmbiguous()) return true; 622 } 623 return false; 624 } 625 }; 626 627 /// OverloadCandidateSet - A set of overload candidates, used in C++ 628 /// overload resolution (C++ 13.3). 629 class OverloadCandidateSet : public llvm::SmallVector<OverloadCandidate, 16> { 630 typedef llvm::SmallVector<OverloadCandidate, 16> inherited; 631 llvm::SmallPtrSet<Decl *, 16> Functions; 632 633 SourceLocation Loc; 634 635 OverloadCandidateSet(const OverloadCandidateSet &); 636 OverloadCandidateSet &operator=(const OverloadCandidateSet &); 637 638 public: 639 OverloadCandidateSet(SourceLocation Loc) : Loc(Loc) {} 640 641 SourceLocation getLocation() const { return Loc; } 642 643 /// \brief Determine when this overload candidate will be new to the 644 /// overload set. 645 bool isNewCandidate(Decl *F) { 646 return Functions.insert(F->getCanonicalDecl()); 647 } 648 649 /// \brief Clear out all of the candidates. 650 void clear(); 651 652 /// Find the best viable function on this overload set, if it exists. 653 OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, 654 OverloadCandidateSet::iterator& Best, 655 bool UserDefinedConversion = false); 656 657 void NoteCandidates(Sema &S, 658 OverloadCandidateDisplayKind OCD, 659 Expr **Args, unsigned NumArgs, 660 const char *Opc = 0, 661 SourceLocation Loc = SourceLocation()); 662 }; 663 664 bool isBetterOverloadCandidate(Sema &S, 665 const OverloadCandidate& Cand1, 666 const OverloadCandidate& Cand2, 667 SourceLocation Loc, 668 bool UserDefinedConversion = false); 669} // end namespace clang 670 671#endif // LLVM_CLANG_SEMA_OVERLOAD_H 672