#
829bcb06 |
| 08-Feb-2023 |
Ziqing Luo <ziqing@udel.edu> |
[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas
Add a pair of clang pragmas: - `#pragma clang unsafe_buffer_usage begin` and - `#pragma clang unsafe_buffer_usage end`, which speci
[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas
Add a pair of clang pragmas: - `#pragma clang unsafe_buffer_usage begin` and - `#pragma clang unsafe_buffer_usage end`, which specify the start and end of an (unsafe buffer checking) opt-out region, respectively.
Behaviors of opt-out regions conform to the following rules:
- No nested nor overlapped opt-out regions are allowed. One cannot start an opt-out region with `... unsafe_buffer_usage begin` but never close it with `... unsafe_buffer_usage end`. Mis-use of the pragmas will be warned. - Warnings raised from unsafe buffer operations inside such an opt-out region will always be suppressed. This behavior CANNOT be changed by `clang diagnostic` pragmas or command-line flags. - Warnings raised from unsafe operations outside of such opt-out regions may be reported on declarations inside opt-out regions. These warnings are NOT suppressed. - An un-suppressed unsafe operation warning may be attached with notes. These notes are NOT suppressed as well regardless of whether they are in opt-out regions.
The implementation maintains a separate sequence of location pairs representing opt-out regions in `Preprocessor`. The `UnsafeBufferUsage` analyzer reads the region sequence to check if an unsafe operation is in an opt-out region. If it is, discard the warning raised from the operation immediately.
This is a re-land after I reverting it at 9aa00c8a306561c4e3ddb09058e66bae322a0769. The compilation error should be resolved.
Reviewed by: NoQ
Differential revision: https://reviews.llvm.org/D140179
show more ...
|
Revision tags: llvmorg-16.0.0-rc2 |
|
#
9aa00c8a |
| 08-Feb-2023 |
Ziqing Luo <ziqing@udel.edu> |
Revert "[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas"
This reverts commit aef05b5dc5c566bcaa15b66c989ccb8d2841ac71. It causes a buildbot failure: https://lab.llvm.org/buildbot/
Revert "[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas"
This reverts commit aef05b5dc5c566bcaa15b66c989ccb8d2841ac71. It causes a buildbot failure: https://lab.llvm.org/buildbot/#/builders/216/builds/16879/steps/6/logs/stdio
show more ...
|
#
aef05b5d |
| 08-Feb-2023 |
Ziqing Luo <ziqing@udel.edu> |
[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas
Add a pair of clang pragmas: - `#pragma clang unsafe_buffer_usage begin` and - `#pragma clang unsafe_buffer_usage end`, which speci
[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas
Add a pair of clang pragmas: - `#pragma clang unsafe_buffer_usage begin` and - `#pragma clang unsafe_buffer_usage end`, which specify the start and end of an (unsafe buffer checking) opt-out region, respectively.
Behaviors of opt-out regions conform to the following rules:
- No nested nor overlapped opt-out regions are allowed. One cannot start an opt-out region with `... unsafe_buffer_usage begin` but never close it with `... unsafe_buffer_usage end`. Mis-use of the pragmas will be warned. - Warnings raised from unsafe buffer operations inside such an opt-out region will always be suppressed. This behavior CANNOT be changed by `clang diagnostic` pragmas or command-line flags. - Warnings raised from unsafe operations outside of such opt-out regions may be reported on declarations inside opt-out regions. These warnings are NOT suppressed. - An un-suppressed unsafe operation warning may be attached with notes. These notes are NOT suppressed as well regardless of whether they are in opt-out regions.
The implementation maintains a separate sequence of location pairs representing opt-out regions in `Preprocessor`. The `UnsafeBufferUsage` analyzer reads the region sequence to check if an unsafe operation is in an opt-out region. If it is, discard the warning raised from the operation immediately.
Reviewed by: NoQ
Differential revision: https://reviews.llvm.org/D140179
show more ...
|
Revision tags: llvmorg-16.0.0-rc1, llvmorg-17-init |
|
#
6ad0788c |
| 14-Jan-2023 |
Kazu Hirata <kazu@google.com> |
[clang] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h".
This is p
[clang] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h".
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
show more ...
|
#
a1580d7b |
| 14-Jan-2023 |
Kazu Hirata <kazu@google.com> |
[clang] Add #include <optional> (NFC)
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>.
I'll post a separate patch to actually replace llvm::Option
[clang] Add #include <optional> (NFC)
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>.
I'll post a separate patch to actually replace llvm::Optional with 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
show more ...
|
Revision tags: llvmorg-15.0.7 |
|
#
854c10f8 |
| 19-Dec-2022 |
Benjamin Kramer <benny.kra@googlemail.com> |
[Clang] Prepare for llvm::Optional becoming std::optional.
The needed tweaks are mostly trivial, the one nasty bit is Clang's usage of OptionalStorage. To keep this working old Optional stays around
[Clang] Prepare for llvm::Optional becoming std::optional.
The needed tweaks are mostly trivial, the one nasty bit is Clang's usage of OptionalStorage. To keep this working old Optional stays around as clang::CustomizableOptional, with the default Storage removed. Optional<File/DirectoryEntryRef> is replaced with a typedef.
I tested this with GCC 7.5, the oldest supported GCC I had around.
Differential Revision: https://reviews.llvm.org/D140332
show more ...
|
#
205c0589 |
| 18-Dec-2022 |
Krzysztof Parzyszek <kparzysz@quicinc.com> |
Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional"
This reverts commit 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.
The Optional*RefDegradesTo*EntryPtr types want to
Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional"
This reverts commit 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.
The Optional*RefDegradesTo*EntryPtr types want to keep the same size as the underlying type, which std::optional doesn't guarantee. For use with llvm::Optional, they define their own storage class, and there is no way to do that in std::optional.
On top of that, that commit broke builds with older GCCs, where std::optional was not trivially copyable (static_assert in the clang sources was failing).
show more ...
|
#
8f0df9f3 |
| 17-Dec-2022 |
Krzysztof Parzyszek <kparzysz@quicinc.com> |
[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional
|
Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4 |
|
#
e8541e4b |
| 27-Oct-2022 |
Chuanqi Xu <yedeng.yd@linux.alibaba.com> |
[NFC] [Modules] Rename modules related things in Preprocessor and AffectingModules
Rename module related things according to the consensus in https://discourse.llvm.org/t/rfc-unifying-the-terminolog
[NFC] [Modules] Rename modules related things in Preprocessor and AffectingModules
Rename module related things according to the consensus in https://discourse.llvm.org/t/rfc-unifying-the-terminology-about-modules-in-clang/66054/ to reduce further confusings.
This only renames things I can make sure. It doesn't mean all the names in Preprocessor are correct now.
show more ...
|
#
e0448245 |
| 26-Oct-2022 |
Sam McCall <sam.mccall@gmail.com> |
[Lex] Stop allocating/deallocating MacroInfo on a linked list. NFC
This list was originally used for to make sure MacroInfo's clever memory management got called (1f1e4bdbf7815c), but that was simpl
[Lex] Stop allocating/deallocating MacroInfo on a linked list. NFC
This list was originally used for to make sure MacroInfo's clever memory management got called (1f1e4bdbf7815c), but that was simplified in 73a29662b9bf640a and 1f1e4bdbf7815c, and there's nothing left.
Differential Revision: https://reviews.llvm.org/D136725
show more ...
|
Revision tags: llvmorg-15.0.3, working, llvmorg-15.0.2 |
|
#
9dc0b167 |
| 22-Sep-2022 |
Jan Svoboda <jan_svoboda@apple.com> |
[clang][deps] Report module map describing compiled module
This patch fixes compilation failure with explicit modules caused by scanner not reporting the module map describing the module whose imple
[clang][deps] Report module map describing compiled module
This patch fixes compilation failure with explicit modules caused by scanner not reporting the module map describing the module whose implementation is being compiled.
Below is a breakdown of the attached test case. Note the VFS that makes frameworks "A" and "B" share the same header "shared/H.h".
In non-modular build, Clang skips the last import, since the "shared/H.h" header has already been included.
During scan (or implicit build), the compiler handles "tu.m" as follows: * `@import B` imports module "B", as expected, * `#import <A/H.h>` is resolved textually (due to `-fmodule-name=A`) to "shared/H.h" (due to the VFS remapping), * `#import <B/H.h>` is resolved to import module "A_Private", since the header "shared/H.h" is already known to be part of that module, and the import is skipped. In the end, the only modular dependency of the TU is "B".
In explicit modular build without `-fmodule-name=A`, TU does depend on module "A_Private" properly, not just textually. Clang therefore builds & loads its PCM, and knows to ignore the last import, since "shared/H.h" is known to be part of "A_Private".
But with current scanner behavior and `-fmodule-name=A` present, the last import fails during explicit build. Clang doesn't know about "A_Private" (it's included textually) and tries to import "B_Private" instead, which it doesn't know about either (the scanner correctly didn't report it as dependency). This is fixed by reporting the module map describing "A" and matching the semantics of implicit build.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D134222
show more ...
|
Revision tags: llvmorg-15.0.1 |
|
#
981cbfb5 |
| 19-Sep-2022 |
Kazu Hirata <kazu@google.com> |
[clang] Don't include StringSwitch.h (NFC)
These files don't seem to use StringSwitch.
|
Revision tags: llvmorg-15.0.0 |
|
#
41667a8b |
| 26-Aug-2022 |
Muhammad Usman Shahid <codesbyusman@gmail.com> |
Diagnosing the Future Keywords
The patch diagnoses an identifier as a future keyword if it exists in a future language mode, such as:
int restrict;
in C modes earlier than C99. We now give a warni
Diagnosing the Future Keywords
The patch diagnoses an identifier as a future keyword if it exists in a future language mode, such as:
int restrict;
in C modes earlier than C99. We now give a warning to the user that such an identifier is a future keyword. Handles keywords from C as well as C++.
Differential Revision: https://reviews.llvm.org/D131683
show more ...
|
Revision tags: llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2 |
|
#
3f18f7c0 |
| 08-Aug-2022 |
Fangrui Song <i@maskray.me> |
[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
With C++17 there is no Clang pedantic warning or MSVC C5051.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D131346
|
Revision tags: llvmorg-15.0.0-rc1, llvmorg-16-init |
|
#
af2d11b1 |
| 01-Jul-2022 |
Iain Sandoe <iain@sandoe.co.uk> |
[C++20][Modules] Implement include translation.
This addresses [cpp.include]/7
(when encountering #include header-name)
If the header identified by the header-name denotes an importable header, it
[C++20][Modules] Implement include translation.
This addresses [cpp.include]/7
(when encountering #include header-name)
If the header identified by the header-name denotes an importable header, it is implementation-defined whether the #include preprocessing directive is instead replaced by an import directive.
In this implementation, include translation is performed _only_ for headers in the Global Module fragment, so: ``` module; #include "will-be-translated.h" // IFF the header unit is available.
export module M; #include "will-not-be-translated.h" // even if the header unit is available ``` The reasoning is that, in general, includes in the module purview would not be validly translatable (they would have to immediately follow the module decl and without any other intervening decls). Otherwise that would violate the rules on contiguous import directives.
This would be quite complex to track in the preprocessor, and for relatively little gain (the user can 'import "will-not-be-translated.h";' instead.)
TODO: This is one area where it becomes increasingly difficult to disambiguate clang modules in C++ from C++ standard modules. That needs to be addressed in both the driver and the FE.
Differential Revision: https://reviews.llvm.org/D128981
show more ...
|
#
5f2cf3a2 |
| 29-Jun-2022 |
Egor Zhdan <e_zhdan@apple.com> |
[Clang][Preprocessor] Fix inconsistent `FLT_EVAL_METHOD` when compiling vs preprocessing
When running `clang -E -Ofast` on macOS, the `__FLT_EVAL_METHOD__` macro is `0`, which causes the following t
[Clang][Preprocessor] Fix inconsistent `FLT_EVAL_METHOD` when compiling vs preprocessing
When running `clang -E -Ofast` on macOS, the `__FLT_EVAL_METHOD__` macro is `0`, which causes the following typedef to be emitted into the preprocessed source: `typedef float float_t`.
However, when running `clang -c -Ofast`, `__FLT_EVAL_METHOD__` is `-1`, and `typedef long double float_t` is emitted.
This causes build errors for certain projects, which are not reproducible when compiling from preprocessed source.
The issue is that `__FLT_EVAL_METHOD__` is configured in `Sema::Sema` which is not executed when running in `-E` mode.
This change moves that logic into the preprocessor initialization method, which is invoked correctly in `-E` mode.
rdar://96134605 rdar://92748429
Differential Revision: https://reviews.llvm.org/D128814
show more ...
|
#
a9a60f20 |
| 28-Jun-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]
"Ascii" StringLiteral instances are actually narrow strings that are UTF-8 encoded and do not have an encoding prefix. (UTF8 StringLiter
[Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]
"Ascii" StringLiteral instances are actually narrow strings that are UTF-8 encoded and do not have an encoding prefix. (UTF8 StringLiteral are also UTF-8 encoded strings, but with the u8 prefix.
To avoid possible confusion both with actuall ASCII strings, and with future works extending the set of literal encodings supported by clang, this rename StringLiteral::isAscii() to isOrdinary(), matching C++ standard terminology.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D128762
show more ...
|
Revision tags: llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4 |
|
#
b4c83a13 |
| 12-May-2022 |
Argyrios Kyrtzidis <kyrtzidis@apple.com> |
[Tooling/DependencyScanning & Preprocessor] Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources
This is a commit with the following changes:
[Tooling/DependencyScanning & Preprocessor] Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources
This is a commit with the following changes:
* Remove `ExcludedPreprocessorDirectiveSkipMapping` and related functionality
Removes `ExcludedPreprocessorDirectiveSkipMapping`; its intended benefit for fast skipping of excluded directived blocks will be superseded by a follow-up patch in the series that will use dependency scanning lexing for the same purpose.
* Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources
Replaces the "source minimization" mechanism with a mechanism that produces lexed dependency directives tokens.
* Make the special lexing for dependency scanning a first-class feature of the `Preprocessor` and `Lexer`
This is bringing the following benefits:
* Full access to the preprocessor state during dependency scanning. E.g. a component can see what includes were taken and where they were located in the actual sources. * Improved performance for dependency scanning. Measurements with a release+thin-LTO build shows ~ -11% reduction in wall time. * Opportunity to use dependency scanning lexing to speed-up skipping of excluded conditional blocks during normal preprocessing (as follow-up, not part of this patch).
For normal preprocessing measurements show differences are below the noise level.
Since, after this change, we don't minimize sources and pass them in place of the real sources, `DependencyScanningFilesystem` is not technically necessary, but it has valuable performance benefits for caching file `stat`s along with the results of scanning the sources. So the setup of using the `DependencyScanningFilesystem` during a dependency scan remains.
Differential Revision: https://reviews.llvm.org/D125486 Differential Revision: https://reviews.llvm.org/D125487 Differential Revision: https://reviews.llvm.org/D125488
show more ...
|
Revision tags: llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1 |
|
#
0eb5891a |
| 29-Mar-2022 |
Timm Bäder <tbaeder@redhat.com> |
[clang][preprocessor] Allow calling DumpToken() on annotation tokens
Differential Revision: https://reviews.llvm.org/D122659
|
Revision tags: llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1 |
|
#
1592d88a |
| 19-Oct-2021 |
Zahira Ammarguellat <zahira.ammarguellat@intel.com> |
Add support for floating-point option `ffp-eval-method` and for `pragma clang fp eval_method`.
Differential Revision: https://reviews.llvm.org/D109239
|
#
f7202723 |
| 26-Jan-2022 |
Jan Svoboda <jan_svoboda@apple.com> |
[clang][lex] Include tracking: simplify and move to preprocessor
This patch replaces the exact include count of each file in `HeaderFileInfo` with a set of included files in `Preprocessor`.
The num
[clang][lex] Include tracking: simplify and move to preprocessor
This patch replaces the exact include count of each file in `HeaderFileInfo` with a set of included files in `Preprocessor`.
The number of includes isn't a property of a header file but rather a preprocessor state. The exact number of includes is not used anywhere except statistic tracking.
Reviewed By: vsapsai
Differential Revision: https://reviews.llvm.org/D114095
show more ...
|
#
105c9131 |
| 18-Jan-2022 |
Jan Svoboda <jan_svoboda@apple.com> |
[clang][lex] NFC: Simplify calls to `LookupFile`
The `{HeaderSearch,Preprocessor}::LookupFile()` functions take an out-parameter `const DirectoryLookup *&`. Most callers end up creating a `const Dir
[clang][lex] NFC: Simplify calls to `LookupFile`
The `{HeaderSearch,Preprocessor}::LookupFile()` functions take an out-parameter `const DirectoryLookup *&`. Most callers end up creating a `const DirectoryLookup *` variable that's otherwise unused.
This patch changes the out-parameter from reference to a pointer, making it possible to simply pass `nullptr` to the function without the ceremony.
Reviewed By: ahoppen
Differential Revision: https://reviews.llvm.org/D117312
show more ...
|
#
e567f37d |
| 14-Oct-2021 |
Kazu Hirata <kazu@google.com> |
[clang] Use llvm::is_contained (NFC)
|
#
1341a2c1 |
| 12-Oct-2021 |
Jan Svoboda <jan_svoboda@apple.com> |
[clang][modules] Default `SourceLocation` parameter in `HeaderSearch::lookupModule`
This fixes an LLDB build failure where the `ImportLoc` argument is missing: https://lab.llvm.org/buildbot#builders
[clang][modules] Default `SourceLocation` parameter in `HeaderSearch::lookupModule`
This fixes an LLDB build failure where the `ImportLoc` argument is missing: https://lab.llvm.org/buildbot#builders/68/builds/19975
This change also makes it possible to drop `SourceLocation()` in `Preprocessor::getCurrentModule`.
show more ...
|
#
638c673a |
| 12-Oct-2021 |
Jan Svoboda <jan_svoboda@apple.com> |
[clang][modules] NFC: Propagate import `SourceLocation` into `HeaderSearch::lookupModule`
This patch propagates the import `SourceLocation` into `HeaderSearch::lookupModule`. This enables remarks on
[clang][modules] NFC: Propagate import `SourceLocation` into `HeaderSearch::lookupModule`
This patch propagates the import `SourceLocation` into `HeaderSearch::lookupModule`. This enables remarks on search path usage (implemented in D102923) to point to the source code that initiated header search.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D111557
show more ...
|