Chris Lattner [Mon, 16 Feb 2009 18:35:08 +0000 (18:35 +0000)]
Add support for deprecating ObjC properties. Unlike GCC, we warn that the
property is deprecated, not the getter/setter if the attribute is on
the property.
Douglas Gregor [Mon, 16 Feb 2009 18:20:44 +0000 (18:20 +0000)]
When a function with a prototype is redeclared without a prototype,
merge the prototype into the redeclaration (and make a note in the
declaration). Fixes PR3588.
Douglas Gregor [Mon, 16 Feb 2009 17:45:42 +0000 (17:45 +0000)]
Adopt a more principled approach to invalid declarations:
- If a declaration is an invalid redeclaration of an existing name,
complain about the invalid redeclaration then avoid adding it to
the AST (we can still parse the definition or initializer, if any).
- If the declaration is invalid but there is no prior declaration
with that name, introduce the invalid declaration into the AST
(for later error recovery).
- If the declaration is an invalid redeclaration of a builtin that
starts with __builtin_, we produce an error and drop the
redeclaration. If it is an invalid redeclaration of a library
builtin (e.g., malloc, printf), warn (don't error!) and drop the
redeclaration.
If a user attempts to define a builtin, produce an error and (if it's
a library builtin like malloc) suggest -ffreestanding.
This addresses <rdar://problem/6097585> and PR2892. However, PR3588 is
still going to cause some problems when builtins are redeclared
without a prototype.
castToDeclContext/castFromDeclContext are only required to be included in the class of decls that directly derive from DeclContext.
Their subclasses don't need them.
castToDeclContext/castFromDeclContext are not meant to be used directly; they are used indirectly by cast/dyn_cast.
All Decl <-> DeclContext casting should be done through cast/dyn_cast.
DeclContext had its "casting machinery" inside the class definition so that if a new declaration context Decl appeared, the necessary changes
would be in one place. Since, now, only DeclNodes.def needs to be modified, move things out-of-line and simplify the DeclContext class.
-In DeclNodes.def, only mark as DeclContexts the top classes that directly derive from DeclContext. If the Decl has subclasses,
it should be marked with DECL_CONTEXT_BASE.
-Use DeclNodes.def to automate the DeclContext::classof and DeclContext::CastTo definitions.
Chris Lattner [Sun, 15 Feb 2009 22:43:40 +0000 (22:43 +0000)]
Refactor the deprecated and unavailable checks into a new
DiagnoseUseOfDeprecatedDecl method. This ensures that they
are treated consistently. This gets us 'unavailable' support
on a few new types of decls, and makes sure we consistently
silence deprecated when the caller is also deprecated.
Chris Lattner [Sun, 15 Feb 2009 21:32:34 +0000 (21:32 +0000)]
fix a fixme in -emit-html output: highlight the entire range of a macro
instantiation, which highlights the arguments of a function like macro
as well as its identifier.
Chris Lattner [Sun, 15 Feb 2009 21:06:39 +0000 (21:06 +0000)]
fix PR3579: __LINE__ expands to the presumed location of the
*end* of a macro instantiation, not the start of it. This is
really all about bug-for-bug compatibility with GCC, but not
doing this breaks the FreeBSD kernel.
Chris Lattner [Sun, 15 Feb 2009 21:06:15 +0000 (21:06 +0000)]
fix PR3579: __LINE__ expands to the presumed location of the
*end* of a macro instantiation, not the start of it. This is
really all about bug-for-bug compatibility with GCC, but not
doing this breaks the FreeBSD kernel.
Chris Lattner [Sun, 15 Feb 2009 20:52:18 +0000 (20:52 +0000)]
track "just a little more" location information for macro instantiations.
Now instead of just tracking the expansion history, also track the full
range of the macro that got replaced. For object-like macros, this doesn't
change anything. For _Pragma and function-like macros, this means we track
the locations of the ')'.
This is required for PR3579 because apparently GCC uses the line of the ')'
of a function-like macro as the location to expand __LINE__ to.
Fixed a bad ir-gen bug which caused a dejagnu test to fail.
Now we are pretty close to be in sync with objc's classic
abi when it comes to passing dejagnu objc executable tests.
Fixed a problem caused by foreward @class use
which consequently caused a Seg fault. during meta-data
generation. It also addresses an issue related to
late binding of newly synthesize ivars (when we support it).
Douglas Gregor [Sat, 14 Feb 2009 18:57:46 +0000 (18:57 +0000)]
Add hook to add attributes to function declarations that we know
about, whether they are builtins or not. Use this to add the
appropriate "format" attribute to NSLog, NSLogv, asprintf, and
vasprintf, and to translate builtin attributes (from Builtins.def)
into actual attributes on the function declaration.
Use the "printf" format attribute on function declarations to
determine whether we should do format string checking, rather than
looking at an ad hoc list of builtins and "known" function names.
Be a bit more careful about when we consider a function a "builtin" in
C++.
Ted Kremenek [Sat, 14 Feb 2009 17:08:39 +0000 (17:08 +0000)]
Patch by Ben Laurie:
ConstraintManager:
- constify getSymVal()
BasicConstraintManager:
- Pull out logic that would be common to ConstraintManagers of a similar nature
and put them in a parent class called 'SimpleConstraintManager'.
RangeConstraintManager:
- Added a new prototype ConstraintManager to track ranges of variables! This
ConstraintManager keeps tracks of ranges of concrete integers that a symbolic
integer may have.
AnalysisConsumer:
- Add driver option to use RangeConstraintManager with GRExprEngine-based
analyses.
Chris Lattner [Sat, 14 Feb 2009 08:09:34 +0000 (08:09 +0000)]
add parser and type checking support for attribute((objc_exception)).
We don't have "zero cost" exceptions for ObjC yet, so there is no codegen
support required.
Chris Lattner [Sat, 14 Feb 2009 07:37:35 +0000 (07:37 +0000)]
Several related changes:
1) implement parser and sema support for reading and verifying attribute(warnunusedresult).
2) rename hasLocalSideEffect to isUnusedResultAWarning, inverting the sense
of its result.
3) extend isUnusedResultAWarning to directly return the loc and range
info that should be reported to the user. Make it substantially more
precise in some cases than what was previously reported.
4) teach isUnusedResultAWarning about CallExpr to decls that are
pure/const/warnunusedresult, fixing a fixme.
5) change warn_attribute_wrong_decl_type to not pass in english strings, instead,
pass in integers and use %select.
Ted Kremenek [Sat, 14 Feb 2009 03:16:10 +0000 (03:16 +0000)]
Added GRStateManager::scanReachableSymbols(), a method which scans the reachable
symbols from an SVal.
- Fixed a bug in EnvironmentManager::RemoveDeadBindings() where it did not mark
live all the symbols reachable from a live block-level expression.
- Fixed a bug in the retain/release checker where it did not stop tracking
symbols that 'escaped' via compound literals being assigned to something the
BasicStoreManager didn't reason about.
Daniel Dunbar [Sat, 14 Feb 2009 02:09:24 +0000 (02:09 +0000)]
x86_64 ABI: Pass simple types directly when possible. This is
important for both keeping the generated LLVM simple and for ensuring
that integer types are passed/promoted correctly.
Douglas Gregor [Sat, 14 Feb 2009 01:52:53 +0000 (01:52 +0000)]
Make it possible for builtins to expression FILE* arguments, so that
we can define builtins such as fprintf, vfprintf, and
__builtin___fprintf_chk. Give a nice error message when we need to
implicitly declare a function like fprintf.
Ted Kremenek [Sat, 14 Feb 2009 01:43:44 +0000 (01:43 +0000)]
Static analyzer:
- Added a new 'node builder' class called GRStmtNodeBuilderRef (name may
change). This is essentially a smart reference to a GRStmtNodeBuilder object
that keeps track of the current context (predecessor node, GRExprEngine
object, etc.) The idea is to gradually simplify the interface between
GRExprEngine and GRTransferFuncs using this new builder (i.e., passing 1
argument instead of 5). It also handles some of the "auto-transition" for node
creation, simplifying some of the logic in GRExprEngine itself.
- Used GRStmtBuilderRef to replace GRTransferFuncs::EvalStore with
GRTransferFuncs::EvalBind. The new EvalBind method will be used at any
arbitrary places where a binding between a location and value takes place.
Moreover, GRTransferFuncs no longer has the responsibility to request
StoreManager to do the binding; this is now in GRExprEngine::EvalBind. All
GRTransferFuncs::EvalBind does is checker-specific logic (which can be a
no-op).
Douglas Gregor [Sat, 14 Feb 2009 00:32:47 +0000 (00:32 +0000)]
Extend builtin "attribute" syntax to include a notation for
printf-like functions, both builtin functions and those in the
C library. The function-call checker now queries this attribute do
determine if we have a printf-like function, rather than scanning
through the list of "known functions IDs". However, there are 5
functions they are not yet "builtins", so the function-call checker
handles them specifically still:
- fprintf and vfprintf: the builtins mechanism cannot (yet)
express FILE* arguments, so these can't be encoded.
- NSLog: the builtins mechanism cannot (yet) express NSString*
arguments, so this (and NSLogv) can't be encoded.
- asprintf and vasprintf: these aren't part of the C99 standard
library, so we really shouldn't be defining them as builtins in
the general case (and we don't seem to have the machinery to make
them builtins only on certain targets and depending on whether
extensions are enabled).