clang 19.0.0git
PtrTypesSemantics.cpp
Go to the documentation of this file.
1//=======- PtrTypesSemantics.cpp ---------------------------------*- C++ -*-==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "PtrTypesSemantics.h"
10#include "ASTUtils.h"
12#include "clang/AST/Decl.h"
13#include "clang/AST/DeclCXX.h"
14#include "clang/AST/ExprCXX.h"
16#include <optional>
17
18using namespace clang;
19
20namespace {
21
22bool hasPublicMethodInBaseClass(const CXXRecordDecl *R,
23 const char *NameToMatch) {
24 assert(R);
25 assert(R->hasDefinition());
26
27 for (const CXXMethodDecl *MD : R->methods()) {
28 const auto MethodName = safeGetName(MD);
29 if (MethodName == NameToMatch && MD->getAccess() == AS_public)
30 return true;
31 }
32 return false;
33}
34
35} // namespace
36
37namespace clang {
38
39std::optional<const clang::CXXRecordDecl *>
40hasPublicMethodInBase(const CXXBaseSpecifier *Base, const char *NameToMatch) {
41 assert(Base);
42
43 const Type *T = Base->getType().getTypePtrOrNull();
44 if (!T)
45 return std::nullopt;
46
48 if (!R)
49 return std::nullopt;
50 if (!R->hasDefinition())
51 return std::nullopt;
52
53 return hasPublicMethodInBaseClass(R, NameToMatch) ? R : nullptr;
54}
55
56std::optional<bool> isRefCountable(const CXXRecordDecl* R)
57{
58 assert(R);
59
60 R = R->getDefinition();
61 if (!R)
62 return std::nullopt;
63
64 bool hasRef = hasPublicMethodInBaseClass(R, "ref");
65 bool hasDeref = hasPublicMethodInBaseClass(R, "deref");
66 if (hasRef && hasDeref)
67 return true;
68
69 CXXBasePaths Paths;
70 Paths.setOrigin(const_cast<CXXRecordDecl *>(R));
71
72 bool AnyInconclusiveBase = false;
73 const auto hasPublicRefInBase =
74 [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
75 auto hasRefInBase = clang::hasPublicMethodInBase(Base, "ref");
76 if (!hasRefInBase) {
77 AnyInconclusiveBase = true;
78 return false;
79 }
80 return (*hasRefInBase) != nullptr;
81 };
82
83 hasRef = hasRef || R->lookupInBases(hasPublicRefInBase, Paths,
84 /*LookupInDependent =*/true);
85 if (AnyInconclusiveBase)
86 return std::nullopt;
87
88 Paths.clear();
89 const auto hasPublicDerefInBase =
90 [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
91 auto hasDerefInBase = clang::hasPublicMethodInBase(Base, "deref");
92 if (!hasDerefInBase) {
93 AnyInconclusiveBase = true;
94 return false;
95 }
96 return (*hasDerefInBase) != nullptr;
97 };
98 hasDeref = hasDeref || R->lookupInBases(hasPublicDerefInBase, Paths,
99 /*LookupInDependent =*/true);
100 if (AnyInconclusiveBase)
101 return std::nullopt;
102
103 return hasRef && hasDeref;
104}
105
106bool isRefType(const std::string &Name) {
107 return Name == "Ref" || Name == "RefAllowingPartiallyDestroyed" ||
108 Name == "RefPtr" || Name == "RefPtrAllowingPartiallyDestroyed";
109}
110
112 assert(F);
113 const std::string &FunctionName = safeGetName(F);
114
115 return isRefType(FunctionName) || FunctionName == "makeRef" ||
116 FunctionName == "makeRefPtr" || FunctionName == "UniqueRef" ||
117 FunctionName == "makeUniqueRef" ||
118 FunctionName == "makeUniqueRefWithoutFastMallocCheck"
119
120 || FunctionName == "String" || FunctionName == "AtomString" ||
121 FunctionName == "UniqueString"
122 // FIXME: Implement as attribute.
123 || FunctionName == "Identifier";
124}
125
127 assert(F);
129 while (!type.isNull()) {
130 if (auto *elaboratedT = type->getAs<ElaboratedType>()) {
131 type = elaboratedT->desugar();
132 continue;
133 }
134 if (auto *specialT = type->getAs<TemplateSpecializationType>()) {
135 if (auto *decl = specialT->getTemplateName().getAsTemplateDecl()) {
136 auto name = decl->getNameAsString();
137 return isRefType(name);
138 }
139 return false;
140 }
141 return false;
142 }
143 return false;
144}
145
146std::optional<bool> isUncounted(const CXXRecordDecl* Class)
147{
148 // Keep isRefCounted first as it's cheaper.
149 if (isRefCounted(Class))
150 return false;
151
152 std::optional<bool> IsRefCountable = isRefCountable(Class);
153 if (!IsRefCountable)
154 return std::nullopt;
155
156 return (*IsRefCountable);
157}
158
159std::optional<bool> isUncountedPtr(const Type* T)
160{
161 assert(T);
162
163 if (T->isPointerType() || T->isReferenceType()) {
164 if (auto *CXXRD = T->getPointeeCXXRecordDecl()) {
165 return isUncounted(CXXRD);
166 }
167 }
168 return false;
169}
170
171std::optional<bool> isGetterOfRefCounted(const CXXMethodDecl* M)
172{
173 assert(M);
174
175 if (isa<CXXMethodDecl>(M)) {
176 const CXXRecordDecl *calleeMethodsClass = M->getParent();
177 auto className = safeGetName(calleeMethodsClass);
178 auto method = safeGetName(M);
179
180 if ((isRefType(className) && (method == "get" || method == "ptr")) ||
181 ((className == "String" || className == "AtomString" ||
182 className == "AtomStringImpl" || className == "UniqueString" ||
183 className == "UniqueStringImpl" || className == "Identifier") &&
184 method == "impl"))
185 return true;
186
187 // Ref<T> -> T conversion
188 // FIXME: Currently allowing any Ref<T> -> whatever cast.
189 if (isRefType(className)) {
190 if (auto *maybeRefToRawOperator = dyn_cast<CXXConversionDecl>(M)) {
191 if (auto *targetConversionType =
192 maybeRefToRawOperator->getConversionType().getTypePtrOrNull()) {
193 return isUncountedPtr(targetConversionType);
194 }
195 }
196 }
197 }
198 return false;
199}
200
202 assert(R);
203 if (auto *TmplR = R->getTemplateInstantiationPattern()) {
204 // FIXME: String/AtomString/UniqueString
205 const auto &ClassName = safeGetName(TmplR);
206 return isRefType(ClassName);
207 }
208 return false;
209}
210
212 assert(F);
213 if (isCtorOfRefCounted(F))
214 return true;
215
216 // FIXME: check # of params == 1
217 const auto FunctionName = safeGetName(F);
218 if (FunctionName == "getPtr" || FunctionName == "WeakPtr" ||
219 FunctionName == "dynamicDowncast" || FunctionName == "downcast" ||
220 FunctionName == "checkedDowncast" ||
221 FunctionName == "uncheckedDowncast" || FunctionName == "bitwise_cast")
222 return true;
223
224 return false;
225}
226
227bool isSingleton(const FunctionDecl *F) {
228 assert(F);
229 // FIXME: check # of params == 1
230 if (auto *MethodDecl = dyn_cast<CXXMethodDecl>(F)) {
231 if (!MethodDecl->isStatic())
232 return false;
233 }
234 const auto &Name = safeGetName(F);
235 std::string SingletonStr = "singleton";
236 auto index = Name.find(SingletonStr);
237 return index != std::string::npos &&
238 index == Name.size() - SingletonStr.size();
239}
240
241// We only care about statements so let's use the simple
242// (non-recursive) visitor.
244 : public ConstStmtVisitor<TrivialFunctionAnalysisVisitor, bool> {
245
246 // Returns false if at least one child is non-trivial.
247 bool VisitChildren(const Stmt *S) {
248 for (const Stmt *Child : S->children()) {
249 if (Child && !Visit(Child))
250 return false;
251 }
252
253 return true;
254 }
255
256 template <typename CheckFunction>
257 bool WithCachedResult(const Stmt *S, CheckFunction Function) {
258 // If the statement isn't in the cache, conservatively assume that
259 // it's not trivial until analysis completes. Insert false to the cache
260 // first to avoid infinite recursion.
261 auto [It, IsNew] = Cache.insert(std::make_pair(S, false));
262 if (!IsNew)
263 return It->second;
264 bool Result = Function();
265 Cache[S] = Result;
266 return Result;
267 }
268
269public:
270 using CacheTy = TrivialFunctionAnalysis::CacheTy;
271
273
274 bool VisitStmt(const Stmt *S) {
275 // All statements are non-trivial unless overriden later.
276 // Don't even recurse into children by default.
277 return false;
278 }
279
281 // A compound statement is allowed as long each individual sub-statement
282 // is trivial.
283 return WithCachedResult(CS, [&]() { return VisitChildren(CS); });
284 }
285
286 bool VisitReturnStmt(const ReturnStmt *RS) {
287 // A return statement is allowed as long as the return value is trivial.
288 if (auto *RV = RS->getRetValue())
289 return Visit(RV);
290 return true;
291 }
292
293 bool VisitDeclStmt(const DeclStmt *DS) { return VisitChildren(DS); }
294 bool VisitDoStmt(const DoStmt *DS) { return VisitChildren(DS); }
295 bool VisitIfStmt(const IfStmt *IS) {
296 return WithCachedResult(IS, [&]() { return VisitChildren(IS); });
297 }
298 bool VisitForStmt(const ForStmt *FS) {
299 return WithCachedResult(FS, [&]() { return VisitChildren(FS); });
300 }
302 return WithCachedResult(FS, [&]() { return VisitChildren(FS); });
303 }
304 bool VisitWhileStmt(const WhileStmt *WS) {
305 return WithCachedResult(WS, [&]() { return VisitChildren(WS); });
306 }
307 bool VisitSwitchStmt(const SwitchStmt *SS) { return VisitChildren(SS); }
308 bool VisitCaseStmt(const CaseStmt *CS) { return VisitChildren(CS); }
309 bool VisitDefaultStmt(const DefaultStmt *DS) { return VisitChildren(DS); }
310
312 // Operator '*' and '!' are allowed as long as the operand is trivial.
313 auto op = UO->getOpcode();
314 if (op == UO_Deref || op == UO_AddrOf || op == UO_LNot)
315 return Visit(UO->getSubExpr());
316
317 if (UO->isIncrementOp() || UO->isDecrementOp()) {
318 // Allow increment or decrement of a POD type.
319 if (auto *RefExpr = dyn_cast<DeclRefExpr>(UO->getSubExpr())) {
320 if (auto *Decl = dyn_cast<VarDecl>(RefExpr->getDecl()))
321 return Decl->isLocalVarDeclOrParm() &&
322 Decl->getType().isPODType(Decl->getASTContext());
323 }
324 }
325 // Other operators are non-trivial.
326 return false;
327 }
328
330 // Binary operators are trivial if their operands are trivial.
331 return Visit(BO->getLHS()) && Visit(BO->getRHS());
332 }
333
335 // Ternary operators are trivial if their conditions & values are trivial.
336 return VisitChildren(CO);
337 }
338
339 bool VisitAtomicExpr(const AtomicExpr *E) { return VisitChildren(E); }
340
342 // Any static_assert is considered trivial.
343 return true;
344 }
345
346 bool VisitCallExpr(const CallExpr *CE) {
347 if (!checkArguments(CE))
348 return false;
349
350 auto *Callee = CE->getDirectCallee();
351 if (!Callee)
352 return false;
353 const auto &Name = safeGetName(Callee);
354
355 if (Name == "WTFCrashWithInfo" || Name == "WTFBreakpointTrap" ||
356 Name == "WTFReportAssertionFailure" ||
357 Name == "compilerFenceForCrash" || Name == "__builtin_unreachable")
358 return true;
359
360 return TrivialFunctionAnalysis::isTrivialImpl(Callee, Cache);
361 }
362
364 // A predefined identifier such as "func" is considered trivial.
365 return true;
366 }
367
369 if (!checkArguments(MCE))
370 return false;
371
372 bool TrivialThis = Visit(MCE->getImplicitObjectArgument());
373 if (!TrivialThis)
374 return false;
375
376 auto *Callee = MCE->getMethodDecl();
377 if (!Callee)
378 return false;
379
380 std::optional<bool> IsGetterOfRefCounted = isGetterOfRefCounted(Callee);
381 if (IsGetterOfRefCounted && *IsGetterOfRefCounted)
382 return true;
383
384 // Recursively descend into the callee to confirm that it's trivial as well.
385 return TrivialFunctionAnalysis::isTrivialImpl(Callee, Cache);
386 }
387
389 if (auto *Expr = E->getExpr()) {
390 if (!Visit(Expr))
391 return false;
392 }
393 return true;
394 }
395
396 bool checkArguments(const CallExpr *CE) {
397 for (const Expr *Arg : CE->arguments()) {
398 if (Arg && !Visit(Arg))
399 return false;
400 }
401 return true;
402 }
403
405 for (const Expr *Arg : CE->arguments()) {
406 if (Arg && !Visit(Arg))
407 return false;
408 }
409
410 // Recursively descend into the callee to confirm that it's trivial.
411 return TrivialFunctionAnalysis::isTrivialImpl(CE->getConstructor(), Cache);
412 }
413
415 return Visit(ICE->getSubExpr());
416 }
417
419 return Visit(ECE->getSubExpr());
420 }
421
423 return Visit(VMT->getSubExpr());
424 }
425
427 return Visit(EWC->getSubExpr());
428 }
429
430 bool VisitParenExpr(const ParenExpr *PE) { return Visit(PE->getSubExpr()); }
431
433 for (const Expr *Child : ILE->inits()) {
434 if (Child && !Visit(Child))
435 return false;
436 }
437 return true;
438 }
439
440 bool VisitMemberExpr(const MemberExpr *ME) {
441 // Field access is allowed but the base pointer may itself be non-trivial.
442 return Visit(ME->getBase());
443 }
444
445 bool VisitCXXThisExpr(const CXXThisExpr *CTE) {
446 // The expression 'this' is always trivial, be it explicit or implicit.
447 return true;
448 }
449
451 // nullptr is trivial.
452 return true;
453 }
454
455 bool VisitDeclRefExpr(const DeclRefExpr *DRE) {
456 // The use of a variable is trivial.
457 return true;
458 }
459
460 // Constant literal expressions are always trivial
461 bool VisitIntegerLiteral(const IntegerLiteral *E) { return true; }
462 bool VisitFloatingLiteral(const FloatingLiteral *E) { return true; }
463 bool VisitFixedPointLiteral(const FixedPointLiteral *E) { return true; }
464 bool VisitCharacterLiteral(const CharacterLiteral *E) { return true; }
465 bool VisitStringLiteral(const StringLiteral *E) { return true; }
466
468 // Constant expressions are trivial.
469 return true;
470 }
471
472private:
473 CacheTy &Cache;
474};
475
476bool TrivialFunctionAnalysis::isTrivialImpl(
477 const Decl *D, TrivialFunctionAnalysis::CacheTy &Cache) {
478 // If the function isn't in the cache, conservatively assume that
479 // it's not trivial until analysis completes. This makes every recursive
480 // function non-trivial. This also guarantees that each function
481 // will be scanned at most once.
482 auto [It, IsNew] = Cache.insert(std::make_pair(D, false));
483 if (!IsNew)
484 return It->second;
485
486 const Stmt *Body = D->getBody();
487 if (!Body)
488 return false;
489
491 bool Result = V.Visit(Body);
492 if (Result)
493 Cache[D] = true;
494
495 return Result;
496}
497
498bool TrivialFunctionAnalysis::isTrivialImpl(
499 const Stmt *S, TrivialFunctionAnalysis::CacheTy &Cache) {
500 // If the statement isn't in the cache, conservatively assume that
501 // it's not trivial until analysis completes. Unlike a function case,
502 // we don't insert an entry into the cache until Visit returns
503 // since Visit* functions themselves make use of the cache.
504
506 bool Result = V.Visit(S);
507 assert(Cache.contains(S) && "Top-level statement not properly cached!");
508 return Result;
509}
510
511} // namespace clang
#define V(N, I)
Definition: ASTContext.h:3273
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition: Expr.h:6437
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3840
Expr * getLHS() const
Definition: Expr.h:3889
Expr * getRHS() const
Definition: Expr.h:3891
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1540
arg_range arguments()
Definition: ExprCXX.h:1664
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1603
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1264
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition: StmtCXX.h:135
Represents a call to a member function that may be written either with member call syntax (e....
Definition: ExprCXX.h:176
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition: ExprCXX.cpp:673
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:654
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2057
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition: DeclCXX.h:2183
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:765
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
method_range methods() const
Definition: DeclCXX.h:660
CXXRecordDecl * getDefinition() const
Definition: DeclCXX.h:564
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Definition: DeclCXX.cpp:1929
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool hasDefinition() const
Definition: DeclCXX.h:571
Represents the this expression in C++.
Definition: ExprCXX.h:1148
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2820
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
Definition: Expr.h:2990
arg_range arguments()
Definition: Expr.h:3059
CaseStmt - Represent a case statement.
Definition: Stmt.h:1801
Expr * getSubExpr()
Definition: Expr.h:3533
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1606
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:4179
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:195
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1072
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1260
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1497
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:501
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: DeclBase.h:1079
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:2725
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:6161
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3730
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3443
This represents one expression.
Definition: Expr.h:110
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:2781
const Expr * getSubExpr() const
Definition: Expr.h:1052
Represents a function declaration or definition.
Definition: Decl.h:1971
QualType getReturnType() const
Definition: Decl.h:2755
IfStmt - This represents an if/then/else.
Definition: Stmt.h:2138
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3655
Describes an C or C++ initializer list.
Definition: Expr.h:4847
ArrayRef< Expr * > inits()
Definition: Expr.h:4887
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4686
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
Definition: ExprCXX.h:4703
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3172
Expr * getBase() const
Definition: Expr.h:3249
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:2130
const Expr * getSubExpr() const
Definition: Expr.h:2145
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1986
A (possibly-)qualified type.
Definition: Type.h:738
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3019
Expr * getRetValue()
Definition: Stmt.h:3050
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:4055
RetTy Visit(PTR(Stmt) S, ParamTys... P)
Definition: StmtVisitor.h:44
Stmt - This represents one statement.
Definition: Stmt.h:84
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1773
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2388
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:5879
bool VisitMemberExpr(const MemberExpr *ME)
bool VisitStringLiteral(const StringLiteral *E)
bool VisitStaticAssertDecl(const StaticAssertDecl *SAD)
bool VisitCXXThisExpr(const CXXThisExpr *CTE)
bool VisitUnaryOperator(const UnaryOperator *UO)
bool VisitPredefinedExpr(const PredefinedExpr *E)
bool VisitSwitchStmt(const SwitchStmt *SS)
bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E)
bool VisitFixedPointLiteral(const FixedPointLiteral *E)
bool VisitDeclRefExpr(const DeclRefExpr *DRE)
bool VisitIntegerLiteral(const IntegerLiteral *E)
bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *VMT)
bool VisitFloatingLiteral(const FloatingLiteral *E)
TrivialFunctionAnalysis::CacheTy CacheTy
bool VisitConditionalOperator(const ConditionalOperator *CO)
bool VisitCompoundStmt(const CompoundStmt *CS)
bool VisitConstantExpr(const ConstantExpr *CE)
bool VisitImplicitCastExpr(const ImplicitCastExpr *ICE)
bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E)
bool VisitExprWithCleanups(const ExprWithCleanups *EWC)
bool VisitBinaryOperator(const BinaryOperator *BO)
bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE)
bool VisitCXXForRangeStmt(const CXXForRangeStmt *FS)
bool VisitWhileStmt(const WhileStmt *WS)
bool VisitCharacterLiteral(const CharacterLiteral *E)
bool VisitInitListExpr(const InitListExpr *ILE)
bool VisitAtomicExpr(const AtomicExpr *E)
bool VisitExplicitCastExpr(const ExplicitCastExpr *ECE)
bool VisitParenExpr(const ParenExpr *PE)
bool VisitDefaultStmt(const DefaultStmt *DS)
bool VisitCXXConstructExpr(const CXXConstructExpr *CE)
bool VisitReturnStmt(const ReturnStmt *RS)
The type-property cache.
Definition: Type.cpp:4353
The base class of the type hierarchy.
Definition: Type.h:1607
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1870
bool isPointerType() const
Definition: Type.h:7402
bool isReferenceType() const
Definition: Type.h:7414
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
Definition: Type.cpp:1855
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2183
Expr * getSubExpr() const
Definition: Expr.h:2228
Opcode getOpcode() const
Definition: Expr.h:2223
static bool isIncrementOp(Opcode Op)
Definition: Expr.h:2269
static bool isDecrementOp(Opcode Op)
Definition: Expr.h:2276
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2584
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
std::optional< bool > isGetterOfRefCounted(const CXXMethodDecl *M)
std::optional< bool > isUncountedPtr(const Type *T)
bool isPtrConversion(const FunctionDecl *F)
bool isCtorOfRefCounted(const clang::FunctionDecl *F)
std::optional< bool > isUncounted(const CXXRecordDecl *Class)
std::optional< const clang::CXXRecordDecl * > hasPublicMethodInBase(const CXXBaseSpecifier *Base, const char *NameToMatch)
std::optional< bool > isRefCountable(const CXXRecordDecl *R)
@ Result
The result type of a method or function.
bool isSingleton(const FunctionDecl *F)
bool isRefCounted(const CXXRecordDecl *R)
bool isReturnValueRefCounted(const clang::FunctionDecl *F)
bool isRefType(const std::string &Name)
const FunctionProtoType * T
std::string safeGetName(const T *ASTNode)
Definition: ASTUtils.h:65
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ AS_public
Definition: Specifiers.h:121