clang  10.0.0svn
Overload.h
Go to the documentation of this file.
1 //===- Overload.h - C++ Overloading -----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the data structures and types used in C++
10 // overload resolution.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_SEMA_OVERLOAD_H
15 #define LLVM_CLANG_SEMA_OVERLOAD_H
16 
17 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclBase.h"
20 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/DeclTemplate.h"
22 #include "clang/AST/Expr.h"
23 #include "clang/AST/Type.h"
24 #include "clang/Basic/LLVM.h"
28 #include "llvm/ADT/ArrayRef.h"
29 #include "llvm/ADT/None.h"
30 #include "llvm/ADT/STLExtras.h"
31 #include "llvm/ADT/SmallPtrSet.h"
32 #include "llvm/ADT/SmallVector.h"
33 #include "llvm/ADT/StringRef.h"
34 #include "llvm/Support/AlignOf.h"
35 #include "llvm/Support/Allocator.h"
36 #include "llvm/Support/Casting.h"
37 #include "llvm/Support/ErrorHandling.h"
38 #include <cassert>
39 #include <cstddef>
40 #include <cstdint>
41 #include <utility>
42 
43 namespace clang {
44 
45 class APValue;
46 class ASTContext;
47 class Sema;
48 
49  /// OverloadingResult - Capture the result of performing overload
50  /// resolution.
52  /// Overload resolution succeeded.
54 
55  /// No viable function found.
57 
58  /// Ambiguous candidates found.
60 
61  /// Succeeded, but refers to a deleted function.
63  };
64 
66  /// Requests that all candidates be shown. Viable candidates will
67  /// be printed first.
69 
70  /// Requests that only viable candidates be shown.
72  };
73 
74  /// The parameter ordering that will be used for the candidate. This is
75  /// used to represent C++20 binary operator rewrites that reverse the order
76  /// of the arguments. If the parameter ordering is Reversed, the Args list is
77  /// reversed (but obviously the ParamDecls for the function are not).
78  ///
79  /// After forming an OverloadCandidate with reversed parameters, the list
80  /// of conversions will (as always) be indexed by argument, so will be
81  /// in reverse parameter order.
83 
84  /// The kinds of rewrite we perform on overload candidates. Note that the
85  /// values here are chosen to serve as both bitflags and as a rank (lower
86  /// values are preferred by overload resolution).
87  enum OverloadCandidateRewriteKind : unsigned {
88  /// Candidate is not a rewritten candidate.
89  CRK_None = 0x0,
90 
91  /// Candidate is a rewritten candidate with a different operator name.
93 
94  /// Candidate is a rewritten candidate with a reversed order of parameters.
95  CRK_Reversed = 0x2,
96  };
97 
98  /// ImplicitConversionKind - The kind of implicit conversion used to
99  /// convert an argument to a parameter's type. The enumerator values
100  /// match with the table titled 'Conversions' in [over.ics.scs] and are listed
101  /// such that better conversion kinds have smaller values.
103  /// Identity conversion (no conversion)
105 
106  /// Lvalue-to-rvalue conversion (C++ [conv.lval])
108 
109  /// Array-to-pointer conversion (C++ [conv.array])
111 
112  /// Function-to-pointer (C++ [conv.array])
114 
115  /// Function pointer conversion (C++17 [conv.fctptr])
117 
118  /// Qualification conversions (C++ [conv.qual])
120 
121  /// Integral promotions (C++ [conv.prom])
123 
124  /// Floating point promotions (C++ [conv.fpprom])
126 
127  /// Complex promotions (Clang extension)
129 
130  /// Integral conversions (C++ [conv.integral])
132 
133  /// Floating point conversions (C++ [conv.double]
135 
136  /// Complex conversions (C99 6.3.1.6)
138 
139  /// Floating-integral conversions (C++ [conv.fpint])
141 
142  /// Pointer conversions (C++ [conv.ptr])
144 
145  /// Pointer-to-member conversions (C++ [conv.mem])
147 
148  /// Boolean conversions (C++ [conv.bool])
150 
151  /// Conversions between compatible types in C99
153 
154  /// Derived-to-base (C++ [over.best.ics])
156 
157  /// Vector conversions
159 
160  /// A vector splat from an arithmetic type
162 
163  /// Complex-real conversions (C99 6.3.1.7)
165 
166  /// Block Pointer conversions
168 
169  /// Transparent Union Conversions
171 
172  /// Objective-C ARC writeback conversion
174 
175  /// Zero constant to event (OpenCL1.2 6.12.10)
177 
178  /// Zero constant to queue
180 
181  /// Conversions allowed in C, but not C++
183 
184  /// C-only conversion between pointers with incompatible types
186 
187  /// The number of conversion kinds
189  };
190 
191  /// ImplicitConversionRank - The rank of an implicit conversion
192  /// kind. The enumerator values match with Table 9 of (C++
193  /// 13.3.3.1.1) and are listed such that better conversion ranks
194  /// have smaller values.
196  /// Exact Match
198 
199  /// Promotion
201 
202  /// Conversion
204 
205  /// OpenCL Scalar Widening
207 
208  /// Complex <-> Real conversion
210 
211  /// ObjC ARC writeback conversion
213 
214  /// Conversion only allowed in the C standard (e.g. void* to char*).
216 
217  /// Conversion not allowed by the C standard, but that we accept as an
218  /// extension anyway.
220  };
221 
223 
224  /// NarrowingKind - The kind of narrowing conversion being performed by a
225  /// standard conversion sequence according to C++11 [dcl.init.list]p7.
227  /// Not a narrowing conversion.
229 
230  /// A narrowing conversion by virtue of the source and destination types.
232 
233  /// A narrowing conversion, because a constant expression got narrowed.
235 
236  /// A narrowing conversion, because a non-constant-expression variable might
237  /// have got narrowed.
239 
240  /// Cannot tell whether this is a narrowing conversion because the
241  /// expression is value-dependent.
243  };
244 
245  /// StandardConversionSequence - represents a standard conversion
246  /// sequence (C++ 13.3.3.1.1). A standard conversion sequence
247  /// contains between zero and three conversions. If a particular
248  /// conversion is not needed, it will be set to the identity conversion
249  /// (ICK_Identity). Note that the three conversions are
250  /// specified as separate members (rather than in an array) so that
251  /// we can keep the size of a standard conversion sequence to a
252  /// single word.
254  public:
255  /// First -- The first conversion can be an lvalue-to-rvalue
256  /// conversion, array-to-pointer conversion, or
257  /// function-to-pointer conversion.
259 
260  /// Second - The second conversion can be an integral promotion,
261  /// floating point promotion, integral conversion, floating point
262  /// conversion, floating-integral conversion, pointer conversion,
263  /// pointer-to-member conversion, or boolean conversion.
265 
266  /// Third - The third conversion can be a qualification conversion
267  /// or a function conversion.
269 
270  /// Whether this is the deprecated conversion of a
271  /// string literal to a pointer to non-const character data
272  /// (C++ 4.2p2).
274 
275  /// Whether the qualification conversion involves a change in the
276  /// Objective-C lifetime (for automatic reference counting).
278 
279  /// IncompatibleObjC - Whether this is an Objective-C conversion
280  /// that we should warn about (if we actually use it).
281  unsigned IncompatibleObjC : 1;
282 
283  /// ReferenceBinding - True when this is a reference binding
284  /// (C++ [over.ics.ref]).
285  unsigned ReferenceBinding : 1;
286 
287  /// DirectBinding - True when this is a reference binding that is a
288  /// direct binding (C++ [dcl.init.ref]).
289  unsigned DirectBinding : 1;
290 
291  /// Whether this is an lvalue reference binding (otherwise, it's
292  /// an rvalue reference binding).
293  unsigned IsLvalueReference : 1;
294 
295  /// Whether we're binding to a function lvalue.
296  unsigned BindsToFunctionLvalue : 1;
297 
298  /// Whether we're binding to an rvalue.
299  unsigned BindsToRvalue : 1;
300 
301  /// Whether this binds an implicit object argument to a
302  /// non-static member function without a ref-qualifier.
304 
305  /// Whether this binds a reference to an object with a different
306  /// Objective-C lifetime qualifier.
308 
309  /// FromType - The type that this conversion is converting
310  /// from. This is an opaque pointer that can be translated into a
311  /// QualType.
312  void *FromTypePtr;
313 
314  /// ToType - The types that this conversion is converting to in
315  /// each step. This is an opaque pointer that can be translated
316  /// into a QualType.
317  void *ToTypePtrs[3];
318 
319  /// CopyConstructor - The copy constructor that is used to perform
320  /// this conversion, when the conversion is actually just the
321  /// initialization of an object via copy constructor. Such
322  /// conversions are either identity conversions or derived-to-base
323  /// conversions.
326 
327  void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); }
328 
329  void setToType(unsigned Idx, QualType T) {
330  assert(Idx < 3 && "To type index is out of range");
331  ToTypePtrs[Idx] = T.getAsOpaquePtr();
332  }
333 
335  ToTypePtrs[0] = T.getAsOpaquePtr();
336  ToTypePtrs[1] = ToTypePtrs[0];
337  ToTypePtrs[2] = ToTypePtrs[0];
338  }
339 
341  return QualType::getFromOpaquePtr(FromTypePtr);
342  }
343 
344  QualType getToType(unsigned Idx) const {
345  assert(Idx < 3 && "To type index is out of range");
346  return QualType::getFromOpaquePtr(ToTypePtrs[Idx]);
347  }
348 
349  void setAsIdentityConversion();
350 
351  bool isIdentityConversion() const {
352  return Second == ICK_Identity && Third == ICK_Identity;
353  }
354 
355  ImplicitConversionRank getRank() const;
357  getNarrowingKind(ASTContext &Context, const Expr *Converted,
358  APValue &ConstantValue, QualType &ConstantType,
359  bool IgnoreFloatToIntegralConversion = false) const;
360  bool isPointerConversionToBool() const;
361  bool isPointerConversionToVoidPointer(ASTContext& Context) const;
362  void dump() const;
363  };
364 
365  /// UserDefinedConversionSequence - Represents a user-defined
366  /// conversion sequence (C++ 13.3.3.1.2).
368  /// Represents the standard conversion that occurs before
369  /// the actual user-defined conversion.
370  ///
371  /// C++11 13.3.3.1.2p1:
372  /// If the user-defined conversion is specified by a constructor
373  /// (12.3.1), the initial standard conversion sequence converts
374  /// the source type to the type required by the argument of the
375  /// constructor. If the user-defined conversion is specified by
376  /// a conversion function (12.3.2), the initial standard
377  /// conversion sequence converts the source type to the implicit
378  /// object parameter of the conversion function.
380 
381  /// EllipsisConversion - When this is true, it means user-defined
382  /// conversion sequence starts with a ... (ellipsis) conversion, instead of
383  /// a standard conversion. In this case, 'Before' field must be ignored.
384  // FIXME. I much rather put this as the first field. But there seems to be
385  // a gcc code gen. bug which causes a crash in a test. Putting it here seems
386  // to work around the crash.
388 
389  /// HadMultipleCandidates - When this is true, it means that the
390  /// conversion function was resolved from an overloaded set having
391  /// size greater than 1.
393 
394  /// After - Represents the standard conversion that occurs after
395  /// the actual user-defined conversion.
397 
398  /// ConversionFunction - The function that will perform the
399  /// user-defined conversion. Null if the conversion is an
400  /// aggregate initialization from an initializer list.
402 
403  /// The declaration that we found via name lookup, which might be
404  /// the same as \c ConversionFunction or it might be a using declaration
405  /// that refers to \c ConversionFunction.
407 
408  void dump() const;
409  };
410 
411  /// Represents an ambiguous user-defined conversion sequence.
413  using ConversionSet =
415 
416  void *FromTypePtr;
417  void *ToTypePtr;
418  char Buffer[sizeof(ConversionSet)];
419 
421  return QualType::getFromOpaquePtr(FromTypePtr);
422  }
423 
424  QualType getToType() const {
425  return QualType::getFromOpaquePtr(ToTypePtr);
426  }
427 
428  void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); }
429  void setToType(QualType T) { ToTypePtr = T.getAsOpaquePtr(); }
430 
432  return *reinterpret_cast<ConversionSet*>(Buffer);
433  }
434 
435  const ConversionSet &conversions() const {
436  return *reinterpret_cast<const ConversionSet*>(Buffer);
437  }
438 
440  conversions().push_back(std::make_pair(Found, D));
441  }
442 
443  using iterator = ConversionSet::iterator;
444 
445  iterator begin() { return conversions().begin(); }
446  iterator end() { return conversions().end(); }
447 
448  using const_iterator = ConversionSet::const_iterator;
449 
450  const_iterator begin() const { return conversions().begin(); }
451  const_iterator end() const { return conversions().end(); }
452 
453  void construct();
454  void destruct();
455  void copyFrom(const AmbiguousConversionSequence &);
456  };
457 
458  /// BadConversionSequence - Records information about an invalid
459  /// conversion sequence.
461  enum FailureKind {
466  rvalue_ref_to_lvalue
467  };
468 
469  // This can be null, e.g. for implicit object arguments.
471 
473 
474  private:
475  // The type we're converting from (an opaque QualType).
476  void *FromTy;
477 
478  // The type we're converting to (an opaque QualType).
479  void *ToTy;
480 
481  public:
482  void init(FailureKind K, Expr *From, QualType To) {
483  init(K, From->getType(), To);
484  FromExpr = From;
485  }
486 
487  void init(FailureKind K, QualType From, QualType To) {
488  Kind = K;
489  FromExpr = nullptr;
490  setFromType(From);
491  setToType(To);
492  }
493 
494  QualType getFromType() const { return QualType::getFromOpaquePtr(FromTy); }
496 
497  void setFromExpr(Expr *E) {
498  FromExpr = E;
499  setFromType(E->getType());
500  }
501 
502  void setFromType(QualType T) { FromTy = T.getAsOpaquePtr(); }
503  void setToType(QualType T) { ToTy = T.getAsOpaquePtr(); }
504  };
505 
506  /// ImplicitConversionSequence - Represents an implicit conversion
507  /// sequence, which may be a standard conversion sequence
508  /// (C++ 13.3.3.1.1), user-defined conversion sequence (C++ 13.3.3.1.2),
509  /// or an ellipsis conversion sequence (C++ 13.3.3.1.3).
511  public:
512  /// Kind - The kind of implicit conversion sequence. BadConversion
513  /// specifies that there is no conversion from the source type to
514  /// the target type. AmbiguousConversion represents the unique
515  /// ambiguous conversion (C++0x [over.best.ics]p10).
516  enum Kind {
517  StandardConversion = 0,
521  BadConversion
522  };
523 
524  private:
525  enum {
526  Uninitialized = BadConversion + 1
527  };
528 
529  /// ConversionKind - The kind of implicit conversion sequence.
530  unsigned ConversionKind : 30;
531 
532  /// Whether the target is really a std::initializer_list, and the
533  /// sequence only represents the worst element conversion.
534  unsigned StdInitializerListElement : 1;
535 
536  void setKind(Kind K) {
537  destruct();
538  ConversionKind = K;
539  }
540 
541  void destruct() {
542  if (ConversionKind == AmbiguousConversion) Ambiguous.destruct();
543  }
544 
545  public:
546  union {
547  /// When ConversionKind == StandardConversion, provides the
548  /// details of the standard conversion sequence.
550 
551  /// When ConversionKind == UserDefinedConversion, provides the
552  /// details of the user-defined conversion sequence.
554 
555  /// When ConversionKind == AmbiguousConversion, provides the
556  /// details of the ambiguous conversion.
558 
559  /// When ConversionKind == BadConversion, provides the details
560  /// of the bad conversion.
562  };
563 
565  : ConversionKind(Uninitialized), StdInitializerListElement(false) {
566  Standard.setAsIdentityConversion();
567  }
568 
570  : ConversionKind(Other.ConversionKind),
571  StdInitializerListElement(Other.StdInitializerListElement) {
572  switch (ConversionKind) {
573  case Uninitialized: break;
574  case StandardConversion: Standard = Other.Standard; break;
575  case UserDefinedConversion: UserDefined = Other.UserDefined; break;
576  case AmbiguousConversion: Ambiguous.copyFrom(Other.Ambiguous); break;
577  case EllipsisConversion: break;
578  case BadConversion: Bad = Other.Bad; break;
579  }
580  }
581 
584  destruct();
585  new (this) ImplicitConversionSequence(Other);
586  return *this;
587  }
588 
590  destruct();
591  }
592 
593  Kind getKind() const {
594  assert(isInitialized() && "querying uninitialized conversion");
595  return Kind(ConversionKind);
596  }
597 
598  /// Return a ranking of the implicit conversion sequence
599  /// kind, where smaller ranks represent better conversion
600  /// sequences.
601  ///
602  /// In particular, this routine gives user-defined conversion
603  /// sequences and ambiguous conversion sequences the same rank,
604  /// per C++ [over.best.ics]p10.
605  unsigned getKindRank() const {
606  switch (getKind()) {
607  case StandardConversion:
608  return 0;
609 
610  case UserDefinedConversion:
611  case AmbiguousConversion:
612  return 1;
613 
614  case EllipsisConversion:
615  return 2;
616 
617  case BadConversion:
618  return 3;
619  }
620 
621  llvm_unreachable("Invalid ImplicitConversionSequence::Kind!");
622  }
623 
624  bool isBad() const { return getKind() == BadConversion; }
625  bool isStandard() const { return getKind() == StandardConversion; }
626  bool isEllipsis() const { return getKind() == EllipsisConversion; }
627  bool isAmbiguous() const { return getKind() == AmbiguousConversion; }
628  bool isUserDefined() const { return getKind() == UserDefinedConversion; }
629  bool isFailure() const { return isBad() || isAmbiguous(); }
630 
631  /// Determines whether this conversion sequence has been
632  /// initialized. Most operations should never need to query
633  /// uninitialized conversions and should assert as above.
634  bool isInitialized() const { return ConversionKind != Uninitialized; }
635 
636  /// Sets this sequence as a bad conversion for an explicit argument.
638  Expr *FromExpr, QualType ToType) {
639  setKind(BadConversion);
640  Bad.init(Failure, FromExpr, ToType);
641  }
642 
643  /// Sets this sequence as a bad conversion for an implicit argument.
645  QualType FromType, QualType ToType) {
646  setKind(BadConversion);
647  Bad.init(Failure, FromType, ToType);
648  }
649 
650  void setStandard() { setKind(StandardConversion); }
651  void setEllipsis() { setKind(EllipsisConversion); }
652  void setUserDefined() { setKind(UserDefinedConversion); }
653 
654  void setAmbiguous() {
655  if (ConversionKind == AmbiguousConversion) return;
656  ConversionKind = AmbiguousConversion;
657  Ambiguous.construct();
658  }
659 
661  setStandard();
662  Standard.setAsIdentityConversion();
663  Standard.setFromType(T);
664  Standard.setAllToTypes(T);
665  }
666 
667  /// Whether the target is really a std::initializer_list, and the
668  /// sequence only represents the worst element conversion.
670  return StdInitializerListElement;
671  }
672 
673  void setStdInitializerListElement(bool V = true) {
674  StdInitializerListElement = V;
675  }
676 
677  // The result of a comparison between implicit conversion
678  // sequences. Use Sema::CompareImplicitConversionSequences to
679  // actually perform the comparison.
680  enum CompareKind {
681  Better = -1,
682  Indistinguishable = 0,
683  Worse = 1
684  };
685 
686  void DiagnoseAmbiguousConversion(Sema &S,
687  SourceLocation CaretLoc,
688  const PartialDiagnostic &PDiag) const;
689 
690  void dump() const;
691  };
692 
698 
699  /// This conversion candidate was not considered because it
700  /// duplicates the work of a trivial or derived-to-base
701  /// conversion.
703 
704  /// This conversion candidate was not considered because it is
705  /// an illegal instantiation of a constructor temploid: it is
706  /// callable with one argument, we only have one argument, and
707  /// its first parameter type is exactly the type of the class.
708  ///
709  /// Defining such a constructor directly is illegal, and
710  /// template-argument deduction is supposed to ignore such
711  /// instantiations, but we can still get one with the right
712  /// kind of implicit instantiation.
714 
715  /// This conversion candidate is not viable because its result
716  /// type is not implicitly convertible to the desired type.
718 
719  /// This conversion function template specialization candidate is not
720  /// viable because the final conversion was not an exact match.
722 
723  /// (CUDA) This candidate was not viable because the callee
724  /// was not accessible from the caller's target (i.e. host->device,
725  /// global->host, device->host).
727 
728  /// This candidate function was not viable because an enable_if
729  /// attribute disabled it.
731 
732  /// This candidate constructor or conversion fonction
733  /// is used implicitly but the explicit(bool) specifier
734  /// was resolved to true
736 
737  /// This candidate was not viable because its address could not be taken.
739 
740  /// This candidate was not viable because its OpenCL extension is disabled.
742 
743  /// This inherited constructor is not viable because it would slice the
744  /// argument.
746 
747  /// This candidate was not viable because it is a non-default multiversioned
748  /// function.
750 
751  /// This constructor/conversion candidate fail due to an address space
752  /// mismatch between the object being constructed and the overload
753  /// candidate.
755  };
756 
757  /// A list of implicit conversion sequences for the arguments of an
758  /// OverloadCandidate.
759  using ConversionSequenceList =
761 
762  /// OverloadCandidate - A single candidate in an overload set (C++ 13.3).
764  /// Function - The actual function that this candidate
765  /// represents. When NULL, this is a built-in candidate
766  /// (C++ [over.oper]) or a surrogate for a conversion to a
767  /// function pointer or reference (C++ [over.call.object]).
769 
770  /// FoundDecl - The original declaration that was looked up /
771  /// invented / otherwise found, together with its access.
772  /// Might be a UsingShadowDecl or a FunctionTemplateDecl.
774 
775  /// BuiltinParamTypes - Provides the parameter types of a built-in overload
776  /// candidate. Only valid when Function is NULL.
777  QualType BuiltinParamTypes[3];
778 
779  /// Surrogate - The conversion function for which this candidate
780  /// is a surrogate, but only if IsSurrogate is true.
782 
783  /// The conversion sequences used to convert the function arguments
784  /// to the function parameters. Note that these are indexed by argument,
785  /// so may not match the parameter order of Function.
787 
788  /// The FixIt hints which can be used to fix the Bad candidate.
790 
791  /// Viable - True to indicate that this overload candidate is viable.
792  bool Viable : 1;
793 
794  /// IsSurrogate - True to indicate that this candidate is a
795  /// surrogate for a conversion to a function pointer or reference
796  /// (C++ [over.call.object]).
797  bool IsSurrogate : 1;
798 
799  /// IgnoreObjectArgument - True to indicate that the first
800  /// argument's conversion, which for this function represents the
801  /// implicit object argument, should be ignored. This will be true
802  /// when the candidate is a static member function (where the
803  /// implicit object argument is just a placeholder) or a
804  /// non-static member function when the call doesn't have an
805  /// object argument.
807 
808  /// True if the candidate was found using ADL.
810 
811  /// Whether this is a rewritten candidate, and if so, of what kind?
813 
814  /// FailureKind - The reason why this candidate is not viable.
815  /// Actually an OverloadFailureKind.
816  unsigned char FailureKind;
817 
818  /// The number of call arguments that were explicitly provided,
819  /// to be used while performing partial ordering of function templates.
821 
822  union {
824 
825  /// FinalConversion - For a conversion function (where Function is
826  /// a CXXConversionDecl), the standard conversion that occurs
827  /// after the call to the overload candidate to convert the result
828  /// of calling the conversion function to the required type.
830  };
831 
832  /// hasAmbiguousConversion - Returns whether this overload
833  /// candidate requires an ambiguous conversion or not.
834  bool hasAmbiguousConversion() const {
835  for (auto &C : Conversions) {
836  if (!C.isInitialized()) return false;
837  if (C.isAmbiguous()) return true;
838  }
839  return false;
840  }
841 
842  bool TryToFixBadConversion(unsigned Idx, Sema &S) {
843  bool CanFix = Fix.tryToFixConversion(
844  Conversions[Idx].Bad.FromExpr,
845  Conversions[Idx].Bad.getFromType(),
846  Conversions[Idx].Bad.getToType(), S);
847 
848  // If at least one conversion fails, the candidate cannot be fixed.
849  if (!CanFix)
850  Fix.clear();
851 
852  return CanFix;
853  }
854 
855  unsigned getNumParams() const {
856  if (IsSurrogate) {
857  QualType STy = Surrogate->getConversionType();
858  while (STy->isPointerType() || STy->isReferenceType())
859  STy = STy->getPointeeType();
860  return STy->castAs<FunctionProtoType>()->getNumParams();
861  }
862  if (Function)
863  return Function->getNumParams();
864  return ExplicitCallArguments;
865  }
866 
867  private:
868  friend class OverloadCandidateSet;
870  : IsADLCandidate(CallExpr::NotADL), RewriteKind(CRK_None) {}
871  };
872 
873  /// OverloadCandidateSet - A set of overload candidates, used in C++
874  /// overload resolution (C++ 13.3).
876  public:
878  /// Normal lookup.
880 
881  /// C++ [over.match.oper]:
882  /// Lookup of operator function candidates in a call using operator
883  /// syntax. Candidates that have no parameters of class type will be
884  /// skipped unless there is a parameter of (reference to) enum type and
885  /// the corresponding argument is of the same enum type.
887 
888  /// C++ [over.match.copy]:
889  /// Copy-initialization of an object of class type by user-defined
890  /// conversion.
892 
893  /// C++ [over.match.ctor], [over.match.list]
894  /// Initialization of an object of class type by constructor,
895  /// using either a parenthesized or braced list of arguments.
897  };
898 
899  /// Information about operator rewrites to consider when adding operator
900  /// functions to a candidate set.
903  : OriginalOperator(OO_None), AllowRewrittenCandidates(false) {}
905  : OriginalOperator(Op), AllowRewrittenCandidates(AllowRewritten) {}
906 
907  /// The original operator as written in the source.
909  /// Whether we should include rewritten candidates in the overload set.
911 
912  /// Would use of this function result in a rewrite using a different
913  /// operator?
915  return OriginalOperator &&
916  FD->getDeclName().getCXXOverloadedOperator() != OriginalOperator;
917  }
918 
920  return AllowRewrittenCandidates || !isRewrittenOperator(FD);
921  }
922 
923  /// Determine the kind of rewrite that should be performed for this
924  /// candidate.
928  if (isRewrittenOperator(FD))
932  return CRK;
933  }
934 
935  /// Determine whether we should consider looking for and adding reversed
936  /// candidates for operator Op.
937  bool shouldAddReversed(OverloadedOperatorKind Op);
938 
939  /// Determine whether we should add a rewritten candidate for \p FD with
940  /// reversed parameter order.
941  bool shouldAddReversed(ASTContext &Ctx, const FunctionDecl *FD);
942  };
943 
944  private:
946  llvm::SmallPtrSet<uintptr_t, 16> Functions;
947 
948  // Allocator for ConversionSequenceLists. We store the first few of these
949  // inline to avoid allocation for small sets.
950  llvm::BumpPtrAllocator SlabAllocator;
951 
952  SourceLocation Loc;
954  OperatorRewriteInfo RewriteInfo;
955 
956  constexpr static unsigned NumInlineBytes =
957  24 * sizeof(ImplicitConversionSequence);
958  unsigned NumInlineBytesUsed = 0;
959  alignas(void *) char InlineSpace[NumInlineBytes];
960 
961  // Address space of the object being constructed.
962  LangAS DestAS = LangAS::Default;
963 
964  /// If we have space, allocates from inline storage. Otherwise, allocates
965  /// from the slab allocator.
966  /// FIXME: It would probably be nice to have a SmallBumpPtrAllocator
967  /// instead.
968  /// FIXME: Now that this only allocates ImplicitConversionSequences, do we
969  /// want to un-generalize this?
970  template <typename T>
971  T *slabAllocate(unsigned N) {
972  // It's simpler if this doesn't need to consider alignment.
973  static_assert(alignof(T) == alignof(void *),
974  "Only works for pointer-aligned types.");
975  static_assert(std::is_trivial<T>::value ||
976  std::is_same<ImplicitConversionSequence, T>::value,
977  "Add destruction logic to OverloadCandidateSet::clear().");
978 
979  unsigned NBytes = sizeof(T) * N;
980  if (NBytes > NumInlineBytes - NumInlineBytesUsed)
981  return SlabAllocator.Allocate<T>(N);
982  char *FreeSpaceStart = InlineSpace + NumInlineBytesUsed;
983  assert(uintptr_t(FreeSpaceStart) % alignof(void *) == 0 &&
984  "Misaligned storage!");
985 
986  NumInlineBytesUsed += NBytes;
987  return reinterpret_cast<T *>(FreeSpaceStart);
988  }
989 
990  void destroyCandidates();
991 
992  public:
994  OperatorRewriteInfo RewriteInfo = {})
995  : Loc(Loc), Kind(CSK), RewriteInfo(RewriteInfo) {}
996  OverloadCandidateSet(const OverloadCandidateSet &) = delete;
997  OverloadCandidateSet &operator=(const OverloadCandidateSet &) = delete;
998  ~OverloadCandidateSet() { destroyCandidates(); }
999 
1000  SourceLocation getLocation() const { return Loc; }
1001  CandidateSetKind getKind() const { return Kind; }
1002  OperatorRewriteInfo getRewriteInfo() const { return RewriteInfo; }
1003 
1004  /// Determine when this overload candidate will be new to the
1005  /// overload set.
1008  uintptr_t Key = reinterpret_cast<uintptr_t>(F->getCanonicalDecl());
1009  Key |= static_cast<uintptr_t>(PO);
1010  return Functions.insert(Key).second;
1011  }
1012 
1013  /// Clear out all of the candidates.
1014  void clear(CandidateSetKind CSK);
1015 
1017 
1018  iterator begin() { return Candidates.begin(); }
1019  iterator end() { return Candidates.end(); }
1020 
1021  size_t size() const { return Candidates.size(); }
1022  bool empty() const { return Candidates.empty(); }
1023 
1024  /// Allocate storage for conversion sequences for NumConversions
1025  /// conversions.
1027  allocateConversionSequences(unsigned NumConversions) {
1028  ImplicitConversionSequence *Conversions =
1029  slabAllocate<ImplicitConversionSequence>(NumConversions);
1030 
1031  // Construct the new objects.
1032  for (unsigned I = 0; I != NumConversions; ++I)
1033  new (&Conversions[I]) ImplicitConversionSequence();
1034 
1035  return ConversionSequenceList(Conversions, NumConversions);
1036  }
1037 
1038  /// Add a new candidate with NumConversions conversion sequence slots
1039  /// to the overload set.
1040  OverloadCandidate &addCandidate(unsigned NumConversions = 0,
1041  ConversionSequenceList Conversions = None) {
1042  assert((Conversions.empty() || Conversions.size() == NumConversions) &&
1043  "preallocated conversion sequence has wrong length");
1044 
1045  Candidates.push_back(OverloadCandidate());
1046  OverloadCandidate &C = Candidates.back();
1047  C.Conversions = Conversions.empty()
1048  ? allocateConversionSequences(NumConversions)
1049  : Conversions;
1050  return C;
1051  }
1052 
1053  /// Find the best viable function on this overload set, if it exists.
1054  OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc,
1056 
1057  SmallVector<OverloadCandidate *, 32> CompleteCandidates(
1059  SourceLocation OpLoc = SourceLocation(),
1060  llvm::function_ref<bool(OverloadCandidate &)> Filter =
1061  [](OverloadCandidate &) { return true; });
1062 
1063  void NoteCandidates(
1065  ArrayRef<Expr *> Args, StringRef Opc = "",
1067  llvm::function_ref<bool(OverloadCandidate &)> Filter =
1068  [](OverloadCandidate &) { return true; });
1069 
1070  void NoteCandidates(Sema &S, ArrayRef<Expr *> Args,
1072  StringRef Opc = "",
1073  SourceLocation OpLoc = SourceLocation());
1074 
1075  LangAS getDestAS() { return DestAS; }
1076 
1077  void setDestAS(LangAS AS) {
1078  assert((Kind == CSK_InitByConstructor ||
1079  Kind == CSK_InitByUserDefinedConversion) &&
1080  "can't set the destination address space when not constructing an "
1081  "object");
1082  DestAS = AS;
1083  }
1084 
1085  };
1086 
1088  const OverloadCandidate &Cand1,
1089  const OverloadCandidate &Cand2,
1090  SourceLocation Loc,
1092 
1097 
1098  explicit operator bool() const { return Constructor; }
1099  };
1100 
1101  // FIXME: Add an AddOverloadCandidate / AddTemplateOverloadCandidate overload
1102  // that takes one of these.
1104  if (isa<UsingDecl>(ND))
1105  return ConstructorInfo{};
1106 
1107  // For constructors, the access check is performed against the underlying
1108  // declaration, not the found declaration.
1109  auto *D = ND->getUnderlyingDecl();
1110  ConstructorInfo Info = {DeclAccessPair::make(ND, D->getAccess()), nullptr,
1111  nullptr};
1112  Info.ConstructorTmpl = dyn_cast<FunctionTemplateDecl>(D);
1113  if (Info.ConstructorTmpl)
1114  D = Info.ConstructorTmpl->getTemplatedDecl();
1115  Info.Constructor = dyn_cast<CXXConstructorDecl>(D);
1116  return Info;
1117  }
1118 
1119 } // namespace clang
1120 
1121 #endif // LLVM_CLANG_SEMA_OVERLOAD_H
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
Definition: Overload.h:820
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
Definition: Overload.h:406
Function pointer conversion (C++17 [conv.fctptr])
Definition: Overload.h:116
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
Definition: Overload.h:273
(CUDA) This candidate was not viable because the callee was not accessible from the caller&#39;s target (...
Definition: Overload.h:726
This candidate constructor or conversion fonction is used implicitly but the explicit(bool) specifier...
Definition: Overload.h:735
void setFromType(QualType T)
Definition: Overload.h:502
Represents a function declaration or definition.
Definition: Decl.h:1784
void setStdInitializerListElement(bool V=true)
Definition: Overload.h:673
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ...
Definition: Overload.h:387
A (possibly-)qualified type.
Definition: Type.h:643
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter&#39;s...
Definition: Overload.h:102
void setFromType(QualType T)
Definition: Overload.h:327
Candidate is not a rewritten candidate.
Definition: Overload.h:89
Conversion not allowed by the C standard, but that we accept as an extension anyway.
Definition: Overload.h:219
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition: Overload.h:760
Information about operator rewrites to consider when adding operator functions to a candidate set...
Definition: Overload.h:901
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Definition: Overload.h:82
A structure used to record information about a failed template argument deduction, for diagnosis.
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
Definition: Overload.h:242
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:557
Vector conversions.
Definition: Overload.h:158
C Language Family Type Representation.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
ConversionSet::const_iterator const_iterator
Definition: Overload.h:448
Complex conversions (C99 6.3.1.6)
Definition: Overload.h:137
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
Definition: Overload.h:553
ConstructorInfo getConstructorInfo(NamedDecl *ND)
Definition: Overload.h:1103
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
Defines the C++ template declaration subclasses.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Not a narrowing conversion.
Definition: Overload.h:228
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
Definition: Overload.h:195
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
Definition: Overload.h:281
virtual void clear()
Ambiguous candidates found.
Definition: Overload.h:59
Conversions between compatible types in C99.
Definition: Overload.h:152
bool IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument&#39;s conversion, which for this function...
Definition: Overload.h:806
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Definition: DeclCXX.h:2727
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl...
Definition: Overload.h:289
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2365
Exact Match.
Definition: Overload.h:197
bool hasAmbiguousConversion() const
hasAmbiguousConversion - Returns whether this overload candidate requires an ambiguous conversion or ...
Definition: Overload.h:834
QualType getFromType() const
Definition: Overload.h:340
OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK, OperatorRewriteInfo RewriteInfo={})
Definition: Overload.h:993
bool IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
Definition: Overload.h:797
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:25
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:439
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
Definition: Overload.h:392
Conversion.
Definition: Overload.h:203
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions=None)
Add a new candidate with NumConversions conversion sequence slots to the overload set...
Definition: Overload.h:1040
ImplicitConversionSequence(const ImplicitConversionSequence &Other)
Definition: Overload.h:569
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:297
Boolean conversions (C++ [conv.bool])
Definition: Overload.h:149
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:160
unsigned BindsToFunctionLvalue
Whether we&#39;re binding to a function lvalue.
Definition: Overload.h:296
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion...
Definition: Overload.h:891
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion. ...
Definition: Overload.h:561
Identity conversion (no conversion)
Definition: Overload.h:104
CallExpr::ADLCallKind IsADLCandidate
True if the candidate was found using ADL.
Definition: Overload.h:809
bool isStdInitializerListElement() const
Whether the target is really a std::initializer_list, and the sequence only represents the worst elem...
Definition: Overload.h:669
Kind
Kind - The kind of implicit conversion sequence.
Definition: Overload.h:516
ConversionSet & conversions()
Definition: Overload.h:431
BadConversionSequence - Records information about an invalid conversion sequence. ...
Definition: Overload.h:460
bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
Determine when this overload candidate will be new to the overload set.
Definition: Overload.h:1006
Floating point conversions (C++ [conv.double].
Definition: Overload.h:134
bool isReferenceType() const
Definition: Type.h:6403
OverloadCandidateRewriteKind RewriteKind
Whether this is a rewritten candidate, and if so, of what kind?
Definition: Overload.h:812
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
Definition: Overload.h:1027
OverloadCandidateDisplayKind
Definition: Overload.h:65
Floating point promotions (C++ [conv.fpprom])
Definition: Overload.h:125
bool isInitialized() const
Determines whether this conversion sequence has been initialized.
Definition: Overload.h:634
OverloadCandidateRewriteKind getRewriteKind(const FunctionDecl *FD, OverloadCandidateParamOrder PO)
Determine the kind of rewrite that should be performed for this candidate.
Definition: Overload.h:926
unsigned BindsToRvalue
Whether we&#39;re binding to an rvalue.
Definition: Overload.h:299
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void setDestAS(LangAS AS)
Definition: Overload.h:1077
Succeeded, but refers to a deleted function.
Definition: Overload.h:62
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
ImplicitConversionSequence & operator=(const ImplicitConversionSequence &Other)
Definition: Overload.h:583
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
Definition: Overload.h:277
QualType getToType(unsigned Idx) const
Definition: Overload.h:344
This candidate function was not viable because an enable_if attribute disabled it.
Definition: Overload.h:730
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
Definition: Overload.h:264
A narrowing conversion, because a constant expression got narrowed.
Definition: Overload.h:234
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it&#39;s an rvalue reference binding).
Definition: Overload.h:293
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
Definition: Overload.h:226
Qualification conversions (C++ [conv.qual])
Definition: Overload.h:119
void * getAsOpaquePtr() const
Definition: Type.h:688
The number of conversion kinds.
Definition: Overload.h:188
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion or a function conversion.
Definition: Overload.h:268
Complex <-> Real conversion.
Definition: Overload.h:209
bool Viable
Viable - True to indicate that this overload candidate is viable.
Definition: Overload.h:792
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
Definition: Overload.h:786
Integral promotions (C++ [conv.prom])
Definition: Overload.h:122
This conversion function template specialization candidate is not viable because the final conversion...
Definition: Overload.h:721
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:877
void setAsIdentityConversion(QualType T)
Definition: Overload.h:660
C-only conversion between pointers with incompatible types.
Definition: Overload.h:185
DeclAccessPair FoundDecl
Definition: Overload.h:1094
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:331
bool AllowRewrittenCandidates
Whether we should include rewritten candidates in the overload set.
Definition: Overload.h:910
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3725
Transparent Union Conversions.
Definition: Overload.h:170
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
Definition: Overload.h:702
CandidateSetKind getKind() const
Definition: Overload.h:1001
A narrowing conversion by virtue of the source and destination types.
Definition: Overload.h:231
Promotion.
Definition: Overload.h:200
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl), the standard conversion that occurs after the call to the overload candidate to convert the result of calling the conversion function to the required type.
Definition: Overload.h:829
ObjC ARC writeback conversion.
Definition: Overload.h:212
OverloadedOperatorKind OriginalOperator
The original operator as written in the source.
Definition: Overload.h:908
OpenCL Scalar Widening.
Definition: Overload.h:206
This represents one expression.
Definition: Expr.h:108
Represents an ambiguous user-defined conversion sequence.
Definition: Overload.h:412
This candidate was not viable because it is a non-default multiversioned function.
Definition: Overload.h:749
This inherited constructor is not viable because it would slice the argument.
Definition: Overload.h:745
Candidate is a rewritten candidate with a reversed order of parameters.
Definition: Overload.h:95
SourceLocation getLocation() const
Definition: Overload.h:1000
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
Definition: Overload.h:396
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:6923
#define V(N, I)
Definition: ASTContext.h:2921
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:62
Zero constant to queue.
Definition: Overload.h:179
#define bool
Definition: stdbool.h:15
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
Definition: Overload.h:324
Overload resolution succeeded.
Definition: Overload.h:53
unsigned ReferenceBinding
ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
Definition: Overload.h:285
Floating-integral conversions (C++ [conv.fpint])
Definition: Overload.h:140
void init(FailureKind K, Expr *From, QualType To)
Definition: Overload.h:482
OperatorRewriteInfo(OverloadedOperatorKind Op, bool AllowRewritten)
Definition: Overload.h:904
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
Definition: Overload.h:713
bool TryToFixBadConversion(unsigned Idx, Sema &S)
Definition: Overload.h:842
QualType getType() const
Definition: Expr.h:137
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
Definition: Overload.h:781
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13...
Definition: Overload.h:367
This candidate was not viable because its address could not be taken.
Definition: Overload.h:738
const ConversionSet & conversions() const
Definition: Overload.h:435
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
Definition: Overload.h:549
bool isRewrittenOperator(const FunctionDecl *FD)
Would use of this function result in a rewrite using a different operator?
Definition: Overload.h:914
bool isAcceptableCandidate(const FunctionDecl *FD)
Definition: Overload.h:919
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2690
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
Definition: Overload.h:87
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
Definition: Overload.h:238
QualType getFromType() const
Definition: Overload.h:494
Lvalue-to-rvalue conversion (C++ [conv.lval])
Definition: Overload.h:107
OverloadFailureKind
Definition: Overload.h:693
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier...
Definition: Overload.h:307
CXXConstructorDecl * Constructor
Definition: Overload.h:1095
llvm::cl::opt< std::string > Filter
Integral conversions (C++ [conv.integral])
Definition: Overload.h:131
SmallVectorImpl< OverloadCandidate >::iterator iterator
Definition: Overload.h:1016
Complex promotions (Clang extension)
Definition: Overload.h:128
#define false
Definition: stdbool.h:17
Kind
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Definition: Overload.h:510
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Definition: Overload.h:763
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor...
Definition: Overload.h:896
ConversionSet::iterator iterator
Definition: Overload.h:443
A vector splat from an arithmetic type.
Definition: Overload.h:161
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
Definition: Overload.h:51
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
Objective-C ARC writeback conversion.
Definition: Overload.h:173
OperatorRewriteInfo getRewriteInfo() const
Definition: Overload.h:1002
void init(FailureKind K, QualType From, QualType To)
Definition: Overload.h:487
Pointer conversions (C++ [conv.ptr])
Definition: Overload.h:143
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax...
Definition: Overload.h:886
Requests that all candidates be shown.
Definition: Overload.h:68
Derived-to-base (C++ [over.best.ics])
Definition: Overload.h:155
Complex-real conversions (C99 6.3.1.7)
Definition: Overload.h:164
This constructor/conversion candidate fail due to an address space mismatch between the object being ...
Definition: Overload.h:754
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
Definition: Overload.h:875
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
Definition: Overload.h:637
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:690
void setFromExpr(Expr *E)
Definition: Overload.h:497
unsigned getNumParams() const
Definition: Overload.h:855
A POD class for pairing a NamedDecl* with an access specifier.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
DeclAccessPair FoundCopyConstructor
Definition: Overload.h:325
Dataflow Directional Tag Classes.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
AccessSpecifier getAccess() const
Definition: DeclBase.h:473
Conversions allowed in C, but not C++.
Definition: Overload.h:182
Array-to-pointer conversion (C++ [conv.array])
Definition: Overload.h:110
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
Definition: Overload.h:379
Requests that only viable candidates be shown.
Definition: Overload.h:71
FunctionDecl * Function
Function - The actual function that this candidate represents.
Definition: Overload.h:768
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
Definition: Overload.h:401
Conversion only allowed in the C standard (e.g. void* to char*).
Definition: Overload.h:215
void setToType(QualType T)
Definition: Overload.h:503
Not an overloaded operator.
Definition: OperatorKinds.h:22
void setAllToTypes(QualType T)
Definition: Overload.h:334
Candidate is a rewritten candidate with a different operator name.
Definition: Overload.h:92
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
Definition: Overload.h:605
This candidate was not viable because its OpenCL extension is disabled.
Definition: Overload.h:741
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
Definition: Overload.h:303
unsigned char FailureKind
FailureKind - The reason why this candidate is not viable.
Definition: Overload.h:816
void setBad(BadConversionSequence::FailureKind Failure, QualType FromType, QualType ToType)
Sets this sequence as a bad conversion for an implicit argument.
Definition: Overload.h:644
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found, together with its access.
Definition: Overload.h:773
Block Pointer conversions.
Definition: Overload.h:167
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:115
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
Definition: Overload.h:789
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion...
Definition: Overload.h:557
void addConversion(NamedDecl *Found, FunctionDecl *D)
Definition: Overload.h:439
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Function-to-pointer (C++ [conv.array])
Definition: Overload.h:113
Defines the clang::SourceLocation class and associated facilities.
QualType getToType() const
Definition: Overload.h:495
FunctionTemplateDecl * ConstructorTmpl
Definition: Overload.h:1096
const_iterator begin() const
Definition: Overload.h:450
void * FromTypePtr
FromType - The type that this conversion is converting from.
Definition: Overload.h:312
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2521
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:945
The class facilities generation and storage of conversion FixIts.
bool isPointerType() const
Definition: Type.h:6391
Zero constant to event (OpenCL1.2 6.12.10)
Definition: Overload.h:176
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
Definition: Overload.h:258
No viable function found.
Definition: Overload.h:56
DeductionFailureInfo DeductionFailure
Definition: Overload.h:823
This represents a decl that may have a name.
Definition: Decl.h:248
Pointer-to-member conversions (C++ [conv.mem])
Definition: Overload.h:146
void setToType(unsigned Idx, QualType T)
Definition: Overload.h:329
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Definition: Decl.cpp:3178
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
Definition: Overload.h:717
const_iterator end() const
Definition: Overload.h:451
Declaration of a template function.
Definition: DeclTemplate.h:961
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
Definition: Overload.h:253