Go to the documentation of this file.
19 #include "llvm/ADT/SmallVector.h"
21 using namespace clang;
28 return CCT::StrongOrdering;
31 return CCT::PartialOrdering;
37 return CCT::StrongOrdering;
44 assert(
VD &&
"must have var decl");
67 assert(hasValidIntValue() &&
"must have a valid value");
68 return VD->evaluateValue()->getStructField(0).getInt();
74 auto It = llvm::find_if(
75 Objects, [&](
ValueInfo const &Info) {
return Info.
Kind == ValueKind; });
76 if (It != Objects.end())
83 if (Lookup.
empty() || !isa<VarDecl>(Lookup.
front()))
85 Objects.emplace_back(ValueKind, cast<VarDecl>(Lookup.
front()));
86 return &Objects.back();
95 StdNS = dyn_cast<NamespaceDecl>(Lookup.
front());
113 auto It = Data.find(
static_cast<char>(
Kind));
114 if (It != Data.end())
119 return &Data.try_emplace((
char)
Kind, Ctx, RD,
Kind).first->second;
126 assert(!Ty.
isNull() &&
"type must be non-null");
134 for (
auto &KV : Data) {
140 if (!RD->getEnclosingNamespaceContext()->isStdNamespace())
145 for (
unsigned I =
static_cast<unsigned>(CCT::First),
146 End =
static_cast<unsigned>(CCT::Last);
148 CCT
Kind =
static_cast<CCT
>(I);
152 if (getCategoryString(
Kind) == RD->getName())
153 return &Data.try_emplace((
char)
Kind, Ctx, RD,
Kind).first->second;
162 assert(Info &&
"info for comparison category not found");
174 case CCKT::PartialOrdering:
175 return "partial_ordering";
176 case CCKT::WeakOrdering:
177 return "weak_ordering";
178 case CCKT::StrongOrdering:
179 return "strong_ordering";
181 llvm_unreachable(
"unhandled cases in switch");
189 case CCVT::Equivalent:
195 case CCVT::Unordered:
198 llvm_unreachable(
"unhandled case in switch");
201 std::vector<ComparisonCategoryResult>
205 std::vector<CCR> Values;
207 bool IsStrong =
Type == CCT::StrongOrdering;
208 Values.push_back(IsStrong ? CCR::Equal : CCR::Equivalent);
209 Values.push_back(CCR::Less);
210 Values.push_back(CCR::Greater);
211 if (
Type == CCT::PartialOrdering)
212 Values.push_back(CCR::Unordered);
Optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
ASTContext & getASTContext() const LLVM_READONLY
field_iterator field_begin() const
bool hasValidIntValue() const
True iff we've successfully evaluated the variable as a constant expression and extracted its integer...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
A (possibly-)qualified type.
const Type * getTypeForDecl() const
const ComparisonCategoryInfo & getInfoForType(QualType Ty) const
Return the comparison category information as specified by getCategoryForType(Ty).
bool isObjectPointerType() const
bool isRealFloatingType() const
Floating point categories.
llvm::APSInt getIntValue() const
Get the constant integer value used by this variable to represent the comparison category result type...
TranslationUnitDecl * getTranslationUnitDecl() const
The base class of the type hierarchy.
const CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
static std::vector< ComparisonCategoryResult > getPossibleResultsForType(ComparisonCategoryType Type)
Return the list of results which are valid for the specified comparison category type.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static const NamespaceDecl * lookupStdNamespace(const ASTContext &Ctx, NamespaceDecl *&StdNS)
ComparisonCategoryType
An enumeration representing the different comparison categories types.
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
Represents a C++ struct/union/class.
ComparisonCategoryResult Kind
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static StringRef getCategoryString(ComparisonCategoryType Kind)
field_iterator field_end() const
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
float __ovld __cnfn distance(float, float)
Returns the distance between p0 and p1.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
ComparisonCategoryType Kind
The Kind of the comparison category type.
static CXXRecordDecl * lookupCXXRecordDecl(const ASTContext &Ctx, const NamespaceDecl *StdNS, ComparisonCategoryType Kind)
The results of name lookup within a DeclContext.
static StringRef getResultString(ComparisonCategoryResult Kind)
Represent a C++ namespace.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.