mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-06-13 10:40:59 +00:00
345 lines
14 KiB
Diff
345 lines
14 KiB
Diff
Index: llvm-toolchain-snapshot_3.5~svn199197/clang/include/clang/Basic/Builtins.def
|
|
===================================================================
|
|
--- llvm-toolchain-snapshot_3.5~svn199197.orig/clang/include/clang/Basic/Builtins.def 2014-01-14 11:30:31.712869048 +0100
|
|
+++ llvm-toolchain-snapshot_3.5~svn199197/clang/include/clang/Basic/Builtins.def 2014-01-14 11:30:31.700869048 +0100
|
|
@@ -471,8 +471,8 @@
|
|
BUILTIN(__builtin___stpcpy_chk, "c*c*cC*z", "nF")
|
|
BUILTIN(__builtin___strcat_chk, "c*c*cC*z", "nF")
|
|
BUILTIN(__builtin___strcpy_chk, "c*c*cC*z", "nF")
|
|
-BUILTIN(__builtin___strlcat_chk, "zc*cC*zz", "nF")
|
|
-BUILTIN(__builtin___strlcpy_chk, "zc*cC*zz", "nF")
|
|
+//BUILTIN(__builtin___strlcat_chk, "zc*cC*zz", "nF")
|
|
+//BUILTIN(__builtin___strlcpy_chk, "zc*cC*zz", "nF")
|
|
BUILTIN(__builtin___strncat_chk, "c*c*cC*zz", "nF")
|
|
BUILTIN(__builtin___strncpy_chk, "c*c*cC*zz", "nF")
|
|
BUILTIN(__builtin___stpncpy_chk, "c*c*cC*zz", "nF")
|
|
@@ -765,8 +765,8 @@
|
|
LIBBUILTIN(_longjmp, "vJi", "fr", "setjmp.h", ALL_GNU_LANGUAGES)
|
|
LIBBUILTIN(siglongjmp, "vSJi", "fr", "setjmp.h", ALL_GNU_LANGUAGES)
|
|
// non-standard but very common
|
|
-LIBBUILTIN(strlcpy, "zc*cC*z", "f", "string.h", ALL_GNU_LANGUAGES)
|
|
-LIBBUILTIN(strlcat, "zc*cC*z", "f", "string.h", ALL_GNU_LANGUAGES)
|
|
+//LIBBUILTIN(strlcpy, "zc*cC*z", "f", "string.h", ALL_GNU_LANGUAGES)
|
|
+//LIBBUILTIN(strlcat, "zc*cC*z", "f", "string.h", ALL_GNU_LANGUAGES)
|
|
// id objc_msgSend(id, SEL, ...)
|
|
LIBBUILTIN(objc_msgSend, "GGH.", "f", "objc/message.h", OBJC_LANG)
|
|
// long double objc_msgSend_fpret(id self, SEL op, ...)
|
|
Index: llvm-toolchain-snapshot_3.5~svn199197/clang/lib/Sema/SemaChecking.cpp
|
|
===================================================================
|
|
--- llvm-toolchain-snapshot_3.5~svn199197.orig/clang/lib/Sema/SemaChecking.cpp 2014-01-14 11:30:31.712869048 +0100
|
|
+++ llvm-toolchain-snapshot_3.5~svn199197/clang/lib/Sema/SemaChecking.cpp 2014-01-14 11:30:31.704869048 +0100
|
|
@@ -817,9 +817,10 @@
|
|
return false;
|
|
|
|
// Handle memory setting and copying functions.
|
|
- if (CMId == Builtin::BIstrlcpy || CMId == Builtin::BIstrlcat)
|
|
- CheckStrlcpycatArguments(TheCall, FnInfo);
|
|
- else if (CMId == Builtin::BIstrncat)
|
|
+// if (CMId == Builtin::BIstrlcpy || CMId == Builtin::BIstrlcat)
|
|
+// CheckStrlcpycatArguments(TheCall, FnInfo);
|
|
+// else
|
|
+ if (CMId == Builtin::BIstrncat)
|
|
CheckStrncatArguments(TheCall, FnInfo);
|
|
else
|
|
CheckMemaccessArguments(TheCall, CMId, FnInfo);
|
|
Index: llvm-toolchain-snapshot_3.5~svn199197/clang/lib/AST/Decl.cpp
|
|
===================================================================
|
|
--- llvm-toolchain-snapshot_3.5~svn199197.orig/clang/lib/AST/Decl.cpp 2014-01-14 11:30:31.712869048 +0100
|
|
+++ llvm-toolchain-snapshot_3.5~svn199197/clang/lib/AST/Decl.cpp 2014-01-14 11:30:31.704869048 +0100
|
|
@@ -3027,10 +3027,10 @@
|
|
case Builtin::BImemmove:
|
|
return Builtin::BImemmove;
|
|
|
|
- case Builtin::BIstrlcpy:
|
|
- return Builtin::BIstrlcpy;
|
|
- case Builtin::BIstrlcat:
|
|
- return Builtin::BIstrlcat;
|
|
+// case Builtin::BIstrlcpy:
|
|
+// return Builtin::BIstrlcpy;
|
|
+// case Builtin::BIstrlcat:
|
|
+// return Builtin::BIstrlcat;
|
|
|
|
case Builtin::BI__builtin_memcmp:
|
|
case Builtin::BImemcmp:
|
|
Index: llvm-toolchain-snapshot_3.5~svn199197/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
|
|
===================================================================
|
|
--- llvm-toolchain-snapshot_3.5~svn199197.orig/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 2014-01-14 11:30:31.712869048 +0100
|
|
+++ llvm-toolchain-snapshot_3.5~svn199197/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 2014-01-14 11:30:31.704869048 +0100
|
|
@@ -238,9 +238,9 @@
|
|
case Builtin::BIstrncpy:
|
|
case Builtin::BIstrncat:
|
|
return TaintPropagationRule(1, 2, 0, true);
|
|
- case Builtin::BIstrlcpy:
|
|
- case Builtin::BIstrlcat:
|
|
- return TaintPropagationRule(1, 2, 0, false);
|
|
+// case Builtin::BIstrlcpy:
|
|
+// case Builtin::BIstrlcat:
|
|
+// return TaintPropagationRule(1, 2, 0, false);
|
|
case Builtin::BIstrndup:
|
|
return TaintPropagationRule(0, 1, ReturnValueIndex);
|
|
|
|
Index: llvm-toolchain-snapshot_3.5~svn199197/clang/test/Sema/builtins.c
|
|
===================================================================
|
|
--- llvm-toolchain-snapshot_3.5~svn199197.orig/clang/test/Sema/builtins.c 2014-01-14 11:30:31.712869048 +0100
|
|
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
@@ -1,199 +0,0 @@
|
|
-// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wno-string-plus-int -triple=i686-apple-darwin9
|
|
-// This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
|
|
-
|
|
-int test1(float a, int b) {
|
|
- return __builtin_isless(a, b); // expected-note {{declared here}}
|
|
-}
|
|
-int test2(int a, int b) {
|
|
- return __builtin_islessequal(a, b); // expected-error {{floating point type}}
|
|
-}
|
|
-
|
|
-int test3(double a, float b) {
|
|
- return __builtin_isless(a, b);
|
|
-}
|
|
-int test4(int* a, double b) {
|
|
- return __builtin_islessequal(a, b); // expected-error {{floating point type}}
|
|
-}
|
|
-
|
|
-int test5(float a, long double b) {
|
|
- return __builtin_isless(a, b, b); // expected-error {{too many arguments}}
|
|
-}
|
|
-int test6(float a, long double b) {
|
|
- return __builtin_islessequal(a); // expected-error {{too few arguments}}
|
|
-}
|
|
-
|
|
-
|
|
-#define CFSTR __builtin___CFStringMakeConstantString
|
|
-void test7() {
|
|
- const void *X;
|
|
- X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
|
|
- 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}}
|
|
-}
|
|
-
|
|
-
|
|
-// atomics.
|
|
-
|
|
-void test9(short v) {
|
|
- unsigned i, old;
|
|
-
|
|
- old = __sync_fetch_and_add(); // expected-error {{too few arguments to function call}}
|
|
- old = __sync_fetch_and_add(&old); // expected-error {{too few arguments to function call}}
|
|
- old = __sync_fetch_and_add((unsigned*)0, 42i); // expected-warning {{imaginary constants are a GNU extension}}
|
|
-
|
|
- // PR7600: Pointers are implicitly casted to integers and back.
|
|
- void *old_ptr = __sync_val_compare_and_swap((void**)0, 0, 0);
|
|
-
|
|
- // Ensure the return type is correct even when implicit casts are stripped
|
|
- // away. This triggers an assertion while checking the comparison otherwise.
|
|
- if (__sync_fetch_and_add(&old, 1) == 1) {
|
|
- }
|
|
-}
|
|
-
|
|
-// overloaded atomics should be declared only once.
|
|
-void test9_1(volatile int* ptr, int val) {
|
|
- __sync_fetch_and_add_4(ptr, val);
|
|
-}
|
|
-void test9_2(volatile int* ptr, int val) {
|
|
- __sync_fetch_and_add(ptr, val);
|
|
-}
|
|
-void test9_3(volatile int* ptr, int val) {
|
|
- __sync_fetch_and_add_4(ptr, val);
|
|
- __sync_fetch_and_add(ptr, val);
|
|
- __sync_fetch_and_add(ptr, val);
|
|
- __sync_fetch_and_add_4(ptr, val);
|
|
- __sync_fetch_and_add_4(ptr, val);
|
|
-}
|
|
-
|
|
-// rdar://7236819
|
|
-void test10(void) __attribute__((noreturn));
|
|
-
|
|
-void test10(void) {
|
|
- __asm__("int3");
|
|
- __builtin_unreachable();
|
|
-
|
|
- // No warning about falling off the end of a noreturn function.
|
|
-}
|
|
-
|
|
-void test11(int X) {
|
|
- switch (X) {
|
|
- case __builtin_eh_return_data_regno(0): // constant foldable.
|
|
- break;
|
|
- }
|
|
-
|
|
- __builtin_eh_return_data_regno(X); // expected-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}}
|
|
-}
|
|
-
|
|
-// PR5062
|
|
-void test12(void) __attribute__((__noreturn__));
|
|
-void test12(void) {
|
|
- __builtin_trap(); // no warning because trap is noreturn.
|
|
-}
|
|
-
|
|
-void test_unknown_builtin(int a, int b) {
|
|
- __builtin_isles(a, b); // expected-error{{use of unknown builtin}} \
|
|
- // expected-note{{did you mean '__builtin_isless'?}}
|
|
-}
|
|
-
|
|
-int test13() {
|
|
- __builtin_eh_return(0, 0); // no warning, eh_return never returns.
|
|
-}
|
|
-
|
|
-// <rdar://problem/8228293>
|
|
-void test14() {
|
|
- int old;
|
|
- old = __sync_fetch_and_min((volatile int *)&old, 1);
|
|
-}
|
|
-
|
|
-// <rdar://problem/8336581>
|
|
-void test15(const char *s) {
|
|
- __builtin_printf("string is %s\n", s);
|
|
-}
|
|
-
|
|
-// PR7885
|
|
-int test16() {
|
|
- return __builtin_constant_p() + // expected-error{{too few arguments}}
|
|
- __builtin_constant_p(1, 2); // expected-error {{too many arguments}}
|
|
-}
|
|
-
|
|
-const int test17_n = 0;
|
|
-const char test17_c[] = {1, 2, 3, 0};
|
|
-const char test17_d[] = {1, 2, 3, 4};
|
|
-typedef int __attribute__((vector_size(16))) IntVector;
|
|
-struct Aggregate { int n; char c; };
|
|
-enum Enum { EnumValue1, EnumValue2 };
|
|
-
|
|
-typedef __typeof(sizeof(int)) size_t;
|
|
-size_t strlen(const char *);
|
|
-
|
|
-void test17() {
|
|
-#define ASSERT(...) { int arr[(__VA_ARGS__) ? 1 : -1]; }
|
|
-#define T(...) ASSERT(__builtin_constant_p(__VA_ARGS__))
|
|
-#define F(...) ASSERT(!__builtin_constant_p(__VA_ARGS__))
|
|
-
|
|
- // __builtin_constant_p returns 1 if the argument folds to:
|
|
- // - an arithmetic constant with value which is known at compile time
|
|
- T(test17_n);
|
|
- T(&test17_c[3] - test17_c);
|
|
- T(3i + 5); // expected-warning {{imaginary constant}}
|
|
- T(4.2 * 7.6);
|
|
- T(EnumValue1);
|
|
- T((enum Enum)(int)EnumValue2);
|
|
-
|
|
- // - the address of the first character of a string literal, losslessly cast
|
|
- // to any type
|
|
- T("string literal");
|
|
- T((double*)"string literal");
|
|
- T("string literal" + 0);
|
|
- T((long)"string literal");
|
|
-
|
|
- // ... and otherwise returns 0.
|
|
- F("string literal" + 1);
|
|
- F(&test17_n);
|
|
- F(test17_c);
|
|
- F(&test17_c);
|
|
- F(&test17_d);
|
|
- F((struct Aggregate){0, 1});
|
|
- F((IntVector){0, 1, 2, 3});
|
|
-
|
|
- // Ensure that a technique used in glibc is handled correctly.
|
|
-#define OPT(...) (__builtin_constant_p(__VA_ARGS__) && strlen(__VA_ARGS__) < 4)
|
|
- // FIXME: These are incorrectly treated as ICEs because strlen is treated as
|
|
- // a builtin.
|
|
- ASSERT(OPT("abc"));
|
|
- ASSERT(!OPT("abcd"));
|
|
- // In these cases, the strlen is non-constant, but the __builtin_constant_p
|
|
- // is 0: the array size is not an ICE but is foldable.
|
|
- ASSERT(!OPT(test17_c)); // expected-warning {{folded}}
|
|
- ASSERT(!OPT(&test17_c[0])); // expected-warning {{folded}}
|
|
- ASSERT(!OPT((char*)test17_c)); // expected-warning {{folded}}
|
|
- ASSERT(!OPT(test17_d)); // expected-warning {{folded}}
|
|
- ASSERT(!OPT(&test17_d[0])); // expected-warning {{folded}}
|
|
- ASSERT(!OPT((char*)test17_d)); // expected-warning {{folded}}
|
|
-
|
|
-#undef OPT
|
|
-#undef T
|
|
-#undef F
|
|
-}
|
|
-
|
|
-void test18() {
|
|
- char src[1024];
|
|
- char dst[2048];
|
|
- size_t result;
|
|
- void *ptr;
|
|
-
|
|
- ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src), sizeof(dst));
|
|
- result = __builtin___strlcpy_chk(dst, src, sizeof(src), sizeof(dst));
|
|
- result = __builtin___strlcat_chk(dst, src, sizeof(src), sizeof(dst));
|
|
-
|
|
- ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src)); // expected-error {{too few arguments to function call}}
|
|
- ptr = __builtin___strlcpy_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
|
|
- ptr = __builtin___strlcat_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
|
|
-}
|
|
-
|
|
-void no_ms_builtins() {
|
|
- __assume(1); // expected-warning {{implicit declaration}}
|
|
- __noop(1); // expected-warning {{implicit declaration}}
|
|
- __debugbreak(); // expected-warning {{implicit declaration}}
|
|
-}
|
|
Index: llvm-toolchain-snapshot_3.5~svn199197/clang/test/Sema/warn-strlcpycat-size.c
|
|
===================================================================
|
|
--- llvm-toolchain-snapshot_3.5~svn199197.orig/clang/test/Sema/warn-strlcpycat-size.c 2014-01-14 11:30:31.712869048 +0100
|
|
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
@@ -1,55 +0,0 @@
|
|
-// RUN: %clang_cc1 -Wstrlcpy-strlcat-size -verify -fsyntax-only %s
|
|
-
|
|
-typedef __SIZE_TYPE__ size_t;
|
|
-size_t strlcpy (char * restrict dst, const char * restrict src, size_t size);
|
|
-size_t strlcat (char * restrict dst, const char * restrict src, size_t size);
|
|
-size_t strlen (const char *s);
|
|
-
|
|
-char s1[100];
|
|
-char s2[200];
|
|
-char * s3;
|
|
-
|
|
-struct {
|
|
- char f1[100];
|
|
- char f2[100][3];
|
|
-} s4, **s5;
|
|
-
|
|
-int x;
|
|
-
|
|
-void f(void)
|
|
-{
|
|
- strlcpy(s1, s2, sizeof(s1)); // no warning
|
|
- strlcpy(s1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
|
|
- strlcpy(s1, s3, strlen(s3)+1); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
|
|
- strlcat(s2, s3, sizeof(s3)); // expected-warning {{size argument in 'strlcat' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
|
|
- strlcpy(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
|
|
- strlcpy((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
|
|
- strlcpy(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
|
|
-}
|
|
-
|
|
-// Don't issue FIXIT for flexible arrays.
|
|
-struct S {
|
|
- int y;
|
|
- char x[];
|
|
-};
|
|
-
|
|
-void flexible_arrays(struct S *s) {
|
|
- char str[] = "hi";
|
|
- strlcpy(s->x, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
|
|
-}
|
|
-
|
|
-// Don't issue FIXIT for destinations of size 1.
|
|
-void size_1() {
|
|
- char z[1];
|
|
- char str[] = "hi";
|
|
-
|
|
- strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
|
|
-}
|
|
-
|
|
-// Support VLAs.
|
|
-void vlas(int size) {
|
|
- char z[size];
|
|
- char str[] = "hi";
|
|
-
|
|
- strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
|
|
-}
|