Skip to content

Commit 23fbaff

Browse files
[ByteCode] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) (#115809)
Note that PointerUnion::{is,get,dyn_cast} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T>
1 parent ffa45f2 commit 23fbaff

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

clang/lib/AST/ByteCode/Descriptor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ struct Descriptor final {
201201
SourceLocation getLocation() const;
202202
SourceInfo getLoc() const;
203203

204-
const Decl *asDecl() const { return Source.dyn_cast<const Decl *>(); }
205-
const Expr *asExpr() const { return Source.dyn_cast<const Expr *>(); }
204+
const Decl *asDecl() const { return dyn_cast<const Decl *>(Source); }
205+
const Expr *asExpr() const { return dyn_cast<const Expr *>(Source); }
206206
const DeclTy &getSource() const { return Source; }
207207

208208
const ValueDecl *asValueDecl() const {

clang/lib/AST/ByteCode/Function.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ class Function final {
9494

9595
/// Returns the original FunctionDecl.
9696
const FunctionDecl *getDecl() const {
97-
return Source.dyn_cast<const FunctionDecl *>();
97+
return dyn_cast<const FunctionDecl *>(Source);
9898
}
9999
const BlockExpr *getExpr() const {
100-
return Source.dyn_cast<const BlockExpr *>();
100+
return dyn_cast<const BlockExpr *>(Source);
101101
}
102102

103103
/// Returns the name of the function decl this code
@@ -146,18 +146,18 @@ class Function final {
146146
/// Checks if the function is a constructor.
147147
bool isConstructor() const {
148148
return isa_and_nonnull<CXXConstructorDecl>(
149-
Source.dyn_cast<const FunctionDecl *>());
149+
dyn_cast<const FunctionDecl *>(Source));
150150
}
151151
/// Checks if the function is a destructor.
152152
bool isDestructor() const {
153153
return isa_and_nonnull<CXXDestructorDecl>(
154-
Source.dyn_cast<const FunctionDecl *>());
154+
dyn_cast<const FunctionDecl *>(Source));
155155
}
156156

157157
/// Returns the parent record decl, if any.
158158
const CXXRecordDecl *getParentDecl() const {
159159
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
160-
Source.dyn_cast<const FunctionDecl *>()))
160+
dyn_cast<const FunctionDecl *>(Source)))
161161
return MD->getParent();
162162
return nullptr;
163163
}
@@ -166,7 +166,7 @@ class Function final {
166166
/// which we generate custom byte code for.
167167
bool isLambdaStaticInvoker() const {
168168
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
169-
Source.dyn_cast<const FunctionDecl *>()))
169+
dyn_cast<const FunctionDecl *>(Source)))
170170
return MD->isLambdaStaticInvoker();
171171
return false;
172172
}
@@ -175,7 +175,7 @@ class Function final {
175175
/// of a lambda record decl.
176176
bool isLambdaCallOperator() const {
177177
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
178-
Source.dyn_cast<const FunctionDecl *>()))
178+
dyn_cast<const FunctionDecl *>(Source)))
179179
return clang::isLambdaCallOperator(MD);
180180
return false;
181181
}

clang/lib/AST/ByteCode/Source.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ SourceRange SourceInfo::getRange() const {
3333
}
3434

3535
const Expr *SourceInfo::asExpr() const {
36-
if (const auto *S = Source.dyn_cast<const Stmt *>())
36+
if (const auto *S = dyn_cast<const Stmt *>(Source))
3737
return dyn_cast<Expr>(S);
3838
return nullptr;
3939
}

clang/lib/AST/ByteCode/Source.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ class SourceInfo final {
8383
SourceLocation getLoc() const;
8484
SourceRange getRange() const;
8585

86-
const Stmt *asStmt() const { return Source.dyn_cast<const Stmt *>(); }
87-
const Decl *asDecl() const { return Source.dyn_cast<const Decl *>(); }
86+
const Stmt *asStmt() const { return dyn_cast<const Stmt *>(Source); }
87+
const Decl *asDecl() const { return dyn_cast<const Decl *>(Source); }
8888
const Expr *asExpr() const;
8989

9090
operator bool() const { return !Source.isNull(); }

0 commit comments

Comments
 (0)