26 if (S->getBeginLoc().isMacroID())
29 if (S->getEndLoc().isMacroID())
32 for (
const Stmt *Child : S->children())
43 if (DR && isa<EnumConstantDecl>(DR->
getDecl()))
46 for (
const Stmt *Child : S->children())
59 if (VD->isStaticLocal())
62 for (
const Stmt *Child : S->children())
71 if (isa<OffsetOfExpr>(S))
74 for (
const Stmt *Child : S->children())
82std::pair<const clang::VarDecl *, const clang::Expr *>
85 const Expr *RHS =
nullptr;
87 if (
auto Assign = dyn_cast_or_null<BinaryOperator>(S)) {
88 if (Assign->isAssignmentOp()) {
90 RHS = Assign->getRHS();
91 if (
auto DE = dyn_cast_or_null<DeclRefExpr>(Assign->getLHS()))
92 VD = dyn_cast_or_null<VarDecl>(DE->getDecl());
94 }
else if (
auto PD = dyn_cast_or_null<DeclStmt>(S)) {
96 assert(PD->isSingleDecl() &&
"We process decls one by one");
97 VD = cast<VarDecl>(PD->getSingleDecl());
101 return std::make_pair(VD, RHS);
108 if (AttrType->getAttrKind() == attr::TypeNullable)
110 else if (AttrType->getAttrKind() == attr::TypeNonNull)
124 std::vector<Token> FilteredTokens;
125 FilteredTokens.reserve(MI->
tokens().size());
127 if (!
T.isOneOf(tok::l_paren, tok::r_paren))
128 FilteredTokens.push_back(
T);
131 const Token &
T = FilteredTokens.back();
136 bool InvalidSpelling =
false;
140 StringRef ValueStr = PP.
getSpelling(
T, Buffer, &InvalidSpelling);
145 llvm::APInt IntValue;
146 constexpr unsigned AutoSenseRadix = 0;
147 if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))
151 size_t Size = FilteredTokens.size();
153 if (FilteredTokens[Size - 2].is(tok::minus))
154 IntValue = -IntValue;
157 return IntValue.getSExtValue();
162 llvm::StringMap<BinaryOperatorKind> BinOps{
163#define BINARY_OPERATION(Name, Spelling) {Spelling, BO_##Name},
164#include "clang/AST/OperationKinds.def"
166 llvm::StringMap<UnaryOperatorKind> UnOps{
167#define UNARY_OPERATION(Name, Spelling) {Spelling, UO_##Name},
168#include "clang/AST/OperationKinds.def"
172#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
175 auto BinOpIt = BinOps.find(Spelling); \
176 if (BinOpIt != BinOps.end()) \
177 return OperatorKind(BinOpIt->second); \
179 llvm_unreachable("operator was expected to be binary but is not"); \
181 auto UnOpIt = UnOps.find(Spelling); \
182 if (UnOpIt != UnOps.end()) \
183 return OperatorKind(UnOpIt->second); \
185 llvm_unreachable("operator was expected to be unary but is not"); \
188#include "clang/Basic/OperatorKinds.def"
190 llvm_unreachable(
"unexpected operator kind");
196 return State->getSVal(Ptr);
204 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC);
205 NS && NS->isStdNamespace())
Defines the clang::Preprocessor interface.
An attributed type is a type to which a type attribute has been applied.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Encapsulates the data about a macro definition (e.g.
ArrayRef< Token > tokens() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
A (possibly-)qualified type.
Stmt - This represents one statement.
Token - This structure provides full information about a lexed token.
The base class of the type hierarchy.
const T * getAs() const
Member-template getAs<specific type>'.
Represents a variable declaration or definition.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
const MemRegion * getAsRegion() const
bool containsEnum(const Stmt *S)
Nullability getNullabilityAnnotation(QualType Type)
Get nullability annotation for a given type.
bool isWithinStdNamespace(const Decl *D)
Returns true if declaration D is in std namespace or any nested namespace or class scope.
bool containsStaticLocal(const Stmt *S)
std::pair< const clang::VarDecl *, const clang::Expr * > parseAssignment(const Stmt *S)
OperatorKind operationKindFromOverloadedOperator(OverloadedOperatorKind OOK, bool IsBinary)
bool containsBuiltinOffsetOf(const Stmt *S)
std::optional< SVal > getPointeeVal(SVal PtrSVal, ProgramStateRef State)
std::optional< int > tryExpandAsInteger(StringRef Macro, const Preprocessor &PP)
Try to parse the value of a defined preprocessor macro.
bool containsMacro(const Stmt *S)
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
const FunctionProtoType * T