Merge "versioner: compile with clang -include foo.h -
."
This commit is contained in:
commit
b1bbf2bb24
3 changed files with 29 additions and 1 deletions
|
@ -42,6 +42,11 @@
|
|||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wnullability-completeness"
|
||||
#endif
|
||||
|
||||
wint_t btowc(int);
|
||||
int fwprintf(FILE *, const wchar_t *, ...);
|
||||
int fwscanf(FILE *, const wchar_t *, ...);
|
||||
|
@ -134,6 +139,10 @@ FILE* open_wmemstream(wchar_t**, size_t*) __INTRODUCED_IN(23);
|
|||
wchar_t* wcsdup(const wchar_t*);
|
||||
size_t wcsnlen(const wchar_t*, size_t);
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _WCHAR_H_ */
|
||||
|
|
|
@ -100,11 +100,12 @@ static void generateTargetCC1Flags(llvm::IntrusiveRefCntPtr<clang::vfs::FileSyst
|
|||
std::vector<std::string> cmd = { "versioner" };
|
||||
cmd.push_back("-std=c11");
|
||||
cmd.push_back("-x");
|
||||
cmd.push_back("c-header");
|
||||
cmd.push_back("c");
|
||||
cmd.push_back("-fsyntax-only");
|
||||
|
||||
cmd.push_back("-Wall");
|
||||
cmd.push_back("-Wextra");
|
||||
cmd.push_back("-Weverything");
|
||||
cmd.push_back("-Werror");
|
||||
cmd.push_back("-Wundef");
|
||||
cmd.push_back("-Wno-unused-macros");
|
||||
|
@ -134,7 +135,9 @@ static void generateTargetCC1Flags(llvm::IntrusiveRefCntPtr<clang::vfs::FileSyst
|
|||
cmd.push_back(dir);
|
||||
}
|
||||
|
||||
cmd.push_back("-include");
|
||||
cmd.push_back(filename_placeholder);
|
||||
cmd.push_back("-");
|
||||
|
||||
auto diags = constructDiags();
|
||||
driver::Driver driver("versioner", llvm::sys::getDefaultTargetTriple(), *diags, vfs);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
@ -190,6 +191,21 @@ static std::unique_ptr<HeaderDatabase> compileHeaders(const std::set<Compilation
|
|||
}
|
||||
}
|
||||
|
||||
// Dup an empty file to stdin, so that we can use `clang -include a.h -` instead of `clang a.h`,
|
||||
// since some warnings don't get generated in files that are compiled directly.
|
||||
FILE* empty_file = tmpfile();
|
||||
if (!empty_file) {
|
||||
err(1, "failed to create temporary file");
|
||||
}
|
||||
|
||||
int empty_file_fd = fileno(empty_file);
|
||||
if (empty_file_fd == -1) {
|
||||
errx(1, "fileno failed on tmpfile");
|
||||
}
|
||||
|
||||
dup2(empty_file_fd, STDIN_FILENO);
|
||||
fclose(empty_file);
|
||||
|
||||
thread_count = std::min(thread_count, jobs.size());
|
||||
|
||||
if (thread_count == 1) {
|
||||
|
|
Loading…
Reference in a new issue