-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sarnie, Nick <[email protected]>
- Loading branch information
Showing
75 changed files
with
9,406 additions
and
2 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.PureVirtualCall.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. title:: clang-tidy - clang-analyzer-cplusplus.PureVirtualCall | ||
|
||
clang-analyzer-cplusplus.PureVirtualCall | ||
======================================== | ||
|
||
Check pure virtual function calls during construction/destruction. | ||
|
||
The clang-analyzer-cplusplus.PureVirtualCall check is an alias of | ||
Clang Static Analyzer cplusplus.PureVirtualCall. |
9 changes: 9 additions & 0 deletions
9
...ls-extra/docs/clang-tidy/checks/clang-analyzer/optin.osx.OSObjectCStyleCast.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. title:: clang-tidy - clang-analyzer-optin.osx.OSObjectCStyleCast | ||
|
||
clang-analyzer-optin.osx.OSObjectCStyleCast | ||
=========================================== | ||
|
||
Checker for C-style casts of OSObjects. | ||
|
||
The clang-analyzer-optin.osx.OSObjectCStyleCast check is an alias of | ||
Clang Static Analyzer optin.osx.OSObjectCStyleCast. |
9 changes: 9 additions & 0 deletions
9
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/osx.MIG.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. title:: clang-tidy - clang-analyzer-osx.MIG | ||
|
||
clang-analyzer-osx.MIG | ||
====================== | ||
|
||
Find violations of the Mach Interface Generator calling convention. | ||
|
||
The clang-analyzer-osx.MIG check is an alias of | ||
Clang Static Analyzer osx.MIG. |
9 changes: 9 additions & 0 deletions
9
...g-tools-extra/docs/clang-tidy/checks/clang-analyzer/osx.OSObjectRetainCount.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. title:: clang-tidy - clang-analyzer-osx.OSObjectRetainCount | ||
|
||
clang-analyzer-osx.OSObjectRetainCount | ||
====================================== | ||
|
||
Check for leaks and improper reference count management for OSObject. | ||
|
||
The clang-analyzer-osx.OSObjectRetainCount check is an alias of | ||
Clang Static Analyzer osx.OSObjectRetainCount. |
9 changes: 9 additions & 0 deletions
9
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/valist.CopyToSelf.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. title:: clang-tidy - clang-analyzer-valist.CopyToSelf | ||
|
||
clang-analyzer-valist.CopyToSelf | ||
================================ | ||
|
||
Check for va_lists which are copied onto itself. | ||
|
||
The clang-analyzer-valist.CopyToSelf check is an alias of | ||
Clang Static Analyzer valist.CopyToSelf. |
9 changes: 9 additions & 0 deletions
9
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/valist.Uninitialized.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. title:: clang-tidy - clang-analyzer-valist.Uninitialized | ||
|
||
clang-analyzer-valist.Uninitialized | ||
=================================== | ||
|
||
Check for usages of uninitialized (or already released) va_lists. | ||
|
||
The clang-analyzer-valist.Uninitialized check is an alias of | ||
Clang Static Analyzer valist.Uninitialized. |
9 changes: 9 additions & 0 deletions
9
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/valist.Unterminated.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. title:: clang-tidy - clang-analyzer-valist.Unterminated | ||
|
||
clang-analyzer-valist.Unterminated | ||
================================== | ||
|
||
Check for va_lists which are not released by a va_end call. | ||
|
||
The clang-analyzer-valist.Unterminated check is an alias of | ||
Clang Static Analyzer valist.Unterminated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// REQUIRES: host-supports-jit, x86_64-linux | ||
|
||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// | ||
// RUN: split-file %s %t | ||
// | ||
// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o | ||
// RUN: %clang++ -shared %t/vec.o -o %t/vec.so | ||
// | ||
// RUN: cat %t/Test.cpp | LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH clang-repl | ||
|
||
//--- vec.cpp | ||
#include <vector> | ||
|
||
//--- Test.cpp | ||
%lib vec.so | ||
#include <vector> | ||
std::vector<int> v; | ||
%quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
__attribute__((visibility("hidden"), nocommon)) | ||
_Bool __aarch64_has_sme_and_tpidr2_el0; | ||
|
||
// We have multiple ways to check that the function has SME, depending on our | ||
// target. | ||
// * For Linux/Glibc we can use getauxval(). | ||
// * For Android we can use getauxval(). | ||
// * For newlib we can use __aarch64_sme_accessible(). | ||
|
||
#if defined(__linux__) | ||
|
||
#if defined(__ANDROID__) | ||
#include <sys/auxv.h> | ||
#elif __has_include(<sys/auxv.h>) | ||
#include <sys/auxv.h> | ||
#else | ||
#define getauxval(x) 0 | ||
#endif | ||
#include "../cpu_model/aarch64/hwcap.inc" | ||
|
||
static _Bool has_sme(void) { return getauxval(AT_HWCAP2) & HWCAP2_SME; } | ||
|
||
#else // defined(__linux__) | ||
|
||
#if defined(COMPILER_RT_SHARED_LIB) | ||
__attribute__((weak)) | ||
#endif | ||
extern _Bool __aarch64_sme_accessible(void); | ||
|
||
static _Bool has_sme(void) { | ||
#if defined(COMPILER_RT_SHARED_LIB) | ||
if (!__aarch64_sme_accessible) | ||
return 0; | ||
#endif | ||
return __aarch64_sme_accessible(); | ||
} | ||
|
||
#endif // defined(__linux__) | ||
|
||
#if __GNUC__ >= 9 | ||
#pragma GCC diagnostic ignored "-Wprio-ctor-dtor" | ||
#endif | ||
__attribute__((constructor(90))) | ||
static void init_aarch64_has_sme(void) { | ||
__aarch64_has_sme_and_tpidr2_el0 = has_sme(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// RUN: %clangxx_msan %s -o %t && %run %t %p | ||
|
||
#include <assert.h> | ||
#include <resolv.h> | ||
#include <string.h> | ||
|
||
#include <sanitizer/msan_interface.h> | ||
|
||
void testWrite() { | ||
char unsigned input[] = {0xff, 0xc5, 0xf7, 0xff, 0x00, 0x00, 0xff, 0x0a, 0x00, | ||
0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, | ||
0x10, 0x01, 0x05, 0x00, 0x01, 0x0a, 0x67, 0x6f, 0x6f, | ||
0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x00}; | ||
char output[1024]; | ||
|
||
int res = dn_expand(input, input + sizeof(input), input + 23, output, | ||
sizeof(output)); | ||
|
||
assert(res == 12); | ||
assert(strcmp(output, "google\\.com") == 0); | ||
__msan_check_mem_is_initialized(output, strlen(output) + 1); | ||
} | ||
|
||
void testWriteZeroLength() { | ||
char unsigned input[] = { | ||
0xff, 0xc5, 0xf7, 0xff, 0x00, 0x00, 0xff, 0x0a, 0x00, 0x00, 0x00, 0x01, | ||
0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x10, 0x01, 0x05, 0x00, 0x01, 0x00, | ||
}; | ||
char output[1024]; | ||
|
||
int res = dn_expand(input, input + sizeof(input), input + 23, output, | ||
sizeof(output)); | ||
|
||
assert(res == 1); | ||
assert(strcmp(output, "") == 0); | ||
__msan_check_mem_is_initialized(output, strlen(output) + 1); | ||
} | ||
|
||
void testComp() { | ||
char unsigned msg[1024]; | ||
char unsigned *mb = msg; | ||
char unsigned *me = msg + sizeof(msg); | ||
char unsigned **pb = (char unsigned **)mb; | ||
pb[0] = msg; | ||
pb[1] = nullptr; | ||
mb += 64; | ||
char unsigned **pe = (char unsigned **)mb; | ||
|
||
char unsigned *n1 = mb; | ||
int res = dn_comp("llvm.org", mb, me - mb, pb, pe); | ||
assert(res == 10); | ||
__msan_check_mem_is_initialized(mb, res); | ||
// pb is [msg, llvm.org, nullptr] | ||
__msan_check_mem_is_initialized(pb, sizeof(*pb) * 3); | ||
mb += res; | ||
|
||
char unsigned *n2 = mb; | ||
res = dn_comp("lab.llvm.org", mb, me - mb, pb, pe); | ||
assert(res == 6); | ||
__msan_check_mem_is_initialized(mb, res); | ||
// pb is [msg, llvm.org, lab.llvm.org, nullptr] | ||
__msan_check_mem_is_initialized(pb, sizeof(*pb) * 4); | ||
mb += res; | ||
|
||
{ | ||
char output[1024]; | ||
res = dn_expand(msg, msg + sizeof(msg), n1, output, sizeof(output)); | ||
|
||
fprintf(stderr, "%d\n", res); | ||
assert(res == 10); | ||
assert(strcmp(output, "llvm.org") == 0); | ||
__msan_check_mem_is_initialized(output, strlen(output) + 1); | ||
} | ||
|
||
{ | ||
char output[1024]; | ||
res = dn_expand(msg, msg + sizeof(msg), n2, output, sizeof(output)); | ||
|
||
assert(res == 6); | ||
assert(strcmp(output, "lab.llvm.org") == 0); | ||
__msan_check_mem_is_initialized(output, strlen(output) + 1); | ||
} | ||
} | ||
|
||
int main(int iArgc, const char *szArgv[]) { | ||
testWrite(); | ||
testWriteZeroLength(); | ||
testComp(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.