friend class JSONDumper;
const SourceManager &SM;
+ ASTContext& Ctx;
PrintingPolicy PrintPolicy;
const comments::CommandTraits *Traits;
StringRef getCommentCommandName(unsigned CommandID) const;
public:
- JSONNodeDumper(raw_ostream &OS, const SourceManager &SrcMgr,
+ JSONNodeDumper(raw_ostream &OS, const SourceManager &SrcMgr, ASTContext &Ctx,
const PrintingPolicy &PrintPolicy,
const comments::CommandTraits *Traits)
- : NodeStreamer(OS), SM(SrcMgr), PrintPolicy(PrintPolicy), Traits(Traits) {
- }
+ : NodeStreamer(OS), SM(SrcMgr), Ctx(Ctx), PrintPolicy(PrintPolicy),
+ Traits(Traits) {}
void Visit(const Attr *A);
void Visit(const Stmt *Node);
void VisitSizeOfPackExpr(const SizeOfPackExpr *SOPE);
void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *ULE);
void VisitAddrLabelExpr(const AddrLabelExpr *ALE);
+ void VisitCXXTypeidExpr(const CXXTypeidExpr *CTE);
void VisitIntegerLiteral(const IntegerLiteral *IL);
void VisitCharacterLiteral(const CharacterLiteral *CL);
}
public:
- JSONDumper(raw_ostream &OS, const SourceManager &SrcMgr,
+ JSONDumper(raw_ostream &OS, const SourceManager &SrcMgr, ASTContext &Ctx,
const PrintingPolicy &PrintPolicy,
const comments::CommandTraits *Traits)
- : NodeDumper(OS, SrcMgr, PrintPolicy, Traits) {}
+ : NodeDumper(OS, SrcMgr, Ctx, PrintPolicy, Traits) {}
JSONNodeDumper &doGetNodeDelegate() { return NodeDumper; }
LLVM_DUMP_METHOD void Decl::dump(raw_ostream &OS, bool Deserialize,
ASTDumpOutputFormat Format) const {
- const ASTContext &Ctx = getASTContext();
+ ASTContext &Ctx = getASTContext();
const SourceManager &SM = Ctx.getSourceManager();
if (ADOF_JSON == Format) {
- JSONDumper P(OS, SM, Ctx.getPrintingPolicy(),
+ JSONDumper P(OS, SM, Ctx, Ctx.getPrintingPolicy(),
&Ctx.getCommentCommandTraits());
(void)Deserialize; // FIXME?
P.Visit(this);
JOS.attribute("labelDeclId", createPointerRepresentation(ALE->getLabel()));
}
+void JSONNodeDumper::VisitCXXTypeidExpr(const CXXTypeidExpr *CTE) {
+ if (CTE->isTypeOperand()) {
+ QualType Adjusted = CTE->getTypeOperand(Ctx);
+ QualType Unadjusted = CTE->getTypeOperandSourceInfo()->getType();
+ JOS.attribute("typeArg", createQualType(Unadjusted));
+ if (Adjusted != Unadjusted)
+ JOS.attribute("adjustedTypeArg", createQualType(Adjusted));
+ }
+}
+
void JSONNodeDumper::VisitIntegerLiteral(const IntegerLiteral *IL) {
JOS.attribute("value",
IL->getValue().toString(
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "const std::type_info"
// CHECK-NEXT: },
-// CHECK-NEXT: "valueCategory": "lvalue"
+// CHECK-NEXT: "valueCategory": "lvalue",
+// CHECK-NEXT: "typeArg": {
+// CHECK-NEXT: "qualType": "S"
+// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "const std::type_info"
// CHECK-NEXT: },
-// CHECK-NEXT: "valueCategory": "lvalue"
+// CHECK-NEXT: "valueCategory": "lvalue",
+// CHECK-NEXT: "typeArg": {
+// CHECK-NEXT: "qualType": "const volatile S"
+// CHECK-NEXT: },
+// CHECK-NEXT: "adjustedTypeArg": {
+// CHECK-NEXT: "qualType": "S"
+// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }