Skip to content

[ByteCode] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) #115809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/AST/ByteCode/Descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ struct Descriptor final {
SourceLocation getLocation() const;
SourceInfo getLoc() const;

const Decl *asDecl() const { return Source.dyn_cast<const Decl *>(); }
const Expr *asExpr() const { return Source.dyn_cast<const Expr *>(); }
const Decl *asDecl() const { return dyn_cast<const Decl *>(Source); }
const Expr *asExpr() const { return dyn_cast<const Expr *>(Source); }
const DeclTy &getSource() const { return Source; }

const ValueDecl *asValueDecl() const {
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/AST/ByteCode/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ class Function final {

/// Returns the original FunctionDecl.
const FunctionDecl *getDecl() const {
return Source.dyn_cast<const FunctionDecl *>();
return dyn_cast<const FunctionDecl *>(Source);
}
const BlockExpr *getExpr() const {
return Source.dyn_cast<const BlockExpr *>();
return dyn_cast<const BlockExpr *>(Source);
}

/// Returns the name of the function decl this code
Expand Down Expand Up @@ -146,18 +146,18 @@ class Function final {
/// Checks if the function is a constructor.
bool isConstructor() const {
return isa_and_nonnull<CXXConstructorDecl>(
Source.dyn_cast<const FunctionDecl *>());
dyn_cast<const FunctionDecl *>(Source));
}
/// Checks if the function is a destructor.
bool isDestructor() const {
return isa_and_nonnull<CXXDestructorDecl>(
Source.dyn_cast<const FunctionDecl *>());
dyn_cast<const FunctionDecl *>(Source));
}

/// Returns the parent record decl, if any.
const CXXRecordDecl *getParentDecl() const {
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
Source.dyn_cast<const FunctionDecl *>()))
dyn_cast<const FunctionDecl *>(Source)))
return MD->getParent();
return nullptr;
}
Expand All @@ -166,7 +166,7 @@ class Function final {
/// which we generate custom byte code for.
bool isLambdaStaticInvoker() const {
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
Source.dyn_cast<const FunctionDecl *>()))
dyn_cast<const FunctionDecl *>(Source)))
return MD->isLambdaStaticInvoker();
return false;
}
Expand All @@ -175,7 +175,7 @@ class Function final {
/// of a lambda record decl.
bool isLambdaCallOperator() const {
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
Source.dyn_cast<const FunctionDecl *>()))
dyn_cast<const FunctionDecl *>(Source)))
return clang::isLambdaCallOperator(MD);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SourceRange SourceInfo::getRange() const {
}

const Expr *SourceInfo::asExpr() const {
if (const auto *S = Source.dyn_cast<const Stmt *>())
if (const auto *S = dyn_cast<const Stmt *>(Source))
return dyn_cast<Expr>(S);
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ByteCode/Source.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class SourceInfo final {
SourceLocation getLoc() const;
SourceRange getRange() const;

const Stmt *asStmt() const { return Source.dyn_cast<const Stmt *>(); }
const Decl *asDecl() const { return Source.dyn_cast<const Decl *>(); }
const Stmt *asStmt() const { return dyn_cast<const Stmt *>(Source); }
const Decl *asDecl() const { return dyn_cast<const Decl *>(Source); }
const Expr *asExpr() const;

operator bool() const { return !Source.isNull(); }
Expand Down
Loading