aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-14[clang-tidy][NFC] change patterns 'anyOf(..., anything())' to ↵Baranov Victor1-8/+5
'optionally(...)' (#143558) Writing `optionally()` instead of `anyOf(..., anything())` lowers code size and gives the author's intention better.
2025-05-25[clang-tidy] Remove unused includes (NFC) (#141420)Kazu Hirata1-2/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2024-01-12[clang-tidy] Fix false-positives in misc-static-assert caused by ↵Piotr Zegar1-1/+9
non-constexpr variables (#77203) Ignore false-positives when referring to non-constexpr variables in non-unevaluated context (like decltype, sizeof, ...). Moved from https://reviews.llvm.org/D158657 Fixes: #24066
2023-08-27[clang-tidy][NFC] Fix modernize-return-braced-init-list findingsPiotr Zegar1-2/+2
Fix issues found by clang-tidy in clang-tidy source directory.
2023-01-14[clang-tidy][NFC] Use C++17 nested namespaces in the clang-tidy folderCarlos Galvez1-6/+2
Fix applied by running: run-clang-tidy.py -checks=-*,modernize-concat-nested-namespaces Differential Revision: https://reviews.llvm.org/D141770
2023-01-07[clang-tools-extra] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-1/+1
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. 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
2023-01-07[clang-tools-extra] Add #include <optional> (NFC)Kazu Hirata1-0/+1
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
2021-06-25[clang-tools-extra] Rename StringRef _lower() method calls to _insensitive()Martin Storsjö1-2/+2
2021-05-30Revert "[clang-tidy] Simplify static assert check"Roman Lebedev1-19/+30
This patch starts to produce a very obvious false-positives, despite the fact the preexisting tests already cover the pattern. they clearly don't actually cover it. https://godbolt.org/z/3zdqvbfxj This reverts commit 1709bb8c7395418236ec94fe3b9d91fed746452b.
2021-03-01[clang-tidy] Tweak misc-static-assert fix in c++17Nathan James1-5/+4
If C++17 mode is enabled and the assert doesn't have a string literal, we can emit a static assert with no message in favour of one with an empty message. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D97313
2021-02-13[clang-tidy] Simplify static assert checkStephen Kelly1-30/+19
Differential Revision: https://reviews.llvm.org/D96223
2020-10-15clang-{tools,unittests}: Stop using SourceManager::getBuffer, NFCDuncan P. N. Exon Smith1-1/+2
Update clang-tools-extra, clang/tools, clang/unittests to migrate from `SourceManager::getBuffer`, which returns an always dereferenceable `MemoryBuffer*`, to `getBufferOrNone` or `getBufferOrFake`, both of which return a `MemoryBufferRef`, depending on whether the call site was checking for validity of the buffer. No functionality change intended. Differential Revision: https://reviews.llvm.org/D89416
2020-03-10[NFC] use hasAnyOperatorName and hasAnyOverloadedOperatorName functions in ↵Nathan James1-1/+1
clang-tidy matchers
2020-03-03[clang-tidy] Change checks to use new isLanguageVersionSupported restrictionNathan James1-5/+0
Summary: Modifies all checks that are language version dependent to use `isLanguageVersionSupported` Reviewers: jdoerfert, lebedev.ri, aaron.ballman, gribozavr2, Eugene.Zelenko Reviewed By: gribozavr2 Subscribers: wuzish, nemanjai, xazax.hun, hiraditya, kbarton, steven_wu, dexonsmith, arphaman, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75340
2019-04-04Make SourceManager::createFileID(UnownedTag, ...) take a const ↵Nico Weber1-1/+1
llvm::MemoryBuffer* Requires making the llvm::MemoryBuffer* stored by SourceManager const, which in turn requires making the accessors for that return const llvm::MemoryBuffer*s and updating all call sites. The original motivation for this was to use it and fix the TODO in CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag version of createFileID, and since llvm::SourceMgr* hands out a const llvm::MemoryBuffer* this is required. I'm not sure if fixing the TODO this way actually works, but this seems like a good change on its own anyways. No intended behavior change. Differential Revision: https://reviews.llvm.org/D60247 llvm-svn: 357724
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-08-09Port getLocEnd -> getEndLocStephen Kelly1-1/+1
Subscribers: nemanjai, ioeric, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D50355 llvm-svn: 339401
2018-08-09Port getLocStart -> getBeginLocStephen Kelly1-2/+2
Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
2017-06-03[clang-tidy] Make misc-static-assert accept assert(!"msg")Florian Gross1-1/+3
Added negated string literals to the set of IsAlwaysFalse expressions to avoid flagging of assert(!"msg"). Differential Revision: http://reviews.llvm.org/D33827 llvm-svn: 304657
2016-08-01[clang-tidy] remove trailing whitespaces and retabKirill Bobyrev1-1/+1
llvm-svn: 277340
2016-05-31[ASTMatchers] Added ignoringParenImpCasts to has matchersPiotr Padlewski1-3/+4
has matcher changed behaviour, and now it matches "as is" and doesn't skip implicit and paren casts http://reviews.llvm.org/D20801 llvm-svn: 271289
2016-05-03[clang-tidy] Speedup misc-static-assert.Samuel Benzaquen1-3/+7
Summary: Speedup the misc-static-assert check by not use `stmt()` as the toplevel matcher. The framework runs a filter on the matchers before trying them on each node and uses the toplevel type for this. Using `stmt()` as the toplevel causes the matcher to be run on every `Stmt` node, even if the node doesn't match the desired types. This change speeds up clang-tidy by ~5% in a benchmark. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19877 llvm-svn: 268430
2016-05-02[clang-tidy] Cleaning namespaces to be more consistant across checkers.Etienne Bergeron1-0/+2
Summary: The goal of the patch is to bring checkers in their appropriate namespace. This path doesn't change any behavior. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19811 llvm-svn: 268264
2015-09-17Refactors AST matching code to use the new AST matcher names. This patch ↵Aaron Ballman1-2/+2
correlates to r247885 which performs the AST matcher rename in Clang. llvm-svn: 247886
2015-08-31Allow the static assert clang-tidy checker to run over C code.Aaron Ballman1-4/+3
llvm-svn: 246495
2015-08-31Using an early return as it is more clear; NFC.Aaron Ballman1-38/+38
llvm-svn: 246447
2015-08-28Disable clang-tidy misc checkers when not compiling in C++ mode. Many of the ↵Aaron Ballman1-30/+42
checkers do not require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct. llvm-svn: 246318
2015-05-29[clang-tidy] Fix for llvm.org/PR23355Szabolcs Sipos1-4/+7
misc-static-assert and misc-assert-side-effect will handle __builtin_expect based asserts correctly. llvm-svn: 238548
2015-05-23[clang-tidy] Fix for llvm.org/PR23572Szabolcs Sipos1-1/+3
misc-static-assert won't report asserts whose conditions contain calls to non constexpr functions. llvm-svn: 238098
2015-05-08[clang-tidy] Fix for llvm.org/PR23161Szabolcs Sipos1-1/+1
The misc-static-assert check will not warn on the followings: assert(NULL == "shouldn't warn"); assert(__null == "shouldn't warn"); Where NULL is a macro defined as __null. llvm-svn: 236812
2015-04-10[clang-tidy] Fix for llvm.org/PR23161Szabolcs Sipos1-8/+12
The misc-static-assert check will not warn on the followings: assert("Some message" == NULL); assert(NULL == "Some message"); llvm-svn: 234596
2015-03-15[clang-tidy] Fix false positives in the misc-static-assert check ↵Alexander Kornienko1-3/+11
http://llvm.org/PR22880 The misc-static-assert check will not warn on assert(false), assert(False), assert(FALSE); where false / False / FALSE are macros expanding to the false or 0 literals. Also added corresponding test cases. http://reviews.llvm.org/D8328 Patch by Szabolcs Sipos! llvm-svn: 232306
2015-03-09[clang-tidy] Fix assertion when a dependent expression is used in an assert.Alexander Kornienko1-1/+3
llvm-svn: 231620
2015-03-02[clang-tidy] Assert related checkersAlexander Kornienko1-0/+138
This patch contains two assert related checkers. These checkers are the part of those that is being open sourced by Ericsson (http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-December/040520.html). The checkers: AssertSideEffect: /// \brief Finds \c assert() with side effect. /// /// The conition of \c assert() is evaluated only in debug builds so a condition /// with side effect can cause different behaviour in debug / relesase builds. StaticAssert: /// \brief Replaces \c assert() with \c static_assert() if the condition is /// evaluatable at compile time. /// /// The condition of \c static_assert() is evaluated at compile time which is /// safer and more efficient. http://reviews.llvm.org/D7375 Patch by Szabolcs Sipos! llvm-svn: 230943