Zhongxing Xu
b0a05f7ca1
Add a checker for CWE-467: Use of sizeof() on a Pointer Type.
...
llvm-svn: 86464
2009-11-08 13:10:34 +00:00
Alexis Hunt
6f3de50ca7
Test commit - minor terminology change to my recent patch suggested by John McCall
...
llvm-svn: 86442
2009-11-08 07:46:34 +00:00
Fariborz Jahanian
d7aa9d8a63
Patch to gives an error that at least points users in the direction of the error, rather
...
than an error about incompatible types. Patch by Sean Hunt.
llvm-svn: 86402
2009-11-07 20:20:40 +00:00
John McCall
b61e9d03c1
Support -Wshorten-64-to-32 for integer types only, which seems to satisfy the
...
core requirements. Fixes rdar://problem/6389954
llvm-svn: 86364
2009-11-07 09:03:53 +00:00
Ted Kremenek
975a119f31
Use SaveAndRestore to simplify logic in LiveVariables::runOnAllBlocks(). Patch by Kovarththanan Rajaratnam!
...
llvm-svn: 86343
2009-11-07 05:57:35 +00:00
Daniel Dunbar
08d5669b01
Add HeaderSearchOptions class, for packaging the information needed to
...
initialize HeaderSearch. Not used yet.
llvm-svn: 86338
2009-11-07 04:20:50 +00:00
Daniel Dunbar
ec87991c8f
Lift InitHeaderSearch::AddEnvVarPaths logic higher.
...
llvm-svn: 86337
2009-11-07 04:20:39 +00:00
Daniel Dunbar
6dc9638153
Formatting fixes.
...
llvm-svn: 86336
2009-11-07 04:20:25 +00:00
Daniel Dunbar
00f8a397c6
Rename PreprocessorInitOptions to PreprocessorOptions for consistency, and fix
...
filenames.
Also, move InitializePreprocessor to Utils.h.
llvm-svn: 86335
2009-11-07 04:20:15 +00:00
Ted Kremenek
ae3361de2d
Remove Checker::CheckType() (and instead using CheckerVisitor::PreVisitDeclStmt()), and refactor VLASizeChecker to have only one Checker subclass (not two) and to not use the node builders directly (and instead use the newer CheckerContext).
...
llvm-svn: 86329
2009-11-07 03:56:57 +00:00
John McCall
fceb64bd04
Implement -Wconversion. Off by default, in the non-gcc group. There's
...
significant work left to be done to reduce the false-positive rate here.
llvm-svn: 86326
2009-11-07 03:30:10 +00:00
Steve Naroff
eae650366d
Add basic code completion support for ObjC messages.
...
Still a work in progress...
llvm-svn: 86323
2009-11-07 02:08:14 +00:00
Douglas Gregor
9eb7701dff
Various improvements to Clang's code-completion infrastructure:
...
- Introduce more code-completion string "chunk" kinds that describe
symbols, the actual text that the user is expected to type, etc.
- Make the generation of macro results optional, since it can be
slow
- Make code-completion accessible through the C API, marshalling the
code-completion results through a temporary file (ick) to maintain
process separation.
The last doesn't have tests yet.
llvm-svn: 86306
2009-11-07 00:00:49 +00:00
Ted Kremenek
795c611cfa
Make the VLASizeChecker implementation private, and its creation only known to GRExprEngineInternalChecks.cpp.
...
llvm-svn: 86292
2009-11-06 21:51:50 +00:00
Ted Kremenek
53a70c055d
Make the implementation of DivZeroChecker private.
...
llvm-svn: 86288
2009-11-06 20:47:51 +00:00
John McCall
e2c91e6b26
Don't warn -Wsign-compare if we're in an unevaluated context, and fixed
...
a typo pointed out by Fariborz.
llvm-svn: 86265
2009-11-06 18:16:06 +00:00
Chris Lattner
45540e91d1
add some const qualifiers, patch by Kovarththanan Rajaratnam!
...
llvm-svn: 86260
2009-11-06 18:01:14 +00:00
Zhongxing Xu
167bce9cf1
Add a checker for CWE-466: Return of Pointer Value Outside of Expected Range.
...
llvm-svn: 86252
2009-11-06 13:30:44 +00:00
John McCall
d59dd65fa4
Create a warning group "non-gcc" for diagnostics which are not enabled
...
by default in GCC. Users who want to emulate gcc's warning behavior
exactly should be able to use CC="clang -Wno-non-gcc"; this should help
projects to transition.
llvm-svn: 86241
2009-11-06 07:53:21 +00:00
Douglas Gregor
d82ae38d53
Rework the fix-it hint for code like
...
get_origin->x
where get_origin is actually a function and the user has forgotten the
parentheses. Instead of giving a lame note for the fix-it, give a
full-fledge error, early, then build the call expression to try to
recover.
llvm-svn: 86238
2009-11-06 06:30:47 +00:00
Douglas Gregor
6af6c3ee56
Turn off -Wsign-compare warnings by default
...
llvm-svn: 86233
2009-11-06 05:24:12 +00:00
Ted Kremenek
bee01e5b61
static analyzer: refactor checking logic for returning the address of a stack variable or a garbage
...
value into their own respective subclasses of Checker (and put them in .cpp files where their
implementation details are hidden from GRExprEngine).
llvm-svn: 86215
2009-11-06 02:24:13 +00:00
Ted Kremenek
2980b975ee
Minor cleanup: use BuiltinBug (which will soon be renamed) for DeferenceChecker and friends so that they always report the same bug type.
...
llvm-svn: 86208
2009-11-06 00:44:32 +00:00
John Thompson
864bf7562f
Eliminate tabls
...
llvm-svn: 86183
2009-11-05 22:03:02 +00:00
Chris Lattner
e4a8c64731
clean up integer preprocessor type definitions, patch by Ken Dyck!
...
llvm-svn: 86177
2009-11-05 21:21:32 +00:00
John Thompson
ed4e2950bc
Adding -fshort-wchar option.
...
llvm-svn: 86167
2009-11-05 20:14:16 +00:00
Sebastian Redl
1060067dd1
Don't allow definitions of array variables without some size information in C++. Fixed PR5401
...
llvm-svn: 86165
2009-11-05 19:47:47 +00:00
Fariborz Jahanian
c5a044e057
Adds doxygen comment for HasSideEffects method.
...
llvm-svn: 86150
2009-11-05 18:47:38 +00:00
Fariborz Jahanian
4127b8ef97
Added support for static variables which require
...
initialization before main. Fixes pr5396.
llvm-svn: 86145
2009-11-05 18:03:03 +00:00
Douglas Gregor
13a2c03801
Eliminate some false positives due to a thinko in the "'blah' is
...
always zero in this context" warning logic. Also, make the diagnostic
itself more precise when referring to pointer values ("NULL" vs. "zero").
llvm-svn: 86143
2009-11-05 17:49:26 +00:00
Sebastian Redl
39c2a8bbbc
Parse C++0x constexpr. Test case follows when this does something useful.
...
llvm-svn: 86135
2009-11-05 15:47:02 +00:00
John McCall
1fa36b7cab
Implement the conditional-operator part of -Wsign-compare. Turn
...
DiagnoseSignCompare into Sema::CheckSignCompare and call it from more places.
Add some enumerator tests. These seem to expose some oddities in the
types we're converting C++ enumerators to; in particular, they're converting
to unsigned before int, which seems to contradict 4.5 [conv.prom] p2.
Note to self: stop baiting Doug in my commit messages.
llvm-svn: 86128
2009-11-05 09:23:39 +00:00
Ted Kremenek
c92ff053e9
Tweak wording and classifications of analyzer diagnostics.
...
llvm-svn: 86127
2009-11-05 08:30:12 +00:00
Daniel Dunbar
0231895ce6
Replace DiagnosticClient::setLangOptions with {Begin,End}SourceFile, and clarify
...
invariants (diagnostics with source informations must occur between
{Begin,End}SourceFile).
llvm-svn: 86113
2009-11-05 02:42:12 +00:00
Daniel Dunbar
b5f2025b77
Convert CreateAnalysisConsumer and friends to just take a const Preprocessor&, and simplify.
...
llvm-svn: 86112
2009-11-05 02:41:58 +00:00
Daniel Dunbar
78eaff4c13
Remove unused SetPreprocessor method.
...
llvm-svn: 86111
2009-11-05 02:41:44 +00:00
Ted Kremenek
165f5b7421
AnalysisManager: Don't rely on PathDiagnosicClients flushing their diagnostics when they are destroyed.
...
llvm-svn: 86110
2009-11-05 02:17:33 +00:00
Ted Kremenek
5e86044ec4
Acting on Daniel's nagging, remove PathDiagnosticClientFactory() and
...
migrate work in the destructors of PathDiagnosticClients from their
destructors to FlushReports(). The destructors now currently call
FlushReports(); this will be fixed in a subsequent patch.
llvm-svn: 86108
2009-11-05 02:09:23 +00:00
Daniel Dunbar
a2ff3b4819
Make html::{SyntaxHighlight,HighlightMacros} take a const Preprocessor.
...
This is conceptually correct, but adds a huge hack to HighlightMacros which is
in fact doing all sorts of mutation to the Preprocessor. See FIXME.
Chris, please review.
llvm-svn: 86107
2009-11-05 01:54:02 +00:00
Daniel Dunbar
07dcd8b9d8
Make LookUpIdentifierInfo const. This makes the Identifiers table mutable and is
...
a little fuzzy, but conceptually it's just uniquing the identifier.
Chris, please review. I debated splitting into const/non-const versions where
the const one propogated constness to the resulting IdentifierInfo*.
llvm-svn: 86106
2009-11-05 01:53:52 +00:00
Daniel Dunbar
f539bfeb4d
StringRefize Preprocessor::getIdentifierInfo.
...
llvm-svn: 86105
2009-11-05 01:53:39 +00:00
Ted Kremenek
209e31b883
Modify GRExprEngine::EvalBind() to take both a "store expression" and
...
an "assign expression", representing the expressions where the value
binding occurs and the assignment takes place respectively. These are
largely syntactic clues for better error reporting.
llvm-svn: 86084
2009-11-05 00:42:23 +00:00
John McCall
644a4181c9
Implement -Wsign-compare, or at least the actual comparison part of it.
...
Conditional operands are next.
Fixes part of rdar://problem/7289584.
llvm-svn: 86083
2009-11-05 00:40:04 +00:00
Daniel Dunbar
d0ba0e6108
Kill PreprocessorFactory, which was both morally repugnant and totally unused.
...
llvm-svn: 86076
2009-11-04 23:56:25 +00:00
Daniel Dunbar
14f00d2e10
Tweak formatting.
...
llvm-svn: 86070
2009-11-04 23:41:27 +00:00
John McCall
e22a04aba9
Diagnose using a field to initialize itself. Patch by Brandon Pearcy!
...
llvm-svn: 86061
2009-11-04 23:02:40 +00:00
Chris Lattner
b689d0c95e
ignore two new -W flags, patch by Tom Jablin!
...
llvm-svn: 86059
2009-11-04 22:47:56 +00:00
Daniel Dunbar
181aaee165
InitializePreprocessor cannot fail.
...
llvm-svn: 86048
2009-11-04 21:13:15 +00:00
Daniel Dunbar
b27ec09a7e
Move -undef flag into PreprocessorInitOptions
...
llvm-svn: 86047
2009-11-04 21:13:02 +00:00
Douglas Gregor
e7b5f81ba5
Eliminate the "old" ways of parsing operator-function-ids and
...
conversion-function-ids; all clients have moved on to
ParseUnqualifiedId.
llvm-svn: 86028
2009-11-04 16:32:12 +00:00
Douglas Gregor
220f4277bd
Switch parsing of using declarations over to ParseUnqualifiedId.
...
llvm-svn: 86027
2009-11-04 16:30:06 +00:00
John McCall
4c98fd8953
Preserve type source information in sizeof/alignof expressions, and pass it
...
through to indexing.
llvm-svn: 86018
2009-11-04 07:28:41 +00:00
Daniel Dunbar
a9be734c24
Fix commento.
...
llvm-svn: 86016
2009-11-04 06:57:08 +00:00
Daniel Dunbar
c2e6a4709e
Factor out a diagnostic options class.
...
llvm-svn: 86010
2009-11-04 06:24:30 +00:00
Ted Kremenek
ef910047b2
Catch uses of undefined values when they are used in assignment, thus catching such bugs closer to the source.
...
llvm-svn: 86003
2009-11-04 04:24:16 +00:00
Ted Kremenek
9db38f6f83
Add mising #ifdef guards.
...
llvm-svn: 86002
2009-11-04 04:03:43 +00:00
John McCall
4976fd4ea9
Diagnose the use of 'fastcall' on functions without prototypes or with
...
varargs prototypes.
llvm-svn: 86001
2009-11-04 03:36:09 +00:00
John McCall
9eff4e60ae
Diagnose __builtin_offsetof on incomplete types. Fixes
...
rdar://problem/7222956
llvm-svn: 85999
2009-11-04 03:03:43 +00:00
John McCall
28a6aeab7e
Change our basic strategy for avoiding deprecation warnings when the decl use
...
appears in a deprecated context. In the new strategy, we emit the warnings
as usual unless we're currently parsing a declaration, where "declaration" is
restricted to mean a decl group or a few special cases in Objective C. If
we *are* parsing a declaration, we queue up the deprecation warnings until
the declaration has been completely parsed, and then emit them only if the
decl is not deprecated.
We also standardize the bookkeeping for deprecation so as to avoid special cases.
llvm-svn: 85998
2009-11-04 02:18:39 +00:00
Zhongxing Xu
259d46407a
Merge ZeroSizedVLAChecker and UndefSizedVLAChecker.
...
llvm-svn: 85996
2009-11-04 01:43:07 +00:00
Tanya Lattner
f9d41df093
Merge constant array and structures. This will create a global variables for arrays and structs that are constant and their initializer is constant. It is on by default but can be disable with the flag -fno-merge-all-constants.
...
llvm-svn: 85991
2009-11-04 01:18:09 +00:00
Douglas Gregor
71395fa1d5
Implement support for parsing dependent template-ids that refer to
...
overloaded operators, e.g.,
p->template operator+<T>()
llvm-svn: 85989
2009-11-04 00:56:37 +00:00
Daniel Dunbar
caa00adafd
Use unsigned char instead of unsigned : 8 to make the optimizer happier.
...
llvm-svn: 85985
2009-11-04 00:34:40 +00:00
Ted Kremenek
b006b82daf
Refactor StoreManager::BindDecl() to take a VarRegion* instead of a VarDecl*, and modify GRExprEngine::EvalBind() to handle decl initialization as well. This paves the way for adding "checker" visitation in EvalBind().
...
llvm-svn: 85983
2009-11-04 00:09:15 +00:00
Ted Kremenek
0fbbb0877d
Change GRTransferFuncs::RegisterChecks() to take a GRExprEngine& instead of a BugReporter&. This paves the way for pulling some of the retain/release checker into a "Checker" class.
...
llvm-svn: 85971
2009-11-03 23:30:34 +00:00
Mike Stump
53f9ded62b
Refine volatile handling, specifically, we must have the canonical
...
type to look at the volatile specifier. I found these all from just
hand auditing the code.
llvm-svn: 85967
2009-11-03 23:25:48 +00:00
Douglas Gregor
3cf81317e4
Parsing and semantic analysis for template-ids that name overloaded
...
operators, e.g.,
operator+<int>
which now works in declarators, id-expressions, and member access
expressions. This commit only implements the non-dependent case, where
we can resolve the template-id to an actual declaration.
llvm-svn: 85966
2009-11-03 23:16:33 +00:00
Chris Lattner
e9d7d78ab3
Implement support for the -undef command line option, patch by
...
Roman Divacky! PR5363
llvm-svn: 85932
2009-11-03 19:50:27 +00:00
Douglas Gregor
30d60cb36e
Replace the code that parses member access expressions after "." or
...
"->" with a use of ParseUnqualifiedId. Collapse
ActOnMemberReferenceExpr, ActOnDestructorReferenceExpr (both of them),
ActOnOverloadedOperatorReferenceExpr,
ActOnConversionOperatorReferenceExpr, and
ActOnMemberTemplateIdReferenceExpr into a single, new action
ActOnMemberAccessExpr that does the same thing more cleanly (and can
keep more source-location information).
llvm-svn: 85930
2009-11-03 19:44:04 +00:00
John McCall
37958aa864
Silence a warning by giving Parser::FieldCallback a virtual destructor, and
...
anchor the vtable to Parser.cpp for good measure.
llvm-svn: 85927
2009-11-03 19:33:12 +00:00
John McCall
d5a36321b9
Reorganize the parsing of decl groups / function definitions so that
...
declarators are parsed primarily within a single function (at least for
these cases). Remove some excess diagnostics arising during parse failures.
llvm-svn: 85924
2009-11-03 19:26:08 +00:00
Ted Kremenek
8d43a6ac3d
Merge NullDerefChecker.[h,cpp] and UndefDerefChecker.[h,cpp]. They are essentially two parts of the same check.
...
llvm-svn: 85911
2009-11-03 18:41:06 +00:00
Douglas Gregor
a121b75d9d
Use ParseUnqualifiedId when parsing id-expressions. This eliminates
...
yet another copy of the unqualified-id parsing code.
Also, use UnqualifiedId to simplify the Action interface for building
id-expressions. ActOnIdentifierExpr, ActOnCXXOperatorFunctionIdExpr,
ActOnCXXConversionFunctionExpr, and ActOnTemplateIdExpr have all been
removed in favor of the new ActOnIdExpression action.
llvm-svn: 85904
2009-11-03 16:56:39 +00:00
Zhongxing Xu
27fee83ec4
Pull VLA size checker into its own files.
...
Split it to two checkers, one for undefined size,
the other for zero size, so that we don't need to query the size
when emitting the bug report.
llvm-svn: 85895
2009-11-03 12:13:38 +00:00
Ted Kremenek
18c7ceee16
Implement: <rdar://problem/6250216> Warn against using -[NSAutoreleasePool release] in GC mode
...
llvm-svn: 85887
2009-11-03 08:03:59 +00:00
Ted Kremenek
924316d7d7
Move 'static inline' functions GetNullarySelector() and GetUnarySelector() from CFRefCount.cpp to ASTContext.h. These functions are likely to be generally useful.
...
llvm-svn: 85886
2009-11-03 08:00:42 +00:00
Zhongxing Xu
9b9d731a8b
Pull AttrNonNullChecker into its own files.
...
llvm-svn: 85883
2009-11-03 07:35:33 +00:00
Zhongxing Xu
ab162e1873
Pull UndefinedArgChecker into its own files.
...
llvm-svn: 85875
2009-11-03 06:46:03 +00:00
Zhongxing Xu
0deca3486e
Pull BadCallChecker into its own files.
...
llvm-svn: 85868
2009-11-03 05:48:04 +00:00
John McCall
cfefb6d197
Switch ParseStructDeclaration to a callback-based API. This will make
...
it easier to track within Sema whether the parser is parsing a declaration.
llvm-svn: 85855
2009-11-03 02:38:08 +00:00
Douglas Gregor
7861a80346
Introduce a new class, UnqualifiedId, that provides a parsed
...
representation of a C++ unqualified-id, along with a single parsing
function (Parser::ParseUnqualifiedId) that will parse all of the
various forms of unqualified-id in C++.
Replace the representation of the declarator name in Declarator with
the new UnqualifiedId class, simplifying declarator-id parsing
considerably and providing more source-location information to
Sema. In the future, I hope to migrate all of the other
unqualified-id-parsing code over to this single representation, then
begin to merge actions that are currently only different because we
didn't have a unqualified notion of the name in the parser.
llvm-svn: 85851
2009-11-03 01:35:08 +00:00
Ted Kremenek
fac290d359
Remove GRExprEngine::CheckerVisitLocation(). It was only called in one place, so we inlined it in to GRExprEngine::EvalLocation().
...
llvm-svn: 85838
2009-11-02 23:19:29 +00:00
Fariborz Jahanian
de8db16a7d
Property declared in continuation class can only be used to
...
change a readonly property declared in the class (and its inherited protocols)
to writable property. (Fixes radar 7350645).
llvm-svn: 85836
2009-11-02 22:45:15 +00:00
John Thompson
ac0b098d4d
Added __has_include and __has_include_next.
...
llvm-svn: 85834
2009-11-02 22:28:12 +00:00
Ted Kremenek
f639b84bc5
Hopefully make gcc-4.0 happy with respect to the following warning:
...
warning: 'class clang::StackFrameContext' has virtual functions but non-virtual destructor
llvm-svn: 85833
2009-11-02 22:24:53 +00:00
Ted Kremenek
69e584d12b
Add "virtual" keywords for clarity.
...
llvm-svn: 85815
2009-11-02 18:54:58 +00:00
Fariborz Jahanian
ec344ed2f5
Diagnose implementation of a property declared in a category
...
in its class implementation instead of crashing. Fixes radar 7350345.
llvm-svn: 85813
2009-11-02 18:45:36 +00:00
Douglas Gregor
bff4e7d180
Fix the type of __builtin_expect, from Ed Schouten!
...
llvm-svn: 85666
2009-10-31 16:04:14 +00:00
Douglas Gregor
249c121883
Add two missing CINDEX_LINKAGE uses, in libCIndex, from Kovarththanan
...
Rajaratnam!
llvm-svn: 85665
2009-10-31 15:48:08 +00:00
Benjamin Kramer
6b289a9cf6
Update CMake file.
...
llvm-svn: 85652
2009-10-31 12:15:23 +00:00
Zhongxing Xu
b1c24724dd
Move CheckDivZero into its own files.
...
llvm-svn: 85651
2009-10-31 10:02:37 +00:00
Zhongxing Xu
358ced08d0
Move UndefDerefChecker into its own file.
...
llvm-svn: 85645
2009-10-31 08:44:33 +00:00
Zhongxing Xu
2261bcadd1
Add header comments.
...
llvm-svn: 85644
2009-10-31 04:12:21 +00:00
Douglas Gregor
1d0015f8e1
Improved fix for PR3844, which recovers better for class template
...
partial specializations and explicit instantiations of non-templates.
llvm-svn: 85620
2009-10-30 22:09:44 +00:00
Douglas Gregor
916462b2f7
Improve diagnostics when parsing something like
...
template<> struct foo<int> { ... };
where "foo" does not refer to a template. Fixes PR3844.
llvm-svn: 85616
2009-10-30 21:46:58 +00:00
John McCall
edf97c4b02
Finally suppress a compiler warning from gcc on release-asserts. Also fixes
...
a crash on <vector> in same, which bears additional investigation.
llvm-svn: 85598
2009-10-30 17:53:18 +00:00
Ted Kremenek
6f2a705a24
Make checkers run in deterministic order.
...
llvm-svn: 85597
2009-10-30 17:47:32 +00:00
Ted Kremenek
89f5c189db
Move NullDerefChecker.h instead a 'Checkers' subdirectory.
...
llvm-svn: 85596
2009-10-30 17:28:40 +00:00
Ted Kremenek
f613e89617
Move all logic for the null dereference checker from GRExprEngineInternalChecks.cpp to a separate .cpp file.
...
llvm-svn: 85595
2009-10-30 17:24:47 +00:00
Douglas Gregor
f329c7c3c0
Include macros in code-completion results
...
llvm-svn: 85594
2009-10-30 16:50:04 +00:00