18 #include "llvm/ADT/SmallVector.h" 20 using namespace clang;
23 assert(
VD &&
"must have var decl");
53 auto It = llvm::find_if(
54 Objects, [&](
ValueInfo const &Info) {
return Info.
Kind == ValueKind; });
55 if (It != Objects.end())
62 if (Lookup.
size() != 1 || !isa<VarDecl>(Lookup.
front()))
64 Objects.emplace_back(ValueKind, cast<VarDecl>(Lookup.
front()));
65 return &Objects.
back();
73 if (Lookup.
size() == 1)
74 StdNS = dyn_cast<NamespaceDecl>(Lookup.
front());
84 if (Lookup.
size() == 1)
92 auto It = Data.find(static_cast<char>(Kind));
98 return &Data.try_emplace((
char)Kind, Ctx, RD, Kind).first->second;
104 ComparisonCategories::lookupInfoForType(
QualType Ty)
const {
105 assert(!Ty.
isNull() &&
"type must be non-null");
113 for (
auto &KV : Data) {
119 if (!RD->getEnclosingNamespaceContext()->isStdNamespace())
124 for (
unsigned I = static_cast<unsigned>(
CCT::First),
127 CCT
Kind =
static_cast<CCT
>(I);
131 if (getCategoryString(Kind) == RD->getName())
132 return &Data.try_emplace((
char)Kind, Ctx, RD, Kind).first->second;
141 assert(Info &&
"info for comparison category not found");
154 return "weak_equality";
156 return "strong_equality";
158 return "partial_ordering";
160 return "weak_ordering";
162 return "strong_ordering";
164 llvm_unreachable(
"unhandled cases in switch");
177 return "nonequivalent";
185 llvm_unreachable(
"unhandled case in switch");
188 std::vector<ComparisonCategoryResult>
192 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