diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 319b362bdf7..222bad3dd29 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -567,29 +567,28 @@ void CWriter::printModule(Module *M) { } -// printSymbolTable - Run through symbol table looking for named constants -// if a named constant is found, emit it's declaration... -// Assuming that symbol table has only types and constants. +/// printSymbolTable - Run through symbol table looking for named constants +/// if a named constant is found, emit it's declaration... +/// Assuming that symbol table has only types and constants. +/// void CWriter::printSymbolTable(const SymbolTable &ST) { for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) { - SymbolTable::type_const_iterator I = ST.type_begin(TI->first); + SymbolTable::type_const_iterator I = ST.type_begin(TI->first); SymbolTable::type_const_iterator End = ST.type_end(TI->first); - for (; I != End; ++I){ + for (; I != End; ++I) { const Value *V = I->second; - if (const Type *Ty = dyn_cast(V)) { - if (const Type *STy = dyn_cast(V)) { - string Name = "struct l_" + makeNameProper(I->first); - Out << Name << ";\n"; - TypeNames.insert(std::make_pair(STy, Name)); - } - else { - string Name = "l_" + makeNameProper(I->first); - Out << "typedef "; - printType(Ty, Name, true); - Out << ";\n"; - } - } + if (const Type *Ty = dyn_cast(V)) + if (const Type *STy = dyn_cast(Ty)) { + string Name = "struct l_" + makeNameProper(I->first); + Out << Name << ";\n"; + TypeNames.insert(std::make_pair(STy, Name)); + } else { + string Name = "l_" + makeNameProper(I->first); + Out << "typedef "; + printType(Ty, Name, true); + Out << ";\n"; + } } } @@ -601,10 +600,9 @@ void CWriter::printSymbolTable(const SymbolTable &ST) { SymbolTable::type_const_iterator I = ST.type_begin(TI->first); SymbolTable::type_const_iterator End = ST.type_end(TI->first); - for (; I != End; ++I) { + for (; I != End; ++I) if (const StructType *STy = dyn_cast(I->second)) - parseStruct(STy); - } + parseStruct(STy); } } @@ -614,14 +612,14 @@ void CWriter::parseStruct(const Type *Ty) { if (const StructType *STy = dyn_cast(Ty)){ //Check to see if we have already printed this struct if (StructPrinted.find(STy) == StructPrinted.end()){ - for (StructType::ElementTypes::const_iterator - I = STy->getElementTypes().begin(), - E = STy->getElementTypes().end(); I != E; ++I) { + for (StructType::ElementTypes::const_iterator + I = STy->getElementTypes().begin(), + E = STy->getElementTypes().end(); I != E; ++I) { const Type *Ty1 = dyn_cast(I->get()); - if (isa(Ty1) || isa(Ty1)) - parseStruct(Ty1); - } - + if (isa(Ty1) || isa(Ty1)) + parseStruct(Ty1); + } + //Print struct StructPrinted.insert(STy); string Name = TypeNames[STy]; @@ -629,7 +627,8 @@ void CWriter::parseStruct(const Type *Ty) { Out << ";\n"; } } - // If it is an array check it's type and continue + + // If it is an array, check it's type and continue else if (const ArrayType *ATy = dyn_cast(Ty)){ const Type *Ty1 = ATy->getElementType(); if (isa(Ty1) || isa(Ty1)) diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 319b362bdf7..222bad3dd29 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -567,29 +567,28 @@ void CWriter::printModule(Module *M) { } -// printSymbolTable - Run through symbol table looking for named constants -// if a named constant is found, emit it's declaration... -// Assuming that symbol table has only types and constants. +/// printSymbolTable - Run through symbol table looking for named constants +/// if a named constant is found, emit it's declaration... +/// Assuming that symbol table has only types and constants. +/// void CWriter::printSymbolTable(const SymbolTable &ST) { for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) { - SymbolTable::type_const_iterator I = ST.type_begin(TI->first); + SymbolTable::type_const_iterator I = ST.type_begin(TI->first); SymbolTable::type_const_iterator End = ST.type_end(TI->first); - for (; I != End; ++I){ + for (; I != End; ++I) { const Value *V = I->second; - if (const Type *Ty = dyn_cast(V)) { - if (const Type *STy = dyn_cast(V)) { - string Name = "struct l_" + makeNameProper(I->first); - Out << Name << ";\n"; - TypeNames.insert(std::make_pair(STy, Name)); - } - else { - string Name = "l_" + makeNameProper(I->first); - Out << "typedef "; - printType(Ty, Name, true); - Out << ";\n"; - } - } + if (const Type *Ty = dyn_cast(V)) + if (const Type *STy = dyn_cast(Ty)) { + string Name = "struct l_" + makeNameProper(I->first); + Out << Name << ";\n"; + TypeNames.insert(std::make_pair(STy, Name)); + } else { + string Name = "l_" + makeNameProper(I->first); + Out << "typedef "; + printType(Ty, Name, true); + Out << ";\n"; + } } } @@ -601,10 +600,9 @@ void CWriter::printSymbolTable(const SymbolTable &ST) { SymbolTable::type_const_iterator I = ST.type_begin(TI->first); SymbolTable::type_const_iterator End = ST.type_end(TI->first); - for (; I != End; ++I) { + for (; I != End; ++I) if (const StructType *STy = dyn_cast(I->second)) - parseStruct(STy); - } + parseStruct(STy); } } @@ -614,14 +612,14 @@ void CWriter::parseStruct(const Type *Ty) { if (const StructType *STy = dyn_cast(Ty)){ //Check to see if we have already printed this struct if (StructPrinted.find(STy) == StructPrinted.end()){ - for (StructType::ElementTypes::const_iterator - I = STy->getElementTypes().begin(), - E = STy->getElementTypes().end(); I != E; ++I) { + for (StructType::ElementTypes::const_iterator + I = STy->getElementTypes().begin(), + E = STy->getElementTypes().end(); I != E; ++I) { const Type *Ty1 = dyn_cast(I->get()); - if (isa(Ty1) || isa(Ty1)) - parseStruct(Ty1); - } - + if (isa(Ty1) || isa(Ty1)) + parseStruct(Ty1); + } + //Print struct StructPrinted.insert(STy); string Name = TypeNames[STy]; @@ -629,7 +627,8 @@ void CWriter::parseStruct(const Type *Ty) { Out << ";\n"; } } - // If it is an array check it's type and continue + + // If it is an array, check it's type and continue else if (const ArrayType *ATy = dyn_cast(Ty)){ const Type *Ty1 = ATy->getElementType(); if (isa(Ty1) || isa(Ty1))