- Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute
Description
APValue recently gained support for dump()ing lvalues, however, the code to handle them is missing support for lvalue bases of type TypeInfoLValue and DynamicAllocLValue:
llvm-project/clang/lib/AST/TextNodeDumper.cpp
Lines 732 to 761 in a29be9f
| case APValue::LValue: { | |
| (void)Context; | |
| OS << "LValue Base="; | |
| APValue::LValueBase B = Value.getLValueBase(); | |
| if (B.isNull()) | |
| OS << "null"; | |
| else if (const auto *BE = B.dyn_cast<const Expr *>()) { | |
| OS << BE->getStmtClassName() << ' '; | |
| dumpPointer(BE); | |
| } else { | |
| const auto *VDB = B.get<const ValueDecl *>(); | |
| OS << VDB->getDeclKindName() << "Decl"; | |
| dumpPointer(VDB); | |
| } | |
| OS << ", Null=" << Value.isNullPointer() | |
| << ", Offset=" << Value.getLValueOffset().getQuantity() | |
| << ", HasPath=" << Value.hasLValuePath(); | |
| if (Value.hasLValuePath()) { | |
| OS << ", PathLength=" << Value.getLValuePath().size(); | |
| OS << ", Path=("; | |
| llvm::ListSeparator Sep; | |
| for (const auto &PathEntry : Value.getLValuePath()) { | |
| // We're printing all entries as array indices because don't have the | |
| // type information here to do anything else. | |
| OS << Sep << PathEntry.getAsArrayIndex(); | |
| } | |
| OS << ")"; | |
| } | |
| return; | |
| } |
Before the else { branch that unconditionally assumes the base to be a const ValueDecl*, we need to check whether the base is a dynamic alloc value or a typeid value:
llvm-project/clang/lib/AST/ExprConstant.cpp
Lines 2124 to 2125 in a29be9f
| if (B.is<TypeInfoLValue>() || B.is<DynamicAllocLValue>()) | |
| return true; |
... and print something appropriate, or at least not crash.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute