Eli Friedman [Sun, 18 Jul 2010 20:49:59 +0000 (20:49 +0000)]
Fix mangling for static member variables of classes inside an extern "C"
linkage specification. Not sure if this is the ideal fix, but I'm reasonably
sure it's correct vs. gcc.
When instantiating function definitions set parameter names to those used in template
The rationale is that we are copying the entire definition including
parameter names which may differ between the declaration and the
definition.
This is particularly important if any parameters are unnamed in the
declaration, as a DeclRef to an unnamed ParmVarDecl would cause the
pretty printer to produce invalid output.
Improve the representation of the atomic builtins in a few ways. First, we make
their call expressions synthetically have the "deduced" types based on their
first argument. We only insert conversions in the AST for arguments whose
values require conversion to match the value type expected. This keeps PR7600
closed by maintaining the return type, but avoids assertions due to unexpected
implicit casts making the type unsigned (test case added from Daniel).
The magic is moved into the codegen for the atomic builtin which inserts the
casts as needed at the IR level to raise the type to an integer suitable for
the LLVM intrinsic. This shouldn't cause any real change in functionality, but
now we can make the builtin be more truly polymorphic.
Eli Friedman [Sat, 17 Jul 2010 20:43:49 +0000 (20:43 +0000)]
Check for casts to an incomplete type in C. Improves diagnostics for cast to
incomplete union (PR5692) and incomplete enum, and fixes obscure
accepts-invalid on cast to incomplete struct.
Prepare the analyzer for the callee in another translation unit:
Let AnalysisContext contain a TranslationUnit.
Let CallEnter refer to an AnalysisContext instead of a FunctionDecl.
John McCall [Sat, 17 Jul 2010 00:43:08 +0000 (00:43 +0000)]
The GNU-runtime ObjC personality function doesn't let us rethrow with URR for
multiple reasons. Rethrow with _objc_exception_throw instead. Fixes PR7656.
Fix APFloat assertion failure in IdempotentOperationChecker resulting in having
an APFloat with different "float semantics" than the compared float literal.
Tom Care [Fri, 16 Jul 2010 20:41:41 +0000 (20:41 +0000)]
Improved false positive rate for the idempotent operations checker and moved it into the default path-sensitive analysis options.
- Added checks for static local variables, self assigned parameters, and truncating/extending self assignments
- Removed command line option (now default with --analyze)
- Updated test cases to pass with idempotent operation warnings
Fix up some of the visiting for array types -- we weren't good about
getting array indices before -- and for some of the builtin operators:
sizeof, offsetof, unaryops like __is_enum.
Also fix the function visitor to visit exception types in function
parameters.
Douglas Gregor [Fri, 16 Jul 2010 16:54:17 +0000 (16:54 +0000)]
When performing template name lookup for a dependent member access
expression such as the "foo" in "this->blah.foo<1, 2>", and we can't
look into the type of "this->blah" (e.g., because it is dependent),
look into the local scope of a template of the same name. Fixes
<rdar://problem/8198511>.
Douglas Gregor [Fri, 16 Jul 2010 15:40:40 +0000 (15:40 +0000)]
Revert Microsoft-specific override of the "typedef requires a name"
diagnostic. Instead, put it and the "declaration does not declare
anything" warning into -Wmissing-declarations.
Add most of the boilerplate support for scanf format string checking. This includes
handling the parsing of scanf format strings and hooking the checking into Sema.
Most of this checking logic piggybacks on what was already there for checking printf format
strings, but the checking logic has been refactored to support both.
What is left to be done is to support argument type checking in format strings and of course
fix the usual tail of bugs that will follow.
Add builtin definition for scanf, including extending the builtin encoding to
represent builtins that have the "scanf" attribution (via the format attribute) just
like we do with printf functions. Follow-up work is needed to add similar support
for fscanf et al.
This is to support format-string checking for scanf functions.
Daniel Dunbar [Fri, 16 Jul 2010 00:31:23 +0000 (00:31 +0000)]
Builtins/ARM: __clear_cache doesn't seem to have a consistent prototype, declare
the builtin as void __clear_cache(...) to workaround this, which appears to
match what GCC does.
Daniel Dunbar [Fri, 16 Jul 2010 00:00:19 +0000 (00:00 +0000)]
IRgen: Support user defined attributes on block runtime functions.
- This issue here is that /usr/include/Blocks.h wants to define some of the
block runtime globals as weak, depending on the target. This doesn't work in
Clang because we aren't using the AST decl for these globals.
- The fix is a pretty gross hack which just watches all the decls for the
specific blocks globals we need to know about; if we see one we use it,
otherwise we use the hand coded type.
In time, I would like to clean this up by changing IRgen to ask Sema/AST for
the decl, which would then be lazily loaded from the builtin table if
necessary. This could be used in a whole host of places in IRgen and would
get rid of a lot of grotty hand coding of LLVM IR; however, we need some
extra Sema support for this as well as support for builtin global variables.
John McCall [Thu, 15 Jul 2010 23:40:35 +0000 (23:40 +0000)]
When deferring the emission of declarations with initializers in C++, remember
the order they appeared in the translation unit. If they get emitted, put them
in their proper order. Fixes rdar://problem/7458115
Douglas Gregor [Thu, 15 Jul 2010 21:05:01 +0000 (21:05 +0000)]
When we're performing tentative parsing to determine whether the
parser is looking at a declaration or an expression, use a '=' to
conclude that we are parsing a declaration.
This is wrong. However, our previous approach of finding a comma after
the '=' is also wrong, because the ',' could be part of a
template-argument-list. So, for now we're going to use the same wrong
heuristic as GCC and Visual C++, because less real-world code is
likely to be broken this way. I've opened PR7655 to keep track of our
wrongness; note also the XFAIL'd test.
Douglas Gregor [Thu, 15 Jul 2010 18:58:16 +0000 (18:58 +0000)]
Reinstate the scalar-cast-to-const-reference improvements, this time
with the proper spelling of "non-class prvalue". Silly me, I think
class rvalues were xvalues rather than prvalues!
Revert 108220 and subsequent patch.
This is not required (I am not 100% sure why) but method.exp from gdb testsuite flagged regression due to this patch.
Douglas Gregor [Thu, 15 Jul 2010 18:04:13 +0000 (18:04 +0000)]
Teach CodeGenFunction::EmitCastLValue() to handle casts to an lvalue
that involve binding a reference to a pure rvalue temporary (e.g., not
a class temporary), by creating a new temporary and copying the result
there. Fixes PR6024.
Daniel Dunbar [Thu, 15 Jul 2010 15:26:14 +0000 (15:26 +0000)]
Driver/Darwin: Allow -m{ios,macosx}-version-min= to be passed with -Xarch.
- This should be safe, because the driver itself shouldn't need to make
decisions that depend on the deployment target.
Sebastian Redl [Wed, 14 Jul 2010 23:45:08 +0000 (23:45 +0000)]
Add a callback interface that allows interested parties to get notified whenever PCHReader deserializes a type or decl (and possibly other things in the future). Have PCHWriter implement these callbacks as noops and register to receive them if we're chaining PCHs. This will allow PCHWriter to track the IDs of these things, which it needs to write the dependent files. WIP
Daniel Dunbar [Wed, 14 Jul 2010 23:39:36 +0000 (23:39 +0000)]
CodeGen/ObjC/NeXT: Fix Obj-C message send to match llvm-gcc when choosing
whether to use objc_msgSend_fpret; the choice is target dependent, not Obj-C ABI
dependent.
- <rdar://problem/8139758> arm objc _objc_msgSend_fpret bug
Douglas Gregor [Wed, 14 Jul 2010 23:20:53 +0000 (23:20 +0000)]
When determining whether an overload set with explicit template
arguments only resolves to a single specialization, make sure to look
through using declarations. Fixes PR7641.
Douglas Gregor [Wed, 14 Jul 2010 23:14:12 +0000 (23:14 +0000)]
When there are extra or missing template parameter lists in a template
definition, we're likely going to end up breaking the invariants of
the template system, e.g., that the depths of template parameter lists
match up with the nesting template of the template. So, make sure we
mark such ill-formed declarations as invalid or don't even build them
at all.
Daniel Dunbar [Wed, 14 Jul 2010 18:46:27 +0000 (18:46 +0000)]
Driver: When re'execing clang, use path to the main executable instead of
looking up Clang in the normal search paths (which may end up finding the wrong
clang).
Wire up '-Wignored-qualifiers' to the warning on 'const' in 'const int f()'.
This flag and warning match GCC semantics. Also, move it to -Wextra as this is
a largely cosmetic issue and doesn't seem to mask problems. Subsequent fixes to
the tests which no longer by default emit the warning. Added explicit test
cases for both C and C++ behavior with the warning turned on.
John McCall [Wed, 14 Jul 2010 04:38:21 +0000 (04:38 +0000)]
Remove a few mangling FIXMEs:
- TSTs whose template is a template template parameter already work
- we don't provide an imaginary type, so we can't mangle one
- we don't need a generic FIXME for vendor type qualifiers
John McCall [Wed, 14 Jul 2010 04:20:34 +0000 (04:20 +0000)]
Implement the standard mangling for array-subscript expressions, and implement
the current proposals from David Vandervoorde for new, delete, throw, typeid,
imaginary literals, string literals, and null literals.