Commit Graph

2189 Commits

Author SHA1 Message Date
Chris Lattner 6d29c10564 Change a couple of the Parser::Diag methods to return DiagnosticInfo
and let the clients push whatever they want into the DiagnosticInfo
instead of hard coding a few forms.  Also switch various clients to
use Diag(Tok, ...) instead of Diag(Tok.getLocation(), ...) as the
canonical form to simplify the code a bit.

llvm-svn: 59509
2008-11-18 07:48:38 +00:00
Chris Lattner 8488c8297c This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed.  In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a 
ton of random stuff.  This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.

In addition to introducing DiagnosticInfo, this also substantially changes how 
Diagnostic::Report works.  Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and 
ID) and returns a fresh DiagnosticInfo *by value*.  The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator.  When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information.  This is a somewhat tricky dance, but it means that the 
accumulated DiagnosticInfo is allowed to keep pointers to other expression 
temporaries without those pointers getting invalidated.

This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema.  For example, instead of calling:

  Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
       SourceRange(BuiltinLoc, RParenLoc));

We will soon be able to just do:

  Diag(BuiltinLoc, diag::err_overload_no_match)
      << typeNames << SourceRange(BuiltinLoc, RParenLoc));

This scales better to support arbitrary types being passed in (not just 
strings) in a type-safe way.  Go operator overloading?!

llvm-svn: 59502
2008-11-18 07:04:44 +00:00
Ted Kremenek 5fa5052d50 Attribute nonnull can be applied to block pointers.
llvm-svn: 59499
2008-11-18 06:52:58 +00:00
Chris Lattner 746d474b28 SourceManager::getLineNumber is logically const except for caching.
Use mutable to make it so.

llvm-svn: 59498
2008-11-18 06:51:15 +00:00
Chris Lattner 3de58149bd eliminate dependence of strange "Diagnostic::Report" method,
delete huge trailing whitespace to fit in 80 cols.

llvm-svn: 59497
2008-11-18 06:07:40 +00:00
Chris Lattner 16ba91396a Change the diagnostics interface to take an array of pointers to
strings instead of array of strings.  This reduces string copying
in some not-very-important cases, but paves the way for future 
improvements.

llvm-svn: 59494
2008-11-18 04:56:44 +00:00
Chris Lattner 53f5d4c1b5 cleanups and simplifications.
llvm-svn: 59491
2008-11-18 04:44:58 +00:00
Ted Kremenek 3d9740da29 - Add Lexer::isPragma() accessor for clients of Lexer that aren't friends.
- Add static method to test if the current lexer is a non-macro/non-pragma
  lexer.
- Refactor some code in PPLexerChange to use this static method.
- No performance change.

llvm-svn: 59486
2008-11-18 01:33:13 +00:00
Chris Lattner 326f757698 minor cleanups and tidying, no functionality change.
llvm-svn: 59485
2008-11-18 01:30:42 +00:00
Chris Lattner 74112917b2 implement a fixme by making warnings for ++/-- on non-modifiable-lvalues better.
llvm-svn: 59484
2008-11-18 01:26:17 +00:00
Chris Lattner 30bd327746 factor some code out into a helper function
llvm-svn: 59483
2008-11-18 01:22:49 +00:00
Ted Kremenek 551c82aa7b Replace more uses of 'CurLexer->' with 'CurPPLexer->'. No performance change.
llvm-svn: 59482
2008-11-18 01:12:54 +00:00
Ted Kremenek 6b73291462 Add hooks to use PTHLexer::Lex instead of Lexer::Lex when CurLexer is null.
Performance tests on Cocoa.h (using the regular Lexer) shows no performance
difference.

llvm-svn: 59479
2008-11-18 01:04:47 +00:00
Ted Kremenek 59e003e538 Added conditional guard 'if (CurLexer)' when using SetCommentRetentionState().
This is because the PTHLexer will not support this method. Performance testing
on preprocessing Cocoa.h shows that this results in a negligible performance
difference (less than 1%).

I tried making Lexer::SetCommentRetentionState() an out-of-line function (a
precursor to making it a virtual function in PreprocessorLexer) and noticed a 1%
decrease in speed (it is called in a hot part of the Preprocessor).

llvm-svn: 59477
2008-11-18 00:43:07 +00:00
Ted Kremenek 30cd88caab Change a bunch of uses of 'CurLexer->' to 'CurPPLexer->', which should be the
alias for the current PreprocessorLexer. No functionality change. Performance
testing shows this results in no performance degradation when preprocessing
Cocoa.h.

llvm-svn: 59474
2008-11-18 00:34:22 +00:00
Ted Kremenek 68ef9fc6ae - Add 'CurPPLexer' to Preprocessor to keep track of the current
PreprocessorLexer, which will either be a 'Lexer' or 'PTHLexer'.
- Added stub field 'CurPTHLexer' to keep track of the current PTHLexer.
- Modified IncludeStackInfo to track both the current PTHLexer and
  current PreprocessorLexer.

llvm-svn: 59472
2008-11-18 00:12:49 +00:00
Sebastian Redl 8071edb297 Implement effects of 'mutable', and a few comments from Chris on its parsing.
llvm-svn: 59470
2008-11-17 23:24:37 +00:00
Douglas Gregor 92751d41a0 Eliminate all of the placeholder identifiers used for constructors,
destructors, and conversion functions. The placeholders were used to
work around the fact that the parser and some of Sema really wanted
declarators to have simple identifiers; now, the code that deals with
declarators will use DeclarationNames.

llvm-svn: 59469
2008-11-17 22:58:34 +00:00
Ted Kremenek c775712192 Fold assertion into second valid else branch. This removes a compiler warning
where the control reaches the end of a non-void function and also allows the
compiler to generate better code.  When this assertion is false we can easily
add more else cases.

llvm-svn: 59468
2008-11-17 22:55:12 +00:00
Steve Naroff 773cdc7c0d Fix <rdar://problem/6333904> [sema] message lookup on super is incorrect
Missing special lookup rule in Sema::ActOnInstanceMessage().

llvm-svn: 59467
2008-11-17 22:29:32 +00:00
Douglas Gregor ae2fbad373 Updated IdentifierResolver to deal with DeclarationNames. The names of
C++ constructors, destructors, and conversion functions now have a
FETokenInfo field that IdentifierResolver can access, so that these
special names are handled just like ordinary identifiers. A few other
Sema routines now use DeclarationNames instead of IdentifierInfo*'s.

To validate this design, this code also implements parsing and
semantic analysis for id-expressions that name conversion functions,
e.g.,

  return operator bool();

The new parser action ActOnConversionFunctionExpr takes the result of
parsing "operator type-id" and turning it into an expression, using
the IdentifierResolver with the DeclarationName of the conversion
function. ActOnDeclarator pushes those conversion function names into
scope so that the IdentifierResolver can find them, of course.

llvm-svn: 59462
2008-11-17 20:34:05 +00:00
Chris Lattner 9b3bbe9db7 Implement rdar://6319320: give a good diagnostic for cases where people
are trying to use the old GCC "casts as lvalue" extension.  We don't and
will hopefully never support this.

llvm-svn: 59460
2008-11-17 19:51:54 +00:00
Steve Naroff 753567f2c1 Fix <rdar://problem/6316324> [sema] spurious warning on comparison of qualified id.
llvm-svn: 59459
2008-11-17 19:49:16 +00:00
Steve Naroff ecf2bb8724 Fix <rdar://problem/6320086> parser rejects block capturing ivar.
llvm-svn: 59444
2008-11-17 16:28:52 +00:00
Douglas Gregor d69246bd5b Some cleanups for C++ operator overloading
llvm-svn: 59443
2008-11-17 16:14:12 +00:00
Douglas Gregor 9edcc802c3 Simplify error messages for two-parameter overloaded increment/decrement operators
llvm-svn: 59442
2008-11-17 15:03:30 +00:00
Douglas Gregor 77324f3854 Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of
languages. DeclarationName is used in NamedDecl to store the name of
the declaration (naturally), and ObjCMethodDecl is now a NamedDecl.

llvm-svn: 59441
2008-11-17 14:58:09 +00:00
Eli Friedman dcbcbb827d A few corrections to the expr constant work. Not enabled at the
moment.

llvm-svn: 59435
2008-11-17 03:57:28 +00:00
Anders Carlsson 4425d8e37b More expr constant work. (Off by default).
llvm-svn: 59433
2008-11-17 01:58:55 +00:00
Anders Carlsson 899c7050b6 Address some comments Eli had.
llvm-svn: 59430
2008-11-16 22:46:56 +00:00
Nuno Lopes 527b5a6858 use HandleConversionToBool() to check if a given cond is foldable (per Eli's comment)
llvm-svn: 59429
2008-11-16 22:06:39 +00:00
Anders Carlsson 9ddf7bedf9 More complex float evaluator support.
llvm-svn: 59428
2008-11-16 21:51:21 +00:00
Chris Lattner 67d7b9204c rename Expr::tryEvaluate to Expr::Evaluate.
llvm-svn: 59426
2008-11-16 21:24:15 +00:00
Anders Carlsson 537969c237 Add very limited support for evaluating complex floats.
llvm-svn: 59425
2008-11-16 20:27:53 +00:00
Chris Lattner 1b03f76113 Trivial tidying
llvm-svn: 59424
2008-11-16 20:22:05 +00:00
Nuno Lopes e236a48210 fix folding of comma if given a non-constant operand.
Eli please take a look, as I'm not sure if this gets the extension warning in the right place

llvm-svn: 59422
2008-11-16 20:09:07 +00:00
Nuno Lopes 420426100c make IntExprEvaluator fold the ?: operator
llvm-svn: 59421
2008-11-16 19:28:31 +00:00
Anders Carlsson 9f9e4249cc More work on the constant evaluator. Eli, it would be great if you could have a look at this.
llvm-svn: 59420
2008-11-16 19:01:22 +00:00
Chris Lattner e6de6252c2 Fix PR3077: tokens that come from macro expansions whose macro was
defined in a system header should be treated as system header tokens
even if they are instantiated in a different place.

llvm-svn: 59418
2008-11-16 18:36:34 +00:00
Chris Lattner 981f33b0b6 add dump and print methods, add operator<< for APValue.
llvm-svn: 59411
2008-11-16 07:46:48 +00:00
Anders Carlsson acc7981883 Add the ability to evaluate comparison operators with floating point numbers as operands.
llvm-svn: 59408
2008-11-16 07:17:21 +00:00
Zhongxing Xu 99a96d6ef3 Enhance modularization: return a <state,loc> pair to let GRExprEngine modify the
environment.

llvm-svn: 59407
2008-11-16 07:06:26 +00:00
Anders Carlsson 430887742e More constant expr work.
llvm-svn: 59405
2008-11-16 06:23:45 +00:00
Chris Lattner 9ce8a533cd daniel prefers completed thoughts.
llvm-svn: 59404
2008-11-16 06:16:27 +00:00
Zhongxing Xu ceca80619f Enhances SCA to process untyped region to typed region conversion.
- RegionView and RegionViewMap is introduced to assist back-mapping from
   super region to subregions.
 - GDM is used to carry RegionView information.
 - AnonTypedRegion is added to represent a typed region introduced by pointer
   casting. Later AnonTypedRegion can be used in other similar cases, e.g.,
   malloc()'ed region.
 - The specific conversion is delegated to store manager.

llvm-svn: 59382
2008-11-16 04:07:26 +00:00
Chris Lattner e132e2432a Start implementing support for @synchonized with the darwin ObjC API.
Patch by Fariborz!

llvm-svn: 59377
2008-11-15 21:26:17 +00:00
Anders Carlsson ee0d90fe30 Check in code that uses tryEvaluate for emitting constant exprs (not used yet).
llvm-svn: 59375
2008-11-15 20:45:50 +00:00
Anders Carlsson c2480a5589 Handle padding in the constant CFString struct. Fixes PR3046.
llvm-svn: 59372
2008-11-15 18:54:24 +00:00
Anders Carlsson c9dacf4fdd Use IgnoreParenCasts. No functionality change.
llvm-svn: 59371
2008-11-15 18:52:06 +00:00
Zhongxing Xu 461b4f4276 Use the allocator of ExplodedGraph. The whole static analysis module uses it.
llvm-svn: 59359
2008-11-15 08:19:58 +00:00