19 #include "llvm/ADT/SmallVector.h" 21 using namespace clang;
24 assert(
VD &&
"must have var decl");
54 auto It = llvm::find_if(
55 Objects, [&](
ValueInfo const &Info) {
return Info.
Kind == ValueKind; });
56 if (It != Objects.end())
63 if (Lookup.
size() != 1 || !isa<VarDecl>(Lookup.
front()))
65 Objects.emplace_back(ValueKind, cast<VarDecl>(Lookup.
front()));
66 return &Objects.
back();
74 if (Lookup.
size() == 1)
75 StdNS = dyn_cast<NamespaceDecl>(Lookup.
front());
85 if (Lookup.
size() == 1)
93 auto It = Data.find(static_cast<char>(Kind));
99 return &Data.try_emplace((
char)Kind, Ctx, RD, Kind).first->second;
105 ComparisonCategories::lookupInfoForType(
QualType Ty)
const {
106 assert(!Ty.
isNull() &&
"type must be non-null");
114 for (
auto &KV : Data) {
120 if (!RD->getEnclosingNamespaceContext()->isStdNamespace())
125 for (
unsigned I = static_cast<unsigned>(
CCT::First),
128 CCT
Kind =
static_cast<CCT
>(I);
132 if (getCategoryString(Kind) == RD->getName())
133 return &Data.try_emplace((
char)Kind, Ctx, RD, Kind).first->second;
142 assert(Info &&
"info for comparison category not found");
155 return "weak_equality";
157 return "strong_equality";
159 return "partial_ordering";
161 return "weak_ordering";
163 return "strong_ordering";
165 llvm_unreachable(
"unhandled cases in switch");
178 return "nonequivalent";
186 llvm_unreachable(
"unhandled case in switch");
189 std::vector<ComparisonCategoryResult>
193 std::vector<CCR> Values;
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
A (possibly-)qualified type.
static CXXRecordDecl * lookupCXXRecordDecl(const ASTContext &Ctx, const NamespaceDecl *StdNS, ComparisonCategoryType Kind)
C Language Family Type Representation.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
Represent a C++ namespace.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
static std::vector< ComparisonCategoryResult > getPossibleResultsForType(ComparisonCategoryType Type)
Return the list of results which are valid for the specified comparison category type.
static StringRef getResultString(ComparisonCategoryResult Kind)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
field_iterator field_begin() const
const ComparisonCategoryInfo & getInfoForType(QualType Ty) const
Return the comparison category information as specified by getCategoryForType(Ty).
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
static StringRef getCategoryString(ComparisonCategoryType Kind)
llvm::APSInt getIntValue() const
Get the constant integer value used by this variable to represent the comparison category result type...
field_iterator field_end() const
APValue & getStructField(unsigned i)
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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.
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
Dataflow Directional Tag Classes.
static const NamespaceDecl * lookupStdNamespace(const ASTContext &Ctx, NamespaceDecl *&StdNS)
CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TranslationUnitDecl * getTranslationUnitDecl() const
Represents a C++ struct/union/class.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
ComparisonCategoryResult Kind