[PATCH] D149824: [clang][Interp] Don't call getSource() on functions without a body

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 03:02:26 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8fb478f2df8: [clang][Interp] Don't call getSource() on functions without a body (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D149824?vs=519380&id=519786#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149824/new/

https://reviews.llvm.org/D149824

Files:
  clang/lib/AST/Interp/EvalEmitter.h
  clang/lib/AST/Interp/Function.cpp


Index: clang/lib/AST/Interp/Function.cpp
===================================================================
--- clang/lib/AST/Interp/Function.cpp
+++ clang/lib/AST/Interp/Function.cpp
@@ -32,6 +32,7 @@
 SourceInfo Function::getSource(CodePtr PC) const {
   assert(PC >= getCodeBegin() && "PC does not belong to this function");
   assert(PC <= getCodeEnd() && "PC Does not belong to this function");
+  assert(hasBody() && "Function has no body");
   unsigned Offset = PC - getCodeBegin();
   using Elem = std::pair<unsigned, SourceInfo>;
   auto It = llvm::lower_bound(SrcMap, Elem{Offset, {}}, llvm::less_first());
Index: clang/lib/AST/Interp/EvalEmitter.h
===================================================================
--- clang/lib/AST/Interp/EvalEmitter.h
+++ clang/lib/AST/Interp/EvalEmitter.h
@@ -71,7 +71,7 @@
 
   /// Returns the source location of the current opcode.
   SourceInfo getSource(const Function *F, CodePtr PC) const override {
-    return F ? F->getSource(PC) : CurrentSource;
+    return (F && F->hasBody()) ? F->getSource(PC) : CurrentSource;
   }
 
   /// Parameter indices.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149824.519786.patch
Type: text/x-patch
Size: 1107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230505/d851a035/attachment.bin>


More information about the cfe-commits mailing list