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 | c4baa06d15a5bc59055f2ab2fa27822f80a3cebd (patch) | |
tree | c0ef38243c65f64af7cb4a67d4a223a453d116cb /clang/test/CodeGen/c-strings.c | |
parent | 6134fbccefd5c4e8ca0f592d0487ea213b864c0d (diff) | |
download | bcm5719-llvm-c4baa06d15a5bc59055f2ab2fa27822f80a3cebd.tar.gz bcm5719-llvm-c4baa06d15a5bc59055f2ab2fa27822f80a3cebd.zip |
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>
llvm-svn: 54768
Diffstat (limited to 'clang/test/CodeGen/c-strings.c')
-rw-r--r-- | clang/test/CodeGen/c-strings.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/test/CodeGen/c-strings.c b/clang/test/CodeGen/c-strings.c new file mode 100644 index 00000000000..baff4ddfc1b --- /dev/null +++ b/clang/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); +} + |