diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-08-13 23:20:05 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-13 23:20:05 +0000 |
commit | 6143293fa4366ee95d7e47e61bd030a34bf68b55 (patch) | |
tree | 9aa742ed437a22a37bd505e604a06d2b1768c667 /test/CodeGen/c-strings.c | |
parent | ae6814efb6c41bd0c0f6413d25097105284d5be7 (diff) |
Add GetAddrOfConstantCString method
- Returns addr of constant for argument + '\0'.
- I couldn't think of a better name.
- Move appropriate users of GetAddrOfConstantString to this.
Rename getStringForStringLiteral to GetStringForStringLiteral.
Add GetAddrOfConstantStringFromLiteral
- This combines GetAddrOfConstantString and
GetStringForStringLiteral. This method can be, but is not yet, more
efficient.
Change GetAddrOfConstantString to not add terminating '\0'
- <rdar://problem/6140956>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54768 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/c-strings.c')
-rw-r--r-- | test/CodeGen/c-strings.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/CodeGen/c-strings.c b/test/CodeGen/c-strings.c new file mode 100644 index 0000000000..baff4ddfc1 --- /dev/null +++ b/test/CodeGen/c-strings.c @@ -0,0 +1,34 @@ +// RUN: clang -emit-llvm -o %t %s && +// RUN: grep "hello" %t | count 3 && +// RUN: grep 'c"hello\\00"' %t | count 2 && +// RUN: grep 'c"hello\\00\\00\\00"' %t | count 1 + +/* Should be 3 hello string, two global (of different sizes), the rest + are shared. */ + +void f0() { + bar("hello"); +} + +void f1() { + static char *x = "hello"; + bar(x); +} + +void f2() { + static char x[] = "hello"; + bar(x); +} + +void f3() { + static char x[8] = "hello"; + bar(x); +} + +void f4() { + static struct s { + char *name; + } x = { "hello" }; + gaz(&x); +} + |