Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,2 @@
BasedOnStyle: LLVM
ColumnLimit: 0

View File

@@ -0,0 +1,87 @@
# Test runner infrastructure for Clang-based tools. This configures the Clang
# test trees for use by Lit, and delegates to LLVM's lit test handlers.
#
# Note that currently we don't support stand-alone builds of Clang, you must
# be building Clang from within a combined LLVM+Clang checkout..
set(CLANG_TOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
set(CLANG_TOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
if (CMAKE_CFG_INTDIR STREQUAL ".")
set(LLVM_BUILD_MODE ".")
else ()
set(LLVM_BUILD_MODE "%(build_mode)s")
endif ()
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
llvm_canonicalize_cmake_booleans(
CLANG_ENABLE_STATIC_ANALYZER)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
)
option(CLANG_TOOLS_TEST_USE_VG "Run Clang tools' tests under Valgrind" OFF)
if(CLANG_TOOLS_TEST_USE_VG)
set(CLANG_TOOLS_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
endif()
set(CLANG_TOOLS_TEST_DEPS
# For the clang-apply-replacements test that uses clang-rename.
clang-rename
# Individual tools we test.
clang-apply-replacements
clang-change-namespace
clangd
clang-include-fixer
clang-move
clang-query
clang-reorder-fields
find-all-symbols
modularize
pp-trace
# These individual tools have no tests, add them here to make them compile
# together with check-clang-tools, so that we won't break them in the future.
global-symbol-builder
# Unit tests
ExtraToolsUnitTests
)
if(CLANG_ENABLE_STATIC_ANALYZER)
list(APPEND CLANG_TOOLS_TEST_DEPS
# For the clang-tidy libclang integration test.
c-index-test
# clang-tidy tests require it.
clang-headers
clang-tidy
)
endif()
set(llvm_utils
FileCheck count not
)
foreach(t ${llvm_utils})
if(TARGET ${t})
list(APPEND CLANG_TOOLS_TEST_DEPS ${t})
endif()
endforeach()
add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CLANG_TOOLS_TEST_DEPS}
ARGS ${CLANG_TOOLS_TEST_EXTRA_ARGS}
)
set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")

View File

@@ -0,0 +1,37 @@
# -*- Python -*-
import platform
import lit.formats
config.name = "Extra Tools Unit Tests"
config.suffixes = [] # Seems not to matter for google tests?
# Test Source and Exec root dirs both point to the same directory where google
# test binaries are built.
config.test_source_root = config.extra_tools_obj_dir
config.test_exec_root = config.test_source_root
# All GoogleTests are named to have 'Tests' as their suffix. The '.' option is
# a special value for GoogleTest indicating that it should look through the
# entire testsuite recursively for tests (alternatively, one could provide a
# ;-separated list of subdirectories).
config.test_format = lit.formats.GoogleTest('.', 'Tests')
if platform.system() == 'Darwin':
shlibpath_var = 'DYLD_LIBRARY_PATH'
elif platform.system() == 'Windows':
shlibpath_var = 'PATH'
else:
shlibpath_var = 'LD_LIBRARY_PATH'
# Point the dynamic loader at dynamic libraries in 'lib'.
shlibpath = os.path.pathsep.join((config.shlibdir, config.llvm_libs_dir,
config.environment.get(shlibpath_var,'')))
# Win32 seeks DLLs along %PATH%.
if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
config.environment[shlibpath_var] = shlibpath

View File

@@ -0,0 +1,9 @@
@LIT_SITE_CFG_IN_HEADER@
config.extra_tools_obj_dir = "@CLANG_TOOLS_BINARY_DIR@/unittests"
config.extra_tools_src_dir = "@CLANG_TOOLS_SOURCE_DIR@/unittests"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.shlibdir = "@SHLIBDIR@"
config.target_triple = "@TARGET_TRIPLE@"
lit_config.load_config(config, "@CLANG_TOOLS_SOURCE_DIR@/test/Unit/lit.cfg")

View File

@@ -0,0 +1,5 @@
namespace std {
class STD {};
}
using namespace std;

View File

@@ -0,0 +1,37 @@
// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" %s -- -std=c++11 | sed 's,// CHECK.*,,' | FileCheck %s
template <class T>
class function;
template <class R, class... ArgTypes>
class function<R(ArgTypes...)> {
public:
template <typename Functor>
function(Functor f) {}
R operator()(ArgTypes...) const {}
};
namespace x {
// CHECK: namespace x {
class X {};
}
namespace na {
namespace nb {
// CHECK: namespace x {
// CHECK-NEXT: namespace y {
void f(function<void(int)> func, int param) { func(param); }
void g() { f([](int x) {}, 1); }
// x::X in function type parameter list will have translation unit context, so
// we simply replace it with fully-qualified name.
using TX = function<x::X(x::X)>;
// CHECK: using TX = function<X(x::X)>;
class A {};
using TA = function<A(A)>;
// CHECK: using TA = function<A(A)>;
// CHECK: } // namespace y
// CHECK-NEXT: } // namespace x
}
}

View File

@@ -0,0 +1,29 @@
// RUN: cp %S/macro.cpp %T/macro.cpp
// RUN: echo "#define USING using na::nc::X" > %T/macro.h
//
// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp" --i %T/macro.cpp --
// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-HEADER %s
//
// RUN: cp %S/macro.cpp %T/macro.cpp
// RUN: echo "#define USING using na::nc::X" > %T/macro.h
// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --i %T/macro.cpp --
// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-CHANGED-HEADER %s
#include "macro.h"
namespace na { namespace nc { class X{}; } }
namespace na {
namespace nb {
USING;
}
}
// CHECK-CC: namespace x {
// CHECK-CC: namespace y {
// CHECK-CC: USING;
// CHECK-CC: } // namespace y
// CHECK-CC: } // namespace x
// CHECK-HEADER: #define USING using na::nc::X
// CHECK-CHANGED-HEADER: #define USING using ::na::nc::X

View File

@@ -0,0 +1,10 @@
// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" %s -- | sed 's,// CHECK.*,,' | FileCheck %s
// CHECK: namespace x {
// CHECK-NEXT: namespace y {
namespace na {
namespace nb {
class A {};
// CHECK: } // namespace y
// CHECK-NEXT: } // namespace x
}
}

View File

@@ -0,0 +1,19 @@
// RUN: echo "^std::.*$" > %T/white-list.txt
// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --whitelist_file %T/white-list.txt %s -- | sed 's,// CHECK.*,,' | FileCheck %s
#include "Inputs/fake-std.h"
// CHECK: namespace x {
// CHECK-NEXT: namespace y {
namespace na {
namespace nb {
void f() {
std::STD x1;
STD x2;
// CHECK: {{^}} std::STD x1;{{$}}
// CHECK-NEXT: {{^}} STD x2;{{$}}
}
// CHECK: } // namespace y
// CHECK-NEXT: } // namespace x
}
}

View File

@@ -0,0 +1,11 @@
// RUN: rm -rf %t
// RUN: mkdir -p %t/fixes
// RUN: cat %s > %t.cpp
// RUN: clang-rename -offset=254 -new-name=Bar -export-fixes=%t/fixes/clang-rename.yaml %t.cpp --
// RUN: clang-apply-replacements %t
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
class Foo {}; // CHECK: class Bar {};
// Use grep -FUbo 'Foo' <file> to get the correct offset of Cla when changing
// this file.

View File

@@ -0,0 +1,32 @@
#ifndef BASIC_H
#define BASIC_H
class Parent {
public:
virtual void func() {}
};
class Derived : public Parent {
public:
virtual void func() {}
// CHECK: virtual void func() override {}
};
extern void ext(int (&)[5], const Parent &);
void func(int t) {
int ints[5];
for (unsigned i = 0; i < 5; ++i) {
int &e = ints[i];
e = t;
// CHECK: for (auto & elem : ints) {
// CHECK-NEXT: elem = t;
}
Derived d;
ext(ints, d);
}
#endif // BASIC_H

View File

@@ -0,0 +1,25 @@
---
MainSourceFile: source1.cpp
Diagnostics:
- DiagnosticName: test-basic
Message: Fix
FilePath: $(path)/basic.h
FileOffset: 242
Replacements:
- FilePath: $(path)/basic.h
Offset: 242
Length: 26
ReplacementText: 'auto & elem : ints'
- FilePath: $(path)/basic.h
Offset: 276
Length: 22
ReplacementText: ''
- FilePath: $(path)/basic.h
Offset: 298
Length: 1
ReplacementText: elem
- FilePath: $(path)/../basic/basic.h
Offset: 148
Length: 0
ReplacementText: 'override '
...

View File

@@ -0,0 +1,13 @@
---
MainSourceFile: source2.cpp
Diagnostics:
- DiagnosticName: test-basic
Message: Fix
FilePath: $(path)/basic.h
FileOffset: 148
Replacements:
- FilePath: $(path)/basic.h
Offset: 148
Length: 0
ReplacementText: 'override '
...

View File

@@ -0,0 +1,17 @@
#ifndef COMMON_H
#define COMMON_H
extern void ext(int (&)[5]);
void func(int t) {
int ints[5];
for (unsigned i = 0; i < 5; ++i) {
ints[i] = t;
}
int *i = 0;
ext(ints);
}
#endif // COMMON_H

View File

@@ -0,0 +1,11 @@
There are conflicting changes to $(path)/common.h:
The following changes conflict:
Replace 8:8-8:33 with "auto & i : ints"
Replace 8:8-8:33 with "int & elem : ints"
The following changes conflict:
Replace 9:5-9:11 with "elem"
Replace 9:5-9:11 with "i"
The following changes conflict:
Remove 12:3-12:14
Insert at 12:12 (int*)
Replace 12:12-12:12 with "nullptr"

View File

@@ -0,0 +1,21 @@
---
MainSourceFile: source1.cpp
Diagnostics:
- DiagnosticName: test-conflict
Message: Fix
FilePath: $(path)/common.h
FileOffset: 106
Replacements:
- FilePath: $(path)/common.h
Offset: 106
Length: 26
ReplacementText: 'auto & i : ints'
- FilePath: $(path)/common.h
Offset: 140
Length: 7
ReplacementText: i
- FilePath: $(path)/common.h
Offset: 160
Length: 12
ReplacementText: ''
...

View File

@@ -0,0 +1,21 @@
---
MainSourceFile: source2.cpp
Diagnostics:
- DiagnosticName: test-conflict
Message: Fix
FilePath: $(path)/common.h
FileOffset: 106
Replacements:
- FilePath: $(path)/common.h
Offset: 106
Length: 26
ReplacementText: 'int & elem : ints'
- FilePath: $(path)/common.h
Offset: 140
Length: 7
ReplacementText: elem
- FilePath: $(path)/common.h
Offset: 169
Length: 1
ReplacementText: nullptr
...

View File

@@ -0,0 +1,13 @@
---
MainSourceFile: source1.cpp
Diagnostics:
- DiagnosticName: test-conflict
Message: Fix
FilePath: $(path)/common.h
FileOffset: 169
Replacements:
- FilePath: $(path)/common.h
Offset: 169
Length: 0
ReplacementText: "(int*)"
...

View File

@@ -0,0 +1,6 @@
// This file intentionally uses a CRLF newlines!
void foo() {
int *x = 0;
}

View File

@@ -0,0 +1,6 @@
// This file intentionally uses a CRLF newlines!
void foo() {
int *x = nullptr;
}

Some files were not shown because too many files have changed in this diff Show More