Commit Graph

24806 Commits

Author SHA1 Message Date
Jordy Rose 722f558f07 Model the effects of strcpy() and stpcpy() in CStringChecker. Other changes:
- Fix memcpy() and friends to actually invalidate the destination buffer.
- Emit a different message for out-of-bounds buffer accesses if the buffer is being written to.
- When conjuring symbols, let ValueManager figure out the type.

llvm-svn: 111120
2010-08-16 07:51:42 +00:00
Charles Davis ebab1ed5d3 Error out if reinterpret_casting between member pointers of two different
sizes.

llvm-svn: 111119
2010-08-16 05:30:44 +00:00
Charles Davis 2d3694297d Err on incomplete class types in member pointers when compiling for the
Microsoft C++ ABI, for now.

llvm-svn: 111118
2010-08-16 04:01:50 +00:00
Charles Davis 53c59df2f7 Implement support for member pointers under the Microsoft C++ ABI in the
AST library.

This also adds infrastructure for supporting multiple C++ ABIs in the AST.

llvm-svn: 111117
2010-08-16 03:33:14 +00:00
Jordy Rose df28e8ec41 - Allow making ElementRegions with complex offsets (expressions or symbols) for the purpose of bounds-checking.
- Rewrite GRState::AssumeInBound to actually do that checking, and to use the normal constraint path.
- Remove ConstraintManager::AssumeInBound.
- Teach RegionStore and FlatStore to ignore those regions for now.

llvm-svn: 111116
2010-08-16 01:15:17 +00:00
David Chisnall 589a494352 Pass some things to the linker that gcc passes. -r is the only one of these that I'm sure about, but the others seem to be listed on FreeBSD by gcc -dumpspecs, so I hope they're right. Apparently -r is also not passed on GNU/Linux (and should be), but I can't see where the toolchain definition for this platform live.
llvm-svn: 111114
2010-08-15 22:58:12 +00:00
Jordy Rose d2b777a409 Move GRState's bind* methods out of its header file -- they're too big for inlining now.
llvm-svn: 111113
2010-08-15 22:19:33 +00:00
Argyrios Kyrtzidis b482eb8b28 Call the base class in StmtProfiler::VisitOverloadExpr.
llvm-svn: 111110
2010-08-15 20:53:20 +00:00
Benjamin Kramer 340045b204 Open AST/PCH files in binary mode.
llvm-svn: 111106
2010-08-15 16:54:31 +00:00
Nick Lewycky 53f1042dc1 Make the FixItOptions object required instead of optional.
llvm-svn: 111105
2010-08-15 16:47:39 +00:00
Zhongxing Xu ee770d40fd StoreManager::RemoveDeadBindings() can take a Store instead of an entire GRState now.
llvm-svn: 111103
2010-08-15 12:45:09 +00:00
Argyrios Kyrtzidis 499e6e49e7 Remove ATTRIBUTE_UNUSED from the common pattern of disallowing copying.
llvm-svn: 111101
2010-08-15 10:17:39 +00:00
Argyrios Kyrtzidis 04c7fa09e4 Don't warn for the common pattern of disallowing copying:
class S {
  S(const S&); // DO NOT IMPLEMENT
  void operator=(const S&); // DO NOT IMPLEMENT
};

llvm-svn: 111100
2010-08-15 10:17:33 +00:00
Zhongxing Xu 0ba9fd6c47 Remove redundant method.
llvm-svn: 111099
2010-08-15 10:08:38 +00:00
Zhongxing Xu bce831f7e0 Implement MallocChecker::EvalDeadSymbols() with the new API. This time we
iterate over symbols being tracked, instead of symbols being dead.

llvm-svn: 111097
2010-08-15 08:19:57 +00:00
Douglas Gregor 3998219789 Extend the code-completion caching infrastructure to include global
declarations (in addition to macros). Each kind of declaration maps to
a certain set of completion contexts, and the ASTUnit completion logic
introduces the completion strings for those declarations if the actual
code-completion occurs in one of the contexts where it matters. 

There are a few new code-completion-context kinds. Without these,
certain completions (e.g., after "using namespace") would need to
suppress all global completions, which would be unfortunate.

Note that we don't get the priorities right for global completions,
because we don't have enough type information. We'll need a way to
compare types in an ASTContext-agnostic way before this can be
implemented.

llvm-svn: 111093
2010-08-15 06:18:01 +00:00
Eli Friedman f8d9817f4b Use Enumerators.data() instead of &Enumerators[0] to fix a potential
assertion failure.

llvm-svn: 111092
2010-08-15 02:27:09 +00:00
Argyrios Kyrtzidis 1cec2cc798 Remove dead code, caught by unused function warnings.
llvm-svn: 111091
2010-08-15 01:15:58 +00:00
Argyrios Kyrtzidis c99bab034c DependentTypeOfExprType and DependentDecltypeType are not seen by client code.
llvm-svn: 111090
2010-08-15 01:15:44 +00:00
Argyrios Kyrtzidis f4505457f8 Call the correct base class in StmtProfiler::VisitUnresolvedLookupExpr.
llvm-svn: 111089
2010-08-15 01:15:38 +00:00
Argyrios Kyrtzidis 3080553b10 Some refactoring on StmtPrinter to avoid unused function warnings.
llvm-svn: 111088
2010-08-15 01:15:33 +00:00
Argyrios Kyrtzidis 0a33cb62a6 Add ATTRIBUTE_UNUSED to methods not supposed to be used.
llvm-svn: 111087
2010-08-15 01:15:27 +00:00
Argyrios Kyrtzidis 1b30d9c0f0 Commit improved version of 111026 & 111027.
Unused warnings for functions:
-static functions
-functions in anonymous namespace
-class methods in anonymous namespace
-class method specializations in anonymous namespace
-function specializations in anonymous namespace

Unused warnings for variables:
-static variables
-variables in anonymous namespace
-static data members in anonymous namespace
-static data members specializations in anonymous namespace

Reveals lots of opportunities for dead code removal in llvm codebase that will
interest my esteemed colleagues.

llvm-svn: 111086
2010-08-15 01:15:20 +00:00
Eli Friedman 1bb53d9cd6 Explicitly handle every case in the switch in RTTIBuilder::BuildTypeInfo.
llvm-svn: 111085
2010-08-15 00:24:31 +00:00
Nick Lewycky 0db53e433e Remember that FixItOptions* is optional and don't crash when it's not provided.
llvm-svn: 111084
2010-08-14 23:03:19 +00:00
Jordy Rose 2a2e21c902 Update CStringChecker to take advantage of the new metadata symbols and region change callback. Now does basic tracking of string length for general regions. Currently this is still only used for modeling strlen().
llvm-svn: 111081
2010-08-14 21:02:52 +00:00
Eli Friedman 9571953f36 PR7884: Fix the implementations of __real__ and __imag__ on real floats.
llvm-svn: 111080
2010-08-14 20:52:13 +00:00
Jordy Rose a797475712 Add a test for alloca region extents.
llvm-svn: 111079
2010-08-14 20:46:10 +00:00
Jordy Rose ac0ab20e3b Add a callback for when region changes occur. Still somewhat of a work-in-progress, but working! Effect on clients: all changes to a store now go through GRState.
llvm-svn: 111078
2010-08-14 20:44:32 +00:00
Jordy Rose 1f3a553b9b Another metadata symbol change (missed a file)
llvm-svn: 111077
2010-08-14 20:22:12 +00:00
Jordy Rose 7fa9bf05bc Add a new metadata symbol type for checkers to use. Metadata symbols must be associated with a region and will be collected if the region dies or its checker fails to mark it as in use.
llvm-svn: 111076
2010-08-14 20:18:45 +00:00
John McCall 32427785c0 More cleanup enabling.
llvm-svn: 111070
2010-08-14 07:46:19 +00:00
Eli Friedman df2392572e PR3344: Downgrade "too many braces around scalar initializer" to a warning.
llvm-svn: 111067
2010-08-14 03:14:53 +00:00
Ted Kremenek aa01481d78 Always recurse into sub-cursors when annotating tokens, as this information is used for annotating macro arguments. This finishes up <rdar://problem/8044584>.
llvm-svn: 111066
2010-08-14 02:50:46 +00:00
Daniel Dunbar 26f898f64e Driver: Increase flags to hold all necessary bits.
llvm-svn: 111065
2010-08-14 02:19:45 +00:00
Ted Kremenek f4ade0ae3f As a heuristic, annotate tokens (via clang_annotateTokens) that are the arguments of a macro instantiation using the closest cursor with the same spelling location. Because macro arguments can get token pasted in any arbitrary order, we use the annotation map to paper over the token -> cursor annotations during our post-processing stage. This fixes most of <rdar://problem/8044584>, but still doesn't work for assert().
llvm-svn: 111062
2010-08-14 01:14:06 +00:00
Douglas Gregor b14904c4a8 Implement caching of code-completion results for macro definitions
when the CXTranslationUnit_CacheCompletionResults option is given to
clang_parseTranslationUnit(). Essentially, we compute code-completion
results for macro definitions after we have parsed the file, then
store an ASTContext-agnostic version of those results (completion
string, cursor kind, priority, and active contexts) in the
ASTUnit. When performing code completion in that ASTUnit, we splice 
the macro definition results into the results provided by the actual
code-completion (which has had macros turned off) before libclang gets
those results. We use completion context information to only splice in
those results that make sense for that context.

With a completion involving all of the macros from Cocoa.h and a few other
system libraries (totally ~8500 macro definitions) living in a
precompiled header, we get about a 9% performance improvement from
code completion, since we no longer have to deserialize all of the
macro definitions from the precompiled header. 

Note that macro definitions are merely the canary; the cache is
designed to also support other top-level declarations, which should be
a bigger performance win. That optimization will be next.

Note also that there is no mechanism for determining when to throw
away the cache and recompute its contents.

llvm-svn: 111051
2010-08-13 22:48:40 +00:00
John McCall 612942d65f Sketch out a framework for delaying the activation of a cleanup.
Not yet complete or used.

llvm-svn: 111044
2010-08-13 21:20:51 +00:00
Argyrios Kyrtzidis 98703d3883 Revert 111026 & 111027, build breakage.
llvm-svn: 111036
2010-08-13 20:13:06 +00:00
Argyrios Kyrtzidis 1063a71e43 The unused warnings extravaganza continues. Warn for:
-static variables
-variables in anonymous namespace (fixes rdar://7794535)
-static data members in anonymous namespace
-static data members specializations in anonymous namespace

llvm-svn: 111027
2010-08-13 18:42:40 +00:00
Argyrios Kyrtzidis 540bc01f50 Expand the unused warnings for functions. Warn for:
-static function declarations
-functions in anonymous namespace
-class methods in anonymous namespace
-class method specializations in anonymous namespace
-function specializations in anonymous namespace

llvm-svn: 111026
2010-08-13 18:42:29 +00:00
Argyrios Kyrtzidis 35672e7852 Change Sema's UnusedStaticFuncs to UnusedFileScopedDecls to allow also keeping track of unused file scoped variables.
This is only preparation, currently only static function definitions are tracked, as before.

llvm-svn: 111025
2010-08-13 18:42:17 +00:00
Fariborz Jahanian 18d90a97df When issuing warning for future conflict resolution,
(nonfragile-abi2), do not consider 'ivar' access
in class methods. Also, improve on diagnostics.
Radar 8304561.

llvm-svn: 111023
2010-08-13 18:09:39 +00:00
Nick Lewycky 078a5e26fd Add a new cc1 option -fix-what-you-can which when combined with the fix-it mode
will apply all fixes even when there were other errors in the file.

llvm-svn: 111020
2010-08-13 17:31:00 +00:00
Douglas Gregor 6bb92ecc0a Add an options parameter to clang_saveTranslationUnit, because we'll want it later
llvm-svn: 111016
2010-08-13 15:35:05 +00:00
Abramo Bagnara c852cef1f2 Fixed NNS insertion in MemberPointerType.
llvm-svn: 111013
2010-08-13 12:56:25 +00:00
John McCall 8823c65abd Properly give unique-external linkage to members of member templates
instantiated with unique-external parameters.

llvm-svn: 111012
2010-08-13 08:35:10 +00:00
John McCall 249eed98bc Fix the help text on -Wwrite-strings.
llvm-svn: 111011
2010-08-13 07:05:45 +00:00
John McCall bd8062dff1 Work around a crash when checking access to injected class names
qua templates.  The current fix suppresses the access check entirely
in this case;  to do better, we'd need to be able to say that a
particular lookup result came from a particular injected class name,
which is not easy to do with the current representation of LookupResult.
This is on my known-problems list.

llvm-svn: 111009
2010-08-13 07:02:08 +00:00
Douglas Gregor e938668003 Implement clang_saveTranslationUnit(), which saves a translation unit
into a PCH/AST file.

llvm-svn: 111006
2010-08-13 05:36:37 +00:00