aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-10-18[clang] Disable -clear-ast-before-backend with -print-statsArthur Eubanks1-0/+2
We still need access to various things in the ASTContext when printing stats. Differential Revision: https://reviews.llvm.org/D111973
2021-10-13[clang] Use llvm::is_contained (NFC)Kazu Hirata1-5/+4
2021-10-07[OpenMP] Introduce new flags to assert thread and team usage in the runtimeJoseph Huber1-0/+13
This patch adds two flags to be supported for the new runtime. The flags are `-fopenmp-assume-threads-oversubscription` and -fopenmp-assume-teams-oversubscription`. These add global values that can be checked by the work sharing runtime functions to make better judgements about how to distribute work between the threads. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D111348
2021-09-30[clang] Don't modify OptRemark if the argument is not relevantArthur Eubanks1-0/+2
A followup to D110201. For example, we'd set OptimizationRemarkMissed's Regex to '.*' when encountering -Rpass. Normally this doesn't actually affect remarks we emit because in clang::ProcessWarningOptions() we'll separately look at all -R arguments and turn on/off corresponding diagnostic groups. However, this is reproducible with -round-trip-args. Reviewed By: JamesNagurne Differential Revision: https://reviews.llvm.org/D110673
2021-09-24DebugInfo: Move the '=' version of -gsimple-template-names to the frontendDavid Blaikie1-2/+5
Based on feedback from Paul Robinson on 38c09ea that the 'mangled' mode is only useful as an LLVM-developer-internal tool in combination with llvm-dwarfdump --verify, so demote that to a frontend-only (not driver) option. The driver support is simply -g{no-,}simple-template-names to switch on simple template names, without the option to use the mangled template name scheme there.
2021-09-22[NFC] Remove trailing spaces from some filesShilei Tian1-2/+2
2021-09-22DebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}David Blaikie1-0/+14
This is to build the foundation of a new debug info feature to use only the base name of template as its debug info name (eg: "t1" instead of the full "t1<int>"). The intent being that a consumer can still retrieve all that information from the DW_TAG_template_*_parameters. So gno-simple-template-names is business as usual/previously ("t1<int>") =simple is the simplified name ("t1") =mangled is a special mode to communicate the full information, but also indicate that the name should be able to be simplified. The data is encoded as "_STNt1|<int>" which will be matched with an llvm-dwarfdump --verify feature to deconstruct this name, rebuild the original name, and then try to rebuild the simple name via the DWARF tags - then compare the latter and the former to ensure that all the data necessary to fully rebuild the name is present.
2021-09-21[clang] Make -Rpass imply -Rpass=.*Arthur Eubanks1-9/+12
Previously with -Rpass (and friends) we'd have remarks "enabled", but without an actual regex. As seen in the test change to line numbers, this can give us better diagnostics by properly enabling NeedLocTracking with -Rpass. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D110201
2021-09-10[OpenMP] Add flag for setting debug in the offloading deviceJoseph Huber1-0/+25
This patch introduces the flags `-fopenmp-target-debug` and `-fopenmp-target-debug=` to set the value of a global in the device. This will be used to enable or disable debugging features statically in the device runtime library. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D109544
2021-09-08[clang][Driver] Update/cleanup LTO logic to ensure that the last lto ↵Usman Nadeem1-2/+3
argument is honored - Make flto an alias of flto=full. - Make foffload-lto an alias of foffload-lto=full. - Make flto_EQ_jobserver, flto_EQ_auto aliases of flto=full, since they are being treated as full lto right now. - Clean up the code for parseLTOMode and setLTOMode. - Replace uses of OPT_flto with OPT_flto_EQ since they alias now. Differential Revision: https://reviews.llvm.org/D108881 Change-Id: I5d867db83a680434fba5c8d85c9a83135d3b81ee
2021-09-08Revert "[clang][Driver] Update/cleanup LTO logic to ensure that the last lto ↵Usman Nadeem1-3/+2
argument is honored" This reverts commit d2d2e5ea480feb09dc0edeac2eb14310de74b372.
2021-09-08[clang][Driver] Update/cleanup LTO logic to ensure that the last lto ↵Usman Nadeem1-2/+3
argument is honored - Make flto an alias of flto=full. - Make foffload-lto an alias of foffload-lto=full. - Make flto_EQ_jobserver, flto_EQ_auto aliases of flto=full, since they are being treated as full lto right now. - Clean up the code for parseLTOMode and setLTOMode. - Replace uses of OPT_flto with OPT_flto_EQ since they alias now. Change-Id: Iea5338c20cb800b43529b20745e92600e2cfd2b1
2021-09-03[modules] Use `HashBuilder` and `MD5` for the module hash.Alexandre Rames1-58/+42
Per the comments, `hash_code` values "are not stable to save or persist", so are unsuitable for the module hash, which must persist across compilations for the implicit module hashes to match. Note that in practice, today, `hash_code` are stable. But this is an implementation detail, with a clear `FIXME` indicating we should switch to a per-execution seed. The stability of `MD5` also allows modules cross-compilation use-cases. The `size_t` underlying storage for `hash_code` varying across platforms could cause mismatching hashes when cross-compiling from a 64bit target to a 32bit target. Note that native endianness is still used for the hash computation. So hashes will differ between platforms of different endianness. Reviewed By: jansvoboda11 Differential Revision: https://reviews.llvm.org/D102943
2021-09-02[clang] NFC: Extract DiagnosticOptions parsingJan Svoboda1-0/+13
The way we parse `DiagnosticOptions` is a bit involved. `DiagnosticOptions` are parsed as part of the cc1-parsing function `CompilerInvocation::CreateFromArgs` which takes `DiagnosticsEngine` as an argument to be able to report errors in command-line arguments. But to create `DiagnosticsEngine`, `DiagnosticOptions` are needed. This is solved by exposing the `ParseDiagnosticArgs` to clients and making its `DiagnosticsEngine` argument optional, essentially breaking the dependency cycle. The `ParseDiagnosticArgs` function takes `llvm::opt::ArgList &`, which each client needs to create from the command-line (typically represented as `std::vector<const char *>`). Creating this data structure in this context is somewhat particular. This code pattern is copy-pasted in some places across the upstream code base and also in downstream repos. To make things a bit more uniform, this patch extracts the code into a new reusable function: `CreateAndPopulateDiagOpts`. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D108918
2021-09-01Revert "[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and ↵Zahira Ammarguellat1-6/+1
extend #pragma float_control similarly" The intent of this patch is to add support of -fp-model=[source|double|extended] to allow the compiler to use a wider type for intermediate floating point calculations. As a side effect to that, the value of FLT_EVAL_METHOD is changed according to the pragma float_control. Unfortunately some issue was uncovered with this change in preprocessing. See details in https://reviews.llvm.org/D93769 . We are therefore reverting this patch until we find a way to reconcile the value of FLT_EVAL_METHOD, the pragma and the -E flow. This reverts commit 66ddac22e2a7f268e91c26d694112970dfa607ae.
2021-08-31[OpenCL] Defines helper function for kernel language compatible OpenCL versionJustas Janickas1-4/+3
This change defines a helper function getOpenCLCompatibleVersion() inside LangOptions class. The function contains mapping between C++ for OpenCL versions and their corresponding compatible OpenCL versions. This mapping function should be updated each time a new C++ for OpenCL language version is introduced. The helper function is expected to simplify conditions on OpenCL C and C++ for OpenCL versions inside compiler code. Code refactoring performed. Differential Revision: https://reviews.llvm.org/D108693
2021-08-18[OpenCL] C++ for OpenCL version 2021 introduced to command line.Justas Janickas1-0/+4
Introduces language standard `lang_openclcpp2021` and allows `clc++2021` as a version flag for `-cl-std` in command line. Defines macros related to C++ for OpenCL version 2021. C++ for OpenCL version 2021 has been proposed in an RFC: https://lists.llvm.org/pipermail/cfe-dev/2021-August/068593.html Differential Revision: https://reviews.llvm.org/D108038
2021-08-13[OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.Justas Janickas1-2/+3
Some Clang diagnostics could only report OpenCL C version. Because C++ for OpenCL can be used as an alternative to OpenCL C, the text for diagnostics should reflect that. Desrciptions modified for these diagnostics: `err_opencl_unknown_type_specifier` `warn_option_invalid_ocl_version` `err_attribute_requires_opencl_version` `warn_opencl_attr_deprecated_ignored` `ext_opencl_ext_vector_type_rgba_selector` Differential Revision: https://reviews.llvm.org/D107648
2021-08-04Apply -fmacro-prefix-map to __builtin_FILE()Pavel Asyutchenko1-9/+9
This matches the behavior of GCC. Patch does not change remapping logic itself, so adding one simple smoke test should be enough. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D107393
2021-08-04[clang][cli] Expose -fno-cxx-modules in cc1Jan Svoboda1-2/+0
For some use-cases, it might be useful to be able to turn off modules for C++ in `-cc1`. (The feature is implied by `-std=C++20`.) This patch exposes the `-fno-cxx-modules` option in `-cc1`. Reviewed By: arphaman Differential Revision: https://reviews.llvm.org/D106864
2021-07-30[OpenCL] Add support of __opencl_c_pipes feature macro.Anton Zabaznov1-1/+1
'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while parsing and then later on check for language options to construct actual pipe. This feature requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well. This is the same patch as in D106748 but with a tiny fix in checking of diagnostic messages. Also added tests when program scope global variables are not supported. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D107154
2021-07-30[OpenCL] Add std flag aliases clc++1.0 and CLC++1.0Anastasia Stulova1-4/+5
Renamed language standard from openclcpp to openclcpp10. Added new std values i.e. '-cl-std=clc++1.0' and '-cl-std=CLC++1.0'. Patch by Topotuna (Justas Janickas)! Differential Revision: https://reviews.llvm.org/D106266
2021-07-30Revert "[OpenCL] Add support of __opencl_c_pipes feature macro."Anton Zabaznov1-1/+1
This reverts commit d1e4b25756730576996457ba7324e9bf210e3693.
2021-07-30[OpenCL] Add support of __opencl_c_pipes feature macro.Anton Zabaznov1-1/+1
'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while parsing and then later on check for language options to construct actual pipe. This feature requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D106748
2021-07-28[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend ↵Melanie Blower1-1/+6
#pragma float_control similarly The Intel compiler ICC supports the option "-fp-model=(source|double|extended)" which causes the compiler to use a wider type for intermediate floating point calculations. Also supported is a way to embed this effect in the source program with #pragma float_control(source|double|extended). This patch extends pragma float_control syntax, and also adds support for a new floating point option "-ffp-eval-method=(source|double|extended)". source: intermediate results use source precision double: intermediate results use double precision extended: intermediate results use extended precision Reviewed By: Aaron Ballman Differential Revision: https://reviews.llvm.org/D93769
2021-07-26[OpenCL] Change default standard version to CL1.2Anastasia Stulova1-1/+1
Set default version for OpenCL C to 1.2. This means that the absence of any standard flag will be equivalent to passing '-cl-std=CL1.2'. Note that this patch also fixes incorrect version check for the pointer to pointer kernel arguments diagnostic and atomic test. Differential Revision: https://reviews.llvm.org/D106504
2021-07-22[DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homingAmy Huang1-6/+9
Add an opt out flag for constructor homing. Differential Revision: https://reviews.llvm.org/D106582
2021-07-20Revert "[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and ↵Melanie Blower1-6/+1
extend #pragma float_control similarly" This reverts commit ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7. There are a couple buildbot problems
2021-07-20[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend ↵Melanie Blower1-1/+6
#pragma float_control similarly The Intel compiler ICC supports the option "-fp-model=(source|double|extended)" which causes the compiler to use a wider type for intermediate floating point calculations. Also supported is a way to embed this effect in the source program with #pragma float_control(source|double|extended). This patch extends pragma float_control syntax, and also adds support for a new floating point option "-ffp-eval-method=(source|double|extended)". source: intermediate results use source precision double: intermediate results use double precision extended: intermediate results use extended precision Reviewed By: Aaron Ballman Differential Revision: https://reviews.llvm.org/D93769
2021-07-19[ifs] Prepare llvm-ifs for elfabi/ifs merging.Haowei Wu1-5/+5
This diff changes llvm-ifs to use unified IFS file format and perform other renaming changes in preparation for the merging between elfabi/ifs. Differential Revision: https://reviews.llvm.org/D99810
2021-06-25[clang] Rename StringRef _lower() method calls to _insensitive()Martin Storsjö1-5/+5
This is mostly a mechanical change, but a testcase that contains parts of the StringRef class (clang/test/Analysis/llvm-conventions.cpp) isn't touched.
2021-06-23[AIX][PowerPC] Remove error when specifying mabi=vec-default on AIXZarko Todorovski1-7/+1
The default Altivec ABI was implemented but the clang error for specifying its use still remains. Users could get around this but not specifying the type of Altivec ABI but we need to remove the error. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D102094
2021-06-22[OpenMP] Remove OpenMP CUDA Target Parallel compiler flagJoseph Huber1-9/+0
Summary: The changes introduced in D97680 turns this command line option into a no-op so it can be removed entirely. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D102940
2021-06-11[ADT] Remove APInt/APSInt toString() std::string variantsSimon Pilgrim1-1/+1
<string> is currently the highest impact header in a clang+llvm build: https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html One of the most common places this is being included is the APInt.h header, which needs it for an old toString() implementation that returns std::string - an inefficient method compared to the SmallString versions that it actually wraps. This patch replaces these APInt/APSInt methods with a pair of llvm::toString() helpers inside StringExtras.h, adjusts users accordingly and removes the <string> from APInt.h - I was hoping that more of these users could be converted to use the SmallString methods, but it appears that most end up creating a std::string anyhow. I avoided trying to use the raw_ostream << operators as well as I didn't want to lose having the integer radix explicit in the code. Differential Revision: https://reviews.llvm.org/D103888
2021-06-01[clang][Fuchsia] Turn on relative-vtables by default for FuchsiaLeonard Chan1-0/+10
All fuchsia targets will now use the relative-vtables ABI by default. Also remove -fexperimental-relative-c++-abi-vtables from test RUNs targeting fuchsia. Differential Revision: https://reviews.llvm.org/D102374
2021-05-27[Clang] Enable __has_feature(coverage_sanitizer)Marco Elver1-1/+1
Like other sanitizers, enable __has_feature(coverage_sanitizer) if clang has enabled at least one SanitizerCoverage instrumentation type. Because coverage instrumentation selection is not handled via normal -fsanitize= (and thus not in SanitizeSet), passing this information through to LangOptions required propagating the already parsed -fsanitize-coverage= options from CodeGenOptions through to LangOptions in FixupInvocation(). Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D103159
2021-05-18Introduce SYCL 2020 modeAaron Ballman1-0/+10
Currently, we have support for SYCL 1.2.1 (also known as SYCL 2017). This patch introduces the start of support for SYCL 2020 mode, which is the latest SYCL standard available at (https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html). This sets the default SYCL to be 2020 in the driver, and introduces the notion of a "default" version (set to 2020) when cc1 is in SYCL mode but there was no explicit -sycl-std= specified on the command line.
2021-05-15Support GCC's -fstack-usage flagPengxuan Zheng1-0/+3
This patch adds support for GCC's -fstack-usage flag. With this flag, a stack usage file (i.e., .su file) is generated for each input source file. The format of the stack usage file is also similar to what is used by GCC. For each function defined in the source file, a line with the following information is produced in the .su file. <source_file>:<line_number>:<function_name> <size_in_byte> <static/dynamic> "Static" means that the function's frame size is static and the size info is an accurate reflection of the frame size. While "dynamic" means the function's frame size can only be determined at run-time because the function manipulates the stack dynamically (e.g., due to variable size objects). The size info only reflects the size of the fixed size frame objects in this case and therefore is not a reliable measure of the total frame size. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D100509
2021-05-12Fix bad mangling of <data-member-prefix> for a closure in the initializer of ↵Richard Smith1-0/+4
a variable at global namespace scope. This implements the direction proposed in https://github.com/itanium-cxx-abi/cxx-abi/pull/126. Differential Revision: https://reviews.llvm.org/D101968
2021-05-11Revert "Fix bad mangling of <data-member-prefix> for a closure in the ↵Richard Smith1-4/+0
initializer of a variable at global namespace scope." This reverts commit 697ac15a0fc71888c372667bdbc5583ab42d4695, for which review was not complete. That change was accidentally pushed when an unrelated change was pushed.
2021-05-11Fix bad mangling of <data-member-prefix> for a closure in the initializer of ↵Richard Smith1-0/+4
a variable at global namespace scope. This implements the direction proposed in https://github.com/itanium-cxx-abi/cxx-abi/pull/126. Differential Revision: https://reviews.llvm.org/D101968
2021-05-11[AIX][TLS] Diagnose use of unimplemented TLS modelsVictor Huang1-0/+8
Add front end diagnostics to report error for unimplemented TLS models set by - compiler option `-ftls-model` - attributes like `__thread int __attribute__((tls_model("local-exec"))) var_name;` Reviewed by: aaron.ballman, nemanjai, PowerPC Differential Revision: https://reviews.llvm.org/D102070
2021-05-04[clang] Add -fc++-abi= flag for specifying which C++ ABI to useLeonard Chan1-0/+18
This implements the flag proposed in RFC http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html. The goal is to add a way to override the default target C++ ABI through a compiler flag. This makes it easier to test and transition between different C++ ABIs through compile flags rather than build flags. In this patch: - Store -fc++-abi= in a LangOpt. This isn't stored in a CodeGenOpt because there are instances outside of codegen where Clang needs to know what the ABI is (particularly through ASTContext::createCXXABI), and we should be able to override the target default if the flag is provided at that point. - Expose the existing ABIs in TargetCXXABI as values that can be passed through this flag. - Create a .def file for these ABIs to make it easier to check flag values. - Add an error for diagnosing bad ABI flag values. Differential Revision: https://reviews.llvm.org/D85802
2021-05-04[clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist=Nico Weber1-14/+15
Use that for internal names (including the default ignorelists of the sanitizers). Differential Revision: https://reviews.llvm.org/D101832
2021-05-01[AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieeeYaxun (Sam) Liu1-0/+5
AMDGPU backend need to know whether floating point opcodes that support exception flag gathering quiet and propagate signaling NaN inputs per IEEE754-2008, which is conveyed by a function attribute "amdgpu-ieee". "amdgpu-ieee"="false" turns this off. Without this function attribute backend assumes it is on for compute functions. -mamdgpu-ieee and -mno-amdgpu-ieee are added to Clang to control this function attribute. By default it is on. -mno-amdgpu-ieee requires -fno-honor-nans or equivalent. Reviewed by: Matt Arsenault Differential Revision: https://reviews.llvm.org/D77013
2021-04-28[clang] Make libBasic not depend on MCNico Weber1-1/+2
Reduces numbers of files built for clang-format from 575 to 449. Requires two small changes: 1. Don't use llvm::ExceptionHandling in LangOptions. This isn't even quite the right type since we don't use all of its values. Tweaks the changes made in: - https://reviews.llvm.org/D93215 - https://reviews.llvm.org/D93216 2. Move section name validation code added (long ago) in commit 30ba67439 out of libBasic into Sema and base the check on the triple. This is a bit less OOP-y, but completely in line with what we do in many other places in Sema. No behavior change. Differential Revision: https://reviews.llvm.org/D101463
2021-04-19[clang][cli] NFC: Move conditional LangOptions parsing/generationJan Svoboda1-40/+41
NFC, this simplifies the main parsing/generating functions by moving logic around conditional `LangOptions` where it belongs. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D100653
2021-04-19[clang][cli] NFC: Use Diags to report parsing success/failureJan Svoboda1-144/+110
`Success` is set to `false` whenever `Diags.Report(diag::err_)` is called. Remove the duplication and use `Diags` as the source of truth when deciding whether to report parsing success/failure. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D100644
2021-04-19[clang] Implement CompilerInvocation copy assignmentJan Svoboda1-0/+17
This patch implements the copy assignment for `CompilerInvocation`. Eventually, the deep-copy operation will be moved into a `clone()` method (D100460), but until then, this is necessary for basic ergonomics. Depends on D100455. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D100473
2021-04-19[clang] Rename CompilerInvocationBase to RefBase, split out ValueBaseJan Svoboda1-3/+4
This patch documents the reason `CompilerInvocationBase` exists and renames it to more descriptive `CompilerInvocationRefBase`. To make the distinction obvious, it also splits out new `CompilerInvocationValueBase` class. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D100455