aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Analysis/fields.c
AgeCommit message (Collapse)AuthorFilesLines
2013-03-01[analyzer] Special-case bitfields when finding sub-region bindings.Jordan Rose1-0/+87
Previously we were assuming that we'd never ask for the sub-region bindings of a bitfield, since a bitfield cannot have subregions. However, unification of code paths has made that assumption invalid. While we could take advantage of this by just checking for the single possible binding, it's probably better to do the right thing, so that if/when we someday support unions we'll do the right thing there, too. This fixes a handful of false positives in analyzing LLVM. <rdar://problem/13325522> llvm-svn: 176388
2012-10-17[analyzer] Create a temporary region when accessing a struct rvalue.Jordan Rose1-1/+11
In C++, rvalues that need to have their address taken (for example, to be passed to a function by const reference) will be wrapped in a MaterializeTemporaryExpr, which lets CodeGen know to create a temporary region to store this value. However, MaterializeTemporaryExprs are /not/ created when a method is called on an rvalue struct, even though the 'this' pointer needs a valid value. CodeGen works around this by creating a temporary region anyway; now, so does the analyzer. The analyzer also does this when accessing a field of a struct rvalue. This is a little unfortunate, since the rest of the struct will soon be thrown away, but it does make things consistent with the rest of the analyzer. This allows us to bring back the assumption that all known 'this' values are Locs. This is a revised version of r164828-9, reverted in r164876-7. <rdar://problem/12137950> llvm-svn: 166120
2012-10-01Revert "[analyzer] Check that a member expr is valid even when the result is ↵Jordan Rose1-7/+0
an lvalue." The original intent of this commit was to catch potential null dereferences early, but it breaks the common "home-grown offsetof" idiom (PR13927): (((struct Foo *)0)->member - ((struct foo *)0)) As it turns out, this appears to be legal in C, per a footnote in C11 6.5.3.2: "Thus, &*E is equivalent to E (even if E is a null pointer)". In C++ this issue is still open: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#232 We'll just have to make sure we have good path notes in the future. This reverts r164441 / 9be016dcd1ca3986873a7b66bd4bc027309ceb59. llvm-svn: 164958
2012-09-29Revert "[analyzer] Create a temporary region for rvalue structs when ↵Jordan Rose1-10/+1
accessing fields" This reverts commit 6f61df3e7256413dcb99afb9673f4206e3c4992c. llvm-svn: 164877
2012-09-28[analyzer] Create a temporary region for rvalue structs when accessing fieldsJordan Rose1-1/+10
Struct rvalues are represented in the analyzer by CompoundVals, LazyCompoundVals, or plain ConjuredSymbols -- none of which have associated regions. If the entire structure is going to persist, this is not a problem -- either the rvalue will be assigned to an existing region, or a MaterializeTemporaryExpr will be present to create a temporary region. However, if we just need a field from the struct, we need to create the temporary region ourselves. This is inspired by the way CodeGen handles calls to temporaries; support for that in the analyzer is coming next. Part of <rdar://problem/12137950> llvm-svn: 164828
2012-09-22[analyzer] Check that a member expr is valid even when the result is an lvalue.Jordan Rose1-0/+7
We want to catch cases like this early, so that we can produce better diagnostics and path notes: Point *p = 0; int *px = &p->x; // should warn here *px = 1; llvm-svn: 164441
2012-08-24Fix analyzer tests.Ted Kremenek1-1/+1
llvm-svn: 162588
2011-08-03[analyzer] rename all experimental checker packages to have 'experimental' ↵Ted Kremenek1-1/+1
be the common root package. llvm-svn: 136835
2011-07-28Really remove FlatStoreManager and BasicStoreManager, this time from the ↵Ted Kremenek1-1/+0
driver. Also remove associated tests. Sorry for the messy commits; this is the result of a botched Git merge. llvm-svn: 136422
2011-02-28[analyzer] Remove '-analyzer-check-objc-mem' flag, the nominee for best ↵Argyrios Kyrtzidis1-2/+2
misnomer award. llvm-svn: 126676
2011-02-24[analyzer] Remove '-analyzer-experimental-internal-checks' flag, it doesn't ↵Argyrios Kyrtzidis1-2/+2
have any checkers associated with it anymore. llvm-svn: 126440
2011-02-03[analyzer] Fix a crash until we can handle temporary struct objects properly.Argyrios Kyrtzidis1-0/+10
llvm-svn: 124822
2010-02-05Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.Ted Kremenek1-2/+2
llvm-svn: 95348
2009-12-15Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar1-2/+2
- This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
2009-12-14Replace clang-cc with clang -cc1.Zhongxing Xu1-2/+2
llvm-svn: 91272
2009-11-29Normalize options to use '-FOO' instead of '--FOO'.Daniel Dunbar1-2/+2
llvm-svn: 90071
2009-11-13Add clang-cc option "--analyzer-experimental-internal-checks". ThisTed Kremenek1-2/+2
option enables new "internal" checks that will eventually be turned on by default but still require broader testing. llvm-svn: 88671
2009-11-08Eliminate &&s in tests.Daniel Dunbar1-1/+1
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious. llvm-svn: 86430
2009-07-29Remove 'StoreManager::OldCastRegion()', TypedViewRegion (which onlyTed Kremenek1-1/+0
OldCastRegion used), and the associated command line option '-analyzer-store=old-basic-cast'. llvm-svn: 77509
2009-07-10Switch BasicStoreManager to use the new CastRegion implementation by default,Ted Kremenek1-1/+1
and replace the 'clang-cc' option '-analyzer-store=basic-new-cast' with '-analyzer-store=basic-old-cast'. We'll keep the old CastRegion implementation around for a little while for regression testing. llvm-svn: 75209
2009-07-06Make 'BasicStoreManager' + 'NewCastRegion' testable from the command line ↵Ted Kremenek1-0/+1
using '-analyzer-store=basic-new-cast'. llvm-svn: 74865
2009-06-21Return UnknownVal for pointer arithmetic on struct fields.Zhongxing Xu1-0/+9
llvm-svn: 73851
2009-05-09When casting VarRegion, if the var type is aggregate type and the cast-toZhongxing Xu1-1/+0
pointee type is scalar type, create element region regardless with the sizes of types. llvm-svn: 71360
2009-05-06Make StoreManager::CastRegion() virtual and implement a new CastRegion() forZhongxing Xu1-0/+1
RegionStore. This CastRegion() performs casts according to the kind of the region being cast instead of the type that is cast to. llvm-svn: 71058
2009-05-04This test no longer fails.Ted Kremenek1-1/+0
llvm-svn: 70834
2009-05-01StoreManager::CastRegion:Ted Kremenek1-2/+2
- Don't layer TypedViewRegions on top of any region except SymbolicRegions and AllocaRegions. This follows from my offline discussion within Zhongxing about how TypedViewRegions really only represent memory getting re-appropriated for a new purpose. Fallout from this change: - Move test case from xfail_rdar_6440393.m to misc-ps-64.m (it now passes). - test/Analysis/fields.c now fails for region store (crash). Marking XFAIL. - test/Analysis/rdar-6441136-region.c now fails (only runs with region store). Marking XFAIL. Diagnosis: The analyzer now correctly identifies an early out-of-bounds memory access then the one flagged: rdar-6541136-region.c:17:3: warning: Load or store into an out-of-bound memory position. *p = 1; ^~ Changing the line: char *p = (void*) &wonky[1]; to char *p = (void*) &wonky[0]; (which should delay the buffer overrun) causes region store to crash, probably because it expects a TypedViewRegion. - test/Analysis/casts.c (region store) now fails (crash). Marking XFAIL. llvm-svn: 70565
2009-03-24Rename clang to clang-cc.Daniel Dunbar1-3/+3
Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
2009-02-17Static Analyzer driver/options (partial) cleanup:Ted Kremenek1-2/+2
- Move all analyzer options logic to AnalysisConsumer.cpp. - Unified specification of stores/constraints/output to be: -analyzer-output=... -analyzer-store=... -analyzer-constraints=... instead of -analyzer-range-constraints, -analyzer-store-basic, etc. - Updated drivers (ccc-analyzer, scan-builds, new ccc) to obey this new interface - Updated test cases to conform to new driver options llvm-svn: 64737
2009-01-22This test case now passes with RegionStore.Ted Kremenek1-1/+2
llvm-svn: 62798
2009-01-20Add -analyze action to run static analyzer, instead of inferring fromDaniel Dunbar1-2/+2
individual checker options. llvm-svn: 62634
2008-10-18Use "VisitLValue" when processing the base for "x.f" field accesses, and ↵Ted Kremenek1-0/+10
"Visit" when processing the base for "x->f" field accesses. llvm-svn: 57754