aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/driver/cc1_main.cpp
AgeCommit message (Collapse)AuthorFilesLines
44 hoursNFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (#151545)James Y Knight1-1/+1
Handles clang::DiagnosticsEngine and clang::DiagnosticIDs. For DiagnosticIDs, this mostly migrates from `new DiagnosticIDs` to convenience method `DiagnosticIDs::create()`. Part of cleanup https://github.com/llvm/llvm-project/issues/151026
11 days[clang][timers][stats] Add a flag to enable timers in the stats file (#149946)Alan Zhao1-1/+1
As reported in #138173, enabling `-ftime-report` adds pass timing info to the stats file if `-stats-file` is specified. This was determined to be WAI. However, if one intentionally wants to put timer information in the stats file, using `-ftime-report` may lead to a lot of logspam (that can't be removed by directing stderr to `/dev/null` as that would also redirect compiler errors). To address this, this PR adds a flag `-stats-file-timers` that adds timer data to the stats file without outputting to stderr.
2025-05-22Reapply "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Jan Svoboda1-2/+2
(#139584)" This reverts commit e2a885537f11f8d9ced1c80c2c90069ab5adeb1d. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
2025-05-22Revert "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Kazu Hirata1-2/+2
(#139584)" This reverts commit 9e306ad4600c4d3392c194a8be88919ee758425c. Multiple builtbot failures have been reported: https://github.com/llvm/llvm-project/pull/139584
2025-05-22[clang] Remove intrusive reference count from `DiagnosticOptions` (#139584)Jan Svoboda1-2/+2
The `DiagnosticOptions` class is currently intrusively reference-counted, which makes reasoning about its lifetime very difficult in some cases. For example, `CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning `DiagnosticOptions &`. One would think this gives `CompilerInvocation` exclusive ownership of the object, but that's not the case: ```c++ void shareOwnership(CompilerInvocation &CI) { llvm::IntrusiveRefCntPtr<DiagnosticOptions> CoOwner = &CI.getDiagnosticOptions(); // ... } ``` This is a perfectly valid pattern that is being actually used in the codebase. I would like to ensure the ownership of `DiagnosticOptions` by `CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a copy-on-write optimization later on. This PR changes usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be intrusively reference-counted.
2025-05-01[clang][frontend] Require invocation to construct `CompilerInstance` (#137668)Jan Svoboda1-4/+7
This PR makes it so that `CompilerInvocation` needs to be provided to `CompilerInstance` on construction. There are a couple of benefits in my view: * Making it impossible to mis-use some `CompilerInstance` APIs. For example there are cases, where `createDiagnostics()` was called before `setInvocation()`, causing the `DiagnosticEngine` to use the default-constructed `DiagnosticOptions` instead of the intended ones. * This shrinks `CompilerInstance`'s state space. * This makes it possible to access **the** invocation in `CompilerInstance`'s constructor (to be used in a follow-up).
2025-04-30[clang] Make `-ftime-report` and `-ftime-report-json` honor ↵Alan Zhao1-4/+5
`-info-output-file` (#138035) This way, the output of `-ftime-report` and `-ftime-report-json` can be redirected to a specific file rather than just stderr.
2025-04-30[clang] Implement JSON formatted -ftime-report (#137737)Alan Zhao1-1/+7
This patch adds a new flag, -ftime-report-json, which outputs the same information as -ftime-report but as JSON instead of -ftime-report's pretty printed format.
2025-03-12[TargetRegistry] Accept Triple in createTargetMachine() (NFC) (#130940)Nikita Popov1-6/+10
This avoids doing a Triple -> std::string -> Triple round trip in lots of places, now that the Module stores a Triple.
2025-01-12-ftime-report: Move FrontendTimer closer to TimeTraceScopeFangrui Song1-0/+4
... to improve consistency and make "Clang time report" cover `FrontendAction::BeginSourceFile` and `FrontendAction::EndSourceFile`.
2024-11-21Reapply "[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)"Kadir Cetinkaya1-1/+2
This reverts commit a1153cd6fedd4c906a9840987934ca4712e34cb2 with fixes to lldb breakages. Fixes https://github.com/llvm/llvm-project/issues/117145.
2024-11-21Revert "[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)"Sylvestre Ledru1-2/+1
Reverted for causing: https://github.com/llvm/llvm-project/issues/117145 This reverts commit bdd10d9d249bd1c2a45e3de56a5accd97e953458.
2024-11-21[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)kadir çetinkaya1-1/+2
Starting with 41e3919ded78d8870f7c95e9181c7f7e29aa3cc4 DiagnosticsEngine creation might perform IO. It was implicitly defaulting to getRealFileSystem. This patch makes it explicit by pushing the decision making to callers. It uses ambient VFS if one is available, and keeps using `getRealFileSystem` if there aren't any VFS.
2024-07-23[clang] Split ObjectFilePCHContainerReader from ObjectFilePCHContainerWriter ↵Chuanqi Xu1-1/+2
(#99599) Close https://github.com/llvm/llvm-project/issues/99479 See https://github.com/llvm/llvm-project/issues/99479 for details
2024-07-21Reapply "Add source file name for template instantiations in -ftime-trace" ↵Utkarsh Saxena1-1/+2
(#99757) Reverts https://github.com/llvm/llvm-project/pull/99731 Remove accidentally added temporary file. Also, fix the uninitialized read of line number.
2024-07-19Revert "Reapply "Add source file name for template instantiations in ↵Jorge Gorbe Moya1-2/+1
-ftime-trace"" (#99731) Reverts llvm/llvm-project#99545 There were a couple of issues reported in the PR: a sanitizer warning (https://lab.llvm.org/buildbot/#/builders/164/builds/1246/steps/14/logs/stdio) and a tmp file accidentally included in the commit.
2024-07-19Reapply "Add source file name for template instantiations in -ftime-trace" ↵Utkarsh Saxena1-1/+2
(#99545) Fix the Windows test.
2024-07-18Revert "Add source file name for template instantiations in -ftime-trace" ↵Utkarsh Saxena1-2/+1
(#99534) Reverts llvm/llvm-project#98320 Breaks windows tests: ``` Step 8 (test-build-unified-tree-check-clang-unit) failure: test (failure) ******************** TEST 'Clang-Unit :: Support/./ClangSupportTests.exe/1/3' FAILED ******************** Script(shard): -- GTEST_OUTPUT=json:C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\tools\clang\unittests\Support\.\ClangSupportTests.exe-Clang-Unit-4296-1-3.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=3 GTEST_SHARD_INDEX=1 C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\tools\clang\unittests\Support\.\ClangSupportTests.exe -- Script: -- C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\tools\clang\unittests\Support\.\ClangSupportTests.exe --gtest_filter=TimeProfilerTest.TemplateInstantiations -- C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Support\TimeProfilerTest.cpp(278): error: Expected equality of these values: R"( Frontend | ParseFunctionDefinition (fooB) | ParseFunctionDefinition (fooMTA) | ParseFunctionDefinition (fooA) | ParseDeclarationOrFunctionDefinition (test.cc:3:5) | | ParseFunctionDefinition (user) | PerformPendingInstantiations | | InstantiateFunction (fooA<int>, ./a.h:7) | | | InstantiateFunction (fooB<int>, ./b.h:3) | | | InstantiateFunction (fooMTA<int>, ./a.h:4) )" Which is: "\nFrontend\n| ParseFunctionDefinition (fooB)\n| ParseFunctionDefinition (fooMTA)\n| ParseFunctionDefinition (fooA)\n| ParseDeclarationOrFunctionDefinition (test.cc:3:5)\n| | ParseFunctionDefinition (user)\n| PerformPendingInstantiations\n| | InstantiateFunction (fooA<int>, ./a.h:7)\n| | | InstantiateFunction (fooB<int>, ./b.h:3)\n| | | InstantiateFunction (fooMTA<int>, ./a.h:4)\n" buildTraceGraph(Json) Which is: "\nFrontend\n| ParseFunctionDefinition (fooB)\n| ParseFunctionDefinition (fooMTA)\n| ParseFunctionDefinition (fooA)\n| ParseDeclarationOrFunctionDefinition (test.cc:3:5)\n| | ParseFunctionDefinition (user)\n| PerformPendingInstantiations\n| | InstantiateFunction (fooA<int>, .\\a.h:7)\n| | | InstantiateFunction (fooB<int>, .\\b.h:3)\n| | | InstantiateFunction (fooMTA<int>, .\\a.h:4)\n" With diff: @@ -7,5 +7,5 @@ | | ParseFunctionDefinition (user) | PerformPendingInstantiations -| | InstantiateFunction (fooA<int>, ./a.h:7) -| | | InstantiateFunction (fooB<int>, ./b.h:3) -| | | InstantiateFunction (fooMTA<int>, ./a.h:4)\n +| | InstantiateFunction (fooA<int>, .\\a.h:7) +| | | InstantiateFunction (fooB<int>, .\\b.h:3) +| | | InstantiateFunction (fooMTA<int>, .\\a.h:4)\n C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Support\TimeProfilerTest.cpp:278 Expected equality of these values: R"( Frontend | ParseFunctionDefinition (fooB) | ParseFunctionDefinition (fooMTA) | ParseFunctionDefinition (fooA) | ParseDeclarationOrFunctionDefinition (test.cc:3:5) | | ParseFunctionDefinition (user) | PerformPendingInstantiations | | InstantiateFunction (fooA<int>, ./a.h:7) ```
2024-07-18Add source file name for template instantiations in -ftime-trace (#98320)Utkarsh Saxena1-1/+2
This is helpful in identifying file and location which contain the particular template declaration.
2024-07-10[RISCV] Add ability to list extensions enabled for a target (#98207)Michael Maitland1-3/+10
bb83a3d introduced `--print-enabled-extensions` command line option for AArch64. This patch introduces RISC-V support for this option. This patch adds documentation for this option. `riscvExtensionsHelp` is renamed to `printSupportedExtensions` to by synonymous with AArch64 and so it is clear what that function does.
2024-06-28Re-land: "[AArch64] Add ability to list extensions enabled for a target" ↵Lucas Duarte Prates1-1/+45
(#95805) (#96795) This introduces the new `--print-enabled-extensions` command line option to AArch64, which prints the list of extensions that are enabled for the target specified by the combination of `--target`/`-march`/`-mcpu` values. The goal of the this option is both to enable the manual inspection of the enabled extensions by users and to enhance the testability of architecture versions and CPU targets implemented in the compiler. As part of this change, a new field for `FEAT_*` architecture feature names was added to the TableGen entries. The output of the existing `--print-supported-extensions` option was updated accordingly to show these in a separate column.
2024-06-26Revert "[AArch64] Add ability to list extensions enabled for a target" (#96768)Lucas Duarte Prates1-45/+1
Reverts llvm/llvm-project#95805 due to test failures caught by the buildbots.
2024-06-26[AArch64] Add ability to list extensions enabled for a target (#95805)Lucas Duarte Prates1-1/+45
This introduces the new `--print-enabled-extensions` command line option to AArch64, which prints the list of extensions that are enabled for the target specified by the combination of `--target`/`-march`/`-mcpu` values. The goal of the this option is both to enable the manual inspection of the enabled extensions by users and to enhance the testability of architecture versions and CPU targets implemented in the compiler. As part of this change, a new field for `FEAT_*` architecture feature names was added to the TableGen entries. The output of the existing `--print-supported-extensions` option was updated accordingly to show these in a separate column.
2024-04-23[RISCV] Split code that tablegen needs out of RISCVISAInfo. (#89684)Craig Topper1-1/+1
This introduces a new file, RISCVISAUtils.cpp and moves the rest of RISCVISAInfo to the TargetParser library. This will allow us to generate part of RISCVISAInfo.cpp using tablegen.
2024-02-12[clang] Remove old Linux kernel workaround for ensuring stack space (#81533)Arthur Eubanks1-62/+0
PR #71709 broke the Linux PIE build with `undefined symbol: alloca` errors. With the newly included `clang/Basic/Builtins.h` in that PR, it surfaces an issue with a combination of two previous patches. 26670dcba1609574cba5942aff78ff97b567c5f3 added `#undef alloca` so clang builtins handling of alloca would work under MSVC (unsure if this is still necessary). 194b6a3b1b1a99cc3c12c466a04320f271ebd8aa added code that calls `alloca` to workaround a Linux kernel < 4.1 bug. Given that Linux 4.1 was EOL in 2018, it should be ok to remove this workaround.
2023-09-22[clang] Enable descriptions for --print-supported-extensions (#66715)Balint Cristian1-3/+11
Enables summary descriptions along with the names of the feature. Descriptions here are simply looked up via the available llvm tablegen data.
2023-09-13[clang][ARM] Enable --print-supported-extensions for ARM (#66083)David Spickett1-0/+3
``` $ ./bin/clang --target=arm-linux-gnueabihf --print-supported-extensions <...> All available -march extensions for ARM crc crypto sha2 aes dotprod <...> ``` This follows the format set by RISC-V and AArch64. As for AArch64, ARM doesn't have versioned extensions like RISC-V does. So there is only 1 column, which contains the name. Any extension without a "feature" is hidden as these cannot be used with -march.
2023-09-11[clang][AArch64] Add --print-supported-extensions support (#65466)David Spickett1-1/+30
This follows the RISC-V work done in 4b40ced4e5ba10b841516b3970e7699ba8ded572. This uses AArch64's target parser instead. We just list the names, without the "+" on them, which matches RISC-V's format. ``` $ ./bin/clang -target aarch64-linux-gnu --print-supported-extensions clang version 18.0.0 (https://github.com/llvm/llvm-project.git 154da8aec20719c82235a6957aa6e461f5a5e030) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: <...> All available -march extensions for AArch64 aes b16b16 bf16 brbe crc crypto cssc <...> ``` Since our extensions don't have versions in the same way there's just one column with the name in. Any extension without a feature name (including the special "none") is not listed as those cannot be passed to -march, they're just for the backend. For example the MTE extension can be added with "+memtag" but MTE2 and MTE3 do not have feature names so they cannot be added to -march. This does not attempt to tackle the fact that clang allows invalid combinations of AArch64 extensions, it simply lists the possible options. It's still up to the user to ask for something sensible. Equally, this has no context of what CPU is being selected. Neither does the RISC-V option, the user has to be aware of that. I've added a target parser test, and a high level clang test that checks RISC-V and AArch64 work and that Intel, that doesn't support this, shows the correct error.
2023-08-31[RISCV] Add --print-supported-extensions support4vtomat1-0/+5
This revision supports --print-supported-extensions, it prints out all of the extensions and corresponding version supported. Reviewed By: craig.topper, kito-cheng Differential Revision: https://reviews.llvm.org/D146054
2023-05-12[Driver] -ftime-trace: derive trace file names from -o and -dumpdirFangrui Song1-14/+3
Inspired by D133662. Close https://github.com/llvm/llvm-project/issues/57285 When -ftime-trace is specified and the driver performs both compilation and linking phases, the trace files are currently placed in the temporary directory (/tmp by default on *NIX). A more sensible behavior would be to derive the trace file names from the -o option, similar to how GCC derives auxiliary and dump file names. Use -dumpdir (D149193) to implement the -gsplit-dwarf like behavior. The following script demonstrates the time trace filenames. ``` #!/bin/sh -e PATH=/tmp/Rel/bin:$PATH # adapt according to your build directory mkdir -p d e f echo 'int main() {}' > d/a.c echo > d/b.c a() { rm $1 || exit 1; } clang -ftime-trace d/a.c d/b.c # previously /tmp/[ab]-*.json a a-a.json; a a-b.json clang -ftime-trace d/a.c d/b.c -o e/x # previously /tmp/[ab]-*.json a e/x-a.json; a e/x-b.json clang -ftime-trace d/a.c d/b.c -o e/x -dumpdir f/ a f/a.json; a f/b.json clang -ftime-trace=f d/a.c d/b.c -o e/x a f/a-*.json; a f/b-*.json clang -c -ftime-trace d/a.c d/b.c a a.json b.json clang -c -ftime-trace=f d/a.c d/b.c a f/a.json f/b.json clang -c -ftime-trace d/a.c -o e/xa.o a e/xa.json clang -c -ftime-trace d/a.c -o e/xa.o -dumpdir f/g a f/ga.json ``` The driver checks `-ftime-trace` and `-ftime-trace=`, infers the trace file name, and passes `-ftime-trace=` to cc1. The `-ftime-trace` cc1 option is removed. With offloading, previously `-ftime-trace` is passed to all offloading actions, causing the same trace file to be overwritten by host and offloading actions. This patch doesn't attempt to support offloading (D133662), but makes a sensible change (`OffloadingPrefix.empty()`) to ensure we don't overwrite the trace file. Minor behavior differences: the trace file is now a result file, which will be removed upon an error. -ftime-trace-granularity=0, like -ftime-trace, can now cause a -Wunused-command-line-argument warning. Reviewed By: Maetveis Differential Revision: https://reviews.llvm.org/D150282
2023-02-06[Modules] Recreate file manager for ftime-trace when compiling a moduleChuanqi Xu1-0/+13
Close https://github.com/llvm/llvm-project/issues/60544. The root cause for the issue is that when we compile a module unit, the file manager (and proprocessor and source manager) are owned by AST instead of the compilaton instance. So the file manager may be invalid when we want to create a time-report file for -ftime-trace when we are compiling a module unit. This patch tries to recreate the file manager for -ftime-trace if we find the file manager is not valid.
2022-12-03[clang] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+2
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-09-03Revert "[Clang] change default storing path of `-ftime-trace`"Junduo Dong1-3/+10
This reverts commit 38941da066a7b785ba4771710189172e94e37824.
2022-09-02[Clang] change default storing path of `-ftime-trace`Junduo Dong1-10/+3
1. This implementation change the default storing behavior of -ftime-trace only. That is, if the compiling job contains the linking action, the executable file' s directory may be seem as the main work directory. Thus the time trace files would be stored in the same directory of linking result. By this approach, the user can easily get the time-trace files in the main work directory. The improved demo results: ``` $ clang++ -ftime-trace -o main.out /demo/main.cpp $ ls . main.out main-[random-string].json ``` 2. In addition, the main codes of time-trace files' path inference have been refactored. * The <path> of -ftime-trace=<path> is infered in clang driver * After that, -ftime-trace=<path> can be added into clang's options By this approach, the dirty work of path processing and judging can be implemented in driver layer, so that the clang may focus on its main work. # $ clang -ftime-trace -o xxx.out xxx.cpp Differential Revision: https://reviews.llvm.org/D131469
2022-07-15[Clang] Add a new clang option "-ftime-trace=<value>"dongjunduo1-1/+10
The time profiler traces the stages during the clang compile process. Each compiling stage of a single source file corresponds to a separately .json file which holds its time tracing data. However, the .json files are stored in the same path/directory as its corresponding stage's '-o' option. For example, if we compile the "demo.cc" to "demo.o" with option "-o /tmp/demo.o", the time trace data file path is "/tmp/demo.json". A typical c++ project can contain multiple source files in different path, but all the json files' paths can be a mess. The option "-ftime-trace=<value>" allows you to specify where the json files should be stored. This allows the users to place the time trace data files of interest in the desired location for further data analysis. Usage: - clang/clang++ -ftime-trace ... - clang/clang++ -ftime-trace=the-directory-you-want ... - clang/clang++ -ftime-trace=the-directory-you-want/ ... - clang/clang++ -ftime-trace=the-full-file-path-you-want ... Differential Revision: https://reviews.llvm.org/D128048
2022-04-28Frontend: Delete output streams before closing CompilerInstance outputsDuncan P. N. Exon Smith1-2/+1
Delete the output streams coming from CompilerInstance::createOutputFile() and friends once writes are finished. Concretely, replacing `OS->flush()` with `OS.reset()` in: - `ExtractAPIAction::EndSourceFileAction()` - `PrecompiledPreambleAction::setEmittedPreamblePCH()` - `cc1_main()'s support for `-ftime-trace` This fixes theoretical bugs related to proxy streams, which may have cleanups to run in their destructor. For example, a proxy that CompilerInstance sometimes uses is `buffer_ostream`, which wraps a `raw_ostream` lacking pwrite support and adds it. `flush()` does not promise that output is complete; `buffer_ostream` needs to wait until the destructor to forward anything so that it can service later calls to `pwrite()`. If the destructor isn't called then the proxied stream hasn't received any content. This also protects against some logic bugs, triggering a null dereference on a later attempt to write to the stream. No tests, since in practice these particular code paths never use use `buffer_ostream`; you need to be writing a binary file to a pipe (such as stdout) to hit it, but `-extract-api` writes a text file and the other two use computed filenames that will never (in practice) be a pipe. This is effectively NFC, for now. But I have some other patches in the works that add guard rails, crashing if the stream hasn't been destructed by the time the CompilerInstance is told to keep the output file, since in most cases this is a problem. Differential Revision: https://reviews.llvm.org/D124635
2022-01-26[clang] Fix serialized diagnostics edge-casesJan Svoboda1-1/+3
The Clang frontend sometimes fails on the following assertion when launched with `-serialize-diagnostic-file <x>`: ``` Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block imbalance"), function ~BitstreamWriter, file BitstreamWriter.h, line 125. ``` This was first noticed when passing an unknown command-line argument to `-cc1`. It turns out the `DiagnosticConsumer::finish()` function should be called as soon as processing of all source files ends, but there are some code paths where that doesn't happen: 1. when command line parsing fails in `cc1_main()`, 2. when `!Act.PrepareToExecute(*this)` or `!createTarget()` evaluate to `true` in `CompilerInstance::ExecuteAction` and the function returns early. This patch ensures `finish()` is called in all those code paths. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D118150
2021-11-02Revert "[NFC] Remove LinkAll*.h"Arthur Eubanks1-0/+1
This reverts commit fe364e5dc78c58a915986d9a44cfd65f919a00c2. Causes breakages, e.g. https://lab.llvm.org/buildbot/#/builders/188/builds/5266
2021-11-02[NFC] Remove LinkAll*.hArthur Eubanks1-1/+0
These were added to prevent functions from being removed by WPO. But that doesn't make sense, correct WPO will not remove functions we actually use. I noticed these because compiling cc1_main.cpp was pulling in random LLVM pass headers. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D112971
2021-10-08Move TargetRegistry.(h|cpp) from Support to MCReid Kleckner1-1/+1
This moves the registry higher in the LLVM library dependency stack. Every client of the target registry needs to link against MC anyway to actually use the target, so we might as well move this out of Support. This allows us to ensure that Support doesn't have includes from MC/*. Differential Revision: https://reviews.llvm.org/D111454
2021-10-05[Support] Change fatal_error_handler_t to take a const char* instead of ↵Simon Pilgrim1-1/+1
std::string https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html Excessive use of the <string> header has a massive impact on compile time; its most commonly included via the ErrorHandling.h header, which has to be included in many key headers, impacting many source files that have no need for std::string. As an initial step toward removing the <string> include from ErrorHandling.h, this patch proposes to update the fatal_error_handler_t handler to just take a raw const char* instead. The next step will be to remove the report_fatal_error std::string variant, which will involve a lot of cleanup and better use of Twine/StringRef. Differential Revision: https://reviews.llvm.org/D111049
2021-02-04[clang][cli] Command line round-trip for HeaderSearch optionsJan Svoboda1-0/+6
This patch implements generation of remaining header search arguments. It's done manually in C++ as opposed to TableGen, because we need the flexibility and don't anticipate reuse. This patch also tests the generation of header search options via a round-trip. This way, the code gets exercised whenever Clang is built and tested in asserts mode. All `check-clang` tests pass. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D94472
2021-01-26Frontend: Fix layering between create{,Default}OutputFile, NFCDuncan P. N. Exon Smith1-7/+3
Fix layering between `CompilerInstance::createDefaultOutputFile` and the two versions of `createOutputFile`. - Add missing configuration flags to `createDefaultOutputFile` so that GeneratePCHAction and GenerateModuleFromModuleMapAction can use it. They previously promised that temporary files were turned on; now `createDefaultOutputFile` handles that logic. - Lift the logic handling `InFile` and `Extension` to `createDefaultOutputFile`, since it's only the callers of that function that are using it. - Rename the deeper of the two `createOutputFile`s to `createOutputFileImpl` and make it private to `CompilerInstance` (to prove that no one else is using it). - Sink the logic for adding to `CompilerInstance::OutputFiles` down to `createOutputFileImpl`, allowing two "optional" (but always used) `std::string*` out parameters to be removed. - Instead of passing a `std::error_code` out parameter into `createOutputFileImpl`, have it return `Expected<>`. - As a drive-by, inline `CompilerInstance::addOutputFile` into its only caller, `createOutputFileImpl`. Clean layering makes it easier for a future commit to extract `createOutputFileImpl` out of `CompilerInstance`. Differential Revision: https://reviews.llvm.org/D93248
2020-06-18[MC] Pass down argv0 & cc1 cmd-line to the back-end and store in MCTargetOptionsAlexandre Ganea1-2/+2
When targetting CodeView, the goal is to store argv0 & cc1 cmd-line in the emitted .OBJ, in order to allow a reproducer from the .OBJ alone. This patch is to simplify https://reviews.llvm.org/D80833
2020-03-26Fix typo, targetFeature should be lowercase.Zakk Chen1-1/+1
this fixing also enable llc -mattr=+cpuhelp Reviewers: ziangwan, kongyi Reviewed By: kongyi Tags: #llvm Differential Revision: https://reviews.llvm.org/D76757
2020-02-12[Clang] When -ftime-trace is used, clean CompilerInstance::OutputFiles ↵Alexandre Ganea1-0/+1
before exiting cc_main() This fixes cc1 execution when '-disable-free' is not used (currently not the case, that flag is always used for cc1).
2020-02-11[Clang][Driver] After default -fintegrated-cc1, make ↵Alexandre Ganea1-1/+2
llvm::report_fatal_error() generate preprocessed source + reproducer.sh again. Added a test for #pragma clang __debug llvm_fatal_error to test for the original issue. Added llvm::sys::Process::Exit() and replaced ::exit() in places where it was appropriate. This new function would call the current CrashRecoveryContext if one is running on the same thread; or call ::exit() otherwise. Fixes PR44705. Differential Revision: https://reviews.llvm.org/D73742
2020-01-02Generalize the pass registration mechanism used by Polly to any third-party toolserge_sans_paille1-11/+0
There's quite a lot of references to Polly in the LLVM CMake codebase. However the registration pattern used by Polly could be useful to other external projects: thanks to that mechanism it would be possible to develop LLVM extension without touching the LLVM code base. This patch has two effects: 1. Remove all code specific to Polly in the llvm/clang codebase, replaicing it with a generic mechanism 2. Provide a generic mechanism to register compiler extensions. A compiler extension is similar to a pass plugin, with the notable difference that the compiler extension can be configured to be built dynamically (like plugins) or statically (like regular passes). As a result, people willing to add extra passes to clang/opt can do it using a separate code repo, but still have their pass be linked in clang/opt as built-in passes. Differential Revision: https://reviews.llvm.org/D61446
2019-12-11[Support] Add TimeTraceScope constructor without detail argRussell Gallop1-1/+1
This simplifies code where no extra details are required Also don't write out detail when it is empty. Differential Revision: https://reviews.llvm.org/D71347
2019-12-03[Support] Add ProcName to TimeTraceProfilerRussell Gallop1-1/+1
This was hard-coded to "clang". This change allows it to to be used on processes other than clang (such as lld). This gets reported as clang-10 on Linux and clang.exe on Windows so adapted test to accommodate this. Differential Revision: https://reviews.llvm.org/D70950