aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/DiagnosticIDs.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-06-10[clang][tablegen] adds human documentation to `WarningOption`Christopher Di Bella1-2/+8
Building on D126796, this commit adds the infrastructure for being able to print out descriptions of what each warning does. Differential Revision: https://reviews.llvm.org/D126832
2022-06-08[clang][driver] adds `-print-diagnostics`Christopher Di Bella1-1/+1
Prints a list of all the warnings that Clang offers. Differential Revision: https://reviews.llvm.org/D126796
2022-04-30Reland [clangd] More precisely enable clang warnings through ClangTidy optionsSam McCall1-9/+21
This reverts commit 26c82f3d1de11cdada57e499b63a05d24e18b656. When tests enable 'Checks: *', we may get extra diagnostics.
2022-04-29Revert "[clangd] More precisely enable clang warnings through ClangTidy options"Nico Weber1-21/+9
This reverts commit 5227be8b6aa0edb2edb0b76e1039a7dd5641c80a. Broke check-clangd, see comment on https://reviews.llvm.org/D124679
2022-04-29[clangd] More precisely enable clang warnings through ClangTidy optionsSam McCall1-9/+21
clang-tidy's behavior is to add the -W flags, and then map all clang diagnostics to "clang-diagnostic-foo" pseudo-check-names, then use Checks to filter those. Previous to this patch, we were handling -W flags but not filtering the diagnostics, assuming both sets of information encoded the same thing. However this intersection is nontrivial when diagnostic group hierarchy is involved. e.g. -Wunused + clang-diagnostic-unused-function should not enable unused label warnings. This patch more closely emulates clang-tidy's behavior, while not going to the extreme of generating tidy check names for all clang diagnostics and filtering them with regexes. Differential Revision: https://reviews.llvm.org/D124679
2022-01-26Revert "Rename llvm::array_lengthof into llvm::size to match std::size from ↵Benjamin Kramer1-2/+2
C++17" This reverts commit ef8206320769ad31422a803a0d6de6077fd231d2. - It conflicts with the existing llvm::size in STLExtras, which will now never be called. - Calling it without llvm:: breaks C++17 compat
2022-01-26Rename llvm::array_lengthof into llvm::size to match std::size from C++17serge-sans-paille1-2/+2
As a conquence move llvm::array_lengthof from STLExtras.h to STLForwardCompat.h (which is included by STLExtras.h so no build breakage expected).
2022-01-12[clang] Introduce support for disabling warnings in system macrosCarlos Galvez1-4/+13
Often we run into situations where we want to ignore warnings from system headers, but Clang will still give warnings about the contents of a macro defined in a system header used in user-code. Introduce a ShowInSystemMacro option to be able to specify which warnings we do want to keep raising warnings for. The current behavior is kept in this patch (i.e. warnings from system macros are enabled by default). The decision as to whether this should be an opt-in or opt-out feature can be made in a separate patch. To put the feature to test, replace duplicated code for Wshadow and Wold-style-cast with the SuppressInSystemMacro tag. Also disable the warning for C++20 designators, fixing #52944. Differential Revision: https://reviews.llvm.org/D116833
2021-11-19[clang][NFC] Inclusive terms: replace some uses of sanity in clangZarko Todorovski1-1/+1
Rewording of comments to avoid using `sanity test, sanity check`. Reviewed By: aaron.ballman, Quuxplusone Differential Revision: https://reviews.llvm.org/D114025
2021-09-30Reland "[clang-cl] Accept `#pragma warning(disable : N)` for some N"Nico Weber1-3/+9
This reverts commit 0cd9d8a48bdddb17de2c6388f9d775353f9acab9 and adds the changes described in https://reviews.llvm.org/D110668#3034461.
2021-09-29Revert "[clang-cl] Accept `#pragma warning(disable : N)` for some N"Amy Huang1-9/+3
because it causes `error: error reading '/wd4091'` errors in compiler-rt builds.
2021-09-29[clang-cl] Accept `#pragma warning(disable : N)` for some NNico Weber1-3/+9
clang-cl maps /wdNNNN to -Wno-flags for a few warnings that map cleanly from cl.exe concepts to clang concepts. This patch adds support for the same numbers to `#pragma warning(disable : NNNN)`. It also lets `#pragma warning(push)` and `#pragma warning(pop)` have an effect, since these are used together with `warning(disable)`. The optional numeric argument to `warning(push)` is ignored, as are the other non-`disable` `pragma warning()` arguments. (Supporting `error` would be easy, but we also don't support `/we`, and those should probably be added together.) The motivating example is that a bunch of code (including in LLVM) uses this idiom to locally disable warnings about calls to deprecated functions in Windows-only code, and 4996 maps nicely to -Wno-deprecated-declarations: #pragma warning(push) #pragma warning(disable: 4996) f(); #pragma warning(pop) Implementation-wise: - Move `/wd` flag handling from Options.td to actual Driver-level code - Extract the function mapping cl.exe IDs to warning groups to the new file clang/lib/Basic/CLWarnings.cpp - Create a diag::Group enum so that CLWarnings.cpp can refer to existing groups by ID (and give DllexportExplicitInstantiationDecl a named group), and add a function to map a diag::Group to the spelling of it's associated commandline flag - Call that new function from PragmaWarningHandler Differential Revision: https://reviews.llvm.org/D110668
2021-03-03[clang][NFC] pack StaticDiagInfoRecNathan James1-13/+13
Exchanging types, reordering fields and borrowing a bit from OptionGroupIndex shrinks this from 12 bytes to 8. This knocks ~20k from the binary size. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D97553
2020-10-19Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host ↵Yaxun (Sam) Liu1-4/+12
device functions" This recommits 7f1f89ec8d9944559042bb6d3b1132eabe3409de and 40df06cdafc010002fc9cfe1dda73d689b7d27a6 with bug fixes for memory sanitizer failure and Tensile build failure.
2020-09-24Revert "Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for ↵Reid Kleckner1-15/+7
host device functions"" This reverts commit e39da8ab6a286ac777d5fe7799f1eb782cf99938. This depends on a change that needs additional design review and needs to be reverted.
2020-09-24[clang] use string tables for static diagnostic descriptionsNathan Froyd1-8/+92
Using a pointer for the description string in StaticDiagInfoRec causes several problems: 1. We don't need to use a whole pointer to represent the string; 2. The use of pointers incurs runtime relocations for those pointers; the relocations take up space on disk and represent runtime overhead; 3. The need to relocate data implies that, on some platforms, the entire array containing StaticDiagInfoRecs cannot be shared between processes. This patch changes the storage scheme for the diagnostic descriptions to avoid these problems. We instead generate (effectively) one large string and then StaticDiagInfoRec conceptually holds offsets into the string. We elected to also move the storage of those offsets into a separate array to further reduce the space required. On x86-64 Linux, this change removes about 120KB of relocations and moves about 60KB from the non-shareable .data.rel.ro section to shareable .rodata. (The array is about 80KB before this, but we eliminated 4 bytes/entry by using offsets rather than pointers.) We actually reap this benefit twice, because these tables show up in both libclang.so and libclang-cpp.so and we get the reduction in both places. Differential Revision: https://reviews.llvm.org/D81865
2020-09-24Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host ↵Yaxun (Sam) Liu1-6/+11
device functions" This recommits 7f1f89ec8d9944559042bb6d3b1132eabe3409de and 40df06cdafc010002fc9cfe1dda73d689b7d27a6 after fixing memory sanitizer failure.
2020-09-17Revert "[CUDA][HIP] Defer overloading resolution diagnostics for host device ↵Yaxun (Sam) Liu1-11/+6
functions" This reverts commit 7f1f89ec8d9944559042bb6d3b1132eabe3409de. This reverts commit 40df06cdafc010002fc9cfe1dda73d689b7d27a6.
2020-09-17[CUDA][HIP] Defer overloading resolution diagnostics for host device functionsYaxun (Sam) Liu1-6/+11
In CUDA/HIP a function may become implicit host device function by pragma or constexpr. A host device function is checked in both host and device compilation. However it may be emitted only on host or device side, therefore the diagnostics should be deferred until it is known to be emitted. Currently clang is only able to defer certain diagnostics. This causes false alarms and limits the usefulness of host device functions. This patch lets clang defer all overloading resolution diagnostics for host device functions. An option -fgpu-defer-diag is added to control this behavior. By default it is off. It is NFC for other languages. Differential Revision: https://reviews.llvm.org/D84364
2020-07-02[NFC][clang] Add missing VALIDATE_DIAG_SIZE()Whisperity1-0/+1
Originally when libCrossTU was introduced in commit e350b0a19629c4cce87f28913b3137f4c7015de3, the macro which thus had all diagnostic kinds covered was not added.
2020-01-29GCC5 buildbot made it to clang. Fix implicit conversions it found.Benjamin Kramer1-1/+1
2019-07-15Use a unique_ptr instead of manual memory management for CustomDiagInfoNico Weber1-5/+3
llvm-svn: 366085
2019-07-03Change std::{lower,upper}_bound to llvm::{lower,upper}_bound or ↵Fangrui Song1-5/+2
llvm::partition_point. NFC llvm-svn: 365006
2019-03-07[libclang] Fix CXTranslationUnit_KeepGoingIvan Donchevskii1-1/+6
Since commit 56f548bbbb7e4387a69708f70724d00e9e076153 [modules] Round-trip -Werror flag through explicit module build. the behavior of CXTranslationUnit_KeepGoing changed: Unresolved #includes are fatal errors again. As a consequence, some templates are not instantiated and lead to confusing errors. Revert to the old behavior: With CXTranslationUnit_KeepGoing fatal errors are mapped to errors. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D58501 llvm-svn: 355586
2019-01-29Fix the behavior of clang's -w flag.James Y Knight1-6/+11
It is intended to disable _all_ warnings, even those upgraded to errors via `-Werror=warningname` or `#pragma clang diagnostic error' Fixes: https://llvm.org/PR38231 Differential Revision: https://reviews.llvm.org/D53199 llvm-svn: 352535
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-07-30Remove trailing spaceFangrui Song1-1/+1
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-2/+2
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-04-06Fix typos in clangAlexander Kornienko1-1/+1
Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
2017-12-20Make DiagnosticIDs::getAllDiagnostics use std::vector. NFC.Gabor Horvath1-1/+1
The size of the result vector is currently around 4600 with Flavor::WarningOrError, which makes std::vector a better candidate than llvm::SmallVector. Patch by: Andras Leitereg! Differential Revision: https://reviews.llvm.org/D39372 llvm-svn: 321190
2017-11-14Make DiagnosticIDs::getAllDiagnostics static. NFC.Gabor Horvath1-1/+1
Patch by: Andras Leitereg! Differential Revision: https://reviews.llvm.org/D39372 llvm-svn: 318150
2017-10-16[refactor] allow the use of refactoring diagnosticsAlex Lorenz1-1/+4
This commit allows the refactoring library to use its own set of refactoring-specific diagnostics to reports things like initiation errors. Differential Revision: https://reviews.llvm.org/D38772 llvm-svn: 315924
2017-09-22Add Cross Translation Unit support libraryGabor Horvath1-1/+3
This patch introduces a class that can help to build tools that require cross translation unit facilities. This class allows function definitions to be loaded from external AST files based on an index. In order to use this functionality an index is required. The index format is a flat text file but it might be replaced with a different solution in the near future. USRs are used as names to look up the functions definitions. This class also does caching to avoid redundant loading of AST files. Right now only function defnitions can be loaded using this API because this is what the in progress cross translation unit feature of the Static Analyzer requires. In to future this might be extended to classes, types etc. Differential Revision: https://reviews.llvm.org/D34512 llvm-svn: 313975
2017-08-28Change Diagnostic Category size error from runtime to compiletimeErich Keane1-12/+23
Diagnostic Categories are fairly annoying, and are only enforced by a runtime-debug-only assert. This puts in a touch more work to get this all done at compile-time with static asserts Differential Revision: https://reviews.llvm.org/D37122 llvm-svn: 311905
2017-07-22[Bash-autocompletion] Fixed typo and add '-' after -WnoYuka Takahashi1-1/+1
Summary: -Wno-<warning> was autocompleted as -Wno<warning>, so fixed this typo. Differential Revision: https://reviews.llvm.org/D35762 llvm-svn: 308824
2017-07-16[Bash-autocompletion] Add support for -W<warning> and -Wno<warning>Yuka Takahashi1-0/+12
Summary: `-W[tab]` will autocomplete warnings defined in this link: https://clang.llvm.org/docs/DiagnosticsReference.html#wweak-vtables Differential Revision: https://reviews.llvm.org/D35447 llvm-svn: 308139
2017-05-04DiagnosticsEngine should clear DelayedDiagID before reporting theAlex Lorenz1-0/+4
delayed diagnostic This fix avoids an infinite recursion that was uncovered in one of our internal tests by r301992. The testcase is the most reduced version of that auto-generated test. This is an improved version of the reverted commit r302037. The previous fix actually managed to expose another subtle bug whereby `fatal_too_many_errors` error was reported twice, with the second report setting the `FatalErrorOccurred` flag. That prevented the notes that followed the diagnostic the caused `fatal_too_many_errors` to be emitted. This commit ensures that notes that follow `fatal_too_many_errors` but that belong to the diagnostic that caused `fatal_too_many_errors` won't be emitted by setting the `FatalErrorOccurred` when emitting `fatal_too_many_errors`. rdar://31962618 llvm-svn: 302151
2017-05-03[modules] Round-trip -Werror flag through explicit module build.Richard Smith1-13/+9
The intent for an explicit module build is that the diagnostics produced within the module are those that were configured when the module was built, not those that are enabled within a user of the module. This includes diagnostics that don't actually show up until the module is used (for instance, diagnostics produced during template instantiation and weird cases like -Wpadded). We serialized and restored the diagnostic state for individual warning groups, but previously did not track the state for flags like -Werror and -Weverything, which are implemented as separate bits rather than as part of the diagnostics mapping information. llvm-svn: 301992
2017-01-26Remove and replace DiagStatePoint tracking and lookup data structure.Richard Smith1-4/+1
Rather than storing a single flat list of SourceLocations where the diagnostic state changes (in source order), we now store a separate list for each FileID in which there is a diagnostic state transition. (State for other files is built and cached lazily, on demand.) This has two consequences: 1) We can now sensibly support modules, and properly track the diagnostic state for modular headers (this matters when, for instance, triggering instantiation of a template defined within a module triggers diagnostics). 2) It's much faster than the old approach, since we can now just do a binary search on the offsets within the FileID rather than needing to call isBeforeInTranslationUnit to determine source order (which is surprisingly slow). For some pathological (but real world) files, this reduces total compilation time by more than 10%. For now, the diagnostic state points for modules are loaded eagerly. It seems feasible to defer this until diagnostic state information for one of the module's files is needed, but that's not part of this patch. llvm-svn: 293123
2016-07-13[PCH/preamble] Make sure that if the preamble/PCH was serialized with errors ↵Argyrios Kyrtzidis1-1/+1
that we set diagnostic engine state appropriately. Otherwise there can be a crash with CFG analysis warnings doing work on invalid AST. Fixes crash of rdar://26224134 llvm-svn: 275313
2016-03-01Optionally demote fatal errors to non-fatal errors.Manuel Klimek1-0/+6
This behavior is enabled when the new CXTranslationUnit_KeepGoing option is passed to clang_parseTranslationUnit{,2}. It is geared towards use by IDEs and similar consumers of the clang-c API where fatal errors may arise when parsing incomplete code mid-edit, or when include paths are not properly configured yet. In such situations one still wants to get as much information as possible about a TU. Previously, the semantic analysis would not instantiate templates or report additional fatal errors after the first fatal error was encountered. Fixes PR24268. Patch by Milian Wolff. llvm-svn: 262318
2015-10-18Add an unnecessary makeArrayRef I add earlier. I didn't realize range-based ↵Craig Topper1-1/+1
for loops worked with arrays. llvm-svn: 250646
2015-10-18Use std::is_sorted instead of a manual loop.Craig Topper1-5/+4
llvm-svn: 250645
2015-10-17Replace a static compare function with a lambda. NFCCraig Topper1-7/+5
llvm-svn: 250621
2015-10-17Use a range-based for loop. Use std::end instead of pointer+array_lengthof. NFCCraig Topper1-11/+9
llvm-svn: 250617
2015-10-16Further increase helfulness of assert messageRichard Barton1-4/+1
If you increase the number of diags of a particular type by one more than the number available you get the nice assert message. If you do it by two more than available you get the old non-helpful message. Combining the two makes sense I think. llvm-svn: 250546
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko1-5/+5
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-5/+5
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2015-03-09Simplify boolean expressions in clang with clang-tidyDavid Blaikie1-1/+1
Patch by Richard (legalize at xmission dot com). Differential Revision: http://reviews.llvm.org/D8155 llvm-svn: 231619
2014-12-05Make DiagnosticErrorTrap work even if SuppressAllDiagnostics is enabled.Richard Smith1-10/+11
Patch by Brad King! llvm-svn: 223525