Merge "Free memory when it is no more used"
diff --git a/benchmarks/tests/interface_test.cpp b/benchmarks/tests/interface_test.cpp
index ff4b255..301c294 100644
--- a/benchmarks/tests/interface_test.cpp
+++ b/benchmarks/tests/interface_test.cpp
@@ -63,7 +63,7 @@
void SystemTests::SanitizeOutput() {
// Cut off anything after the arguments, since that varies with time.
- sanitized_output_ = std::regex_replace(raw_output_, std::regex(".+(BM_\\S+) +.+"), "$1");
+ sanitized_output_ = std::regex_replace(raw_output_, std::regex(".*(BM_\\S+)\\s+.+"), "$1");
// Remove everything before the header.
sanitized_output_.erase(0, sanitized_output_.find("------------------------------------------------"));
@@ -165,7 +165,8 @@
" [--benchmark_filter=<regex>]\n"
" [--benchmark_min_time=<min_time>]\n"
" [--benchmark_repetitions=<num_repetitions>]\n"
- " [--benchmark_report_aggregates_only={true|false}\n"
+ " [--benchmark_report_aggregates_only={true|false}]\n"
+ " [--benchmark_display_aggregates_only={true|false}]\n"
" [--benchmark_format=<console|json|csv>]\n"
" [--benchmark_out=<filename>]\n"
" [--benchmark_out_format=<json|console|csv>]\n"
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index 6dd2f9c..91913e8 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -167,9 +167,14 @@
// SIGSTKSZ (8KiB) is not big enough.
// An snprintf to a stack buffer of size PATH_MAX consumes ~7KiB of stack.
-// Also, on 64-bit, logging uses more than 8KiB by itself:
-// https://code.google.com/p/android/issues/detail?id=187064
+// On 64-bit, logging uses more than 8KiB by itself, ucontext is comically
+// large on aarch64, and we have effectively infinite address space, so double
+// the signal stack size.
+#if defined(__LP64__)
+#define SIGNAL_STACK_SIZE_WITHOUT_GUARD (32 * 1024)
+#else
#define SIGNAL_STACK_SIZE_WITHOUT_GUARD (16 * 1024)
+#endif
// Traditionally we gave threads a 1MiB stack. When we started
// allocating per-thread alternate signal stacks to ease debugging of
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index 42237d0..eba18a8 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -31,12 +31,7 @@
__BEGIN_DECLS
-// Remove this workaround once b/37423073 is fixed.
-#if !__has_attribute(alloc_size)
-#define __BIONIC_ALLOC_SIZE(...)
-#else
#define __BIONIC_ALLOC_SIZE(...) __attribute__((__alloc_size__(__VA_ARGS__)))
-#endif
/**
* [malloc(3)](http://man7.org/linux/man-pages/man3/malloc.3.html) allocates
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index 01f42b7..0961a94 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -63,11 +63,6 @@
},
},
- // Clang lld link flags do not work with special link rules
- // for libunwind_llvm yet. Linked aosp_arm-eng image failed to
- // boot up in the emulator. http://b/78118944.
- use_clang_lld: false,
-
static_libs: [
"libasync_safe",
"libbase",
diff --git a/libc/tzcode/bionic.cpp b/libc/tzcode/bionic.cpp
index 0efcc7b..51fd39a 100644
--- a/libc/tzcode/bionic.cpp
+++ b/libc/tzcode/bionic.cpp
@@ -205,7 +205,7 @@
olson_id, entry_length);
if (fd >= 0) return fd;
- fd = __bionic_open_tzdata_path("/apex/com.android.tzdata.apex/etc/tzdata",
+ fd = __bionic_open_tzdata_path("/apex/com.android.tzdata/etc/tzdata",
olson_id, entry_length);
if (fd >= 0) return fd;
diff --git a/linker/Android.bp b/linker/Android.bp
index 779cd3f..8ef540c 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -167,10 +167,6 @@
"-Wl,-soname,ld-android.so",
],
- // lld bug: https://bugs.llvm.org/show_bug.cgi?id=36295
- // error: symbol __aeabi_*@@LIBC_N has undefined version LIBC_N
- use_clang_lld: false,
-
cflags: [
"-fno-stack-protector",
"-Wstrict-overflow=5",
diff --git a/tests/Android.bp b/tests/Android.bp
index c334032..6a644b6 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -630,6 +630,10 @@
static_executable: true,
stl: "libc++_static",
+
+ // libclang_rt.builtins does not work with libm
+ // http://b/117167374
+ no_libcrt: true,
}
// -----------------------------------------------------------------------------
diff --git a/tests/buffer_tests.cpp b/tests/buffer_tests.cpp
index a5a0c2a..7563448 100644
--- a/tests/buffer_tests.cpp
+++ b/tests/buffer_tests.cpp
@@ -227,6 +227,18 @@
}
}
+// Malloc can return a tagged pointer, which is not accepted in mm system calls like mprotect.
+// Clear top 8 bits of the address on 64-bit platforms.
+static int MprotectHeap(void* addr, size_t len, int prot) {
+#if defined(__LP64__)
+ constexpr uintptr_t mask = (static_cast<uintptr_t>(1) << 56) - 1;
+ void* untagged_addr = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(addr) & mask);
+#else
+ void* untagged_addr = addr;
+#endif
+ return mprotect(untagged_addr, len, prot);
+}
+
void RunSingleBufferAlignTest(
size_t max_test_size, void (*test_func)(uint8_t*, size_t),
size_t (*set_incr)(size_t)) {
@@ -358,14 +370,14 @@
memset(memory, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_NONE) == 0);
for (size_t i = 0; i < pagesize; i++) {
uint8_t* buf = &memory[pagesize-i];
test_func(buf, i);
}
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
free(memory);
}
@@ -379,7 +391,7 @@
memset(memory, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_NONE) == 0);
uint8_t* dst_buffer = new uint8_t[2*pagesize];
// Change the dst alignment as we change the source.
@@ -391,7 +403,7 @@
test_func(src, dst, j);
}
}
- ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
free(memory);
delete[] dst_buffer;
}
@@ -409,7 +421,7 @@
memset(memory1, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory1[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory1[pagesize], pagesize, PROT_NONE) == 0);
uint8_t* memory2;
ASSERT_TRUE(posix_memalign(reinterpret_cast<void**>(&memory2), pagesize,
@@ -417,7 +429,7 @@
memset(memory2, 0x23, 2*pagesize);
// Make the second page unreadable and unwritable.
- ASSERT_TRUE(mprotect(&memory2[pagesize], pagesize, PROT_NONE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory2[pagesize], pagesize, PROT_NONE) == 0);
for (size_t i = 0; i < pagesize; i++) {
uint8_t* buf1 = &memory1[pagesize-i];
@@ -445,8 +457,8 @@
}
}
- ASSERT_TRUE(mprotect(&memory1[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
- ASSERT_TRUE(mprotect(&memory2[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory1[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
+ ASSERT_TRUE(MprotectHeap(&memory2[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
free(memory1);
free(memory2);
}
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index cb98cae..c1681ea 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -136,6 +136,7 @@
TEST(dl, preinit_system_calls) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN; // hwasan not initialized in preinit_array
std::string helper = GetTestlibRoot() +
"/preinit_syscall_test_helper/preinit_syscall_test_helper";
chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607
@@ -153,6 +154,9 @@
ExecTestHelper eth;
eth.SetArgs({ helper.c_str(), nullptr });
eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, 0, nullptr);
+#else
+ // Force a failure when not compiled for bionic so the test is considered a pass.
+ ASSERT_TRUE(false);
#endif
}
@@ -235,6 +239,7 @@
// whose search paths include the 'ns2/' subdir.
TEST(dl, exec_with_ld_config_file) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN; // libclang_rt.hwasan is not found with custom ld config
if (!is_debuggable_build()) {
// LD_CONFIG_FILE is not supported on user build
return;
@@ -257,6 +262,7 @@
// additional namespaces other than the default namespace.
TEST(dl, exec_with_ld_config_file_with_ld_preload) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN; // libclang_rt.hwasan is not found with custom ld config
if (!is_debuggable_build()) {
// LD_CONFIG_FILE is not supported on user build
return;
diff --git a/tests/getcwd_test.cpp b/tests/getcwd_test.cpp
index f8f205e..791ffae 100644
--- a/tests/getcwd_test.cpp
+++ b/tests/getcwd_test.cpp
@@ -20,6 +20,8 @@
#include <limits.h>
#include <unistd.h>
+#include "utils.h"
+
TEST(getcwd, auto_full) {
// If we let the library do all the work, everything's fine.
errno = 0;
@@ -49,6 +51,7 @@
}
TEST(getcwd, auto_too_large) {
+ SKIP_WITH_HWASAN; // allocation size too large
// If we ask the library to allocate an unreasonably large buffer, ERANGE.
errno = 0;
char* cwd = getcwd(nullptr, static_cast<size_t>(-1));
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
index 5c4eb42..79c9a06 100644
--- a/tests/libs/Android.bp
+++ b/tests/libs/Android.bp
@@ -531,8 +531,6 @@
defaults: ["bionic_testlib_defaults"],
srcs: ["dl_df_1_global.cpp"],
ldflags: ["-Wl,-z,global"],
- // b/80109858, clang lld ignores -z,global
- use_clang_lld: false,
target: {
host: {
@@ -561,8 +559,6 @@
defaults: ["bionic_testlib_defaults"],
srcs: ["dl_df_1_global_dummy.cpp"],
ldflags: ["-Wl,-z,global"],
- // b/80109858, clang lld ignores -z,global
- use_clang_lld: false,
target: {
host: {
diff --git a/tests/libs/cfi_test_helper.cpp b/tests/libs/cfi_test_helper.cpp
index ff313a2..c1a7b6d 100644
--- a/tests/libs/cfi_test_helper.cpp
+++ b/tests/libs/cfi_test_helper.cpp
@@ -27,11 +27,13 @@
static int g_count;
// Mock a CFI-enabled library without relying on the compiler.
-extern "C" __attribute__((aligned(4096))) void __cfi_check(uint64_t /*CallSiteTypeId*/,
- void* /*TargetAddr*/, void* /*Diag*/) {
+extern "C" __attribute__((no_sanitize("hwaddress"))) __attribute__((aligned(4096)))
+void __cfi_check(uint64_t /*CallSiteTypeId*/, void* /*TargetAddr*/, void* /*Diag*/) {
++g_count;
}
+// This code runs before hwasan is initialized.
+__attribute__((no_sanitize("hwaddress")))
void preinit_ctor() {
CHECK(g_count == 0);
__cfi_slowpath(42, reinterpret_cast<void*>(&preinit_ctor));
diff --git a/tests/malloc_iterate_test.cpp b/tests/malloc_iterate_test.cpp
index 2b7b887..5e60a6d 100644
--- a/tests/malloc_iterate_test.cpp
+++ b/tests/malloc_iterate_test.cpp
@@ -26,6 +26,8 @@
#include <procinfo/process_map.h>
+#include "utils.h"
+
extern "C" void malloc_disable();
extern "C" void malloc_enable();
extern "C" int malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t base,
@@ -130,6 +132,7 @@
// Verify that small allocs can be found properly.
TEST(malloc_iterate, small_allocs) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
TestDataType test_data;
// Try to cycle through all of the different small bins.
@@ -153,6 +156,7 @@
// Verify that large allocs can be found properly.
TEST(malloc_iterate, large_allocs) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
TestDataType test_data;
// Try some larger sizes.
@@ -172,6 +176,7 @@
// non-allocated pointers.
TEST(malloc_iterate, invalid_pointers) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
TestDataType test_data = {};
// Find all of the maps that are not [anon:libc_malloc].
@@ -192,6 +197,7 @@
TEST(malloc_iterate, malloc_disable_prevents_allocs) {
#if defined(__BIONIC__)
+ SKIP_WITH_HWASAN;
pid_t pid;
if ((pid = fork()) == 0) {
malloc_disable();
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index c4f13f6..8b670f0 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -25,6 +25,7 @@
#include <tinyxml2.h>
#include "private/bionic_config.h"
+#include "utils.h"
#if defined(__BIONIC__)
#define HAVE_REALLOCARRAY 1
@@ -41,6 +42,7 @@
}
TEST(malloc, malloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, malloc(SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -59,12 +61,14 @@
}
TEST(malloc, calloc_illegal) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, calloc(-1, 100));
ASSERT_EQ(ENOMEM, errno);
}
TEST(malloc, calloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, calloc(1, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -80,6 +84,7 @@
}
TEST(malloc, memalign_multiple) {
+ SKIP_WITH_HWASAN; // hwasan requires power of 2 alignment.
// Memalign test where the alignment is any value.
for (size_t i = 0; i <= 12; i++) {
for (size_t alignment = 1 << i; alignment < (1U << (i+1)); alignment++) {
@@ -94,10 +99,12 @@
}
TEST(malloc, memalign_overflow) {
+ SKIP_WITH_HWASAN;
ASSERT_EQ(nullptr, memalign(4096, SIZE_MAX));
}
TEST(malloc, memalign_non_power2) {
+ SKIP_WITH_HWASAN;
void* ptr;
for (size_t align = 0; align <= 256; align++) {
ptr = memalign(align, 1024);
@@ -280,6 +287,7 @@
}
TEST(malloc, realloc_overflow) {
+ SKIP_WITH_HWASAN;
errno = 0;
ASSERT_EQ(nullptr, realloc(nullptr, SIZE_MAX));
ASSERT_EQ(ENOMEM, errno);
@@ -504,6 +512,27 @@
ASSERT_EQ(0, errno);
}
+TEST(malloc, mallopt_decay) {
+#if defined(__BIONIC__)
+ errno = 0;
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 1));
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 0));
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 1));
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, 0));
+#else
+ GTEST_LOG_(INFO) << "This tests a bionic implementation detail.\n";
+#endif
+}
+
+TEST(malloc, mallopt_purge) {
+#if defined(__BIONIC__)
+ errno = 0;
+ ASSERT_EQ(1, mallopt(M_PURGE, 0));
+#else
+ GTEST_LOG_(INFO) << "This tests a bionic implementation detail.\n";
+#endif
+}
+
TEST(malloc, reallocarray_overflow) {
#if HAVE_REALLOCARRAY
// Values that cause overflow to a result small enough (8 on LP64) that malloc would "succeed".
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 1c3e1d1..14848ae 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -35,6 +35,8 @@
#include <limits>
#include <string>
+#include "utils.h"
+
#if defined(__BIONIC__)
#define ALIGNED_ALLOC_AVAILABLE 1
#elif defined(__GLIBC_PREREQ)
@@ -191,6 +193,7 @@
}
TEST(stdlib, posix_memalign_sweep) {
+ SKIP_WITH_HWASAN;
void* ptr;
// These should all fail.
@@ -230,11 +233,13 @@
}
TEST(stdlib, posix_memalign_overflow) {
+ SKIP_WITH_HWASAN;
void* ptr;
ASSERT_NE(0, posix_memalign(&ptr, 16, SIZE_MAX));
}
TEST(stdlib, aligned_alloc_sweep) {
+ SKIP_WITH_HWASAN;
#if defined(ALIGNED_ALLOC_AVAILABLE)
// Verify powers of 2 up to 2048 allocate, and verify that all other
// alignment values between the powers of 2 fail.
@@ -259,6 +264,7 @@
}
TEST(stdlib, aligned_alloc_overflow) {
+ SKIP_WITH_HWASAN;
#if defined(ALIGNED_ALLOC_AVAILABLE)
ASSERT_TRUE(aligned_alloc(16, SIZE_MAX) == nullptr);
#else
@@ -267,6 +273,7 @@
}
TEST(stdlib, aligned_alloc_size_not_multiple_of_alignment) {
+ SKIP_WITH_HWASAN;
#if defined(ALIGNED_ALLOC_AVAILABLE)
for (size_t size = 1; size <= 2048; size++) {
void* ptr = aligned_alloc(2048, size);
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index e82f15d..4ec5976 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -488,23 +488,6 @@
ASSERT_EQ(EINVAL, errno);
}
-TEST(time, timer_delete_multiple) {
- timer_t timer_id;
- ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, nullptr, &timer_id));
- ASSERT_EQ(0, timer_delete(timer_id));
- ASSERT_EQ(-1, timer_delete(timer_id));
- ASSERT_EQ(EINVAL, errno);
-
- sigevent_t se;
- memset(&se, 0, sizeof(se));
- se.sigev_notify = SIGEV_THREAD;
- se.sigev_notify_function = NoOpNotifyFunction;
- ASSERT_EQ(0, timer_create(CLOCK_MONOTONIC, &se, &timer_id));
- ASSERT_EQ(0, timer_delete(timer_id));
- ASSERT_EQ(-1, timer_delete(timer_id));
- ASSERT_EQ(EINVAL, errno);
-}
-
TEST(time, timer_create_multiple) {
Counter counter1(Counter::CountNotifyFunction);
Counter counter2(Counter::CountNotifyFunction);
diff --git a/tests/utils.h b/tests/utils.h
index c8656dc..5fc1d93 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -58,6 +58,14 @@
return (dlopen("libc.so", 0) != nullptr);
}
+extern "C" void __hwasan_init() __attribute__((weak));
+
+static inline bool running_with_hwasan() {
+ return &__hwasan_init != 0;
+}
+
+#define SKIP_WITH_HWASAN if (running_with_hwasan()) { return; }
+
#if defined(__linux__)
#include <sys/sysmacros.h>
diff --git a/tools/versioner/src/Driver.cpp b/tools/versioner/src/Driver.cpp
index 7c4aa23..8ba3d42 100644
--- a/tools/versioner/src/Driver.cpp
+++ b/tools/versioner/src/Driver.cpp
@@ -29,7 +29,6 @@
#include <clang/AST/ASTConsumer.h>
#include <clang/Basic/Diagnostic.h>
#include <clang/Basic/TargetInfo.h>
-#include <clang/Basic/VirtualFileSystem.h>
#include <clang/Driver/Compilation.h>
#include <clang/Driver/Driver.h>
#include <clang/Frontend/CompilerInstance.h>
@@ -42,6 +41,7 @@
#include <llvm/ADT/IntrusiveRefCntPtr.h>
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/StringRef.h>
+#include <llvm/Support/VirtualFileSystem.h>
#include "Arch.h"
#include "DeclarationDatabase.h"
@@ -93,7 +93,7 @@
// Run it once to generate flags for each target, and memoize the results.
static std::unordered_map<CompilationType, std::vector<std::string>> cc1_flags;
static const char* filename_placeholder = "__VERSIONER_PLACEHOLDER__";
-static void generateTargetCC1Flags(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+static void generateTargetCC1Flags(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
CompilationType type,
const std::vector<std::string>& include_dirs) {
std::vector<std::string> cmd = { "versioner" };
@@ -207,7 +207,7 @@
return result;
}
-void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
const std::set<CompilationType>& types,
const std::unordered_map<Arch, CompilationRequirements>& reqs) {
if (!cc1_flags.empty()) {
@@ -242,7 +242,7 @@
}
}
-void compileHeader(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void compileHeader(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
HeaderDatabase* header_database, CompilationType type,
const std::string& filename) {
auto diags = constructDiags();
diff --git a/tools/versioner/src/Driver.h b/tools/versioner/src/Driver.h
index 48683e4..99e57ae 100644
--- a/tools/versioner/src/Driver.h
+++ b/tools/versioner/src/Driver.h
@@ -31,10 +31,10 @@
std::vector<std::string> dependencies;
};
-void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void initializeTargetCC1FlagCache(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
const std::set<CompilationType>& types,
const std::unordered_map<Arch, CompilationRequirements>& reqs);
-void compileHeader(llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> vfs,
+void compileHeader(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
HeaderDatabase* header_database, CompilationType type,
const std::string& filename);
diff --git a/tools/versioner/src/VFS.cpp b/tools/versioner/src/VFS.cpp
index 8f9de88..d797f82 100644
--- a/tools/versioner/src/VFS.cpp
+++ b/tools/versioner/src/VFS.cpp
@@ -25,14 +25,14 @@
#include <string>
#include <android-base/unique_fd.h>
-#include <clang/Basic/VirtualFileSystem.h>
#include <llvm/ADT/IntrusiveRefCntPtr.h>
#include <llvm/Support/MemoryBuffer.h>
+#include <llvm/Support/VirtualFileSystem.h>
#include "Utils.h"
using android::base::unique_fd;
-using namespace clang::vfs;
+using namespace llvm::vfs;
static void addDirectoryToVFS(InMemoryFileSystem* vfs, const std::string& path) {
char* paths[] = { const_cast<char*>(path.c_str()), nullptr };
diff --git a/tools/versioner/src/VFS.h b/tools/versioner/src/VFS.h
index e2ab002..e4aac75 100644
--- a/tools/versioner/src/VFS.h
+++ b/tools/versioner/src/VFS.h
@@ -20,8 +20,8 @@
#include <string>
#include <llvm/ADT/IntrusiveRefCntPtr.h>
-#include <clang/Basic/VirtualFileSystem.h>
+#include <llvm/Support/VirtualFileSystem.h>
-llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> createCommonVFS(const std::string& header_dir,
- const std::string& dependency_dir,
- bool add_versioning_header);
+llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> createCommonVFS(const std::string& header_dir,
+ const std::string& dependency_dir,
+ bool add_versioning_header);