From 2a81645de598e34f94f3586c8233b39280f09870 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 9 Dec 2013 10:44:32 +0000 Subject: [-cxx-abi microsoft] Mangle large integral constants correctly Testing has revealed that large integral constants (i.e. > INT64_MAX) are always mangled as-if they are negative, even in places where it would not make sense for them to be negative (like non-type template parameters of type unsigned long long). To address this, we change the way we model number mangling: always mangle as-if our number is an int64_t. This should result in correct results when we have large unsigned numbers. N.B. Bizarrely, things that are 32-bit displacements like vbptr offsets are mangled as-if they are unsigned 32-bit numbers. This is a pretty egregious waste of space, it would be a 4x savings if we could mangle it like a signed 32-bit number. Instead, we explicitly cast these displacements to uint32_t and let the mangler proceed. llvm-svn: 196771 --- clang/test/CodeGenCXX/mangle-ms-templates.cpp | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'clang/test/CodeGenCXX/mangle-ms-templates.cpp') diff --git a/clang/test/CodeGenCXX/mangle-ms-templates.cpp b/clang/test/CodeGenCXX/mangle-ms-templates.cpp index 713f8e96892..514f5739ffd 100644 --- a/clang/test/CodeGenCXX/mangle-ms-templates.cpp +++ b/clang/test/CodeGenCXX/mangle-ms-templates.cpp @@ -24,6 +24,18 @@ class IntTemplate { IntTemplate() {} }; +template +class LongLongTemplate { + public: + LongLongTemplate() {} +}; + +template +class UnsignedLongLongTemplate { + public: + UnsignedLongLongTemplate() {} +}; + template<> class BoolTemplate { public: @@ -108,6 +120,32 @@ void template_mangling() { IntTemplate<65535> ffff; // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ" // X64: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QEAA@XZ" + + IntTemplate<-1> neg_1; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?0@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?0@@QEAA@XZ" + IntTemplate<-9> neg_9; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?8@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?8@@QEAA@XZ" + IntTemplate<-10> neg_10; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?9@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?9@@QEAA@XZ" + IntTemplate<-11> neg_11; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0?L@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$IntTemplate@$0?L@@@QEAA@XZ" + + LongLongTemplate<-9223372036854775807LL-1LL> int64_min; +// CHECK: call {{.*}} @"\01??0?$LongLongTemplate@$0?IAAAAAAAAAAAAAAA@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$LongLongTemplate@$0?IAAAAAAAAAAAAAAA@@@QEAA@XZ" + LongLongTemplate<9223372036854775807LL> int64_max; +// CHECK: call {{.*}} @"\01??0?$LongLongTemplate@$0HPPPPPPPPPPPPPPP@@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$LongLongTemplate@$0HPPPPPPPPPPPPPPP@@@QEAA@XZ" + UnsignedLongLongTemplate<18446744073709551615ULL> uint64_max; +// CHECK: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QEAA@XZ" + UnsignedLongLongTemplate<(unsigned long long)-1> uint64_neg_1; +// CHECK: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QAE@XZ" +// X64: call {{.*}} @"\01??0?$UnsignedLongLongTemplate@$0?0@@QEAA@XZ" } namespace space { -- cgit v1.2.3