Skip to content

Commit

Permalink
SymtabAPI::Type: add support for C++ r-value references
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Haines committed Nov 20, 2021
1 parent 71027cb commit 52fa241
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions symtabAPI/h/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,16 @@ class SYMTAB_EXPORT typeTypedef: public derivedType {
};

class SYMTAB_EXPORT typeRef : public derivedType {
private:
bool is_rvalue_{false};
protected:
void fixupUnknowns(Module *);
public:
struct rvalue_t final{};
typeRef();
typeRef(typeId_t ID, boost::shared_ptr<Type> refType, std::string name);
typeRef(typeId_t ID, boost::shared_ptr<Type> refType, std::string name, rvalue_t) :
typeRef(ID, refType, name) { is_rvalue_ = true; }
typeRef(typeId_t i, Type* r, std::string n)
: typeRef(i, r->reshare(), n) {}
typeRef(boost::shared_ptr<Type> refType, std::string name);
Expand All @@ -655,6 +660,7 @@ class SYMTAB_EXPORT typeRef : public derivedType {
bool isCompatible(boost::shared_ptr<Type> x) { return isCompatible(x.get()); }
bool isCompatible(Type *otype);
bool operator==(const Type &otype) const;
bool is_rvalue() const noexcept { return is_rvalue_; }
};

class SYMTAB_EXPORT typeSubrange : public rangedType {
Expand Down
11 changes: 11 additions & 0 deletions symtabAPI/src/dwarfWalker.C
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ bool DwarfWalker::parse_int(Dwarf_Die e, bool parseSib, bool dissociate_context)
case DW_TAG_ptr_to_member_type:
case DW_TAG_pointer_type:
case DW_TAG_reference_type:
case DW_TAG_rvalue_reference_type:
ret = parseTypeReferences();
break;
case DW_TAG_compile_unit:
Expand Down Expand Up @@ -1486,6 +1487,16 @@ bool DwarfWalker::parseTypeReferences() {
(void*)indirectType.get(), indirectType->getName().c_str(), type_id(),
offset(), indirectType->getSize(), (void*)tc());
break;
case DW_TAG_rvalue_reference_type:
if(!nameDefined()) {
curName() = "&&";
}
indirectType = tc()->addOrUpdateType(Type::make_shared<typeRef>(
type_id(), typePointedTo, curName(), typeRef::rvalue_t{}));
dwarf_printf("(0x%lx) Created type %p / %s for type_id %d, offset 0x%lx, size %u, in TC %p\n", id(),
(void*)indirectType.get(), indirectType->getName().c_str(), type_id(),
offset(), indirectType->getSize(), (void*)tc());
break;
default:
dwarf_printf("(0x%lx) Warning: nothing done for tag 0x%x, dwarf_tag(): 0x%x\n",
id(), tag(), (unsigned int)dwarf_tag(&e));
Expand Down

0 comments on commit 52fa241

Please sign in to comment.