2006-11-04 15:16:25 +08:00
|
|
|
//===--- StmtPrinter.cpp - Printing implementation for Stmt ASTs ----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-11-04 15:16:25 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2007-08-09 06:51:59 +08:00
|
|
|
// This file implements the Stmt::dumpPretty/Stmt::printPretty methods, which
|
|
|
|
// pretty print the AST back out to C code.
|
2006-11-04 15:16:25 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/StmtVisitor.h"
|
2009-01-06 13:10:23 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2007-10-18 02:36:42 +08:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2011-01-15 09:15:58 +08:00
|
|
|
#include "clang/AST/DeclTemplate.h"
|
2007-09-01 05:30:12 +08:00
|
|
|
#include "clang/AST/PrettyPrinter.h"
|
2008-09-13 13:16:45 +08:00
|
|
|
#include "llvm/Support/Format.h"
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
#include "clang/AST/Expr.h"
|
2010-09-08 08:15:04 +08:00
|
|
|
#include "clang/AST/ExprCXX.h"
|
2006-11-04 15:16:25 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// StmtPrinter Visitor
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace {
|
2009-11-29 03:03:38 +08:00
|
|
|
class StmtPrinter : public StmtVisitor<StmtPrinter> {
|
2011-07-23 18:55:15 +08:00
|
|
|
raw_ostream &OS;
|
2009-05-30 13:03:24 +08:00
|
|
|
ASTContext &Context;
|
2006-11-04 15:16:25 +08:00
|
|
|
unsigned IndentLevel;
|
2007-09-01 05:30:12 +08:00
|
|
|
clang::PrinterHelper* Helper;
|
2009-05-30 04:38:28 +08:00
|
|
|
PrintingPolicy Policy;
|
|
|
|
|
2006-11-04 15:16:25 +08:00
|
|
|
public:
|
2011-07-23 18:55:15 +08:00
|
|
|
StmtPrinter(raw_ostream &os, ASTContext &C, PrinterHelper* helper,
|
2009-06-30 09:26:17 +08:00
|
|
|
const PrintingPolicy &Policy,
|
2009-05-30 04:38:28 +08:00
|
|
|
unsigned Indentation = 0)
|
2009-05-30 13:03:24 +08:00
|
|
|
: OS(os), Context(C), IndentLevel(Indentation), Helper(helper),
|
|
|
|
Policy(Policy) {}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-30 04:38:28 +08:00
|
|
|
void PrintStmt(Stmt *S) {
|
|
|
|
PrintStmt(S, Policy.Indentation);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintStmt(Stmt *S, int SubIndent) {
|
2007-05-21 06:52:15 +08:00
|
|
|
IndentLevel += SubIndent;
|
2007-06-01 02:21:33 +08:00
|
|
|
if (S && isa<Expr>(S)) {
|
2006-11-05 02:52:07 +08:00
|
|
|
// If this is an expr used in a stmt context, indent and newline it.
|
|
|
|
Indent();
|
2007-08-21 12:04:25 +08:00
|
|
|
Visit(S);
|
2007-05-31 01:57:36 +08:00
|
|
|
OS << ";\n";
|
2006-11-05 02:52:07 +08:00
|
|
|
} else if (S) {
|
2007-08-21 12:04:25 +08:00
|
|
|
Visit(S);
|
2006-11-05 02:52:07 +08:00
|
|
|
} else {
|
2007-05-28 09:47:47 +08:00
|
|
|
Indent() << "<<<NULL STATEMENT>>>\n";
|
2006-11-05 02:52:07 +08:00
|
|
|
}
|
2007-05-21 06:52:15 +08:00
|
|
|
IndentLevel -= SubIndent;
|
2006-11-05 02:52:07 +08:00
|
|
|
}
|
2009-05-30 08:19:54 +08:00
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
void PrintRawCompoundStmt(CompoundStmt *S);
|
2007-06-06 04:52:47 +08:00
|
|
|
void PrintRawDecl(Decl *D);
|
2008-10-07 02:39:36 +08:00
|
|
|
void PrintRawDeclStmt(DeclStmt *S);
|
Pretty print if/else/elseif chains nicer, like this:
void printutf8(unsigned int X) {
if (X <= 127)
printf("%c", (char)X);
else if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
instead of:
if (X <= 127)
printf("%c", (char)X);
else
if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else
if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
llvm-svn: 39648
2007-06-12 06:26:23 +08:00
|
|
|
void PrintRawIfStmt(IfStmt *If);
|
2008-12-23 05:35:02 +08:00
|
|
|
void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
|
2011-02-09 05:17:54 +08:00
|
|
|
void PrintCallArgs(CallExpr *E);
|
2011-04-28 09:08:34 +08:00
|
|
|
void PrintRawSEHExceptHandler(SEHExceptStmt *S);
|
|
|
|
void PrintRawSEHFinallyStmt(SEHFinallyStmt *S);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2006-11-05 02:52:07 +08:00
|
|
|
void PrintExpr(Expr *E) {
|
|
|
|
if (E)
|
2007-08-21 12:04:25 +08:00
|
|
|
Visit(E);
|
2006-11-04 15:16:25 +08:00
|
|
|
else
|
2006-11-05 02:52:07 +08:00
|
|
|
OS << "<null expr>";
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2011-07-23 18:55:15 +08:00
|
|
|
raw_ostream &Indent(int Delta = 0) {
|
2009-05-30 04:38:28 +08:00
|
|
|
for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
|
|
|
|
OS << " ";
|
2006-11-04 15:16:25 +08:00
|
|
|
return OS;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
void Visit(Stmt* S) {
|
2007-09-01 05:30:12 +08:00
|
|
|
if (Helper && Helper->handledStmt(S,OS))
|
|
|
|
return;
|
|
|
|
else StmtVisitor<StmtPrinter>::Visit(S);
|
|
|
|
}
|
2010-08-15 09:15:33 +08:00
|
|
|
|
2010-10-23 16:21:37 +08:00
|
|
|
void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
|
2010-08-15 09:15:33 +08:00
|
|
|
Indent() << "<<unknown stmt type>>\n";
|
|
|
|
}
|
2010-10-23 16:21:37 +08:00
|
|
|
void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
|
2010-08-15 09:15:33 +08:00
|
|
|
OS << "<<unknown expr type>>";
|
|
|
|
}
|
|
|
|
void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-15 09:15:33 +08:00
|
|
|
#define ABSTRACT_STMT(CLASS)
|
2008-11-14 20:46:07 +08:00
|
|
|
#define STMT(CLASS, PARENT) \
|
2007-08-21 12:04:25 +08:00
|
|
|
void Visit##CLASS(CLASS *Node);
|
2010-05-05 23:24:00 +08:00
|
|
|
#include "clang/AST/StmtNodes.inc"
|
2006-11-05 04:18:38 +08:00
|
|
|
};
|
2006-11-05 02:52:07 +08:00
|
|
|
}
|
|
|
|
|
2006-11-05 04:18:38 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Stmt printing methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
/// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
|
|
|
|
/// with no newline after the }.
|
|
|
|
void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
|
|
|
|
OS << "{\n";
|
2006-11-04 15:16:25 +08:00
|
|
|
for (CompoundStmt::body_iterator I = Node->body_begin(), E = Node->body_end();
|
2006-11-05 02:52:07 +08:00
|
|
|
I != E; ++I)
|
|
|
|
PrintStmt(*I);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
Indent() << "}";
|
|
|
|
}
|
|
|
|
|
2007-06-06 04:52:47 +08:00
|
|
|
void StmtPrinter::PrintRawDecl(Decl *D) {
|
2009-06-30 10:35:04 +08:00
|
|
|
D->print(OS, Policy, IndentLevel);
|
2009-02-11 04:16:46 +08:00
|
|
|
}
|
|
|
|
|
2008-10-07 02:39:36 +08:00
|
|
|
void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) {
|
2009-05-30 08:19:54 +08:00
|
|
|
DeclStmt::decl_iterator Begin = S->decl_begin(), End = S->decl_end();
|
2011-07-23 18:55:15 +08:00
|
|
|
SmallVector<Decl*, 2> Decls;
|
2009-09-09 23:08:12 +08:00
|
|
|
for ( ; Begin != End; ++Begin)
|
2009-05-30 12:20:30 +08:00
|
|
|
Decls.push_back(*Begin);
|
2009-05-30 08:19:54 +08:00
|
|
|
|
2009-06-30 10:35:04 +08:00
|
|
|
Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
|
2008-10-07 02:39:36 +08:00
|
|
|
}
|
2007-06-06 04:52:47 +08:00
|
|
|
|
|
|
|
void StmtPrinter::VisitNullStmt(NullStmt *Node) {
|
|
|
|
Indent() << ";\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
|
2009-05-30 08:19:54 +08:00
|
|
|
Indent();
|
|
|
|
PrintRawDeclStmt(Node);
|
|
|
|
OS << ";\n";
|
2007-05-30 06:59:26 +08:00
|
|
|
}
|
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
|
|
|
|
Indent();
|
|
|
|
PrintRawCompoundStmt(Node);
|
2007-05-31 13:08:56 +08:00
|
|
|
OS << "\n";
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
|
|
|
|
2006-11-05 08:19:50 +08:00
|
|
|
void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
|
2007-05-21 06:52:15 +08:00
|
|
|
Indent(-1) << "case ";
|
2006-11-05 08:19:50 +08:00
|
|
|
PrintExpr(Node->getLHS());
|
|
|
|
if (Node->getRHS()) {
|
|
|
|
OS << " ... ";
|
|
|
|
PrintExpr(Node->getRHS());
|
|
|
|
}
|
|
|
|
OS << ":\n";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-05-21 06:52:15 +08:00
|
|
|
PrintStmt(Node->getSubStmt(), 0);
|
2006-11-05 08:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
|
2007-05-21 06:52:15 +08:00
|
|
|
Indent(-1) << "default:\n";
|
|
|
|
PrintStmt(Node->getSubStmt(), 0);
|
2006-11-05 08:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
|
2007-05-28 14:56:27 +08:00
|
|
|
Indent(-1) << Node->getName() << ":\n";
|
2007-05-21 06:52:15 +08:00
|
|
|
PrintStmt(Node->getSubStmt(), 0);
|
2006-11-05 08:19:50 +08:00
|
|
|
}
|
|
|
|
|
Pretty print if/else/elseif chains nicer, like this:
void printutf8(unsigned int X) {
if (X <= 127)
printf("%c", (char)X);
else if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
instead of:
if (X <= 127)
printf("%c", (char)X);
else
if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else
if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
llvm-svn: 39648
2007-06-12 06:26:23 +08:00
|
|
|
void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
|
2009-02-08 04:05:48 +08:00
|
|
|
OS << "if (";
|
2006-11-05 02:52:07 +08:00
|
|
|
PrintExpr(If->getCond());
|
2009-02-08 04:05:48 +08:00
|
|
|
OS << ')';
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
|
|
|
|
OS << ' ';
|
|
|
|
PrintRawCompoundStmt(CS);
|
|
|
|
OS << (If->getElse() ? ' ' : '\n');
|
|
|
|
} else {
|
|
|
|
OS << '\n';
|
|
|
|
PrintStmt(If->getThen());
|
|
|
|
if (If->getElse()) Indent();
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
if (Stmt *Else = If->getElse()) {
|
|
|
|
OS << "else";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
|
|
|
|
OS << ' ';
|
|
|
|
PrintRawCompoundStmt(CS);
|
|
|
|
OS << '\n';
|
Pretty print if/else/elseif chains nicer, like this:
void printutf8(unsigned int X) {
if (X <= 127)
printf("%c", (char)X);
else if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
instead of:
if (X <= 127)
printf("%c", (char)X);
else
if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else
if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
llvm-svn: 39648
2007-06-12 06:26:23 +08:00
|
|
|
} else if (IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
|
|
|
|
OS << ' ';
|
|
|
|
PrintRawIfStmt(ElseIf);
|
2007-05-21 07:04:55 +08:00
|
|
|
} else {
|
|
|
|
OS << '\n';
|
|
|
|
PrintStmt(If->getElse());
|
|
|
|
}
|
2006-11-05 02:52:07 +08:00
|
|
|
}
|
2006-11-05 04:40:44 +08:00
|
|
|
}
|
|
|
|
|
Pretty print if/else/elseif chains nicer, like this:
void printutf8(unsigned int X) {
if (X <= 127)
printf("%c", (char)X);
else if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
instead of:
if (X <= 127)
printf("%c", (char)X);
else
if (X <= 2047)
printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
else
if (X <= 65535)
printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
else
printf("UNKNOWN %d\n", X);
llvm-svn: 39648
2007-06-12 06:26:23 +08:00
|
|
|
void StmtPrinter::VisitIfStmt(IfStmt *If) {
|
|
|
|
Indent();
|
|
|
|
PrintRawIfStmt(If);
|
|
|
|
}
|
|
|
|
|
2006-11-05 04:59:27 +08:00
|
|
|
void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
|
|
|
|
Indent() << "switch (";
|
|
|
|
PrintExpr(Node->getCond());
|
2007-05-21 07:04:55 +08:00
|
|
|
OS << ")";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-05-21 07:04:55 +08:00
|
|
|
// Pretty print compoundstmt bodies (very common).
|
|
|
|
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
|
|
|
|
OS << " ";
|
|
|
|
PrintRawCompoundStmt(CS);
|
|
|
|
OS << "\n";
|
|
|
|
} else {
|
|
|
|
OS << "\n";
|
|
|
|
PrintStmt(Node->getBody());
|
|
|
|
}
|
2006-11-05 04:59:27 +08:00
|
|
|
}
|
|
|
|
|
2006-11-05 04:40:44 +08:00
|
|
|
void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
|
|
|
|
Indent() << "while (";
|
|
|
|
PrintExpr(Node->getCond());
|
|
|
|
OS << ")\n";
|
|
|
|
PrintStmt(Node->getBody());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitDoStmt(DoStmt *Node) {
|
2007-09-16 05:49:37 +08:00
|
|
|
Indent() << "do ";
|
|
|
|
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
|
|
|
|
PrintRawCompoundStmt(CS);
|
|
|
|
OS << " ";
|
|
|
|
} else {
|
|
|
|
OS << "\n";
|
|
|
|
PrintStmt(Node->getBody());
|
|
|
|
Indent();
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-17 09:05:34 +08:00
|
|
|
OS << "while (";
|
2006-11-05 04:40:44 +08:00
|
|
|
PrintExpr(Node->getCond());
|
2009-05-17 09:05:34 +08:00
|
|
|
OS << ");\n";
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
|
|
|
|
2006-11-05 04:18:38 +08:00
|
|
|
void StmtPrinter::VisitForStmt(ForStmt *Node) {
|
|
|
|
Indent() << "for (";
|
2007-06-06 04:52:47 +08:00
|
|
|
if (Node->getInit()) {
|
|
|
|
if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
|
2008-10-07 02:39:36 +08:00
|
|
|
PrintRawDeclStmt(DS);
|
2007-06-06 04:52:47 +08:00
|
|
|
else
|
|
|
|
PrintExpr(cast<Expr>(Node->getInit()));
|
|
|
|
}
|
2007-09-16 05:49:37 +08:00
|
|
|
OS << ";";
|
|
|
|
if (Node->getCond()) {
|
|
|
|
OS << " ";
|
2007-06-06 04:52:47 +08:00
|
|
|
PrintExpr(Node->getCond());
|
2007-09-16 05:49:37 +08:00
|
|
|
}
|
|
|
|
OS << ";";
|
|
|
|
if (Node->getInc()) {
|
|
|
|
OS << " ";
|
2007-06-06 04:52:47 +08:00
|
|
|
PrintExpr(Node->getInc());
|
2007-09-16 05:49:37 +08:00
|
|
|
}
|
|
|
|
OS << ") ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-09-16 05:49:37 +08:00
|
|
|
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
|
|
|
|
PrintRawCompoundStmt(CS);
|
|
|
|
OS << "\n";
|
|
|
|
} else {
|
|
|
|
OS << "\n";
|
|
|
|
PrintStmt(Node->getBody());
|
|
|
|
}
|
2006-11-05 04:18:38 +08:00
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
|
2008-01-03 06:54:34 +08:00
|
|
|
Indent() << "for (";
|
|
|
|
if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement()))
|
2008-10-07 02:39:36 +08:00
|
|
|
PrintRawDeclStmt(DS);
|
2008-01-03 06:54:34 +08:00
|
|
|
else
|
|
|
|
PrintExpr(cast<Expr>(Node->getElement()));
|
|
|
|
OS << " in ";
|
|
|
|
PrintExpr(Node->getCollection());
|
|
|
|
OS << ") ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-01-03 06:54:34 +08:00
|
|
|
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
|
|
|
|
PrintRawCompoundStmt(CS);
|
|
|
|
OS << "\n";
|
|
|
|
} else {
|
|
|
|
OS << "\n";
|
|
|
|
PrintStmt(Node->getBody());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-15 06:09:26 +08:00
|
|
|
void StmtPrinter::VisitCXXForRangeStmt(CXXForRangeStmt *Node) {
|
|
|
|
Indent() << "for (";
|
|
|
|
PrintingPolicy SubPolicy(Policy);
|
|
|
|
SubPolicy.SuppressInitializers = true;
|
|
|
|
Node->getLoopVariable()->print(OS, SubPolicy, IndentLevel);
|
|
|
|
OS << " : ";
|
|
|
|
PrintExpr(Node->getRangeInit());
|
|
|
|
OS << ") {\n";
|
|
|
|
PrintStmt(Node->getBody());
|
|
|
|
Indent() << "}\n";
|
|
|
|
}
|
|
|
|
|
2006-11-05 09:46:01 +08:00
|
|
|
void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
|
2007-05-28 14:56:27 +08:00
|
|
|
Indent() << "goto " << Node->getLabel()->getName() << ";\n";
|
2006-11-05 09:46:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
|
2006-11-05 09:51:06 +08:00
|
|
|
Indent() << "goto *";
|
2006-11-05 09:46:01 +08:00
|
|
|
PrintExpr(Node->getTarget());
|
2007-05-31 14:00:14 +08:00
|
|
|
OS << ";\n";
|
2006-11-05 09:46:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
|
2007-05-31 14:00:14 +08:00
|
|
|
Indent() << "continue;\n";
|
2006-11-05 09:46:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
|
2007-05-31 14:00:14 +08:00
|
|
|
Indent() << "break;\n";
|
2006-11-05 09:46:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-05 02:52:07 +08:00
|
|
|
void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
|
|
|
|
Indent() << "return";
|
|
|
|
if (Node->getRetValue()) {
|
|
|
|
OS << " ";
|
|
|
|
PrintExpr(Node->getRetValue());
|
|
|
|
}
|
2007-05-31 14:00:14 +08:00
|
|
|
OS << ";\n";
|
2006-11-05 02:52:07 +08:00
|
|
|
}
|
2006-11-04 15:16:25 +08:00
|
|
|
|
2007-10-29 12:04:16 +08:00
|
|
|
|
|
|
|
void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
|
2007-11-24 07:12:25 +08:00
|
|
|
Indent() << "asm ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-24 07:12:25 +08:00
|
|
|
if (Node->isVolatile())
|
|
|
|
OS << "volatile ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-24 07:12:25 +08:00
|
|
|
OS << "(";
|
2007-11-21 03:21:03 +08:00
|
|
|
VisitStringLiteral(Node->getAsmString());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
// Outputs
|
|
|
|
if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
|
|
|
|
Node->getNumClobbers() != 0)
|
|
|
|
OS << " : ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
|
|
|
|
if (i != 0)
|
|
|
|
OS << ", ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
if (!Node->getOutputName(i).empty()) {
|
|
|
|
OS << '[';
|
|
|
|
OS << Node->getOutputName(i);
|
|
|
|
OS << "] ";
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-10 12:59:06 +08:00
|
|
|
VisitStringLiteral(Node->getOutputConstraintLiteral(i));
|
2007-11-22 09:36:19 +08:00
|
|
|
OS << " ";
|
|
|
|
Visit(Node->getOutputExpr(i));
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
// Inputs
|
|
|
|
if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0)
|
|
|
|
OS << " : ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
|
|
|
|
if (i != 0)
|
|
|
|
OS << ", ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
if (!Node->getInputName(i).empty()) {
|
|
|
|
OS << '[';
|
|
|
|
OS << Node->getInputName(i);
|
|
|
|
OS << "] ";
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-10 12:59:06 +08:00
|
|
|
VisitStringLiteral(Node->getInputConstraintLiteral(i));
|
2007-11-22 09:36:19 +08:00
|
|
|
OS << " ";
|
|
|
|
Visit(Node->getInputExpr(i));
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
// Clobbers
|
|
|
|
if (Node->getNumClobbers() != 0)
|
|
|
|
OS << " : ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
|
|
|
|
if (i != 0)
|
|
|
|
OS << ", ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-22 09:36:19 +08:00
|
|
|
VisitStringLiteral(Node->getClobber(i));
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-21 03:21:03 +08:00
|
|
|
OS << ");\n";
|
2007-10-29 12:04:16 +08:00
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
|
2007-11-03 02:16:07 +08:00
|
|
|
Indent() << "@try";
|
|
|
|
if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
|
|
|
|
PrintRawCompoundStmt(TS);
|
|
|
|
OS << "\n";
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-04-24 06:50:49 +08:00
|
|
|
for (unsigned I = 0, N = Node->getNumCatchStmts(); I != N; ++I) {
|
|
|
|
ObjCAtCatchStmt *catchStmt = Node->getCatchStmt(I);
|
2007-11-03 02:16:07 +08:00
|
|
|
Indent() << "@catch(";
|
2009-03-04 03:52:17 +08:00
|
|
|
if (catchStmt->getCatchParamDecl()) {
|
|
|
|
if (Decl *DS = catchStmt->getCatchParamDecl())
|
|
|
|
PrintRawDecl(DS);
|
2007-11-03 02:16:07 +08:00
|
|
|
}
|
|
|
|
OS << ")";
|
2009-09-09 23:08:12 +08:00
|
|
|
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
|
|
|
|
PrintRawCompoundStmt(CS);
|
|
|
|
OS << "\n";
|
|
|
|
}
|
2007-11-03 02:16:07 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
if (ObjCAtFinallyStmt *FS = static_cast<ObjCAtFinallyStmt *>(
|
|
|
|
Node->getFinallyStmt())) {
|
2007-11-07 08:46:42 +08:00
|
|
|
Indent() << "@finally";
|
|
|
|
PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
|
2007-11-03 02:16:07 +08:00
|
|
|
OS << "\n";
|
2009-09-09 23:08:12 +08:00
|
|
|
}
|
2007-11-02 05:12:44 +08:00
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
|
2007-11-02 05:12:44 +08:00
|
|
|
}
|
|
|
|
|
2008-01-08 03:49:32 +08:00
|
|
|
void StmtPrinter::VisitObjCAtCatchStmt (ObjCAtCatchStmt *Node) {
|
2007-11-02 05:12:44 +08:00
|
|
|
Indent() << "@catch (...) { /* todo */ } \n";
|
|
|
|
}
|
|
|
|
|
2008-01-31 01:38:29 +08:00
|
|
|
void StmtPrinter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *Node) {
|
2007-11-07 10:00:49 +08:00
|
|
|
Indent() << "@throw";
|
|
|
|
if (Node->getThrowExpr()) {
|
|
|
|
OS << " ";
|
|
|
|
PrintExpr(Node->getThrowExpr());
|
|
|
|
}
|
|
|
|
OS << ";\n";
|
|
|
|
}
|
|
|
|
|
2008-01-31 01:38:29 +08:00
|
|
|
void StmtPrinter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *Node) {
|
2008-01-30 02:21:32 +08:00
|
|
|
Indent() << "@synchronized (";
|
|
|
|
PrintExpr(Node->getSynchExpr());
|
|
|
|
OS << ")";
|
2008-01-31 01:38:29 +08:00
|
|
|
PrintRawCompoundStmt(Node->getSynchBody());
|
|
|
|
OS << "\n";
|
2008-01-30 02:21:32 +08:00
|
|
|
}
|
|
|
|
|
2011-06-16 07:02:42 +08:00
|
|
|
void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
|
|
|
|
Indent() << "@autoreleasepool";
|
|
|
|
PrintRawCompoundStmt(dyn_cast<CompoundStmt>(Node->getSubStmt()));
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
2008-12-23 05:35:02 +08:00
|
|
|
void StmtPrinter::PrintRawCXXCatchStmt(CXXCatchStmt *Node) {
|
|
|
|
OS << "catch (";
|
2008-12-23 03:15:10 +08:00
|
|
|
if (Decl *ExDecl = Node->getExceptionDecl())
|
|
|
|
PrintRawDecl(ExDecl);
|
|
|
|
else
|
|
|
|
OS << "...";
|
|
|
|
OS << ") ";
|
|
|
|
PrintRawCompoundStmt(cast<CompoundStmt>(Node->getHandlerBlock()));
|
2008-12-23 05:35:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
|
|
|
|
Indent();
|
|
|
|
PrintRawCXXCatchStmt(Node);
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
|
|
|
|
Indent() << "try ";
|
|
|
|
PrintRawCompoundStmt(Node->getTryBlock());
|
2009-09-09 23:08:12 +08:00
|
|
|
for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
|
2008-12-23 05:35:02 +08:00
|
|
|
OS << " ";
|
|
|
|
PrintRawCXXCatchStmt(Node->getHandler(i));
|
|
|
|
}
|
2008-12-23 03:15:10 +08:00
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
2011-04-28 09:08:34 +08:00
|
|
|
void StmtPrinter::VisitSEHTryStmt(SEHTryStmt *Node) {
|
|
|
|
Indent() << (Node->getIsCXXTry() ? "try " : "__try ");
|
|
|
|
PrintRawCompoundStmt(Node->getTryBlock());
|
|
|
|
SEHExceptStmt *E = Node->getExceptHandler();
|
|
|
|
SEHFinallyStmt *F = Node->getFinallyHandler();
|
|
|
|
if(E)
|
|
|
|
PrintRawSEHExceptHandler(E);
|
|
|
|
else {
|
|
|
|
assert(F && "Must have a finally block...");
|
|
|
|
PrintRawSEHFinallyStmt(F);
|
|
|
|
}
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::PrintRawSEHFinallyStmt(SEHFinallyStmt *Node) {
|
|
|
|
OS << "__finally ";
|
|
|
|
PrintRawCompoundStmt(Node->getBlock());
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::PrintRawSEHExceptHandler(SEHExceptStmt *Node) {
|
|
|
|
OS << "__except (";
|
|
|
|
VisitExpr(Node->getFilterExpr());
|
|
|
|
OS << ")\n";
|
|
|
|
PrintRawCompoundStmt(Node->getBlock());
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitSEHExceptStmt(SEHExceptStmt *Node) {
|
|
|
|
Indent();
|
|
|
|
PrintRawSEHExceptHandler(Node);
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitSEHFinallyStmt(SEHFinallyStmt *Node) {
|
|
|
|
Indent();
|
|
|
|
PrintRawSEHFinallyStmt(Node);
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
2006-11-05 04:18:38 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Expr printing methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2006-11-04 15:16:25 +08:00
|
|
|
|
2006-11-05 02:52:07 +08:00
|
|
|
void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
|
2009-10-24 02:54:35 +08:00
|
|
|
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
|
|
|
|
Qualifier->print(OS, Policy);
|
2010-08-12 06:01:17 +08:00
|
|
|
OS << Node->getNameInfo();
|
2010-08-20 07:49:38 +08:00
|
|
|
if (Node->hasExplicitTemplateArgs())
|
2009-10-24 02:54:35 +08:00
|
|
|
OS << TemplateSpecializationType::PrintTemplateArgumentList(
|
|
|
|
Node->getTemplateArgs(),
|
|
|
|
Node->getNumTemplateArgs(),
|
2010-05-05 23:23:54 +08:00
|
|
|
Policy);
|
2009-01-06 13:10:23 +08:00
|
|
|
}
|
|
|
|
|
2009-11-20 06:55:06 +08:00
|
|
|
void StmtPrinter::VisitDependentScopeDeclRefExpr(
|
|
|
|
DependentScopeDeclRefExpr *Node) {
|
2011-01-24 23:44:00 +08:00
|
|
|
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
|
|
|
|
Qualifier->print(OS, Policy);
|
2010-08-12 06:01:17 +08:00
|
|
|
OS << Node->getNameInfo();
|
2009-11-25 03:00:30 +08:00
|
|
|
if (Node->hasExplicitTemplateArgs())
|
|
|
|
OS << TemplateSpecializationType::PrintTemplateArgumentList(
|
|
|
|
Node->getTemplateArgs(),
|
|
|
|
Node->getNumTemplateArgs(),
|
|
|
|
Policy);
|
Introduce a new expression type, UnresolvedDeclRefExpr, that describes
dependent qualified-ids such as
Fibonacci<N - 1>::value
where N is a template parameter. These references are "unresolved"
because the name is dependent and, therefore, cannot be resolved to a
declaration node (as we would do for a DeclRefExpr or
QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to
DeclRefExprs, QualifiedDeclRefExprs, etc.
Also, be a bit more careful about keeping only a single set of
specializations for a class template, and instantiating from the
definition of that template rather than a previous declaration. In
general, we need a better solution for this for all TagDecls, because
it's too easy to accidentally look at a declaration that isn't the
definition.
We can now process a simple Fibonacci computation described as a
template metaprogram.
llvm-svn: 67308
2009-03-20 01:26:29 +08:00
|
|
|
}
|
|
|
|
|
2009-11-21 16:51:07 +08:00
|
|
|
void StmtPrinter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
|
2009-07-01 06:34:41 +08:00
|
|
|
if (Node->getQualifier())
|
|
|
|
Node->getQualifier()->print(OS, Policy);
|
2010-08-12 06:01:17 +08:00
|
|
|
OS << Node->getNameInfo();
|
2009-11-25 03:00:30 +08:00
|
|
|
if (Node->hasExplicitTemplateArgs())
|
|
|
|
OS << TemplateSpecializationType::PrintTemplateArgumentList(
|
|
|
|
Node->getTemplateArgs(),
|
2009-07-01 06:34:41 +08:00
|
|
|
Node->getNumTemplateArgs(),
|
2009-11-25 03:00:30 +08:00
|
|
|
Policy);
|
2009-07-01 06:34:41 +08:00
|
|
|
}
|
|
|
|
|
2007-11-12 22:29:37 +08:00
|
|
|
void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
|
2007-11-13 06:29:28 +08:00
|
|
|
if (Node->getBase()) {
|
|
|
|
PrintExpr(Node->getBase());
|
|
|
|
OS << (Node->isArrow() ? "->" : ".");
|
|
|
|
}
|
2010-04-17 17:33:03 +08:00
|
|
|
OS << Node->getDecl();
|
2007-11-12 22:29:37 +08:00
|
|
|
}
|
|
|
|
|
2008-05-30 08:40:33 +08:00
|
|
|
void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
|
2010-10-15 00:04:05 +08:00
|
|
|
if (Node->isSuperReceiver())
|
|
|
|
OS << "super.";
|
|
|
|
else if (Node->getBase()) {
|
2008-05-30 08:40:33 +08:00
|
|
|
PrintExpr(Node->getBase());
|
|
|
|
OS << ".";
|
|
|
|
}
|
2010-10-15 00:04:05 +08:00
|
|
|
|
2010-12-02 09:19:52 +08:00
|
|
|
if (Node->isImplicitProperty())
|
|
|
|
OS << Node->getImplicitPropertyGetter()->getSelector().getAsString();
|
|
|
|
else
|
|
|
|
OS << Node->getExplicitProperty()->getName();
|
2008-11-23 02:39:36 +08:00
|
|
|
}
|
|
|
|
|
2008-08-10 09:53:14 +08:00
|
|
|
void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
|
2007-07-21 13:21:51 +08:00
|
|
|
switch (Node->getIdentType()) {
|
|
|
|
default:
|
|
|
|
assert(0 && "unknown case");
|
2008-08-10 09:53:14 +08:00
|
|
|
case PredefinedExpr::Func:
|
2007-07-21 13:21:51 +08:00
|
|
|
OS << "__func__";
|
|
|
|
break;
|
2008-08-10 09:53:14 +08:00
|
|
|
case PredefinedExpr::Function:
|
2007-07-21 13:21:51 +08:00
|
|
|
OS << "__FUNCTION__";
|
|
|
|
break;
|
2008-08-10 09:53:14 +08:00
|
|
|
case PredefinedExpr::PrettyFunction:
|
2007-07-21 13:21:51 +08:00
|
|
|
OS << "__PRETTY_FUNCTION__";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 04:39:23 +08:00
|
|
|
void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
|
2007-07-13 13:18:11 +08:00
|
|
|
unsigned value = Node->getValue();
|
2011-07-27 13:40:30 +08:00
|
|
|
|
|
|
|
switch (Node->getKind()) {
|
|
|
|
case CharacterLiteral::Ascii: break; // no prefix.
|
|
|
|
case CharacterLiteral::Wide: OS << 'L'; break;
|
|
|
|
case CharacterLiteral::UTF16: OS << 'u'; break;
|
|
|
|
case CharacterLiteral::UTF32: OS << 'U'; break;
|
|
|
|
}
|
|
|
|
|
2007-07-14 07:58:20 +08:00
|
|
|
switch (value) {
|
|
|
|
case '\\':
|
|
|
|
OS << "'\\\\'";
|
|
|
|
break;
|
|
|
|
case '\'':
|
|
|
|
OS << "'\\''";
|
|
|
|
break;
|
|
|
|
case '\a':
|
|
|
|
// TODO: K&R: the meaning of '\\a' is different in traditional C
|
|
|
|
OS << "'\\a'";
|
|
|
|
break;
|
|
|
|
case '\b':
|
|
|
|
OS << "'\\b'";
|
|
|
|
break;
|
|
|
|
// Nonstandard escape sequence.
|
|
|
|
/*case '\e':
|
|
|
|
OS << "'\\e'";
|
|
|
|
break;*/
|
|
|
|
case '\f':
|
|
|
|
OS << "'\\f'";
|
|
|
|
break;
|
|
|
|
case '\n':
|
|
|
|
OS << "'\\n'";
|
|
|
|
break;
|
|
|
|
case '\r':
|
|
|
|
OS << "'\\r'";
|
|
|
|
break;
|
|
|
|
case '\t':
|
|
|
|
OS << "'\\t'";
|
|
|
|
break;
|
|
|
|
case '\v':
|
|
|
|
OS << "'\\v'";
|
|
|
|
break;
|
|
|
|
default:
|
2008-02-23 08:52:04 +08:00
|
|
|
if (value < 256 && isprint(value)) {
|
2007-07-14 07:58:20 +08:00
|
|
|
OS << "'" << (char)value << "'";
|
|
|
|
} else if (value < 256) {
|
2008-09-13 13:16:45 +08:00
|
|
|
OS << "'\\x" << llvm::format("%x", value) << "'";
|
2007-07-14 07:58:20 +08:00
|
|
|
} else {
|
|
|
|
// FIXME what to really do here?
|
|
|
|
OS << value;
|
|
|
|
}
|
2007-07-13 13:18:11 +08:00
|
|
|
}
|
2007-04-27 04:39:23 +08:00
|
|
|
}
|
|
|
|
|
2007-02-22 07:46:25 +08:00
|
|
|
void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
|
2007-05-21 13:45:03 +08:00
|
|
|
bool isSigned = Node->getType()->isSignedIntegerType();
|
|
|
|
OS << Node->getValue().toString(10, isSigned);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-05-21 13:45:03 +08:00
|
|
|
// Emit suffixes. Integer literals are always a builtin integer type.
|
2009-09-22 07:43:11 +08:00
|
|
|
switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
|
2007-05-21 13:45:03 +08:00
|
|
|
default: assert(0 && "Unexpected type for integer literal!");
|
|
|
|
case BuiltinType::Int: break; // no suffix.
|
|
|
|
case BuiltinType::UInt: OS << 'U'; break;
|
|
|
|
case BuiltinType::Long: OS << 'L'; break;
|
|
|
|
case BuiltinType::ULong: OS << "UL"; break;
|
|
|
|
case BuiltinType::LongLong: OS << "LL"; break;
|
|
|
|
case BuiltinType::ULongLong: OS << "ULL"; break;
|
|
|
|
}
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2007-02-22 06:05:47 +08:00
|
|
|
void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
|
2007-08-01 08:23:58 +08:00
|
|
|
// FIXME: print value more precisely.
|
2008-06-08 06:13:43 +08:00
|
|
|
OS << Node->getValueAsApproximateDouble();
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2007-08-26 11:42:43 +08:00
|
|
|
|
|
|
|
void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
|
|
|
|
PrintExpr(Node->getSubExpr());
|
|
|
|
OS << "i";
|
|
|
|
}
|
|
|
|
|
2007-02-22 07:46:25 +08:00
|
|
|
void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
|
2011-07-27 13:40:30 +08:00
|
|
|
switch (Str->getKind()) {
|
|
|
|
case StringLiteral::Ascii: break; // no prefix.
|
|
|
|
case StringLiteral::Wide: OS << 'L'; break;
|
|
|
|
case StringLiteral::UTF8: OS << "u8"; break;
|
|
|
|
case StringLiteral::UTF16: OS << 'u'; break;
|
|
|
|
case StringLiteral::UTF32: OS << 'U'; break;
|
|
|
|
}
|
2006-11-05 04:29:31 +08:00
|
|
|
OS << '"';
|
2007-10-15 10:50:23 +08:00
|
|
|
|
2006-11-05 04:29:31 +08:00
|
|
|
// FIXME: this doesn't print wstrings right.
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef StrData = Str->getString();
|
|
|
|
for (StringRef::iterator I = StrData.begin(), E = StrData.end();
|
2010-08-17 20:54:38 +08:00
|
|
|
I != E; ++I) {
|
|
|
|
unsigned char Char = *I;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-01-17 03:25:18 +08:00
|
|
|
switch (Char) {
|
|
|
|
default:
|
|
|
|
if (isprint(Char))
|
|
|
|
OS << (char)Char;
|
|
|
|
else // Output anything hard as an octal escape.
|
|
|
|
OS << '\\'
|
|
|
|
<< (char)('0'+ ((Char >> 6) & 7))
|
|
|
|
<< (char)('0'+ ((Char >> 3) & 7))
|
|
|
|
<< (char)('0'+ ((Char >> 0) & 7));
|
|
|
|
break;
|
|
|
|
// Handle some common non-printable cases to make dumps prettier.
|
2006-11-05 04:29:31 +08:00
|
|
|
case '\\': OS << "\\\\"; break;
|
|
|
|
case '"': OS << "\\\""; break;
|
|
|
|
case '\n': OS << "\\n"; break;
|
|
|
|
case '\t': OS << "\\t"; break;
|
|
|
|
case '\a': OS << "\\a"; break;
|
|
|
|
case '\b': OS << "\\b"; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << '"';
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2006-11-05 02:52:07 +08:00
|
|
|
void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
|
|
|
|
OS << "(";
|
|
|
|
PrintExpr(Node->getSubExpr());
|
2007-06-01 02:21:33 +08:00
|
|
|
OS << ")";
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2006-11-05 02:52:07 +08:00
|
|
|
void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
|
2007-08-24 05:46:40 +08:00
|
|
|
if (!Node->isPostfix()) {
|
2006-11-06 07:54:51 +08:00
|
|
|
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-15 06:39:26 +08:00
|
|
|
// Print a space if this is an "identifier operator" like __real, or if
|
|
|
|
// it might be concatenated incorrectly like '+'.
|
2007-08-24 05:46:40 +08:00
|
|
|
switch (Node->getOpcode()) {
|
|
|
|
default: break;
|
2010-08-25 19:45:40 +08:00
|
|
|
case UO_Real:
|
|
|
|
case UO_Imag:
|
|
|
|
case UO_Extension:
|
2007-08-24 05:46:40 +08:00
|
|
|
OS << ' ';
|
|
|
|
break;
|
2010-08-25 19:45:40 +08:00
|
|
|
case UO_Plus:
|
|
|
|
case UO_Minus:
|
2009-06-15 06:39:26 +08:00
|
|
|
if (isa<UnaryOperator>(Node->getSubExpr()))
|
|
|
|
OS << ' ';
|
|
|
|
break;
|
2007-08-24 05:46:40 +08:00
|
|
|
}
|
|
|
|
}
|
2006-11-05 02:52:07 +08:00
|
|
|
PrintExpr(Node->getSubExpr());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2006-11-06 07:54:51 +08:00
|
|
|
if (Node->isPostfix())
|
|
|
|
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
|
2007-08-31 01:59:59 +08:00
|
|
|
}
|
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
|
|
|
|
OS << "__builtin_offsetof(";
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << Node->getTypeSourceInfo()->getType().getAsString(Policy) << ", ";
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
bool PrintedSomething = false;
|
|
|
|
for (unsigned i = 0, n = Node->getNumComponents(); i < n; ++i) {
|
|
|
|
OffsetOfExpr::OffsetOfNode ON = Node->getComponent(i);
|
|
|
|
if (ON.getKind() == OffsetOfExpr::OffsetOfNode::Array) {
|
|
|
|
// Array node
|
|
|
|
OS << "[";
|
|
|
|
PrintExpr(Node->getIndexExpr(ON.getArrayExprIndex()));
|
|
|
|
OS << "]";
|
|
|
|
PrintedSomething = true;
|
|
|
|
continue;
|
|
|
|
}
|
2010-04-29 08:18:15 +08:00
|
|
|
|
|
|
|
// Skip implicit base indirections.
|
|
|
|
if (ON.getKind() == OffsetOfExpr::OffsetOfNode::Base)
|
|
|
|
continue;
|
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
// Field or identifier node.
|
|
|
|
IdentifierInfo *Id = ON.getFieldName();
|
|
|
|
if (!Id)
|
|
|
|
continue;
|
2010-05-05 23:23:54 +08:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
if (PrintedSomething)
|
|
|
|
OS << ".";
|
|
|
|
else
|
|
|
|
PrintedSomething = true;
|
2010-05-05 23:23:54 +08:00
|
|
|
OS << Id->getName();
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
llvm-svn: 102542
2010-04-29 06:16:22 +08:00
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2011-03-12 03:24:49 +08:00
|
|
|
void StmtPrinter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node){
|
|
|
|
switch(Node->getKind()) {
|
|
|
|
case UETT_SizeOf:
|
|
|
|
OS << "sizeof";
|
|
|
|
break;
|
|
|
|
case UETT_AlignOf:
|
|
|
|
OS << "__alignof";
|
|
|
|
break;
|
|
|
|
case UETT_VecStep:
|
|
|
|
OS << "vec_step";
|
|
|
|
break;
|
|
|
|
}
|
2008-11-12 01:56:53 +08:00
|
|
|
if (Node->isArgumentType())
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << "(" << Node->getArgumentType().getAsString(Policy) << ")";
|
2008-11-12 01:56:53 +08:00
|
|
|
else {
|
|
|
|
OS << " ";
|
|
|
|
PrintExpr(Node->getArgumentExpr());
|
|
|
|
}
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2011-04-15 08:35:48 +08:00
|
|
|
|
|
|
|
void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
|
|
|
|
OS << "_Generic(";
|
|
|
|
PrintExpr(Node->getControllingExpr());
|
|
|
|
for (unsigned i = 0; i != Node->getNumAssocs(); ++i) {
|
|
|
|
OS << ", ";
|
|
|
|
QualType T = Node->getAssocType(i);
|
|
|
|
if (T.isNull())
|
|
|
|
OS << "default";
|
|
|
|
else
|
|
|
|
OS << T.getAsString(Policy);
|
|
|
|
OS << ": ";
|
|
|
|
PrintExpr(Node->getAssocExpr(i));
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2006-11-05 02:52:07 +08:00
|
|
|
void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
|
2007-08-21 00:18:38 +08:00
|
|
|
PrintExpr(Node->getLHS());
|
2006-11-05 02:52:07 +08:00
|
|
|
OS << "[";
|
2007-08-21 00:18:38 +08:00
|
|
|
PrintExpr(Node->getRHS());
|
2006-11-05 02:52:07 +08:00
|
|
|
OS << "]";
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
|
|
|
|
2011-02-09 05:17:54 +08:00
|
|
|
void StmtPrinter::PrintCallArgs(CallExpr *Call) {
|
2006-11-05 02:52:07 +08:00
|
|
|
for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
|
2008-04-08 12:40:51 +08:00
|
|
|
if (isa<CXXDefaultArgExpr>(Call->getArg(i))) {
|
|
|
|
// Don't print any defaulted arguments
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-11-05 02:52:07 +08:00
|
|
|
if (i) OS << ", ";
|
|
|
|
PrintExpr(Call->getArg(i));
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2011-02-09 05:17:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitCallExpr(CallExpr *Call) {
|
|
|
|
PrintExpr(Call->getCallee());
|
|
|
|
OS << "(";
|
|
|
|
PrintCallArgs(Call);
|
2006-11-05 02:52:07 +08:00
|
|
|
OS << ")";
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2006-11-05 02:52:07 +08:00
|
|
|
void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
|
2009-01-09 06:45:41 +08:00
|
|
|
// FIXME: Suppress printing implicit bases (like "this")
|
|
|
|
PrintExpr(Node->getBase());
|
2010-01-12 05:17:32 +08:00
|
|
|
if (FieldDecl *FD = dyn_cast<FieldDecl>(Node->getMemberDecl()))
|
|
|
|
if (FD->isAnonymousStructOrUnion())
|
|
|
|
return;
|
2009-01-09 06:45:41 +08:00
|
|
|
OS << (Node->isArrow() ? "->" : ".");
|
2009-09-01 07:41:50 +08:00
|
|
|
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
|
|
|
|
Qualifier->print(OS, Policy);
|
|
|
|
|
2010-08-12 06:01:17 +08:00
|
|
|
OS << Node->getMemberNameInfo();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-20 07:49:38 +08:00
|
|
|
if (Node->hasExplicitTemplateArgs())
|
2009-09-01 08:37:14 +08:00
|
|
|
OS << TemplateSpecializationType::PrintTemplateArgumentList(
|
|
|
|
Node->getTemplateArgs(),
|
|
|
|
Node->getNumTemplateArgs(),
|
|
|
|
Policy);
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2009-07-25 01:54:45 +08:00
|
|
|
void StmtPrinter::VisitObjCIsaExpr(ObjCIsaExpr *Node) {
|
|
|
|
PrintExpr(Node->getBase());
|
|
|
|
OS << (Node->isArrow() ? "->isa" : ".isa");
|
|
|
|
}
|
|
|
|
|
2008-04-19 07:10:10 +08:00
|
|
|
void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
|
2007-07-29 07:10:27 +08:00
|
|
|
PrintExpr(Node->getBase());
|
|
|
|
OS << ".";
|
|
|
|
OS << Node->getAccessor().getName();
|
|
|
|
}
|
2008-10-28 23:36:24 +08:00
|
|
|
void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) {
|
2010-07-01 00:31:08 +08:00
|
|
|
OS << "(" << Node->getType().getAsString(Policy) << ")";
|
2006-11-05 02:52:07 +08:00
|
|
|
PrintExpr(Node->getSubExpr());
|
|
|
|
}
|
2007-07-20 05:32:11 +08:00
|
|
|
void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << "(" << Node->getType().getAsString(Policy) << ")";
|
2007-07-20 05:32:11 +08:00
|
|
|
PrintExpr(Node->getInitializer());
|
|
|
|
}
|
2007-07-14 00:58:59 +08:00
|
|
|
void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
|
2007-07-14 07:32:42 +08:00
|
|
|
// No need to print anything, simply forward to the sub expression.
|
|
|
|
PrintExpr(Node->getSubExpr());
|
2007-07-14 00:58:59 +08:00
|
|
|
}
|
2006-11-05 02:52:07 +08:00
|
|
|
void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
|
|
|
|
PrintExpr(Node->getLHS());
|
|
|
|
OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
|
2007-08-25 10:00:02 +08:00
|
|
|
PrintExpr(Node->getRHS());
|
|
|
|
}
|
|
|
|
void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
|
|
|
|
PrintExpr(Node->getLHS());
|
|
|
|
OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
|
2006-11-05 02:52:07 +08:00
|
|
|
PrintExpr(Node->getRHS());
|
|
|
|
}
|
|
|
|
void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
|
|
|
|
PrintExpr(Node->getCond());
|
2011-02-17 18:25:35 +08:00
|
|
|
OS << " ? ";
|
|
|
|
PrintExpr(Node->getLHS());
|
|
|
|
OS << " : ";
|
2006-11-05 02:52:07 +08:00
|
|
|
PrintExpr(Node->getRHS());
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
|
|
|
|
2007-05-28 14:56:27 +08:00
|
|
|
// GNU extensions.
|
|
|
|
|
2011-02-17 18:25:35 +08:00
|
|
|
void
|
|
|
|
StmtPrinter::VisitBinaryConditionalOperator(BinaryConditionalOperator *Node) {
|
|
|
|
PrintExpr(Node->getCommon());
|
|
|
|
OS << " ?: ";
|
|
|
|
PrintExpr(Node->getFalseExpr());
|
|
|
|
}
|
2007-08-04 01:31:20 +08:00
|
|
|
void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
|
2007-05-28 14:56:27 +08:00
|
|
|
OS << "&&" << Node->getLabel()->getName();
|
|
|
|
}
|
|
|
|
|
2007-07-25 00:58:17 +08:00
|
|
|
void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
|
|
|
|
OS << "(";
|
|
|
|
PrintRawCompoundStmt(E->getSubStmt());
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2007-08-04 05:21:27 +08:00
|
|
|
void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
|
|
|
|
OS << "__builtin_choose_expr(";
|
|
|
|
PrintExpr(Node->getCond());
|
2007-08-04 08:20:15 +08:00
|
|
|
OS << ", ";
|
2007-08-04 05:21:27 +08:00
|
|
|
PrintExpr(Node->getLHS());
|
2007-08-04 08:20:15 +08:00
|
|
|
OS << ", ";
|
2007-08-04 05:21:27 +08:00
|
|
|
PrintExpr(Node->getRHS());
|
|
|
|
OS << ")";
|
|
|
|
}
|
2007-07-25 00:58:17 +08:00
|
|
|
|
2008-11-29 12:51:27 +08:00
|
|
|
void StmtPrinter::VisitGNUNullExpr(GNUNullExpr *) {
|
|
|
|
OS << "__null";
|
|
|
|
}
|
|
|
|
|
2008-05-15 03:38:39 +08:00
|
|
|
void StmtPrinter::VisitShuffleVectorExpr(ShuffleVectorExpr *Node) {
|
|
|
|
OS << "__builtin_shufflevector(";
|
|
|
|
for (unsigned i = 0, e = Node->getNumSubExprs(); i != e; ++i) {
|
|
|
|
if (i) OS << ", ";
|
|
|
|
PrintExpr(Node->getExpr(i));
|
|
|
|
}
|
|
|
|
OS << ")";
|
2008-01-18 01:46:27 +08:00
|
|
|
}
|
|
|
|
|
2007-08-31 12:56:16 +08:00
|
|
|
void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
|
2009-05-30 08:56:08 +08:00
|
|
|
if (Node->getSyntacticForm()) {
|
|
|
|
Visit(Node->getSyntacticForm());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-31 12:56:16 +08:00
|
|
|
OS << "{ ";
|
|
|
|
for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
|
|
|
|
if (i) OS << ", ";
|
2009-01-29 05:54:33 +08:00
|
|
|
if (Node->getInit(i))
|
|
|
|
PrintExpr(Node->getInit(i));
|
|
|
|
else
|
|
|
|
OS << "0";
|
2007-08-31 12:56:16 +08:00
|
|
|
}
|
|
|
|
OS << " }";
|
|
|
|
}
|
|
|
|
|
2009-08-11 07:49:36 +08:00
|
|
|
void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
|
|
|
|
OS << "( ";
|
|
|
|
for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
|
|
|
|
if (i) OS << ", ";
|
|
|
|
PrintExpr(Node->getExpr(i));
|
|
|
|
}
|
|
|
|
OS << " )";
|
|
|
|
}
|
|
|
|
|
2009-01-22 08:58:24 +08:00
|
|
|
void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
|
2009-01-29 05:54:33 +08:00
|
|
|
for (DesignatedInitExpr::designators_iterator D = Node->designators_begin(),
|
|
|
|
DEnd = Node->designators_end();
|
|
|
|
D != DEnd; ++D) {
|
|
|
|
if (D->isFieldDesignator()) {
|
|
|
|
if (D->getDotLoc().isInvalid())
|
|
|
|
OS << D->getFieldName()->getName() << ":";
|
|
|
|
else
|
|
|
|
OS << "." << D->getFieldName()->getName();
|
|
|
|
} else {
|
|
|
|
OS << "[";
|
|
|
|
if (D->isArrayDesignator()) {
|
|
|
|
PrintExpr(Node->getArrayIndex(*D));
|
|
|
|
} else {
|
|
|
|
PrintExpr(Node->getArrayRangeStart(*D));
|
|
|
|
OS << " ... ";
|
2009-09-09 23:08:12 +08:00
|
|
|
PrintExpr(Node->getArrayRangeEnd(*D));
|
2009-01-29 05:54:33 +08:00
|
|
|
}
|
|
|
|
OS << "]";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << " = ";
|
|
|
|
PrintExpr(Node->getInit());
|
2009-01-22 08:58:24 +08:00
|
|
|
}
|
|
|
|
|
2009-01-30 01:44:32 +08:00
|
|
|
void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
|
2009-06-30 09:26:17 +08:00
|
|
|
if (Policy.LangOpts.CPlusPlus)
|
2009-05-30 08:08:05 +08:00
|
|
|
OS << "/*implicit*/" << Node->getType().getAsString(Policy) << "()";
|
|
|
|
else {
|
|
|
|
OS << "/*implicit*/(" << Node->getType().getAsString(Policy) << ")";
|
|
|
|
if (Node->getType()->isRecordType())
|
|
|
|
OS << "{}";
|
|
|
|
else
|
|
|
|
OS << 0;
|
|
|
|
}
|
2009-01-30 01:44:32 +08:00
|
|
|
}
|
|
|
|
|
2007-10-16 04:28:48 +08:00
|
|
|
void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
|
2009-05-30 12:20:30 +08:00
|
|
|
OS << "__builtin_va_arg(";
|
2007-10-16 04:28:48 +08:00
|
|
|
PrintExpr(Node->getSubExpr());
|
|
|
|
OS << ", ";
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << Node->getType().getAsString(Policy);
|
2007-10-16 04:28:48 +08:00
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2007-05-28 14:56:27 +08:00
|
|
|
// C++
|
2008-11-15 00:09:21 +08:00
|
|
|
void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
|
|
|
|
const char *OpStrings[NUM_OVERLOADED_OPERATORS] = {
|
|
|
|
"",
|
|
|
|
#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
|
|
|
|
Spelling,
|
|
|
|
#include "clang/Basic/OperatorKinds.def"
|
|
|
|
};
|
|
|
|
|
|
|
|
OverloadedOperatorKind Kind = Node->getOperator();
|
|
|
|
if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
|
|
|
|
if (Node->getNumArgs() == 1) {
|
|
|
|
OS << OpStrings[Kind] << ' ';
|
|
|
|
PrintExpr(Node->getArg(0));
|
|
|
|
} else {
|
|
|
|
PrintExpr(Node->getArg(0));
|
|
|
|
OS << ' ' << OpStrings[Kind];
|
|
|
|
}
|
|
|
|
} else if (Kind == OO_Call) {
|
|
|
|
PrintExpr(Node->getArg(0));
|
|
|
|
OS << '(';
|
|
|
|
for (unsigned ArgIdx = 1; ArgIdx < Node->getNumArgs(); ++ArgIdx) {
|
|
|
|
if (ArgIdx > 1)
|
|
|
|
OS << ", ";
|
|
|
|
if (!isa<CXXDefaultArgExpr>(Node->getArg(ArgIdx)))
|
|
|
|
PrintExpr(Node->getArg(ArgIdx));
|
|
|
|
}
|
|
|
|
OS << ')';
|
|
|
|
} else if (Kind == OO_Subscript) {
|
|
|
|
PrintExpr(Node->getArg(0));
|
|
|
|
OS << '[';
|
|
|
|
PrintExpr(Node->getArg(1));
|
|
|
|
OS << ']';
|
|
|
|
} else if (Node->getNumArgs() == 1) {
|
|
|
|
OS << OpStrings[Kind] << ' ';
|
|
|
|
PrintExpr(Node->getArg(0));
|
|
|
|
} else if (Node->getNumArgs() == 2) {
|
|
|
|
PrintExpr(Node->getArg(0));
|
|
|
|
OS << ' ' << OpStrings[Kind] << ' ';
|
|
|
|
PrintExpr(Node->getArg(1));
|
|
|
|
} else {
|
|
|
|
assert(false && "unknown overloaded operator");
|
|
|
|
}
|
|
|
|
}
|
2007-05-28 14:56:27 +08:00
|
|
|
|
2008-12-22 13:46:06 +08:00
|
|
|
void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
|
|
|
|
VisitCallExpr(cast<CallExpr>(Node));
|
|
|
|
}
|
|
|
|
|
2011-02-10 05:07:24 +08:00
|
|
|
void StmtPrinter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *Node) {
|
|
|
|
PrintExpr(Node->getCallee());
|
|
|
|
OS << "<<<";
|
|
|
|
PrintCallArgs(Node->getConfig());
|
|
|
|
OS << ">>>(";
|
|
|
|
PrintCallArgs(Node);
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2008-10-28 03:41:14 +08:00
|
|
|
void StmtPrinter::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
|
|
|
|
OS << Node->getCastName() << '<';
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << Node->getTypeAsWritten().getAsString(Policy) << ">(";
|
2007-05-28 14:56:27 +08:00
|
|
|
PrintExpr(Node->getSubExpr());
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2008-10-28 03:41:14 +08:00
|
|
|
void StmtPrinter::VisitCXXStaticCastExpr(CXXStaticCastExpr *Node) {
|
|
|
|
VisitCXXNamedCastExpr(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *Node) {
|
|
|
|
VisitCXXNamedCastExpr(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *Node) {
|
|
|
|
VisitCXXNamedCastExpr(Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitCXXConstCastExpr(CXXConstCastExpr *Node) {
|
|
|
|
VisitCXXNamedCastExpr(Node);
|
|
|
|
}
|
|
|
|
|
2008-11-11 19:37:55 +08:00
|
|
|
void StmtPrinter::VisitCXXTypeidExpr(CXXTypeidExpr *Node) {
|
|
|
|
OS << "typeid(";
|
|
|
|
if (Node->isTypeOperand()) {
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << Node->getTypeOperand().getAsString(Policy);
|
2008-11-11 19:37:55 +08:00
|
|
|
} else {
|
|
|
|
PrintExpr(Node->getExprOperand());
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2010-09-08 20:20:18 +08:00
|
|
|
void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) {
|
|
|
|
OS << "__uuidof(";
|
|
|
|
if (Node->isTypeOperand()) {
|
|
|
|
OS << Node->getTypeOperand().getAsString(Policy);
|
|
|
|
} else {
|
|
|
|
PrintExpr(Node->getExprOperand());
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2007-05-28 14:56:27 +08:00
|
|
|
void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
|
|
|
|
OS << (Node->getValue() ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
2009-05-11 02:38:11 +08:00
|
|
|
void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) {
|
|
|
|
OS << "nullptr";
|
|
|
|
}
|
|
|
|
|
2008-11-04 22:32:21 +08:00
|
|
|
void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) {
|
|
|
|
OS << "this";
|
|
|
|
}
|
|
|
|
|
2008-02-26 08:51:44 +08:00
|
|
|
void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
|
|
|
|
if (Node->getSubExpr() == 0)
|
|
|
|
OS << "throw";
|
|
|
|
else {
|
|
|
|
OS << "throw ";
|
|
|
|
PrintExpr(Node->getSubExpr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-08 12:40:51 +08:00
|
|
|
void StmtPrinter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Node) {
|
|
|
|
// Nothing to print: we picked up the default argument
|
|
|
|
}
|
|
|
|
|
2008-08-22 23:38:55 +08:00
|
|
|
void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << Node->getType().getAsString(Policy);
|
2008-08-22 23:38:55 +08:00
|
|
|
OS << "(";
|
|
|
|
PrintExpr(Node->getSubExpr());
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2009-05-31 04:03:25 +08:00
|
|
|
void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
|
2010-01-29 10:39:32 +08:00
|
|
|
PrintExpr(Node->getSubExpr());
|
|
|
|
}
|
|
|
|
|
2009-01-17 02:33:17 +08:00
|
|
|
void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << Node->getType().getAsString(Policy);
|
2009-01-17 02:33:17 +08:00
|
|
|
OS << "(";
|
|
|
|
for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(),
|
2009-09-09 23:08:12 +08:00
|
|
|
ArgEnd = Node->arg_end();
|
2009-01-17 02:33:17 +08:00
|
|
|
Arg != ArgEnd; ++Arg) {
|
|
|
|
if (Arg != Node->arg_begin())
|
|
|
|
OS << ", ";
|
|
|
|
PrintExpr(*Arg);
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2010-07-08 14:14:04 +08:00
|
|
|
void StmtPrinter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *Node) {
|
2010-09-08 08:15:04 +08:00
|
|
|
if (TypeSourceInfo *TSInfo = Node->getTypeSourceInfo())
|
|
|
|
OS << TSInfo->getType().getAsString(Policy) << "()";
|
|
|
|
else
|
|
|
|
OS << Node->getType().getAsString(Policy) << "()";
|
2008-08-22 23:38:55 +08:00
|
|
|
}
|
|
|
|
|
2008-11-22 03:14:01 +08:00
|
|
|
void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
|
|
|
|
if (E->isGlobalNew())
|
|
|
|
OS << "::";
|
|
|
|
OS << "new ";
|
|
|
|
unsigned NumPlace = E->getNumPlacementArgs();
|
|
|
|
if (NumPlace > 0) {
|
|
|
|
OS << "(";
|
|
|
|
PrintExpr(E->getPlacementArg(0));
|
|
|
|
for (unsigned i = 1; i < NumPlace; ++i) {
|
|
|
|
OS << ", ";
|
|
|
|
PrintExpr(E->getPlacementArg(i));
|
|
|
|
}
|
|
|
|
OS << ") ";
|
|
|
|
}
|
|
|
|
if (E->isParenTypeId())
|
|
|
|
OS << "(";
|
2008-12-03 06:08:59 +08:00
|
|
|
std::string TypeS;
|
|
|
|
if (Expr *Size = E->getArraySize()) {
|
|
|
|
llvm::raw_string_ostream s(TypeS);
|
2009-05-30 13:32:46 +08:00
|
|
|
Size->printPretty(s, Context, Helper, Policy);
|
2008-12-03 06:08:59 +08:00
|
|
|
s.flush();
|
|
|
|
TypeS = "[" + TypeS + "]";
|
|
|
|
}
|
2009-05-30 04:38:28 +08:00
|
|
|
E->getAllocatedType().getAsStringInternal(TypeS, Policy);
|
2008-12-03 06:08:59 +08:00
|
|
|
OS << TypeS;
|
2008-11-22 03:14:01 +08:00
|
|
|
if (E->isParenTypeId())
|
|
|
|
OS << ")";
|
|
|
|
|
|
|
|
if (E->hasInitializer()) {
|
|
|
|
OS << "(";
|
|
|
|
unsigned NumCons = E->getNumConstructorArgs();
|
|
|
|
if (NumCons > 0) {
|
|
|
|
PrintExpr(E->getConstructorArg(0));
|
|
|
|
for (unsigned i = 1; i < NumCons; ++i) {
|
|
|
|
OS << ", ";
|
|
|
|
PrintExpr(E->getConstructorArg(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
|
|
|
|
if (E->isGlobalDelete())
|
|
|
|
OS << "::";
|
|
|
|
OS << "delete ";
|
|
|
|
if (E->isArrayForm())
|
|
|
|
OS << "[] ";
|
|
|
|
PrintExpr(E->getArgument());
|
|
|
|
}
|
|
|
|
|
2009-09-05 01:36:40 +08:00
|
|
|
void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
|
|
|
|
PrintExpr(E->getBase());
|
|
|
|
if (E->isArrow())
|
|
|
|
OS << "->";
|
|
|
|
else
|
|
|
|
OS << '.';
|
|
|
|
if (E->getQualifier())
|
|
|
|
E->getQualifier()->print(OS, Policy);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-05 01:36:40 +08:00
|
|
|
std::string TypeS;
|
2010-02-25 09:56:36 +08:00
|
|
|
if (IdentifierInfo *II = E->getDestroyedTypeIdentifier())
|
|
|
|
OS << II->getName();
|
|
|
|
else
|
|
|
|
E->getDestroyedType().getAsStringInternal(TypeS, Policy);
|
2009-09-05 01:36:40 +08:00
|
|
|
OS << TypeS;
|
|
|
|
}
|
|
|
|
|
2009-04-23 10:32:43 +08:00
|
|
|
void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
|
2011-01-25 01:25:03 +08:00
|
|
|
for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
|
|
|
|
if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
|
|
|
|
// Don't print any defaulted arguments
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i) OS << ", ";
|
|
|
|
PrintExpr(E->getArg(i));
|
2010-01-14 05:41:11 +08:00
|
|
|
}
|
2009-04-23 10:32:43 +08:00
|
|
|
}
|
|
|
|
|
2010-12-06 16:20:24 +08:00
|
|
|
void StmtPrinter::VisitExprWithCleanups(ExprWithCleanups *E) {
|
2009-04-25 06:47:04 +08:00
|
|
|
// Just forward to the sub expression.
|
|
|
|
PrintExpr(E->getSubExpr());
|
|
|
|
}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
void
|
Introduce a new expression type, CXXUnresolvedConstructExpr, to
describe the construction of a value of a given type using function
syntax, e.g.,
T(a1, a2, ..., aN)
when the type or any of its arguments are type-dependent. In this
case, we don't know what kind of type-construction this will be: it
might construct a temporary of type 'T' (which might be a class or
non-class type) or might perform a conversion to type 'T'. Also,
implement printing of and template instantiation for this new
expression type. Due to the change in Sema::ActOnCXXTypeConstructExpr,
our existing tests cover template instantiation of this new expression
node.
llvm-svn: 72176
2009-05-21 02:46:25 +08:00
|
|
|
StmtPrinter::VisitCXXUnresolvedConstructExpr(
|
|
|
|
CXXUnresolvedConstructExpr *Node) {
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << Node->getTypeAsWritten().getAsString(Policy);
|
Introduce a new expression type, CXXUnresolvedConstructExpr, to
describe the construction of a value of a given type using function
syntax, e.g.,
T(a1, a2, ..., aN)
when the type or any of its arguments are type-dependent. In this
case, we don't know what kind of type-construction this will be: it
might construct a temporary of type 'T' (which might be a class or
non-class type) or might perform a conversion to type 'T'. Also,
implement printing of and template instantiation for this new
expression type. Due to the change in Sema::ActOnCXXTypeConstructExpr,
our existing tests cover template instantiation of this new expression
node.
llvm-svn: 72176
2009-05-21 02:46:25 +08:00
|
|
|
OS << "(";
|
|
|
|
for (CXXUnresolvedConstructExpr::arg_iterator Arg = Node->arg_begin(),
|
2009-09-09 23:08:12 +08:00
|
|
|
ArgEnd = Node->arg_end();
|
Introduce a new expression type, CXXUnresolvedConstructExpr, to
describe the construction of a value of a given type using function
syntax, e.g.,
T(a1, a2, ..., aN)
when the type or any of its arguments are type-dependent. In this
case, we don't know what kind of type-construction this will be: it
might construct a temporary of type 'T' (which might be a class or
non-class type) or might perform a conversion to type 'T'. Also,
implement printing of and template instantiation for this new
expression type. Due to the change in Sema::ActOnCXXTypeConstructExpr,
our existing tests cover template instantiation of this new expression
node.
llvm-svn: 72176
2009-05-21 02:46:25 +08:00
|
|
|
Arg != ArgEnd; ++Arg) {
|
|
|
|
if (Arg != Node->arg_begin())
|
|
|
|
OS << ", ";
|
|
|
|
PrintExpr(*Arg);
|
|
|
|
}
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2009-11-20 06:55:06 +08:00
|
|
|
void StmtPrinter::VisitCXXDependentScopeMemberExpr(
|
|
|
|
CXXDependentScopeMemberExpr *Node) {
|
2009-12-02 06:10:20 +08:00
|
|
|
if (!Node->isImplicitAccess()) {
|
|
|
|
PrintExpr(Node->getBase());
|
|
|
|
OS << (Node->isArrow() ? "->" : ".");
|
|
|
|
}
|
2009-09-04 00:14:30 +08:00
|
|
|
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
|
|
|
|
Qualifier->print(OS, Policy);
|
2009-12-02 06:10:20 +08:00
|
|
|
else if (Node->hasExplicitTemplateArgs())
|
2009-09-09 08:23:06 +08:00
|
|
|
// FIXME: Track use of "template" keyword explicitly?
|
|
|
|
OS << "template ";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-08-12 06:01:17 +08:00
|
|
|
OS << Node->getMemberNameInfo();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-12-02 06:10:20 +08:00
|
|
|
if (Node->hasExplicitTemplateArgs()) {
|
2009-09-09 08:23:06 +08:00
|
|
|
OS << TemplateSpecializationType::PrintTemplateArgumentList(
|
|
|
|
Node->getTemplateArgs(),
|
|
|
|
Node->getNumTemplateArgs(),
|
|
|
|
Policy);
|
|
|
|
}
|
2009-05-23 05:13:27 +08:00
|
|
|
}
|
|
|
|
|
2009-12-01 06:42:35 +08:00
|
|
|
void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
|
2009-12-02 06:10:20 +08:00
|
|
|
if (!Node->isImplicitAccess()) {
|
|
|
|
PrintExpr(Node->getBase());
|
|
|
|
OS << (Node->isArrow() ? "->" : ".");
|
|
|
|
}
|
2009-12-01 06:42:35 +08:00
|
|
|
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
|
|
|
|
Qualifier->print(OS, Policy);
|
|
|
|
|
|
|
|
// FIXME: this might originally have been written with 'template'
|
|
|
|
|
2010-08-12 06:01:17 +08:00
|
|
|
OS << Node->getMemberNameInfo();
|
2009-12-01 06:42:35 +08:00
|
|
|
|
|
|
|
if (Node->hasExplicitTemplateArgs()) {
|
|
|
|
OS << TemplateSpecializationType::PrintTemplateArgumentList(
|
|
|
|
Node->getTemplateArgs(),
|
|
|
|
Node->getNumTemplateArgs(),
|
|
|
|
Policy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-06 04:52:13 +08:00
|
|
|
static const char *getTypeTraitName(UnaryTypeTrait UTT) {
|
|
|
|
switch (UTT) {
|
|
|
|
case UTT_HasNothrowAssign: return "__has_nothrow_assign";
|
|
|
|
case UTT_HasNothrowConstructor: return "__has_nothrow_constructor";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_HasNothrowCopy: return "__has_nothrow_copy";
|
2009-01-06 04:52:13 +08:00
|
|
|
case UTT_HasTrivialAssign: return "__has_trivial_assign";
|
2011-05-10 02:22:59 +08:00
|
|
|
case UTT_HasTrivialDefaultConstructor: return "__has_trivial_constructor";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_HasTrivialCopy: return "__has_trivial_copy";
|
2009-01-06 04:52:13 +08:00
|
|
|
case UTT_HasTrivialDestructor: return "__has_trivial_destructor";
|
|
|
|
case UTT_HasVirtualDestructor: return "__has_virtual_destructor";
|
|
|
|
case UTT_IsAbstract: return "__is_abstract";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_IsArithmetic: return "__is_arithmetic";
|
|
|
|
case UTT_IsArray: return "__is_array";
|
2009-01-06 04:52:13 +08:00
|
|
|
case UTT_IsClass: return "__is_class";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_IsCompleteType: return "__is_complete_type";
|
|
|
|
case UTT_IsCompound: return "__is_compound";
|
|
|
|
case UTT_IsConst: return "__is_const";
|
2009-01-06 04:52:13 +08:00
|
|
|
case UTT_IsEmpty: return "__is_empty";
|
|
|
|
case UTT_IsEnum: return "__is_enum";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_IsFloatingPoint: return "__is_floating_point";
|
|
|
|
case UTT_IsFunction: return "__is_function";
|
|
|
|
case UTT_IsFundamental: return "__is_fundamental";
|
|
|
|
case UTT_IsIntegral: return "__is_integral";
|
2011-05-01 15:23:20 +08:00
|
|
|
case UTT_IsLiteral: return "__is_literal";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_IsLvalueReference: return "__is_lvalue_reference";
|
|
|
|
case UTT_IsMemberFunctionPointer: return "__is_member_function_pointer";
|
|
|
|
case UTT_IsMemberObjectPointer: return "__is_member_object_pointer";
|
|
|
|
case UTT_IsMemberPointer: return "__is_member_pointer";
|
|
|
|
case UTT_IsObject: return "__is_object";
|
2009-01-06 04:52:13 +08:00
|
|
|
case UTT_IsPOD: return "__is_pod";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_IsPointer: return "__is_pointer";
|
2009-01-06 04:52:13 +08:00
|
|
|
case UTT_IsPolymorphic: return "__is_polymorphic";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_IsReference: return "__is_reference";
|
|
|
|
case UTT_IsRvalueReference: return "__is_rvalue_reference";
|
|
|
|
case UTT_IsScalar: return "__is_scalar";
|
|
|
|
case UTT_IsSigned: return "__is_signed";
|
|
|
|
case UTT_IsStandardLayout: return "__is_standard_layout";
|
|
|
|
case UTT_IsTrivial: return "__is_trivial";
|
2011-05-13 08:31:07 +08:00
|
|
|
case UTT_IsTriviallyCopyable: return "__is_trivially_copyable";
|
2009-01-06 04:52:13 +08:00
|
|
|
case UTT_IsUnion: return "__is_union";
|
2011-04-28 07:09:49 +08:00
|
|
|
case UTT_IsUnsigned: return "__is_unsigned";
|
|
|
|
case UTT_IsVoid: return "__is_void";
|
|
|
|
case UTT_IsVolatile: return "__is_volatile";
|
2009-01-06 04:52:13 +08:00
|
|
|
}
|
2011-05-01 15:23:20 +08:00
|
|
|
llvm_unreachable("Type trait not covered by switch statement");
|
2010-12-07 08:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *getTypeTraitName(BinaryTypeTrait BTT) {
|
|
|
|
switch (BTT) {
|
2010-12-09 06:35:30 +08:00
|
|
|
case BTT_IsBaseOf: return "__is_base_of";
|
2011-04-28 07:09:49 +08:00
|
|
|
case BTT_IsConvertible: return "__is_convertible";
|
|
|
|
case BTT_IsSame: return "__is_same";
|
2010-12-09 06:35:30 +08:00
|
|
|
case BTT_TypeCompatible: return "__builtin_types_compatible_p";
|
2011-01-28 04:28:01 +08:00
|
|
|
case BTT_IsConvertibleTo: return "__is_convertible_to";
|
2010-12-07 08:08:36 +08:00
|
|
|
}
|
2011-05-01 15:23:23 +08:00
|
|
|
llvm_unreachable("Binary type trait not covered by switch");
|
2009-01-06 04:52:13 +08:00
|
|
|
}
|
|
|
|
|
2011-04-28 08:16:57 +08:00
|
|
|
static const char *getTypeTraitName(ArrayTypeTrait ATT) {
|
|
|
|
switch (ATT) {
|
|
|
|
case ATT_ArrayRank: return "__array_rank";
|
|
|
|
case ATT_ArrayExtent: return "__array_extent";
|
|
|
|
}
|
2011-05-01 15:23:23 +08:00
|
|
|
llvm_unreachable("Array type trait not covered by switch");
|
2011-04-28 08:16:57 +08:00
|
|
|
}
|
|
|
|
|
2011-04-25 14:54:41 +08:00
|
|
|
static const char *getExpressionTraitName(ExpressionTrait ET) {
|
|
|
|
switch (ET) {
|
|
|
|
case ET_IsLValueExpr: return "__is_lvalue_expr";
|
|
|
|
case ET_IsRValueExpr: return "__is_rvalue_expr";
|
|
|
|
}
|
2011-05-01 15:23:23 +08:00
|
|
|
llvm_unreachable("Expression type trait not covered by switch");
|
2011-04-25 14:54:41 +08:00
|
|
|
}
|
|
|
|
|
2009-01-06 04:52:13 +08:00
|
|
|
void StmtPrinter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
|
|
|
OS << getTypeTraitName(E->getTrait()) << "("
|
2010-07-01 03:16:48 +08:00
|
|
|
<< E->getQueriedType().getAsString(Policy) << ")";
|
2009-01-06 04:52:13 +08:00
|
|
|
}
|
|
|
|
|
2010-12-07 08:08:36 +08:00
|
|
|
void StmtPrinter::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
|
|
|
|
OS << getTypeTraitName(E->getTrait()) << "("
|
|
|
|
<< E->getLhsType().getAsString(Policy) << ","
|
|
|
|
<< E->getRhsType().getAsString(Policy) << ")";
|
|
|
|
}
|
|
|
|
|
2011-04-28 08:16:57 +08:00
|
|
|
void StmtPrinter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
|
|
|
|
OS << getTypeTraitName(E->getTrait()) << "("
|
|
|
|
<< E->getQueriedType().getAsString(Policy) << ")";
|
|
|
|
}
|
|
|
|
|
2011-04-25 14:54:41 +08:00
|
|
|
void StmtPrinter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
|
|
|
|
OS << getExpressionTraitName(E->getTrait()) << "(";
|
|
|
|
PrintExpr(E->getQueriedExpression());
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2010-09-11 04:55:43 +08:00
|
|
|
void StmtPrinter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
|
|
|
|
OS << "noexcept(";
|
|
|
|
PrintExpr(E->getOperand());
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2011-01-05 01:33:58 +08:00
|
|
|
void StmtPrinter::VisitPackExpansionExpr(PackExpansionExpr *E) {
|
2011-01-04 01:17:50 +08:00
|
|
|
PrintExpr(E->getPattern());
|
|
|
|
OS << "...";
|
|
|
|
}
|
|
|
|
|
2011-01-05 01:33:58 +08:00
|
|
|
void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
|
|
|
|
OS << "sizeof...(" << E->getPack()->getNameAsString() << ")";
|
|
|
|
}
|
|
|
|
|
2011-01-15 09:15:58 +08:00
|
|
|
void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
|
|
|
|
SubstNonTypeTemplateParmPackExpr *Node) {
|
|
|
|
OS << Node->getParameterPack()->getNameAsString();
|
|
|
|
}
|
|
|
|
|
2011-07-15 13:09:51 +08:00
|
|
|
void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
|
|
|
|
SubstNonTypeTemplateParmExpr *Node) {
|
|
|
|
Visit(Node->getReplacement());
|
|
|
|
}
|
|
|
|
|
2011-06-22 01:03:29 +08:00
|
|
|
void StmtPrinter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *Node){
|
|
|
|
PrintExpr(Node->GetTemporaryExpr());
|
|
|
|
}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
// Obj-C
|
2007-08-22 01:43:55 +08:00
|
|
|
|
|
|
|
void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
|
|
|
|
OS << "@";
|
|
|
|
VisitStringLiteral(Node->getString());
|
|
|
|
}
|
2007-05-28 14:56:27 +08:00
|
|
|
|
2007-08-22 23:14:15 +08:00
|
|
|
void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
|
2010-07-01 03:16:48 +08:00
|
|
|
OS << "@encode(" << Node->getEncodedType().getAsString(Policy) << ')';
|
2007-08-22 23:14:15 +08:00
|
|
|
}
|
|
|
|
|
2007-10-17 04:40:23 +08:00
|
|
|
void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
|
2008-11-24 12:00:27 +08:00
|
|
|
OS << "@selector(" << Node->getSelector().getAsString() << ')';
|
2007-10-17 04:40:23 +08:00
|
|
|
}
|
|
|
|
|
2007-10-18 00:58:11 +08:00
|
|
|
void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
|
2010-04-17 17:33:03 +08:00
|
|
|
OS << "@protocol(" << Node->getProtocol() << ')';
|
2007-10-18 00:58:11 +08:00
|
|
|
}
|
|
|
|
|
2007-09-19 07:55:05 +08:00
|
|
|
void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
|
|
|
|
OS << "[";
|
Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:
1) Send to a object instance described by an expression (e.g., [x method:5])
2) Send to a class described by the class name (e.g., [NSString method:5])
3) Send to a superclass class (e.g, [super method:5] in class method)
4) Send to a superclass instance (e.g., [super method:5] in instance method)
Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:
1) Unchanged; the object instance is represented by an Expr*.
2) Previously stored the ObjCInterfaceDecl* referring to the class
receiving the message. Now stores a TypeSourceInfo* so that we know
how the class was spelled. This both maintains typedef information
and opens the door for more complicated C++ types (e.g., dependent
types). There was an alternative, unused representation of these
sends by naming the class via an IdentifierInfo *. In practice, we
either had an ObjCInterfaceDecl *, from which we would get the
IdentifierInfo *, or we fell into the case below...
3) Previously represented by a class message whose IdentifierInfo *
referred to "super". Sema and CodeGen would use isStr("super") to
determine if they had a send to super. Now represented as a
"class super" send, where we have both the location of the "super"
keyword and the ObjCInterfaceDecl* of the superclass we're
targetting (statically).
4) Previously represented by an instance message whose receiver is a
an ObjCSuperExpr, which Sema and CodeGen would check for via
isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
where we have both the location of the "super" keyword and the
ObjCInterfaceDecl* of the superclass we're targetting
(statically). Note that ObjCSuperExpr only has one remaining use in
the AST, which is for "super.prop" references.
The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!
This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:
if (message has a receiver expression) {
// instance message
if (isa<ObjCSuperExpr>(...)) {
// send to super
} else {
// send to an object
}
} else {
// class message
if (name->isStr("super")) {
// class send to super
} else {
// send to class
}
}
with a switch
switch (E->getReceiverKind()) {
case ObjCMessageExpr::SuperInstance: ...
case ObjCMessageExpr::Instance: ...
case ObjCMessageExpr::SuperClass: ...
case ObjCMessageExpr::Class:...
}
There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.
llvm-svn: 101972
2010-04-21 08:45:42 +08:00
|
|
|
switch (Mess->getReceiverKind()) {
|
|
|
|
case ObjCMessageExpr::Instance:
|
|
|
|
PrintExpr(Mess->getInstanceReceiver());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::Class:
|
|
|
|
OS << Mess->getClassReceiver().getAsString(Policy);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ObjCMessageExpr::SuperInstance:
|
|
|
|
case ObjCMessageExpr::SuperClass:
|
|
|
|
OS << "Super";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-05-03 01:32:38 +08:00
|
|
|
OS << ' ';
|
2008-04-16 12:30:16 +08:00
|
|
|
Selector selector = Mess->getSelector();
|
2007-10-03 04:01:56 +08:00
|
|
|
if (selector.isUnarySelector()) {
|
2011-02-19 06:29:55 +08:00
|
|
|
OS << selector.getNameForSlot(0);
|
2007-10-03 04:01:56 +08:00
|
|
|
} else {
|
|
|
|
for (unsigned i = 0, e = Mess->getNumArgs(); i != e; ++i) {
|
2008-05-03 01:32:38 +08:00
|
|
|
if (i < selector.getNumArgs()) {
|
|
|
|
if (i > 0) OS << ' ';
|
|
|
|
if (selector.getIdentifierInfoForSlot(i))
|
2008-11-24 12:00:27 +08:00
|
|
|
OS << selector.getIdentifierInfoForSlot(i)->getName() << ':';
|
2008-05-03 01:32:38 +08:00
|
|
|
else
|
|
|
|
OS << ":";
|
|
|
|
}
|
|
|
|
else OS << ", "; // Handle variadic methods.
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-10-03 04:01:56 +08:00
|
|
|
PrintExpr(Mess->getArg(i));
|
|
|
|
}
|
2007-09-19 07:55:05 +08:00
|
|
|
}
|
|
|
|
OS << "]";
|
|
|
|
}
|
|
|
|
|
2011-06-16 07:02:42 +08:00
|
|
|
void
|
|
|
|
StmtPrinter::VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
|
|
|
|
PrintExpr(E->getSubExpr());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StmtPrinter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
|
|
|
|
OS << "(" << E->getBridgeKindName() << E->getType().getAsString(Policy)
|
|
|
|
<< ")";
|
|
|
|
PrintExpr(E->getSubExpr());
|
|
|
|
}
|
2008-11-04 22:56:14 +08:00
|
|
|
|
2008-09-04 02:15:37 +08:00
|
|
|
void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
|
2008-10-09 01:01:13 +08:00
|
|
|
BlockDecl *BD = Node->getBlockDecl();
|
2008-09-04 02:15:37 +08:00
|
|
|
OS << "^";
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-09-04 02:15:37 +08:00
|
|
|
const FunctionType *AFT = Node->getFunctionType();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-02-27 07:50:07 +08:00
|
|
|
if (isa<FunctionNoProtoType>(AFT)) {
|
2008-09-04 02:15:37 +08:00
|
|
|
OS << "()";
|
2009-02-27 07:50:07 +08:00
|
|
|
} else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
|
2008-09-04 02:15:37 +08:00
|
|
|
OS << '(';
|
|
|
|
std::string ParamStr;
|
2008-10-09 01:01:13 +08:00
|
|
|
for (BlockDecl::param_iterator AI = BD->param_begin(),
|
|
|
|
E = BD->param_end(); AI != E; ++AI) {
|
|
|
|
if (AI != BD->param_begin()) OS << ", ";
|
2008-11-24 12:00:27 +08:00
|
|
|
ParamStr = (*AI)->getNameAsString();
|
2009-05-30 04:38:28 +08:00
|
|
|
(*AI)->getType().getAsStringInternal(ParamStr, Policy);
|
2008-09-04 02:15:37 +08:00
|
|
|
OS << ParamStr;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-02-27 07:50:07 +08:00
|
|
|
const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
|
2008-09-04 02:15:37 +08:00
|
|
|
if (FT->isVariadic()) {
|
2008-10-09 01:01:13 +08:00
|
|
|
if (!BD->param_empty()) OS << ", ";
|
2008-09-04 02:15:37 +08:00
|
|
|
OS << "...";
|
|
|
|
}
|
|
|
|
OS << ')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) {
|
2010-04-17 17:33:03 +08:00
|
|
|
OS << Node->getDecl();
|
2008-09-04 02:15:37 +08:00
|
|
|
}
|
2010-11-16 07:31:06 +08:00
|
|
|
|
|
|
|
void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {}
|
|
|
|
|
2011-06-04 08:47:47 +08:00
|
|
|
void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
|
|
|
|
OS << "__builtin_astype(";
|
|
|
|
PrintExpr(Node->getSrcExpr());
|
|
|
|
OS << ", " << Node->getType().getAsString();
|
|
|
|
OS << ")";
|
|
|
|
}
|
|
|
|
|
2006-11-04 15:16:25 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Stmt method implementations
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-05-30 13:03:24 +08:00
|
|
|
void Stmt::dumpPretty(ASTContext& Context) const {
|
2010-08-09 18:54:31 +08:00
|
|
|
printPretty(llvm::errs(), Context, 0,
|
2009-06-30 09:26:17 +08:00
|
|
|
PrintingPolicy(Context.getLangOptions()));
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
|
|
|
|
2011-07-23 18:55:15 +08:00
|
|
|
void Stmt::printPretty(raw_ostream &OS, ASTContext& Context,
|
2009-05-30 13:03:24 +08:00
|
|
|
PrinterHelper* Helper,
|
2009-05-30 04:38:28 +08:00
|
|
|
const PrintingPolicy &Policy,
|
|
|
|
unsigned Indentation) const {
|
2006-11-05 02:52:07 +08:00
|
|
|
if (this == 0) {
|
|
|
|
OS << "<NULL>";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-17 06:46:09 +08:00
|
|
|
if (Policy.Dump && &Context) {
|
2010-08-09 18:54:31 +08:00
|
|
|
dump(OS, Context.getSourceManager());
|
2009-05-30 08:08:05 +08:00
|
|
|
return;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-30 13:03:24 +08:00
|
|
|
StmtPrinter P(OS, Context, Helper, Policy, Indentation);
|
2007-08-21 12:04:25 +08:00
|
|
|
P.Visit(const_cast<Stmt*>(this));
|
2006-11-04 15:16:25 +08:00
|
|
|
}
|
2007-09-01 05:30:12 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// PrinterHelper
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Implement virtual destructor.
|
2007-09-11 23:32:40 +08:00
|
|
|
PrinterHelper::~PrinterHelper() {}
|