BBalazs Benics[analyzer] Improve loads from reinterpret-cast fields
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
Update the file headers across all of the LLVM projects in the monorepo 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 | 7 年前 | |
[analyzer] CheckerContext: Make the Preprocessor available Summary: This patch hooks the Preprocessor trough BugReporter to the CheckerContext so the checkers could look for macro definitions. Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D69731 | 6 年前 | |
[clang] Use value instead of getValue (NFC) | 3 年前 | |
[analyzer] Fix static_cast on pointer-to-member handling This commit fixes bug #48739. The bug was caused by the way static_casts on pointer-to-member caused the CXXBaseSpecifier list of a MemberToPointer to grow instead of shrink. The list is now grown by implicit casts and corresponding entries are removed by static_casts. No-op static_casts cause no effect. Reviewed By: vsavchenko Differential Revision: https://reviews.llvm.org/D95877 | 5 年前 | |
Update the file headers across all of the LLVM projects in the monorepo 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 | 7 年前 | |
[clang, clang-tools-extra] Use has_value instead of hasValue (NFC) | 3 年前 | |
Remove redundaunt virtual specifiers (NFC) Identified with tidy-modernize-use-override. | 3 年前 | |
[analyzer][NFC] Separate CallDescription from CallEvent CallDescriptions deserve its own translation unit. This patch simply moves the corresponding parts. Also includes the CallDescription.h where it's necessary. Reviewed By: martong, xazax.hun, Szelethus Differential Revision: https://reviews.llvm.org/D113587 | 4 年前 | |
[clang] Don't use Optional::getValue (NFC) | 3 年前 | |
[clang] Don't use Optional::getValue (NFC) | 3 年前 | |
[analyzer][NFC] Fix inconsistent references to checkers as "checks" Traditionally, clang-tidy uses the term check, and the analyzer uses checker, but in the very early years, this wasn't the case, and code originating from the early 2010's still incorrectly refer to checkers as checks. This patch attempts to hunt down most of these, aiming to refer to checkers as checkers, but preserve references to callback functions (like checkPreCall) as checks. Differential Revision: https://reviews.llvm.org/D67140 llvm-svn: 371760 | 6 年前 | |
[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions Depends on D125709 Reviewed By: martong Differential Revision: https://reviews.llvm.org/D127742 | 3 年前 | |
[analyzer] Model comparision methods of std::unique_ptr This patch handles all the comparision methods (defined via overloaded operators) on std::unique_ptr. These operators compare the underlying pointers, which is modelled by comparing the corresponding inner-pointer SVal. There is also a special case for comparing the same pointer. Differential Revision: https://reviews.llvm.org/D104616 | 4 年前 | |
[analyzer] Dump checker name if multiple checkers evaluate the same call Previously, if accidentally multiple checkers eval::Call-ed the same CallEvent, in debug builds the analyzer detected this and crashed with the message stating this. Unfortunately, the message did not state the offending checkers violating this invariant. This revision addresses this by printing a more descriptive message before aborting. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D112889 | 4 年前 | |
[clang] Fix modules build after D82585 Just getting the bots running again. See the D82585 for more info. | 5 年前 | |
[analyzer] Introduce common bug category "Unused code". This category is generic enough to hold a variety of checkers. Currently it contains the Dead Stores checker and an alpha unreachable code checker. Differential Revision: https://reviews.llvm.org/D98741 | 5 年前 | |
[analyzer][NFC] Add LLVM_UNLIKELY to assumeDualImpl Aligned with the measures we had in D124674, this condition seems to be unlikely. Nevertheless, I've made some new measurments with stats just for this, and data confirms this is indeed unlikely. Differential Revision: https://reviews.llvm.org/D127190 | 4 年前 | |
[clang][analyzer][ctu] Make CTU a two phase analysis This new CTU implementation is the natural extension of the normal single TU analysis. The approach consists of two analysis phases. During the first phase, we do a normal single TU analysis. During this phase, if we find a foreign function (that could be inlined from another TU) then we don’t inline that immediately, we rather mark that to be analysed later. When the first phase is finished then we start the second phase, the CTU phase. In this phase, we continue the analysis from that point (exploded node) which had been enqueued during the first phase. We gradually extend the exploded graph of the single TU analysis with the new node that was created by the inlining of the foreign function. We count the number of analysis steps of the first phase and we limit the second (ctu) phase with this number. This new implementation makes it convenient for the users to run the single-TU and the CTU analysis in one go, they don't need to run the two analysis separately. Thus, we name this new implementation as "onego" CTU. Discussion: https://discourse.llvm.org/t/rfc-much-faster-cross-translation-unit-ctu-analysis-implementation/61728 Differential Revision: https://reviews.llvm.org/D123773 | 4 年前 | |
[analyzer] DynamicSize: Rename 'size' to 'extent' | 5 年前 | |
[clang] Add a raw_ostream operator<< overload for QualType Under the hood this prints the same as QualType::getAsString() but cuts out the middle-man when that string is sent to another raw_ostream. Also cleaned up all the call sites where this occurs. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D123926 | 4 年前 | |
[clang] Don't use Optional::getValue (NFC) | 3 年前 | |
[analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer It turns out llvm::isa<> is variadic, and we could have used this at a lot of places. The following patterns: x && isa<T1>(x) || isa<T2>(x) ... Will be replaced by: isa_and_non_null<T1, T2, ...>(x) Sometimes it caused further simplifications, when it would cause even more code smell. Aside from this, keep in mind that within assert() or any macro functions, we need to wrap the isa<> expression within a parenthesis, due to the parsing of the comma. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D111982 | 4 年前 | |
[analyzer] Fix unused variable warning in release builds. NFC. | 3 年前 | |
[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions Depends on D125709 Reviewed By: martong Differential Revision: https://reviews.llvm.org/D127742 | 3 年前 | |
[clang][analyzer][NFC] Use value_or instead of ValueOr The latter is deprecated. | 3 年前 | |
[analyzer] ArrayInitLoopExpr with array of non-POD type This patch introduces the evaluation of ArrayInitLoopExpr in case of structured bindings and implicit copy/move constructor. The idea is to call the copy constructor for every element in the array. The parameter of the copy constructor is also manually selected, as it is not a part of the CFG. Differential Revision: https://reviews.llvm.org/D129496 | 3 年前 | |
[analyzer][NFC] Don't bind values to ObjCForCollectionStmt, replace it with a GDM trait Based on the discussion in D82598#2171312. Thanks @NoQ! D82598 is titled "Get rid of statement liveness, because such a thing doesn't exist", and indeed, expressions express a value, non-expression statements don't. if (a && get() || []{ return true; }()) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ has a value ~ has a value ~~~~~~~~~~ has a value ~~~~~~~~~~~~~~~~~~~~ has a value ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ doesn't have a value That is simple enough, so it would only make sense if we only assigned symbolic values to expressions in the static analyzer. Yet the interface checkers can access presents, among other strange things, the following two methods: ProgramState::BindExpr(const Stmt *S, const LocationContext *LCtx, SVal V, bool Invalidate=true) ProgramState::getSVal(const Stmt *S, const LocationContext *LCtx) So, what gives? Turns out, we make an exception for ReturnStmt (which we'll leave for another time) and ObjCForCollectionStmt. For any other loops, in order to know whether we should analyze another iteration, among other things, we evaluate it's condition. Which is a problem for ObjCForCollectionStmt, because it simply doesn't have one (CXXForRangeStmt has an implicit one!). In its absence, we assigned the actual statement with a concrete 1 or 0 to indicate whether there are any more iterations left. However, this is wildly incorrect, its just simply not true that the for statement has a value of 1 or 0, we can't calculate its liveness because that doesn't make any sense either, so this patch turns it into a GDM trait. Fixing this allows us to reinstate the assert removed in https://reviews.llvm.org/rG032b78a0762bee129f33e4255ada6d374aa70c71. Differential Revision: https://reviews.llvm.org/D86736 | 5 年前 | |
Update the file headers across all of the LLVM projects in the monorepo 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 | 7 年前 | |
[clang] Use llvm::reverse (NFC) | 4 年前 | |
[APInt] Remove all uses of zextOrSelf, sextOrSelf and truncOrSelf Most clients only used these methods because they wanted to be able to extend or truncate to the same bit width (which is a no-op). Now that the standard zext, sext and trunc allow this, there is no reason to use the OrSelf versions. The OrSelf versions additionally have the strange behaviour of allowing extending to a *smaller* width, or truncating to a *larger* width, which are also treated as no-ops. A small amount of client code relied on this (ConstantRange::castOp and MicrosoftCXXNameMangler::mangleNumber) and needed rewriting. Differential Revision: https://reviews.llvm.org/D125557 | 4 年前 | |
[analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer It turns out llvm::isa<> is variadic, and we could have used this at a lot of places. The following patterns: x && isa<T1>(x) || isa<T2>(x) ... Will be replaced by: isa_and_non_null<T1, T2, ...>(x) Sometimes it caused further simplifications, when it would cause even more code smell. Aside from this, keep in mind that within assert() or any macro functions, we need to wrap the isa<> expression within a parenthesis, due to the parsing of the comma. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D111982 | 4 年前 | |
[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays Some code [0] consider that trailing arrays are flexible, whatever their size. Support for these legacy code has been introduced in f8f632498307d22e10fab0704548b270b15f1e1e but it prevents evaluation of __builtin_object_size and __builtin_dynamic_object_size in some legit cases. Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is desirable. n = 0: current behavior, any trailing array member is a flexible array. The default. n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member n = 2: any trailing array member of undefined or 0 size is a flexible array member This takes into account two specificities of clang: array bounds as macro id disqualify FAM, as well as non standard layout. Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions | 3 年前 | |
[clang] Use value instead of getValue (NFC) | 3 年前 | |
[analyzer] print() JSONify: Environment implementation Summary: - Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D62081 llvm-svn: 361976 | 6 年前 | |
[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions Depends on D125709 Reviewed By: martong Differential Revision: https://reviews.llvm.org/D127742 | 3 年前 | |
[analyzer] Add new function clang_analyzer_value to ExprInspectionChecker Summary: Introduce a new function 'clang_analyzer_value'. It emits a report that in turn prints a RangeSet or APSInt associated with SVal. If there is no associated value, prints "n/a". | 3 年前 | |
[analyzer] Fix crash in RangedConstraintManager.cpp This change fixes a crash in RangedConstraintManager.cpp:assumeSym due to an unhandled BO_Div case. clang: <root>clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:51: virtual clang::ento::ProgramStateRef clang::ento::RangedConstraintManager::assumeSym(clang::ento::ProgramStateRef, clang::ento::SymbolRef, bool): Assertion `BinaryOperator::isComparisonOp(Op)' failed. Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D122277 | 4 年前 | |
[analyzer] Improve loads from reinterpret-cast fields Consider this example: lang=C++ struct header { unsigned a : 1; unsigned b : 1; }; struct parse_t { unsigned bits0 : 1; unsigned bits2 : 2; // <-- header unsigned bits4 : 4; }; int parse(parse_t *p) { unsigned copy = p->bits2; clang_analyzer_dump(copy); // expected-warning@-1 {{reg_$1<unsigned int SymRegion{reg_$0<struct Bug_55934::parse_t * p>}.bits2>}} header *bits = (header *)© clang_analyzer_dump(bits->b); // <--- Was UndefinedVal previously. // expected-warning@-1 {{derived_$2{reg_$1<unsigned int SymRegion{reg_$0<struct Bug_55934::parse_t * p>}.bits2>,Element{copy,0 S64b,struct Bug_55934::header}.b}}} return bits->b; // no-warning: it's not UndefinedVal } bits->b should have the same content as the second bit of p->bits2 (assuming that the bitfields are in spelling order). --- The Store has the correct bindings. The problem is with the load of bits->b. It will eventually reach RegionStoreManager::getBindingForField() with Element{copy,0 S64b,struct header}.b, which is a FieldRegion. It did not find any direct bindings, so the getBindingForFieldOrElementCommon() gets called. That won't find any bindings, but it sees that the variable is on the //stack//, thus it must be an uninitialized local variable; thus it returns UndefinedVal. Instead of doing this, it should have created a //derived symbol// representing the slice of the region corresponding to the member. So, if the value of copy is reg1, then the value of bits->b should be derived{reg1, elem{copy,0, header}.b}. Actually, the getBindingForElement() already does exactly this for reinterpret-casts, so I decided to hoist that and reuse the logic. Fixes #55934 Reviewed By: martong Differential Revision: https://reviews.llvm.org/D128535 | 3 年前 | |
[llvm][clang][NFC] updates inline licence info Some files still contained the old University of Illinois Open Source Licence header. This patch replaces that with the Apache 2 with LLVM Exception licence. Differential Revision: https://reviews.llvm.org/D107528 | 4 年前 | |
[analyzer][NFC] Use SValVisitor instead of explicit helper functions Summary: Get rid of explicit function splitting in favor of specifically designed Visitor. Move logic from a family of evalCastKind and evalCastSubKind helper functions to SValVisitor. Differential Revision: https://reviews.llvm.org/D130029 | 3 年前 | |
[analyzer] Add new function clang_analyzer_value to ExprInspectionChecker Summary: Introduce a new function 'clang_analyzer_value'. It emits a report that in turn prints a RangeSet or APSInt associated with SVal. If there is no associated value, prints "n/a". | 3 年前 | |
[clang] Convert for_each to range-based for loops (NFC) | 4 年前 | |
[analyzer] Remove NotifyAssumeClients Depends on D126560. Differential Revision: https://reviews.llvm.org/D126878 | 4 年前 | |
[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions Depends on D125709 Reviewed By: martong Differential Revision: https://reviews.llvm.org/D127742 | 3 年前 | |
[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions Depends on D125709 Reviewed By: martong Differential Revision: https://reviews.llvm.org/D127742 | 3 年前 | |
[analyzer] Add UnarySymExpr This patch adds a new descendant to the SymExpr hierarchy. This way, now we can assign constraints to symbolic unary expressions. Only the unary minus and bitwise negation are handled. Differential Revision: https://reviews.llvm.org/D125318 | 4 年前 | |
Fix a typo (occured => occurred) Reported: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1005195 | 4 年前 | |
Use llvm::less_second (NFC) | 4 年前 |