[cfe-commits] r39262 - /cfe/cfe/trunk/Driver/clang.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:42:08 PDT 2007
Author: sabre
Date: Wed Jul 11 11:42:07 2007
New Revision: 39262
URL: http://llvm.org/viewvc/llvm-project?rev=39262&view=rev
Log:
Pretty print function prototypes as well.
Modified:
cfe/cfe/trunk/Driver/clang.cpp
Modified: cfe/cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/clang.cpp?rev=39262&r1=39261&r2=39262&view=diff
==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:42:07 2007
@@ -814,14 +814,16 @@
static void PrintFunctionDecl(FunctionDecl *FD) {
FunctionTypeProto *FT = cast<FunctionTypeProto>(FD->getType());
+ bool HasBody = FD->getBody();
std::string Proto = FD->getName();
Proto += "(";
for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
if (i) Proto += ", ";
- VarDecl *Param = FD->getParamDecl(i);
- std::string ParamStr = Param->getName();
- Param->getType().getAsString(ParamStr);
+ std::string ParamStr;
+ if (HasBody) ParamStr = FD->getParamDecl(i)->getName();
+
+ FT->getArgType(i).getAsString(ParamStr);
Proto += ParamStr;
}
Proto += ")";
@@ -834,9 +836,17 @@
std::cerr << " ";
FD->getBody()->dump();
std::cerr << "\n";
+ } else {
+ std::cerr << ";\n";
}
}
+static void PrintTypeDefDecl(TypedefDecl *TD) {
+ std::string S = TD->getName();
+ TD->getType().getAsString(S);
+ std::cerr << "typedef " << S << ";\n";
+}
+
static void PrintASTs(Preprocessor &PP, unsigned MainFileID) {
ASTContext Context(PP);
ASTStreamerTy *Streamer = ASTStreamer_Init(Context, MainFileID);
@@ -844,6 +854,8 @@
while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
PrintFunctionDecl(FD);
+ } else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
+ PrintTypeDefDecl(TD);
} else {
std::cerr << "Read top-level variable decl: '" << D->getName() << "'\n";
}
More information about the cfe-commits
mailing list