diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2019-06-20 16:22:35 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2019-06-20 16:22:35 +0000 |
commit | 1fffe8d6eede5afedb6da94443229657df724d22 (patch) | |
tree | ec9b2427b9aeb72245de57551f7d692b8649b000 /clang/lib | |
parent | 6ab35c9dc0bc92223f5927829823920d3bc674c6 (diff) | |
download | llvm-1fffe8d6eede5afedb6da94443229657df724d22.zip llvm-1fffe8d6eede5afedb6da94443229657df724d22.tar.gz llvm-1fffe8d6eede5afedb6da94443229657df724d22.tar.bz2 |
Dump more information about expressions involving temporaries when dumping the AST to JSON.
llvm-svn: 363943
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/JSONNodeDumper.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index 15e198d..24d44cf 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -1026,6 +1026,51 @@ void JSONNodeDumper::VisitCXXConstructExpr(const CXXConstructExpr *CE) { } } +void JSONNodeDumper::VisitExprWithCleanups(const ExprWithCleanups *EWC) { + attributeOnlyIfTrue("cleanupsHaveSideEffects", + EWC->cleanupsHaveSideEffects()); + if (EWC->getNumObjects()) { + JOS.attributeArray("cleanups", [this, EWC] { + for (const ExprWithCleanups::CleanupObject &CO : EWC->getObjects()) + JOS.value(createBareDeclRef(CO)); + }); + } +} + +void JSONNodeDumper::VisitCXXBindTemporaryExpr( + const CXXBindTemporaryExpr *BTE) { + const CXXTemporary *Temp = BTE->getTemporary(); + JOS.attribute("temp", createPointerRepresentation(Temp)); + if (const CXXDestructorDecl *Dtor = Temp->getDestructor()) + JOS.attribute("dtor", createBareDeclRef(Dtor)); +} + +void JSONNodeDumper::VisitMaterializeTemporaryExpr( + const MaterializeTemporaryExpr *MTE) { + if (const ValueDecl *VD = MTE->getExtendingDecl()) + JOS.attribute("extendingDecl", createBareDeclRef(VD)); + + switch (MTE->getStorageDuration()) { + case SD_Automatic: + JOS.attribute("storageDuration", "automatic"); + break; + case SD_Dynamic: + JOS.attribute("storageDuration", "dynamic"); + break; + case SD_FullExpression: + JOS.attribute("storageDuration", "full expression"); + break; + case SD_Static: + JOS.attribute("storageDuration", "static"); + break; + case SD_Thread: + JOS.attribute("storageDuration", "thread"); + break; + } + + attributeOnlyIfTrue("boundToLValueRef", MTE->isBoundToLvalueReference()); +} + void JSONNodeDumper::VisitIntegerLiteral(const IntegerLiteral *IL) { JOS.attribute("value", IL->getValue().toString( |