diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-17 22:01:05 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-17 22:01:05 +0000 |
commit | 5ab116553171e67015f63178a3927de22400e3da (patch) | |
tree | 783c4344096e148c8bcfb1303c6b1987ccb48c44 /clang/lib/Sema/SemaOverload.h | |
parent | 8345a70c671dbd5d7dcfbd1e0e1f68fc9ed0e0c6 (diff) | |
download | bcm5719-llvm-5ab116553171e67015f63178a3927de22400e3da.tar.gz bcm5719-llvm-5ab116553171e67015f63178a3927de22400e3da.zip |
Improve our handling of user-defined conversions as part of overload
resolution. There are two sources of problems involving user-defined
conversions that this change eliminates, along with providing simpler
interfaces for checking implicit conversions:
- It eliminates a case of infinite recursion found in Boost.
- It eliminates the search for the constructor needed to copy a temporary
generated by an implicit conversion from overload
resolution. Overload resolution assumes that, if it gets a value
of the parameter's class type (or a derived class thereof), there
is a way to copy if... even if there isn't. We now model this
properly.
llvm-svn: 101680
Diffstat (limited to 'clang/lib/Sema/SemaOverload.h')
-rw-r--r-- | clang/lib/Sema/SemaOverload.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOverload.h b/clang/lib/Sema/SemaOverload.h index 2b9604ac146..5e611113083 100644 --- a/clang/lib/Sema/SemaOverload.h +++ b/clang/lib/Sema/SemaOverload.h @@ -381,6 +381,33 @@ namespace clang { assert(isInitialized() && "querying uninitialized conversion"); return Kind(ConversionKind); } + + /// \brief Return a ranking of the implicit conversion sequence + /// kind, where smaller ranks represent better conversion + /// sequences. + /// + /// In particular, this routine gives user-defined conversion + /// sequences and ambiguous conversion sequences the same rank, + /// per C++ [over.best.ics]p10. + unsigned getKindRank() const { + switch (getKind()) { + case StandardConversion: + return 0; + + case UserDefinedConversion: + case AmbiguousConversion: + return 1; + + case EllipsisConversion: + return 2; + + case BadConversion: + return 3; + } + + return 3; + } + bool isBad() const { return getKind() == BadConversion; } bool isStandard() const { return getKind() == StandardConversion; } bool isEllipsis() const { return getKind() == EllipsisConversion; } |