Commit Graph

35162 Commits

Author SHA1 Message Date
Douglas Gregor d6a58286f5 Fix broken unit test
llvm-svn: 148547
2012-01-20 16:33:00 +00:00
Douglas Gregor 32fbe31246 Extract the (InputKind, std::string) pair used to describe inputs to
the front end into its own class, FrontendInputFile, to make it easier
to introduce new per-input data. No functionality change.

llvm-svn: 148546
2012-01-20 16:28:04 +00:00
Benjamin Kramer 469214426a Localize variable, remove unused assignment.
Found by the clang static analyzer.

llvm-svn: 148544
2012-01-20 14:57:34 +00:00
Benjamin Kramer 1dd48bc76f Remove unused variables.
Found by clang's own static analyzer.

llvm-svn: 148542
2012-01-20 14:42:32 +00:00
Ted Kremenek b9ff6b2302 Reenable DeadStoresChecker under --analyze, and move the IdempotentOperationsChecker to the 'experimental' category. Fixes <rdar://problem/10146347>.
llvm-svn: 148533
2012-01-20 06:00:17 +00:00
Ted Kremenek 89eaf8d531 Implement checker that looks for calls to mktemps and friends that have fewer than 6 Xs. Implements <rdar://problem/6336672>.
llvm-svn: 148531
2012-01-20 05:35:06 +00:00
Ted Kremenek c54dc9515d Turn 'SecuritySyntaxChecker' into a "meta" security checker for insecure APIs. Now
multiple checks are exposed as separate checkers, but CheckerManager only creates
one Checker object.

llvm-svn: 148525
2012-01-20 01:44:29 +00:00
Argyrios Kyrtzidis 908c4dcc5d [libclang] Fix crash when indexing attributes, rdar://10702250.
llvm-svn: 148524
2012-01-20 01:38:51 +00:00
Eli Friedman 456f01833b Remove PotentiallyPotentiallyEvaluated, and replace it with a much simpler and less error-prone way of handling the relevant cases. Towards marking of whether a declaration is used more accurately.
llvm-svn: 148522
2012-01-20 01:26:23 +00:00
Anna Zaks 3b754b25bd [analyzer] Add socket API as a source of taint.
llvm-svn: 148518
2012-01-20 00:11:19 +00:00
Anna Zaks 282dc1437f [analyzer] Skip casts when determining taint dependencies + pretty
printing.

llvm-svn: 148517
2012-01-20 00:11:16 +00:00
Anna Zaks 43de767b55 [analyzer] Add a utility method that allows to find the macro name used
at the given location. 

This could be useful when checkers' logic depends on whether a function
is called with a given macro argument.

llvm-svn: 148516
2012-01-20 00:11:12 +00:00
Anna Zaks 9796f2aa56 [analyzer] Cleanup of Symbol dump methods.
This solves a the issue of crashing gdb when dumping a symbol; +
consistent vitualization.

llvm-svn: 148515
2012-01-20 00:11:08 +00:00
Anna Zaks 03e0651ff3 [analyzer] www: A minor cleanup to the dev manual.
llvm-svn: 148514
2012-01-20 00:11:04 +00:00
Richard Smith ab3fe0f9ba Further testing for instantiation of out-of-line constexpr static data member
template definitions.

llvm-svn: 148506
2012-01-19 22:50:02 +00:00
Richard Smith 45bb45523f An instantiation of a constexpr static data member in a class template is
constexpr.

llvm-svn: 148505
2012-01-19 22:46:17 +00:00
Richard Trieu 4972a6dd08 Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =.

llvm-svn: 148499
2012-01-19 22:01:51 +00:00
Benjamin Kramer 704fe866b2 Silence set-but-unused warning.
llvm-svn: 148496
2012-01-19 21:12:23 +00:00
Argyrios Kyrtzidis 7838a2bffb Introduce Lexer::getSourceText() that returns a string for the source
that the given source range encompasses.

llvm-svn: 148481
2012-01-19 15:59:19 +00:00
Argyrios Kyrtzidis a99e02d019 Introduce Lexer::makeFileCharRange() that accepts a token source range
and returns a character range with file locations.

llvm-svn: 148480
2012-01-19 15:59:14 +00:00
Argyrios Kyrtzidis 1b07c344b4 For Lexer's isAt[Start/End]OfMacroExpansion add an out parameter for the macro
start/end location.

It is commonly needed after calling the function; with this way we avoid
recalculating it.

llvm-svn: 148479
2012-01-19 15:59:08 +00:00
Argyrios Kyrtzidis d169911cc0 Add unit testing for Lexer.
llvm-svn: 148478
2012-01-19 15:59:01 +00:00
Evgeniy Stepanov 5dfe9f2b2f Extend unwind.h with the ARM unwinder interface.
These declarations come from the sample code in the
"Exception Handling ABI for the ARM Architecture" document.

llvm-svn: 148469
2012-01-19 11:39:05 +00:00
Tanya Lattner 3dd33b296a A few style changes.
Change CheckVectorLogicalOperands to pass params by ref.
Add another test case.

llvm-svn: 148452
2012-01-19 01:16:16 +00:00
Kaelyn Uhrain edb4acf16b Remove the now-unused CorrectTypoContext enum.
llvm-svn: 148441
2012-01-19 00:33:34 +00:00
Richard Smith f8379a0fc3 constexpr: converted constant expression handling for enumerator values, case
values and non-type template arguments of integral and enumeration types.

This change causes some legal C++98 code to no longer compile in C++11 mode, by
enforcing the C++11 rule that narrowing integral conversions are not permitted
in the final implicit conversion sequence for the above cases.

llvm-svn: 148439
2012-01-18 23:55:52 +00:00
Richard Trieu c64d3230d2 Change the error when a '+=' follows a declaration to suggest a fixit to '=' instead of just suggesting a ';'.
Old error:
plusequaldeclare1.cc:3:8: error: expected ';' at end of declaration
  int x += 6;
       ^
       ;

New error:
plusequaldeclare1.cc:3:9: error: invalid '+=' at end of declaration; did you
      mean '='?
  int x += 6;
        ^~
        =

llvm-svn: 148433
2012-01-18 22:54:52 +00:00
Fariborz Jahanian f9a05d26db Use -Wdeprecated-objc-isa-usage for option to issue
deprecated usage of 'isa'. // rdar://8290002

llvm-svn: 148430
2012-01-18 22:18:30 +00:00
Kaelyn Uhrain b1378408e4 Convert SemaDecl.cpp to pass callback objects to CorrectTypo.
Includes tests highlighting the cases where accuracy has improved
(there is one call that does no filtering beyond selecting the set
of allowed keywords, and one call that only triggers for ObjC code
for which a test by someone who knows ObjC would be welcome). Also
fixes a small typo in one of the suggestion messages, and drops a
malformed "expected-note" for a suggestion that did not occur even
when the malformed note was committed as r145930.

llvm-svn: 148420
2012-01-18 21:41:41 +00:00
Douglas Gregor 4fc9f3e819 Optimize unqualified/global name lookup in modules by introducing a
generational scheme for identifiers that avoids searching the hash
tables of a given module more than once for a given
identifier. Previously, loading any new module invalidated all of the
previous lookup results for all identifiers, causing us to perform the
lookups repeatedly.

llvm-svn: 148412
2012-01-18 20:56:22 +00:00
Anna Zaks 1bea4bf590 Refactor: Pull getImmediateMacroName() out of DiagnosticRenderer and
into Lexer and Preprocessor; making it widely available.

llvm-svn: 148410
2012-01-18 20:17:16 +00:00
Fariborz Jahanian 28324b0066 objc: deprecate direct usage of 'isa' of objc objects
in favor of usage of api's intended for.
// rdar://8290002

llvm-svn: 148404
2012-01-18 19:08:56 +00:00
Douglas Gregor 226173ae93 In the driver, -fmodules enables modules for C/Objective-C but one
also needs -fcxx-modules to enable modules for C++/Objective-C++.

llvm-svn: 148393
2012-01-18 15:19:58 +00:00
Seth Cantrell 6255c257e9 Add and update tests for character literals
llvm-svn: 148392
2012-01-18 12:27:10 +00:00
Seth Cantrell 9c2d6f0279 stop claiming unicode escape sequences are too long in strings, because they never are
llvm-svn: 148391
2012-01-18 12:27:08 +00:00
Seth Cantrell 02f8605974 Fix char literal types in C
L'x' is actually wchar_t

support C11 u and U char literals

llvm-svn: 148390
2012-01-18 12:27:06 +00:00
Seth Cantrell 8b2b677f39 Improves support for Unicode in character literals
Updates ProcessUCNExcape() for C++. C++11 allows UCNs in character
and string literals that represent control characters and basic
source characters. Also C++03 allows UCNs that refer to surrogate
codepoints.

UTF-8 sequences in character literals are now handled as single
c-chars.

Added error for multiple characters in Unicode character literals.

Added errors for when a the execution charset encoding of a c-char
cannot be represented as a single code unit in the associated
character type. Note that for the purposes of this error the asso-
ciated character type for a narrow character literal is char, not
int, even though in C narrow character literals have type int.

llvm-svn: 148389
2012-01-18 12:27:04 +00:00
Seth Cantrell c9196651fc test svn commit access
llvm-svn: 148388
2012-01-18 12:11:32 +00:00
Kaelyn Uhrain 79d01c1760 Convert DiagnoseEmptyLookup to use correction callbacks.
No new unit tests yet as there is no behavioral change
(except for slightly more specific filtering in
Sema::ActOnStartOfLambdaDefinition). Tests will be added
as the code paths are traced in greater depth to determine
how to improve the results--there are at least one or two
known bugs that require those improvements. This commit
lays the groundwork for those changes.

llvm-svn: 148382
2012-01-18 05:58:54 +00:00
Richard Smith 66e05fe630 Move narrowing conversion detection code from SemaInit to SemaOverload, ready
for it to be used in converted constant expression checking, and fix a couple
of issues:
 - Conversion operators implicitly invoked prior to the narrowing conversion
   were not being correctly handled when determining whether a constant value
   was narrowed.
 - For conversions from floating-point to integral types, the diagnostic text
   incorrectly always claimed that the source expression was not a constant
   expression.

llvm-svn: 148381
2012-01-18 05:21:49 +00:00
Nick Lewycky e2367d2508 Add testcase for r148375!
llvm-svn: 148378
2012-01-18 04:28:31 +00:00
Eli Friedman 7bda7f7533 Make PotentiallyPotentiallyEvaluated contexts work correctly when referencing a class field from outside an instance method.
llvm-svn: 148376
2012-01-18 03:53:45 +00:00
Nick Lewycky 9ed5b156a2 Fix a string over-run detected by ASAN.
llvm-svn: 148375
2012-01-18 03:41:19 +00:00
Richard Smith 9cf080fba3 A call to strlen is not a constant expression, even if we're treating it as a
builtin.

llvm-svn: 148374
2012-01-18 03:06:12 +00:00
Eli Friedman 1f4f9ddee8 The value of a case statement is a potentially evaluated context. Found by inspection.
llvm-svn: 148373
2012-01-18 02:54:10 +00:00
Anna Zaks 7f6a6b7507 [analyzer] Refactor: prePropagateTaint ->
TaintPropagationRule::process().

Also remove the "should be a pointer argument" warning - should be
handled elsewhere.

llvm-svn: 148372
2012-01-18 02:45:13 +00:00
Anna Zaks 560dbe9ac9 [analyzer] Taint: warn when tainted data is used to specify a buffer
size (Ex: in malloc, memcpy, strncpy..)

(Maybe some of this could migrate to the CString checker. One issue
with that is that we might want to separate security issues from
regular API misuse.)

llvm-svn: 148371
2012-01-18 02:45:11 +00:00
Anna Zaks 5d324e509c [analyzer] Taint: add taint propagation rules for string and memory copy
functions.

llvm-svn: 148370
2012-01-18 02:45:07 +00:00
Anna Zaks 28db7ceabd Constify FunctionDecl::getmemoryFunctionKind().
llvm-svn: 148369
2012-01-18 02:45:01 +00:00
Nick Lewycky 72cd229398 Fix special king of typo.
llvm-svn: 148368
2012-01-18 01:50:13 +00:00