diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/Interp/Source.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/AST/Interp/Source.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/Interp/Source.cpp b/contrib/llvm-project/clang/lib/AST/Interp/Source.cpp index 4bec87812638..45cd0ad4fd42 100644 --- a/contrib/llvm-project/clang/lib/AST/Interp/Source.cpp +++ b/contrib/llvm-project/clang/lib/AST/Interp/Source.cpp @@ -22,18 +22,32 @@ SourceLocation SourceInfo::getLoc() const { return SourceLocation(); } +SourceRange SourceInfo::getRange() const { + if (const Expr *E = asExpr()) + return E->getSourceRange(); + if (const Stmt *S = asStmt()) + return S->getSourceRange(); + if (const Decl *D = asDecl()) + return D->getSourceRange(); + return SourceRange(); +} + const Expr *SourceInfo::asExpr() const { - if (auto *S = Source.dyn_cast<const Stmt *>()) + if (const auto *S = Source.dyn_cast<const Stmt *>()) return dyn_cast<Expr>(S); return nullptr; } -const Expr *SourceMapper::getExpr(Function *F, CodePtr PC) const { +const Expr *SourceMapper::getExpr(const Function *F, CodePtr PC) const { if (const Expr *E = getSource(F, PC).asExpr()) return E; llvm::report_fatal_error("missing source expression"); } -SourceLocation SourceMapper::getLocation(Function *F, CodePtr PC) const { +SourceLocation SourceMapper::getLocation(const Function *F, CodePtr PC) const { return getSource(F, PC).getLoc(); } + +SourceRange SourceMapper::getRange(const Function *F, CodePtr PC) const { + return getSource(F, PC).getRange(); +} |