mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-20 12:05:48 -04:00
[clangd] Log cc1 args at verbose level.
Summary: This will help debugging driver issues. Reviewers: kbobyrev Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70832
This commit is contained in:
parent
66ab932fcc
commit
407ac2eb5f
@ -42,7 +42,8 @@ void IgnoreDiagnostics::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
|
|||||||
|
|
||||||
std::unique_ptr<CompilerInvocation>
|
std::unique_ptr<CompilerInvocation>
|
||||||
buildCompilerInvocation(const ParseInputs &Inputs,
|
buildCompilerInvocation(const ParseInputs &Inputs,
|
||||||
clang::DiagnosticConsumer &D) {
|
clang::DiagnosticConsumer &D,
|
||||||
|
std::vector<std::string> *CC1Args) {
|
||||||
std::vector<const char *> ArgStrs;
|
std::vector<const char *> ArgStrs;
|
||||||
for (const auto &S : Inputs.CompileCommand.CommandLine)
|
for (const auto &S : Inputs.CompileCommand.CommandLine)
|
||||||
ArgStrs.push_back(S.c_str());
|
ArgStrs.push_back(S.c_str());
|
||||||
@ -57,7 +58,7 @@ buildCompilerInvocation(const ParseInputs &Inputs,
|
|||||||
CompilerInstance::createDiagnostics(new DiagnosticOptions, &D, false);
|
CompilerInstance::createDiagnostics(new DiagnosticOptions, &D, false);
|
||||||
std::unique_ptr<CompilerInvocation> CI = createInvocationFromCommandLine(
|
std::unique_ptr<CompilerInvocation> CI = createInvocationFromCommandLine(
|
||||||
ArgStrs, CommandLineDiagsEngine, Inputs.FS,
|
ArgStrs, CommandLineDiagsEngine, Inputs.FS,
|
||||||
/*ShouldRecoverOnErrors=*/true);
|
/*ShouldRecoverOnErrors=*/true, CC1Args);
|
||||||
if (!CI)
|
if (!CI)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
// createInvocationFromCommandLine sets DisableFree.
|
// createInvocationFromCommandLine sets DisableFree.
|
||||||
|
@ -52,8 +52,8 @@ struct ParseInputs {
|
|||||||
|
|
||||||
/// Builds compiler invocation that could be used to build AST or preamble.
|
/// Builds compiler invocation that could be used to build AST or preamble.
|
||||||
std::unique_ptr<CompilerInvocation>
|
std::unique_ptr<CompilerInvocation>
|
||||||
buildCompilerInvocation(const ParseInputs &Inputs,
|
buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
|
||||||
clang::DiagnosticConsumer &D);
|
std::vector<std::string> *CC1Args = nullptr);
|
||||||
|
|
||||||
/// Creates a compiler instance, configured so that:
|
/// Creates a compiler instance, configured so that:
|
||||||
/// - Contents of the parsed file are remapped to \p MainFile.
|
/// - Contents of the parsed file are remapped to \p MainFile.
|
||||||
|
@ -407,8 +407,12 @@ void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags) {
|
|||||||
llvm::join(Inputs.CompileCommand.CommandLine, " "));
|
llvm::join(Inputs.CompileCommand.CommandLine, " "));
|
||||||
// Rebuild the preamble and the AST.
|
// Rebuild the preamble and the AST.
|
||||||
StoreDiags CompilerInvocationDiagConsumer;
|
StoreDiags CompilerInvocationDiagConsumer;
|
||||||
|
std::vector<std::string> CC1Args;
|
||||||
std::unique_ptr<CompilerInvocation> Invocation =
|
std::unique_ptr<CompilerInvocation> Invocation =
|
||||||
buildCompilerInvocation(Inputs, CompilerInvocationDiagConsumer);
|
buildCompilerInvocation(Inputs, CompilerInvocationDiagConsumer);
|
||||||
|
// Log cc1 args even (especially!) if creating invocation failed.
|
||||||
|
if (!CC1Args.empty())
|
||||||
|
vlog("cc1 args: {0}", llvm::join(CC1Args, " "));
|
||||||
std::vector<Diag> CompilerInvocationDiags =
|
std::vector<Diag> CompilerInvocationDiags =
|
||||||
CompilerInvocationDiagConsumer.take();
|
CompilerInvocationDiagConsumer.take();
|
||||||
if (!Invocation) {
|
if (!Invocation) {
|
||||||
|
@ -217,14 +217,18 @@ createChainedIncludesSource(CompilerInstance &CI,
|
|||||||
/// non-null (and possibly incorrect) CompilerInvocation if any errors were
|
/// non-null (and possibly incorrect) CompilerInvocation if any errors were
|
||||||
/// encountered. When this flag is false, always return null on errors.
|
/// encountered. When this flag is false, always return null on errors.
|
||||||
///
|
///
|
||||||
/// \return A CompilerInvocation, or 0 if none was built for the given
|
/// \param CC1Args - if non-null, will be populated with the args to cc1
|
||||||
|
/// expanded from \p Args. May be set even if nullptr is returned.
|
||||||
|
///
|
||||||
|
/// \return A CompilerInvocation, or nullptr if none was built for the given
|
||||||
/// argument vector.
|
/// argument vector.
|
||||||
std::unique_ptr<CompilerInvocation> createInvocationFromCommandLine(
|
std::unique_ptr<CompilerInvocation> createInvocationFromCommandLine(
|
||||||
ArrayRef<const char *> Args,
|
ArrayRef<const char *> Args,
|
||||||
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
|
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
|
||||||
IntrusiveRefCntPtr<DiagnosticsEngine>(),
|
IntrusiveRefCntPtr<DiagnosticsEngine>(),
|
||||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr,
|
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr,
|
||||||
bool ShouldRecoverOnErrors = false);
|
bool ShouldRecoverOnErrors = false,
|
||||||
|
std::vector<std::string> *CC1Args = nullptr);
|
||||||
|
|
||||||
/// Return the value of the last argument as an integer, or a default. If Diags
|
/// Return the value of the last argument as an integer, or a default. If Diags
|
||||||
/// is non-null, emits an error if the argument is given, but non-integral.
|
/// is non-null, emits an error if the argument is given, but non-integral.
|
||||||
|
@ -26,7 +26,8 @@ using namespace llvm::opt;
|
|||||||
|
|
||||||
std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
|
std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
|
||||||
ArrayRef<const char *> ArgList, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
|
ArrayRef<const char *> ArgList, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
|
||||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool ShouldRecoverOnErorrs) {
|
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool ShouldRecoverOnErorrs,
|
||||||
|
std::vector<std::string> *CC1Args) {
|
||||||
if (!Diags.get()) {
|
if (!Diags.get()) {
|
||||||
// No diagnostics engine was provided, so create our own diagnostics object
|
// No diagnostics engine was provided, so create our own diagnostics object
|
||||||
// with the default options.
|
// with the default options.
|
||||||
@ -89,6 +90,8 @@ std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ArgStringList &CCArgs = Cmd.getArguments();
|
const ArgStringList &CCArgs = Cmd.getArguments();
|
||||||
|
if (CC1Args)
|
||||||
|
*CC1Args = {CCArgs.begin(), CCArgs.end()};
|
||||||
auto CI = std::make_unique<CompilerInvocation>();
|
auto CI = std::make_unique<CompilerInvocation>();
|
||||||
if (!CompilerInvocation::CreateFromArgs(*CI, CCArgs, *Diags) &&
|
if (!CompilerInvocation::CreateFromArgs(*CI, CCArgs, *Diags) &&
|
||||||
!ShouldRecoverOnErorrs)
|
!ShouldRecoverOnErorrs)
|
||||||
|
Loading…
Reference in New Issue
Block a user