summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ItaniumMangle.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-04-24 03:07:16 +0000
committerJohn McCall <rjmccall@apple.com>2011-04-24 03:07:16 +0000
commitd8d1e2ae665ccbd205df9cc16933227541e4e3b7 (patch)
tree07a73a1b51f937b9d22916ca2aa02f8e06e3f06c /clang/lib/AST/ItaniumMangle.cpp
parent82270b46790450b56430d84ec0bd0b7cb7da6ac7 (diff)
downloadbcm5719-llvm-d8d1e2ae665ccbd205df9cc16933227541e4e3b7.tar.gz
bcm5719-llvm-d8d1e2ae665ccbd205df9cc16933227541e4e3b7.zip
The ABI settled on mangling float literals with lowercase hex dumps.
APInt::toString doesn't do those, but it's easy to postprocess that output, and that's probably better than adding another knob to that method. llvm-svn: 130081
Diffstat (limited to 'clang/lib/AST/ItaniumMangle.cpp')
-rw-r--r--clang/lib/AST/ItaniumMangle.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 6f4edc38940..3663ed705eb 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -553,11 +553,24 @@ void CXXNameMangler::mangleUnscopedTemplateName(TemplateName Template) {
addSubstitution(Template);
}
-void CXXNameMangler::mangleFloat(const llvm::APFloat &F) {
- // TODO: avoid this copy with careful stream management.
- llvm::SmallString<20> Buffer;
- F.bitcastToAPInt().toString(Buffer, 16, false);
- Out.write(Buffer.data(), Buffer.size());
+void CXXNameMangler::mangleFloat(const llvm::APFloat &f) {
+ // ABI:
+ // Floating-point literals are encoded using a fixed-length
+ // lowercase hexadecimal string corresponding to the internal
+ // representation (IEEE on Itanium), high-order bytes first,
+ // without leading zeroes. For example: "Lf bf800000 E" is -1.0f
+ // on Itanium.
+ // APInt::toString uses uppercase hexadecimal, and it's not really
+ // worth embellishing that interface for this use case, so we just
+ // do a second pass to lowercase things.
+ typedef llvm::SmallString<20> buffer_t;
+ buffer_t buffer;
+ f.bitcastToAPInt().toString(buffer, 16, false);
+
+ for (buffer_t::iterator i = buffer.begin(), e = buffer.end(); i != e; ++i)
+ if (isupper(*i)) *i = tolower(*i);
+
+ Out.write(buffer.data(), buffer.size());
}
void CXXNameMangler::mangleNumber(const llvm::APSInt &Value) {
OpenPOWER on IntegriCloud