aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
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
2021-04-14[clang] Fix copy constructor of CompilerInvocationJan Svoboda1-2/+4
The `CompilerInvocationBase` class factors out members of `CompilerInvocation` that need special handling (initialization or copy constructor), so that `CompilerInvocation` can be implemented as a simple value object. Currently, the `AnalyzerOpts` member of `CompilerInvocation` violates that setup. This patch extracts the member to `CompilerInvocationBase` and handles it in the copy constructor the same way other it handles other members. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D99568
2021-03-30[clang][cli] Fix round-trip of OPT_plugin_argJohn Brawn1-2/+7
The test Frontend/plugin-delayed-template.cpp is failing when asserts are enabled because it hits an assertion in denormalizeStringImpl when trying to round-trip OPT_plugin_arg. Fix this by adjusting how the option is handled, as the first part is joined to -plugin-arg and the second is separate. Differential Revision: https://reviews.llvm.org/D99606
2021-03-25[Debugify] Expose original debug info preservation check as CC1 optionDjordje Todorovic1-0/+6
In order to test the preservation of the original Debug Info metadata in your projects, a front end option could be very useful, since users usually report that a concrete entity (e.g. variable x, or function fn2()) is missing debug info. The [0] is an example of running the utility on GDB Project. This depends on: D82546 and D82545. Differential Revision: https://reviews.llvm.org/D82547
2021-03-24[OpenCL] Added distinct file extension for C++ for OpenCL.Anastasia Stulova1-2/+17
Files compiled with C++ for OpenCL mode can now have a distinct file extension - clcpp, then clang driver picks the compilation mode automatically (-x clcpp) without the use of -cl-std=clc++. Differential Revision: https://reviews.llvm.org/D96771
2021-03-17[SYCL] Rework the SYCL driver optionsAaron Ballman1-0/+5
SYCL compilations initiated by the driver will spawn off one or more frontend compilation jobs (one for device and one for host). This patch reworks the driver options to make upstreaming this from the downstream SYCL fork easier. This patch introduces a language option to identify host executions (SYCLIsHost) and a -cc1 frontend option to enable this mode. -fsycl and -fno-sycl become driver-only options that are rejected when passed to -cc1. This is because the frontend and beyond should be looking at whether the user is doing a device or host compilation specifically. Because the frontend should only ever be in one mode or the other, -fsycl-is-device and -fsycl-is-host are mutually exclusive options.
2021-03-12[NFC] Adjust SmallVector.h header to workaround XL build compiler issuexling-Liao1-2/+2
In order to prevent further building issues related to the usage of SmallVector in other compilation unit, this patch adjusts the llvm.h header as a workaround instead. Besides, this patch reverts previous workarounds: 1. Revert "[NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX" This reverts commit 561fb7f60ab631e712c3fb6bbeb47061222c6818. 2.Revert "[clang][cli] Fix build failure in CompilerInvocation" This reverts commit 8dc70bdcd0fe4efb65876dce0144d9c3386a2f07. Differential Revision: https://reviews.llvm.org/D98552
2021-03-09Revert D97743 "Define __GCC_HAVE_DWARF2_CFI_ASM if applicable"Fangrui Song1-5/+0
This reverts commit c11ff4bbada3b5127a1f010e0a97a1e6e46fb61a & df67d3526962ae51446b1390e7c40e045e580ec2. Trying to make the change to the driver to avoid round-trip issues.
2021-03-09Define __GCC_HAVE_DWARF2_CFI_ASM if applicableFangrui Song1-0/+5
In -fno-exceptions -fno-asynchronous-unwind-tables -g0 mode, GCC does not emit `.cfi_*` directives. ``` % diff <(gcc -fno-asynchronous-unwind-tables -dM -E a.c) <(gcc -dM -E a.c) 130a131 > #define __GCC_HAVE_DWARF2_CFI_ASM 1 ``` This macro is useful because code can decide whether inline asm should include `.cfi_*` directives. `.cfi_*` directives without `.cfi_startproc` can cause assembler errors (integrated assembler: `this directive must appear between .cfi_startproc and .cfi_endproc directives`). Differential Revision: https://reviews.llvm.org/D97743
2021-03-09[AIX] do not emit visibility attribute into IR when there is ↵diggerlin1-24/+27
-mignore-xcoff-visibility SUMMARY: n the patch https://reviews.llvm.org/D87451 "add new option -mignore-xcoff-visibility" we did as "The option -mignore-xcoff-visibility has no effect on visibility attribute when compile with -emit-llvm option to generated LLVM IR." in these patch we let -mignore-xcoff-visibility effect on generating IR too. the new feature only work on AIX OS Reviewer: Jason Liu, Differential Revision: https://reviews.llvm.org/D89986
2021-03-05[clang][cli] Fix generation of '-fvisibility' with regards to ↵Jan Svoboda1-0/+17
'-mignore-xcoff-visibility' This patch fixes failure of the `CodeGen/aix-ignore-xcoff-visibility.cpp` test with command line round-trip. The absence of '-fvisibility' implies '-mignore-xcoff-visibility'. The problem is that when '-fvisibility default' is passed to -cc1, it isn't being generated. (This adheres to the principle that generation doesn't produce arguments with default values.) However, that caused '-mignore-xcoff-visibility' to be implied in the generated command line (without '-fvisibility'), while it wasn't implied in the original command line (with '-fvisibility'). This patch fixes that by always generating '-fvisibility' and explains the situation in comment. (The '-mginore-xcoff-visibility' option was added in D87451). Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D97552
2021-03-02[clang][cli] NFC: Use .str() instead of operator<<Jan Svoboda1-8/+3
2021-03-02[clang][cli] NFC: Use .str() instead of operator<<Jan Svoboda1-16/+6
2021-02-26[clang][cli] Implement '-cuid=' marshallingJan Svoboda1-5/+0
This patch adds marshalling to the `-cuid=` option introduced in D95007. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D97461
2021-02-26[clang][cli] Fix build failure in CompilerInvocationJan Svoboda1-2/+2
There is a report that https://reviews.llvm.org/D96280 causes a build failure with error: too few template arguments for class template 'SmallVector'. This patch attempts to fix that by explicitly specifying N for SmallVector<T, N>.
2021-02-25[Driver] Rename -fprofile-{prefix-map,compilation-dir} to ↵Petr Hosek1-4/+4
-fcoverage-{prefix-map,compilation-dir} These flags affect coverage mapping (-fcoverage-mapping), not -fprofile-[instr-]generate so it makes more sense to use the -fcoverage-* prefix. Differential Revision: https://reviews.llvm.org/D97434
2021-02-25[NFC] Switch to auto marshalling infrastructure for ↵Dan Liew1-13/+0
`-fsanitize-address-destructor-kind=` flag. This change simplifies `clang/lib/Frontend/CompilerInvocation.cpp` because we no longer need to manually parse the flag and set codegen options in the frontend. However, we still need to manually parse the flag in the driver because: * The marshalling infrastructure doesn't operate there. * We need to do some platform specific checks in the driver that will likely never be supported by any kind of marshalling infrastructure. rdar://71609176 Differential Revision: https://reviews.llvm.org/D97327
2021-02-25[Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & ↵Dan Liew1-0/+13
frontend option. The new `-fsanitize-address-destructor-kind=` option allows control over how module destructors are emitted by ASan. The new option is consumed by both the driver and the frontend and is propagated into codegen options by the frontend. Both the legacy and new pass manager code have been updated to consume the new option from the codegen options. It would be nice if the new utility functions (`AsanDtorKindToString` and `AsanDtorKindFromString`) could live in LLVM instead of Clang so they could be consumed by other language frontends. Unfortunately that doesn't work because the clang driver doesn't link against the LLVM instrumentation library. rdar://71609176 Differential Revision: https://reviews.llvm.org/D96572
2021-02-25[clang] Remove a superfluous semicolon, silencing GCC warnings. NFC.Martin Storsjö1-1/+1