[cfe-commits] r39310 - /cfe/cfe/trunk/Driver/clang.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:42:53 PDT 2007
Author: sabre
Date: Wed Jul 11 11:42:53 2007
New Revision: 39310
URL: http://llvm.org/viewvc/llvm-project?rev=39310&view=rev
Log:
fix printing of unprototyped function decls.
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=39310&r1=39309&r2=39310&view=diff
==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:42:53 2007
@@ -819,27 +819,31 @@
}
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 += ", ";
- std::string ParamStr;
- if (HasBody) ParamStr = FD->getParamDecl(i)->getName();
+ FunctionType *AFT = cast<FunctionType>(FD->getType());
+ if (FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(AFT)) {
+ Proto += "(";
+ for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
+ if (i) Proto += ", ";
+ std::string ParamStr;
+ if (HasBody) ParamStr = FD->getParamDecl(i)->getName();
+
+ FT->getArgType(i).getAsString(ParamStr);
+ Proto += ParamStr;
+ }
- FT->getArgType(i).getAsString(ParamStr);
- Proto += ParamStr;
- }
-
- if (FT->isVariadic()) {
- if (FD->getNumParams()) Proto += ", ";
- Proto += "...";
+ if (FT->isVariadic()) {
+ if (FD->getNumParams()) Proto += ", ";
+ Proto += "...";
+ }
+ Proto += ")";
+ } else {
+ assert(isa<FunctionTypeNoProto>(AFT));
+ Proto += "()";
}
- Proto += ")";
-
- FT->getResultType().getAsString(Proto);
+ AFT->getResultType().getAsString(Proto);
std::cerr << "\n" << Proto;
More information about the cfe-commits
mailing list