aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp2
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp2
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp53
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp3
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp2
-rw-r--r--clang/lib/Frontend/PrecompiledPreamble.cpp10
6 files changed, 49 insertions, 23 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index cb44568..d53b64a 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1651,6 +1651,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
AST->Reader = nullptr;
// Create a file manager object to provide access to and cache the filesystem.
+ Clang->setVirtualFileSystem(AST->getVirtualFileSystemPtr());
Clang->setFileManager(AST->getFileManagerPtr());
// Create the source manager.
@@ -2290,6 +2291,7 @@ void ASTUnit::CodeComplete(
"IR inputs not support here!");
// Use the source and file managers that we were given.
+ Clang->setVirtualFileSystem(FileMgr->getVirtualFileSystemPtr());
Clang->setFileManager(FileMgr);
Clang->setSourceManager(SourceMgr);
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 5844366..374138f 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -160,8 +160,6 @@ bool CompilerInstance::createTarget() {
}
void CompilerInstance::setFileManager(IntrusiveRefCntPtr<FileManager> Value) {
- if (!hasVirtualFileSystem())
- setVirtualFileSystem(Value->getVirtualFileSystemPtr());
assert(Value == nullptr ||
getVirtualFileSystemPtr() == Value->getVirtualFileSystemPtr());
FileMgr = std::move(Value);
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 5bd15f5..d2cb751 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1833,10 +1833,6 @@ void CompilerInvocationBase::GenerateCodeGenArgs(const CodeGenOptions &Opts,
serializeSanitizerKinds(Opts.SanitizeAnnotateDebugInfo))
GenerateArg(Consumer, OPT_fsanitize_annotate_debug_info_EQ, Sanitizer);
- if (Opts.AllocTokenMax)
- GenerateArg(Consumer, OPT_falloc_token_max_EQ,
- std::to_string(*Opts.AllocTokenMax));
-
if (!Opts.EmitVersionIdentMetadata)
GenerateArg(Consumer, OPT_Qn);
@@ -2350,15 +2346,6 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
}
}
- if (const auto *Arg = Args.getLastArg(options::OPT_falloc_token_max_EQ)) {
- StringRef S = Arg->getValue();
- uint64_t Value = 0;
- if (S.getAsInteger(0, Value))
- Diags.Report(diag::err_drv_invalid_value) << Arg->getAsString(Args) << S;
- else
- Opts.AllocTokenMax = Value;
- }
-
Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true);
if (!LangOpts->CUDAIsDevice)
@@ -3966,6 +3953,29 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
if (!Opts.RandstructSeed.empty())
GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed);
+
+ if (Opts.AllocTokenMax)
+ GenerateArg(Consumer, OPT_falloc_token_max_EQ,
+ std::to_string(*Opts.AllocTokenMax));
+
+ if (Opts.AllocTokenMode) {
+ StringRef S;
+ switch (*Opts.AllocTokenMode) {
+ case llvm::AllocTokenMode::Increment:
+ S = "increment";
+ break;
+ case llvm::AllocTokenMode::Random:
+ S = "random";
+ break;
+ case llvm::AllocTokenMode::TypeHash:
+ S = "typehash";
+ break;
+ case llvm::AllocTokenMode::TypeHashPointerSplit:
+ S = "typehashpointersplit";
+ break;
+ }
+ GenerateArg(Consumer, OPT_falloc_token_mode_EQ, S);
+ }
}
bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
@@ -4544,6 +4554,23 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
if (const Arg *A = Args.getLastArg(OPT_frandomize_layout_seed_EQ))
Opts.RandstructSeed = A->getValue(0);
+ if (const auto *Arg = Args.getLastArg(options::OPT_falloc_token_max_EQ)) {
+ StringRef S = Arg->getValue();
+ uint64_t Value = 0;
+ if (S.getAsInteger(0, Value))
+ Diags.Report(diag::err_drv_invalid_value) << Arg->getAsString(Args) << S;
+ else
+ Opts.AllocTokenMax = Value;
+ }
+
+ if (const auto *Arg = Args.getLastArg(options::OPT_falloc_token_mode_EQ)) {
+ StringRef S = Arg->getValue();
+ if (auto Mode = getAllocTokenModeFromString(S))
+ Opts.AllocTokenMode = Mode;
+ else
+ Diags.Report(diag::err_drv_invalid_value) << Arg->getAsString(Args) << S;
+ }
+
// Validate options for HLSL
if (Opts.HLSL) {
// TODO: Revisit restricting SPIR-V to logical once we've figured out how to
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 1b63c40..ed1169e 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -629,7 +629,7 @@ static std::error_code collectModuleHeaderIncludes(
// Check whether this entry has an extension typically associated with
// headers.
if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
- .Cases(".h", ".H", ".hh", ".hpp", true)
+ .Cases({".h", ".H", ".hh", ".hpp"}, true)
.Default(false))
continue;
@@ -945,6 +945,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
// Set the shared objects, these are reset when we finish processing the
// file, otherwise the CompilerInstance will happily destroy them.
+ CI.setVirtualFileSystem(AST->getVirtualFileSystemPtr());
CI.setFileManager(AST->getFileManagerPtr());
CI.setSourceManager(AST->getSourceManagerPtr());
CI.setPreprocessor(AST->getPreprocessorPtr());
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index baad6317..47f1d5a 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -585,6 +585,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__HIP_MEMORY_SCOPE_WORKGROUP", "3");
Builder.defineMacro("__HIP_MEMORY_SCOPE_AGENT", "4");
Builder.defineMacro("__HIP_MEMORY_SCOPE_SYSTEM", "5");
+ Builder.defineMacro("__HIP_MEMORY_SCOPE_CLUSTER", "6");
if (LangOpts.HIPStdPar) {
Builder.defineMacro("__HIPSTDPAR__");
if (LangOpts.HIPStdParInterposeAlloc) {
@@ -873,6 +874,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__MEMORY_SCOPE_WRKGRP", "2");
Builder.defineMacro("__MEMORY_SCOPE_WVFRNT", "3");
Builder.defineMacro("__MEMORY_SCOPE_SINGLE", "4");
+ Builder.defineMacro("__MEMORY_SCOPE_CLUSTR", "5");
// Define macros for the OpenCL memory scope.
// The values should match AtomicScopeOpenCLModel::ID enum.
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp
index 03f70b7..9bf18b4 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -479,16 +479,12 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
Diagnostics->Reset();
ProcessWarningOptions(*Diagnostics, Clang->getDiagnosticOpts(), *VFS);
- VFS = createVFSFromCompilerInvocation(Clang->getInvocation(), *Diagnostics,
- VFS);
-
// Create a file manager object to provide access to and cache the filesystem.
- Clang->setFileManager(
- llvm::makeIntrusiveRefCnt<FileManager>(Clang->getFileSystemOpts(), VFS));
+ Clang->createVirtualFileSystem(VFS);
+ Clang->createFileManager();
// Create the source manager.
- Clang->setSourceManager(llvm::makeIntrusiveRefCnt<SourceManager>(
- *Diagnostics, Clang->getFileManager()));
+ Clang->createSourceManager();
auto PreambleDepCollector = std::make_shared<PreambleDependencyCollector>();
Clang->addDependencyCollector(PreambleDepCollector);