diff options
Diffstat (limited to 'test/Tooling')
-rw-r--r-- | test/Tooling/Inputs/mock-libcxx/bin/clang | 1 | ||||
-rw-r--r-- | test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector | 1 | ||||
-rw-r--r-- | test/Tooling/auto-detect-from-source.cpp | 10 | ||||
-rw-r--r-- | test/Tooling/clang-check-analyzer.cpp | 3 | ||||
-rw-r--r-- | test/Tooling/clang-check-ast-dump.cpp | 3 | ||||
-rw-r--r-- | test/Tooling/clang-check-extra-arg.cpp | 4 | ||||
-rw-r--r-- | test/Tooling/clang-check-mac-libcxx-abspath.cpp | 17 | ||||
-rw-r--r-- | test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp | 16 | ||||
-rw-r--r-- | test/Tooling/clang-check-mac-libcxx-relpath.cpp | 17 | ||||
-rw-r--r-- | test/Tooling/clang-diff-json.cpp | 6 |
10 files changed, 71 insertions, 7 deletions
diff --git a/test/Tooling/Inputs/mock-libcxx/bin/clang b/test/Tooling/Inputs/mock-libcxx/bin/clang new file mode 100644 index 0000000000000..ed34c1f81868b --- /dev/null +++ b/test/Tooling/Inputs/mock-libcxx/bin/clang @@ -0,0 +1 @@ +This file is a placeholder to keep its parent directory in git. diff --git a/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector b/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector new file mode 100644 index 0000000000000..8512477b5d8e8 --- /dev/null +++ b/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector @@ -0,0 +1 @@ +class vector {}; diff --git a/test/Tooling/auto-detect-from-source.cpp b/test/Tooling/auto-detect-from-source.cpp index 12a660d585a98..e6241a9ec3e56 100644 --- a/test/Tooling/auto-detect-from-source.cpp +++ b/test/Tooling/auto-detect-from-source.cpp @@ -1,8 +1,12 @@ // RUN: rm -rf %t // RUN: mkdir %t -// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json +// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -DSECRET=XYZZY -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json // RUN: cp "%s" "%t/test.cpp" // RUN: not clang-check "%t/test.cpp" 2>&1 | FileCheck %s -// CHECK: C++ requires -invalid; +// CHECK: XYZZY +SECRET; + +// Copy to a different file, and rely on the command being inferred. +// RUN: cp "%s" "%t/other.cpp" +// RUN: not clang-check "%t/other.cpp" 2>&1 | FileCheck %s diff --git a/test/Tooling/clang-check-analyzer.cpp b/test/Tooling/clang-check-analyzer.cpp index ee0a6dc369caf..72e1a20e5ff01 100644 --- a/test/Tooling/clang-check-analyzer.cpp +++ b/test/Tooling/clang-check-analyzer.cpp @@ -1,4 +1,7 @@ // RUN: clang-check -analyze "%s" -- -c 2>&1 | FileCheck %s +// RUN: clang-check -analyze "%s" -- -c -flto -Wa,--noexecstack 2>&1 | FileCheck %s +// RUN: clang-check -analyze "%s" -- -c -no-integrated-as -flto=thin 2>&1 | FileCheck %s +// RUN: clang-check -analyze "%s" -- -c -flto=full 2>&1 | FileCheck %s // CHECK: Dereference of null pointer void a(int *x) { if(x){} *x = 47; } diff --git a/test/Tooling/clang-check-ast-dump.cpp b/test/Tooling/clang-check-ast-dump.cpp index d8643c79428ed..496d489fd6090 100644 --- a/test/Tooling/clang-check-ast-dump.cpp +++ b/test/Tooling/clang-check-ast-dump.cpp @@ -32,7 +32,8 @@ // CHECK-ATTR: test_namespace // CHECK-ATTR-NEXT: FieldDecl{{.*}}n // CHECK-ATTR-NEXT: AlignedAttr -// CHECK-ATTR-NEXT: BinaryOperator +// CHECK-ATTR-NEXT: ConstantExpr +// CHECK-ATTR-NEXT: BinaryOperator // // RUN: clang-check -ast-dump -ast-dump-filter test_namespace::AfterNullNode "%s" -- 2>&1 | FileCheck -check-prefix CHECK-AFTER-NULL %s // CHECK-AFTER-NULL: class AfterNullNode diff --git a/test/Tooling/clang-check-extra-arg.cpp b/test/Tooling/clang-check-extra-arg.cpp index a5d00bc8e8923..df5fb930eedcd 100644 --- a/test/Tooling/clang-check-extra-arg.cpp +++ b/test/Tooling/clang-check-extra-arg.cpp @@ -2,4 +2,8 @@ // CHECK: unknown warning option '-Wunimplemented-warning-before' // CHECK: unknown warning option '-Wunimplemented-warning' + +// Check we do not crash with -extra-arg=-gsplit-dwarf (we did, under linux). +// RUN: clang-check "%s" -extra-arg=-gsplit-dwarf -- -c + void a(){} diff --git a/test/Tooling/clang-check-mac-libcxx-abspath.cpp b/test/Tooling/clang-check-mac-libcxx-abspath.cpp new file mode 100644 index 0000000000000..476ba3ce0849a --- /dev/null +++ b/test/Tooling/clang-check-mac-libcxx-abspath.cpp @@ -0,0 +1,17 @@ +// Clang on MacOS can find libc++ living beside the installed compiler. +// This test makes sure our libTooling-based tools emulate this properly. +// +// RUN: rm -rf %t +// RUN: mkdir %t +// +// Install the mock libc++ (simulates the libc++ directory structure). +// RUN: cp -r %S/Inputs/mock-libcxx %t/ +// +// Pretend clang is installed beside the mock library that we provided. +// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json +// RUN: cp "%s" "%t/test.cpp" +// clang-check will produce an error code if the mock library is not found. +// RUN: clang-check -p "%t" "%t/test.cpp" + +#include <mock_vector> +vector v; diff --git a/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp b/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp new file mode 100644 index 0000000000000..035155c96c925 --- /dev/null +++ b/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp @@ -0,0 +1,16 @@ +// Clang on MacOS can find libc++ living beside the installed compiler. +// This test makes sure our libTooling-based tools emulate this properly with +// fixed compilation database. +// +// RUN: rm -rf %t +// RUN: mkdir %t +// +// Install the mock libc++ (simulates the libc++ directory structure). +// RUN: cp -r %S/Inputs/mock-libcxx %t/ +// +// RUN: cp $(which clang-check) %t/mock-libcxx/bin/ +// RUN: cp "%s" "%t/test.cpp" +// RUN: %t/mock-libcxx/bin/clang-check -p "%t" "%t/test.cpp" -- -stdlib=libc++ + +#include <mock_vector> +vector v; diff --git a/test/Tooling/clang-check-mac-libcxx-relpath.cpp b/test/Tooling/clang-check-mac-libcxx-relpath.cpp new file mode 100644 index 0000000000000..099be5ecd4984 --- /dev/null +++ b/test/Tooling/clang-check-mac-libcxx-relpath.cpp @@ -0,0 +1,17 @@ +// Clang on MacOS can find libc++ living beside the installed compiler. +// This test makes sure our libTooling-based tools emulate this properly. +// +// RUN: rm -rf %t +// RUN: mkdir %t +// +// Install the mock libc++ (simulates the libc++ directory structure). +// RUN: cp -r %S/Inputs/mock-libcxx %t/ +// +// Pretend clang is installed beside the mock library that we provided. +// RUN: echo '[{"directory":"%t","command":"mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json +// RUN: cp "%s" "%t/test.cpp" +// clang-check will produce an error code if the mock library is not found. +// RUN: clang-check -p "%t" "%t/test.cpp" + +#include <mock_vector> +vector v; diff --git a/test/Tooling/clang-diff-json.cpp b/test/Tooling/clang-diff-json.cpp index 20c808cb0f19b..cc2bb0805e53f 100644 --- a/test/Tooling/clang-diff-json.cpp +++ b/test/Tooling/clang-diff-json.cpp @@ -1,10 +1,10 @@ // RUN: clang-diff -ast-dump-json %s -- \ -// RUN: | '%python' -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \ +// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \ // RUN: | FileCheck %s -// CHECK: "begin": 301, +// CHECK: "begin": 311, // CHECK: "type": "FieldDecl", -// CHECK: "end": 321, +// CHECK: "end": 319, // CHECK: "type": "CXXRecordDecl", class A { int x; |