mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
simplify handling "don't print top level name" processing, so that we get
stuff like %A = type { %A*} instead of an upref. llvm-svn: 65748
This commit is contained in:
parent
7482f84ae6
commit
0cefb564d4
@ -38,8 +38,11 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void print(const Type *Ty, raw_ostream &OS);
|
void print(const Type *Ty, raw_ostream &OS, bool IgnoreTopLevelName = false);
|
||||||
void printAtLeastOneLevel(const Type *Ty, raw_ostream &OS);
|
|
||||||
|
void printAtLeastOneLevel(const Type *Ty, raw_ostream &OS) {
|
||||||
|
print(Ty, OS, true);
|
||||||
|
}
|
||||||
|
|
||||||
/// hasTypeName - Return true if the type has a name in TypeNames, false
|
/// hasTypeName - Return true if the type has a name in TypeNames, false
|
||||||
/// otherwise.
|
/// otherwise.
|
||||||
@ -52,7 +55,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void CalcTypeName(const Type *Ty, SmallVectorImpl<const Type *> &TypeStack,
|
void CalcTypeName(const Type *Ty, SmallVectorImpl<const Type *> &TypeStack,
|
||||||
raw_ostream &OS);
|
raw_ostream &OS, bool IgnoreTopLevelName = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// WriteTypeSymbolic - This attempts to write the specified type as a symbolic
|
// WriteTypeSymbolic - This attempts to write the specified type as a symbolic
|
||||||
|
@ -166,15 +166,15 @@ TypePrinting::~TypePrinting() {
|
|||||||
/// use of type names or up references to shorten the type name where possible.
|
/// use of type names or up references to shorten the type name where possible.
|
||||||
void TypePrinting::CalcTypeName(const Type *Ty,
|
void TypePrinting::CalcTypeName(const Type *Ty,
|
||||||
SmallVectorImpl<const Type *> &TypeStack,
|
SmallVectorImpl<const Type *> &TypeStack,
|
||||||
raw_ostream &OS) {
|
raw_ostream &OS, bool IgnoreTopLevelName) {
|
||||||
// Check to see if the type is named.
|
// Check to see if the type is named.
|
||||||
DenseMap<const Type*, std::string> &TM = getTypeNamesMap(TypeNames);
|
if (!IgnoreTopLevelName) {
|
||||||
DenseMap<const Type *, std::string>::iterator I = TM.find(Ty);
|
DenseMap<const Type*, std::string> &TM = getTypeNamesMap(TypeNames);
|
||||||
if (I != TM.end() &&
|
DenseMap<const Type *, std::string>::iterator I = TM.find(Ty);
|
||||||
// If the name wasn't temporarily removed use it.
|
if (I != TM.end()) {
|
||||||
!I->second.empty()) {
|
OS << I->second;
|
||||||
OS << I->second;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if the Type is already on the stack...
|
// Check to see if the Type is already on the stack...
|
||||||
@ -273,13 +273,16 @@ void TypePrinting::CalcTypeName(const Type *Ty,
|
|||||||
/// printTypeInt - The internal guts of printing out a type that has a
|
/// printTypeInt - The internal guts of printing out a type that has a
|
||||||
/// potentially named portion.
|
/// potentially named portion.
|
||||||
///
|
///
|
||||||
void TypePrinting::print(const Type *Ty, raw_ostream &OS) {
|
void TypePrinting::print(const Type *Ty, raw_ostream &OS,
|
||||||
|
bool IgnoreTopLevelName) {
|
||||||
// Check to see if the type is named.
|
// Check to see if the type is named.
|
||||||
DenseMap<const Type*, std::string> &TM = getTypeNamesMap(TypeNames);
|
DenseMap<const Type*, std::string> &TM = getTypeNamesMap(TypeNames);
|
||||||
DenseMap<const Type*, std::string>::iterator I = TM.find(Ty);
|
if (!IgnoreTopLevelName) {
|
||||||
if (I != TM.end()) {
|
DenseMap<const Type*, std::string>::iterator I = TM.find(Ty);
|
||||||
OS << I->second;
|
if (I != TM.end()) {
|
||||||
return;
|
OS << I->second;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise we have a type that has not been named but is a derived type.
|
// Otherwise we have a type that has not been named but is a derived type.
|
||||||
@ -289,33 +292,12 @@ void TypePrinting::print(const Type *Ty, raw_ostream &OS) {
|
|||||||
std::string TypeName;
|
std::string TypeName;
|
||||||
|
|
||||||
raw_string_ostream TypeOS(TypeName);
|
raw_string_ostream TypeOS(TypeName);
|
||||||
CalcTypeName(Ty, TypeStack, TypeOS);
|
CalcTypeName(Ty, TypeStack, TypeOS, IgnoreTopLevelName);
|
||||||
OS << TypeOS.str();
|
OS << TypeOS.str();
|
||||||
|
|
||||||
// Cache type name for later use.
|
// Cache type name for later use.
|
||||||
TM.insert(std::make_pair(Ty, TypeOS.str()));
|
if (!IgnoreTopLevelName)
|
||||||
}
|
TM.insert(std::make_pair(Ty, TypeOS.str()));
|
||||||
|
|
||||||
/// printAtLeastOneLevel - Print out one level of the possibly complex type
|
|
||||||
/// without considering any symbolic types that we may have equal to it.
|
|
||||||
void TypePrinting::printAtLeastOneLevel(const Type *Ty, raw_ostream &OS) {
|
|
||||||
// If the type does not have a name, then it is already guaranteed to print at
|
|
||||||
// least one level.
|
|
||||||
DenseMap<const Type*, std::string> &TM = getTypeNamesMap(TypeNames);
|
|
||||||
DenseMap<const Type*, std::string>::iterator I = TM.find(Ty);
|
|
||||||
if (I == TM.end())
|
|
||||||
return print(Ty, OS);
|
|
||||||
|
|
||||||
// Otherwise, temporarily remove the name and print it.
|
|
||||||
std::string OldName;
|
|
||||||
std::swap(OldName, I->second);
|
|
||||||
|
|
||||||
// Print the type without the name.
|
|
||||||
SmallVector<const Type *, 16> TypeStack;
|
|
||||||
CalcTypeName(Ty, TypeStack, OS);
|
|
||||||
|
|
||||||
// Restore the name.
|
|
||||||
std::swap(OldName, I->second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user