// CFString checking
def err_cfstring_literal_not_string_constant : Error<
"CFString literal is not a string constant">;
-def warn_cfstring_literal_contains_nul_character : Warning<
- "CFString literal contains NUL character">;
def warn_cfstring_truncated : Warning<
"input conversion stopped due to an input byte that does not "
"belong to the input codeset UTF-8">;
return true;
}
- size_t NulPos = Literal->getString().find('\0');
- if (NulPos != llvm::StringRef::npos) {
- Diag(getLocationOfStringLiteralByte(Literal, NulPos),
- diag::warn_cfstring_literal_contains_nul_character)
- << Arg->getSourceRange();
- }
if (Literal->containsNonAsciiOrNull()) {
llvm::StringRef String = Literal->getString();
unsigned NumBytes = String.size();
void test7() {
const void *X;
X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
- X = CFSTR("\0"); // expected-warning {{ CFString literal contains NUL character }}
+ X = CFSTR("\0"); // no-warning
X = CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible integer to pointer conversion}}
X = CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
}
// rdar://6079877
void test2() {
id str = @"foo"
- "bar\0" // expected-warning {{literal contains NUL character}}
+ "bar\0" // no-warning
@"baz" " blarg";
id str2 = @"foo"
"bar"
@"baz"
- " b\0larg"; // expected-warning {{literal contains NUL character}}
+ " b\0larg"; // no-warning
if (@encode(int) == "foo") { } // expected-warning {{result of comparison against @encode is unspecified}}