summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-11-20 03:37:32 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-11-20 03:37:32 +0000
commite9f130cfdf4961b0f110fd20b1c18951328bef2d (patch)
tree8bc4b9f83156bb8fb162641492f8ee1078e003d7
parentc8b9badef76ff45c93a2a46249cc59cdde4991cc (diff)
downloadbcm5719-llvm-e9f130cfdf4961b0f110fd20b1c18951328bef2d.tar.gz
bcm5719-llvm-e9f130cfdf4961b0f110fd20b1c18951328bef2d.zip
Preserve numeric literal suffixes during type canonicalization.
Patch by Pierre Gousseau! Test cases altered significantly by me. llvm-svn: 222404
-rw-r--r--clang/lib/AST/StmtProfile.cpp2
-rw-r--r--clang/test/CodeGenCXX/mangle-literal-suffix.cpp17
-rw-r--r--clang/test/SemaTemplate/canonical-expr-type.cpp8
3 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 647b643486c..d1f25d63b3f 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -501,6 +501,7 @@ void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
VisitExpr(S);
S->getValue().Profile(ID);
+ ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
}
void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
@@ -513,6 +514,7 @@ void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
VisitExpr(S);
S->getValue().Profile(ID);
ID.AddBoolean(S->isExact());
+ ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
}
void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
diff --git a/clang/test/CodeGenCXX/mangle-literal-suffix.cpp b/clang/test/CodeGenCXX/mangle-literal-suffix.cpp
new file mode 100644
index 00000000000..7a3e8ad3ba4
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-literal-suffix.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple mips-none-none -emit-llvm -o - %s | FileCheck %s
+
+template <class T> void g3(char (&buffer)[sizeof(T() + 5.0)]) {}
+template void g3(char (&)[sizeof(double)]);
+// CHECK: _Z2g3IdEvRAszplcvT__ELd4014000000000000E_c
+
+template <class T> void g4(char (&buffer)[sizeof(T() + 5.0L)]) {}
+template void g4(char (&)[sizeof(long double)]);
+// CHECK: _Z2g4IeEvRAszplcvT__ELe4014000000000000E_c
+
+template <class T> void g5(char (&buffer)[sizeof(T() + 5)]) {}
+template void g5(char (&)[sizeof(int)]);
+// CHECK: _Z2g5IiEvRAszplcvT__ELi5E_c
+
+template <class T> void g6(char (&buffer)[sizeof(T() + 5L)]) {}
+template void g6(char (&)[sizeof(long int)]);
+// CHECK: _Z2g6IlEvRAszplcvT__ELl5E_c
diff --git a/clang/test/SemaTemplate/canonical-expr-type.cpp b/clang/test/SemaTemplate/canonical-expr-type.cpp
index 4770c4fa3ed..f8d7d7ec1a2 100644
--- a/clang/test/SemaTemplate/canonical-expr-type.cpp
+++ b/clang/test/SemaTemplate/canonical-expr-type.cpp
@@ -47,3 +47,11 @@ struct X2 {
void f0(type2);
void f0(type3); // expected-error{{redeclared}}
};
+
+// Test canonicalization doesn't conflate different literal suffixes.
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0L)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0LL)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0.f)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0.)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0.l)]) {}
OpenPOWER on IntegriCloud