aboutsummaryrefslogtreecommitdiff
path: root/clang/tools
diff options
context:
space:
mode:
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp5
-rw-r--r--clang/tools/clang-format/ClangFormat.cpp16
-rw-r--r--clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp6
-rw-r--r--clang/tools/clang-import-test/clang-import-test.cpp2
-rw-r--r--clang/tools/clang-installapi/ClangInstallAPI.cpp13
-rw-r--r--clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp14
-rw-r--r--clang/tools/clang-repl/CMakeLists.txt15
-rw-r--r--clang/tools/diagtool/ShowEnabledWarnings.cpp4
-rw-r--r--clang/tools/diagtool/TreeView.cpp2
-rw-r--r--clang/tools/driver/cc1_main.cpp2
-rw-r--r--clang/tools/driver/cc1as_main.cpp3
-rw-r--r--clang/tools/driver/cc1gen_reproducer_main.cpp4
-rw-r--r--clang/tools/driver/driver.cpp4
-rw-r--r--clang/tools/libclang/CIndexCodeCompletion.cpp6
14 files changed, 49 insertions, 47 deletions
diff --git a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
index 0b621b8..ddb2944 100644
--- a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -134,10 +134,9 @@ GetDiagnosticsEngine(DiagnosticOptions &DiagOpts) {
TextDiagnosticPrinter *DiagClient =
new TextDiagnosticPrinter(llvm::errs(), DiagOpts);
DiagClient->setPrefix("clang-extdef-mappping");
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> DiagEngine(
- new DiagnosticsEngine(DiagID, DiagOpts, DiagClient));
+ auto DiagEngine = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(
+ DiagnosticIDs::create(), DiagOpts, DiagClient);
Diags.swap(DiagEngine);
// Retain this one time so it's not destroyed by ASTUnit::LoadFromASTFile
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp
index 24ad3cb..5f6502f 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -237,12 +237,11 @@ static bool parseLineRange(StringRef Input, unsigned &FromLine,
static bool fillRanges(MemoryBuffer *Code,
std::vector<tooling::Range> &Ranges) {
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), DiagOpts);
+ DiagnosticsEngine Diagnostics(DiagnosticIDs::create(), DiagOpts);
SourceManager Sources(Diagnostics, Files);
const auto ID = createInMemoryFile("<irrelevant>", *Code, Sources, Files,
InMemoryFileSystem.get());
@@ -511,15 +510,14 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
if (OutputXML) {
outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
} else {
- IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto InMemoryFileSystem =
+ makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticOptions DiagOpts;
ClangFormatDiagConsumer IgnoreDiagnostics;
- DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), DiagOpts,
- &IgnoreDiagnostics, false);
+ DiagnosticsEngine Diagnostics(DiagnosticIDs::create(), DiagOpts,
+ &IgnoreDiagnostics, false);
SourceManager Sources(Diagnostics, Files);
FileID ID = createInMemoryFile(AssumedFileName, *Code, Sources, Files,
InMemoryFileSystem.get());
diff --git a/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp b/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
index 98925c0..8259361 100644
--- a/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
+++ b/clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
@@ -33,9 +33,8 @@ void clang_fuzzer::HandleCXX(const std::string &S,
new FileManager(FileSystemOptions()));
IgnoringDiagConsumer Diags;
DiagnosticOptions DiagOpts;
- DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<clang::DiagnosticIDs>(new DiagnosticIDs()), DiagOpts,
- &Diags, false);
+ DiagnosticsEngine Diagnostics(DiagnosticIDs::create(), DiagOpts, &Diags,
+ false);
std::unique_ptr<clang::CompilerInvocation> Invocation(
tooling::newInvocation(&Diagnostics, CC1Args, /*BinaryName=*/nullptr));
std::unique_ptr<llvm::MemoryBuffer> Input =
@@ -49,4 +48,3 @@ void clang_fuzzer::HandleCXX(const std::string &S,
action->runInvocation(std::move(Invocation), Files.get(), PCHContainerOps,
&Diags);
}
-
diff --git a/clang/tools/clang-import-test/clang-import-test.cpp b/clang/tools/clang-import-test/clang-import-test.cpp
index 7f5df92..ab021a5 100644
--- a/clang/tools/clang-import-test/clang-import-test.cpp
+++ b/clang/tools/clang-import-test/clang-import-test.cpp
@@ -236,7 +236,7 @@ std::unique_ptr<CodeGenerator> BuildCodeGen(CompilerInstance &CI,
llvm::LLVMContext &LLVMCtx) {
StringRef ModuleName("$__module");
return std::unique_ptr<CodeGenerator>(CreateLLVMCodeGen(
- CI.getDiagnostics(), ModuleName, &CI.getVirtualFileSystem(),
+ CI.getDiagnostics(), ModuleName, CI.getVirtualFileSystemPtr(),
CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
LLVMCtx));
}
diff --git a/clang/tools/clang-installapi/ClangInstallAPI.cpp b/clang/tools/clang-installapi/ClangInstallAPI.cpp
index 60e9fc4..70091fc 100644
--- a/clang/tools/clang-installapi/ClangInstallAPI.cpp
+++ b/clang/tools/clang-installapi/ClangInstallAPI.cpp
@@ -77,16 +77,17 @@ static bool run(ArrayRef<const char *> Args, const char *ProgName) {
ArrayRef(Args).slice(1), MissingArgIndex, MissingArgCount);
ParseDiagnosticArgs(DiagOpts, ParsedArgs);
- IntrusiveRefCntPtr<DiagnosticsEngine> Diag = new clang::DiagnosticsEngine(
- new clang::DiagnosticIDs(), DiagOpts,
+ auto Diag = llvm::makeIntrusiveRefCnt<clang::DiagnosticsEngine>(
+ clang::DiagnosticIDs::create(), DiagOpts,
new clang::TextDiagnosticPrinter(llvm::errs(), DiagOpts));
// Create file manager for all file operations and holding in-memory generated
// inputs.
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
- new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
- new llvm::vfs::InMemoryFileSystem);
+ auto OverlayFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
+ llvm::vfs::getRealFileSystem());
+ auto InMemoryFileSystem =
+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
IntrusiveRefCntPtr<clang::FileManager> FM(
new FileManager(clang::FileSystemOptions(), OverlayFileSystem));
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 9d34b62..1d91f5f2 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -474,10 +474,10 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
StringRef Arch = Args.getLastArgValue(OPT_arch_EQ);
// Create a new file to write the linked device image to. Assume that the
// input filename already has the device and architecture.
- auto TempFileOrErr =
- createOutputFile(sys::path::filename(ExecutableName) + "." +
- Triple.getArchName() + "." + Arch,
- "img");
+ std::string OutputFileBase =
+ "." + Triple.getArchName().str() + "." + Arch.str();
+ auto TempFileOrErr = createOutputFile(
+ sys::path::filename(ExecutableName) + OutputFileBase, "img");
if (!TempFileOrErr)
return TempFileOrErr.takeError();
@@ -486,6 +486,12 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
"--no-default-config",
"-o",
*TempFileOrErr,
+ // Without -dumpdir, Clang will place auxiliary output files in the
+ // temporary directory of TempFileOrErr, where they will not easily be
+ // found by the user and might eventually be automatically removed. Tell
+ // Clang to instead place them alongside the final executable.
+ "-dumpdir",
+ Args.MakeArgString(ExecutableName + OutputFileBase + ".img."),
Args.MakeArgString("--target=" + Triple.getTriple()),
};
diff --git a/clang/tools/clang-repl/CMakeLists.txt b/clang/tools/clang-repl/CMakeLists.txt
index 68d86dd..c3d14ce 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -19,14 +19,14 @@ if(MSVC)
set_target_properties(clang-repl PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
# RTTI/C++ symbols
- set(clang_repl_exports ${clang_repl_exports} ??_7type_info@@6B@
- ?__type_info_root_node@@3U__type_info_node@@A
- ?nothrow@std@@3Unothrow_t@1@B
+ set(clang_repl_exports ${clang_repl_exports} ??_7type_info@@6B@,DATA
+ ?__type_info_root_node@@3U__type_info_node@@A,DATA
+ ?nothrow@std@@3Unothrow_t@1@B,DATA
)
# Compiler added symbols for static variables. NOT for VStudio < 2015
- set(clang_repl_exports ${clang_repl_exports} _Init_thread_abort _Init_thread_epoch
- _Init_thread_footer _Init_thread_header _tls_index
+ set(clang_repl_exports ${clang_repl_exports} _Init_thread_abort _Init_thread_epoch,DATA
+ _Init_thread_footer _Init_thread_header _tls_index,DATA
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -50,7 +50,10 @@ if(MSVC)
endif()
# List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...'
- list(TRANSFORM clang_repl_exports PREPEND "LINKER:/EXPORT:")
+ # The 'SHELL' prefix tells CMake to use a space instead of comma as the
+ # separator between the driver and linker options, which we need since MSVC's
+ # linker uses `,DATA` as a suffix to indicate that data is being exported.
+ list(TRANSFORM clang_repl_exports PREPEND "LINKER:SHELL:/EXPORT:")
set_property(TARGET clang-repl APPEND PROPERTY LINK_OPTIONS ${clang_repl_exports})
diff --git a/clang/tools/diagtool/ShowEnabledWarnings.cpp b/clang/tools/diagtool/ShowEnabledWarnings.cpp
index 0d1455d..bea0288 100644
--- a/clang/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/clang/tools/diagtool/ShowEnabledWarnings.cpp
@@ -55,7 +55,6 @@ static char getCharForLevel(DiagnosticsEngine::Level Level) {
static IntrusiveRefCntPtr<DiagnosticsEngine>
createDiagnostics(unsigned int argc, char **argv) {
- IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(new DiagnosticIDs());
DiagnosticOptions DiagOpts;
// Buffer diagnostics from argument parsing so that we can output them using a
@@ -67,7 +66,8 @@ createDiagnostics(unsigned int argc, char **argv) {
Args.push_back("diagtool");
Args.append(argv, argv + argc);
CreateInvocationOptions CIOpts;
- CIOpts.Diags = new DiagnosticsEngine(DiagIDs, DiagOpts, DiagsBuffer);
+ CIOpts.Diags = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(
+ DiagnosticIDs::create(), DiagOpts, DiagsBuffer);
std::unique_ptr<CompilerInvocation> Invocation =
createInvocation(Args, CIOpts);
if (!Invocation)
diff --git a/clang/tools/diagtool/TreeView.cpp b/clang/tools/diagtool/TreeView.cpp
index 7e47c74..13b8015 100644
--- a/clang/tools/diagtool/TreeView.cpp
+++ b/clang/tools/diagtool/TreeView.cpp
@@ -32,7 +32,7 @@ public:
static bool isIgnored(unsigned DiagID) {
// FIXME: This feels like a hack.
static DiagnosticOptions DiagOpts;
- static clang::DiagnosticsEngine Diags(new DiagnosticIDs, DiagOpts);
+ static clang::DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts);
return Diags.isIgnored(DiagID, SourceLocation());
}
diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 9b1e390..854ab3e 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -217,7 +217,7 @@ static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
ensureSufficientStack();
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+ IntrusiveRefCntPtr<DiagnosticIDs> DiagID = DiagnosticIDs::create();
// Register the support for object-file-wrapped Clang modules.
auto PCHOps = std::make_shared<PCHContainerOperations>();
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index f938e7e..e9243ca 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -662,8 +662,7 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
TextDiagnosticPrinter *DiagClient =
new TextDiagnosticPrinter(errs(), DiagOpts);
DiagClient->setPrefix("clang -cc1as");
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- DiagnosticsEngine Diags(DiagID, DiagOpts, DiagClient);
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts, DiagClient);
// Set an error handler, so that any LLVM backend diagnostics go through our
// error handler.
diff --git a/clang/tools/driver/cc1gen_reproducer_main.cpp b/clang/tools/driver/cc1gen_reproducer_main.cpp
index 8d7171e..ddff0d0 100644
--- a/clang/tools/driver/cc1gen_reproducer_main.cpp
+++ b/clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -119,8 +119,8 @@ generateReproducerForInvocationArguments(ArrayRef<const char *> Argv,
DiagnosticOptions DiagOpts;
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- DiagnosticsEngine Diags(DiagID, DiagOpts, new IgnoringDiagConsumer());
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
+ new IgnoringDiagConsumer());
auto VFS = llvm::vfs::getRealFileSystem();
ProcessWarningOptions(Diags, DiagOpts, *VFS, /*ReportDiags=*/false);
Driver TheDriver(ToolContext.Path, llvm::sys::getDefaultTargetTriple(), Diags,
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 9ed8d4e..e5c3c4e 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -331,9 +331,7 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
new TextDiagnosticPrinter(llvm::errs(), *DiagOpts);
FixupDiagPrefixExeName(DiagClient, ProgName);
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
-
- DiagnosticsEngine Diags(DiagID, *DiagOpts, DiagClient);
+ DiagnosticsEngine Diags(DiagnosticIDs::create(), *DiagOpts, DiagClient);
if (!DiagOpts->DiagnosticSerializationFile.empty()) {
auto SerializedConsumer =
diff --git a/clang/tools/libclang/CIndexCodeCompletion.cpp b/clang/tools/libclang/CIndexCodeCompletion.cpp
index 8f6729b..adac7c3 100644
--- a/clang/tools/libclang/CIndexCodeCompletion.cpp
+++ b/clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -357,8 +357,8 @@ static std::atomic<unsigned> CodeCompletionResultObjects;
AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults(
IntrusiveRefCntPtr<FileManager> FileMgr)
: CXCodeCompleteResults(),
- Diag(new DiagnosticsEngine(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), DiagOpts)),
+ Diag(llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagnosticIDs::create(),
+ DiagOpts)),
FileMgr(std::move(FileMgr)),
SourceMgr(new SourceManager(*Diag, *this->FileMgr)),
CodeCompletionAllocator(
@@ -763,7 +763,7 @@ clang_codeCompleteAt_Impl(CXTranslationUnit TU, const char *complete_filename,
RemappedFiles, (options & CXCodeComplete_IncludeMacros),
(options & CXCodeComplete_IncludeCodePatterns),
IncludeBriefComments, Capture,
- CXXIdx->getPCHContainerOperations(), *Results->Diag,
+ CXXIdx->getPCHContainerOperations(), Results->Diag,
Results->LangOpts, *Results->SourceMgr, *Results->FileMgr,
Results->Diagnostics, Results->TemporaryBuffers,
/*SyntaxOnlyAction=*/nullptr);