Commit Graph

24355 Commits

Author SHA1 Message Date
Daniel Dunbar deaff5d792 Update for LLVM API change.
llvm-svn: 108665
2010-07-19 00:33:53 +00:00
Rafael Espindola 7661436220 Refactor the code a bit so that there is only one call to BuildCompilation. The
StringPointers vector will also be used in the normal case to handle @file
arguments.

llvm-svn: 108660
2010-07-18 22:03:55 +00:00
Daniel Dunbar b31b76f1eb Driver: Fix a possible use after free.
llvm-svn: 108659
2010-07-18 21:16:15 +00:00
Chandler Carruth 3973af797a Fix a goof in my previous patch -- not all of the builtins return a value, some
fixed return types.

llvm-svn: 108657
2010-07-18 20:54:12 +00:00
Eli Friedman f8340deacd 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.

llvm-svn: 108656
2010-07-18 20:49:59 +00:00
Chris Lattner e03a5745b1 daniel doesn't hate me, he hates macpython 2.5, which
is a very reasonable position on life!

llvm-svn: 108651
2010-07-18 18:42:35 +00:00
Peter Collingbourne 9e73cae25e 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.

llvm-svn: 108643
2010-07-18 16:45:46 +00:00
Douglas Gregor 3efffd05d5 Revert -Wdiscard-qual typo
llvm-svn: 108641
2010-07-18 11:27:38 +00:00
Chandler Carruth bc8cab16c5 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.

llvm-svn: 108638
2010-07-18 07:23:17 +00:00
Chris Lattner ad4f38b1a9 BUILD_ARCHIVE is the default for libraries, no need to set it.
llvm-svn: 108633
2010-07-18 00:14:47 +00:00
Eli Friedman 3ee1022f37 Fix crash initializing a bit-field with a non-constant in a place where we
try to evaluate the initializer as a constant.

llvm-svn: 108632
2010-07-17 23:55:01 +00:00
Eli Friedman e98194d9e8 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.

llvm-svn: 108630
2010-07-17 20:43:49 +00:00
Fariborz Jahanian aea8e1e3d2 Added PCH/ASTImporter code for ObjCIvarDecl's field.
llvm-svn: 108627
2010-07-17 18:35:47 +00:00
Chris Lattner 52c00bdd5b Add another terrible VC++ compatibility hack: allow users to
allow invalid token pastes (when in -fms-extensions mode)
with -Wno-invalid-token-paste

llvm-svn: 108624
2010-07-17 16:24:30 +00:00
Chris Lattner b2c4937ee4 rename test
llvm-svn: 108623
2010-07-17 16:18:46 +00:00
Chris Lattner 3e40dd34c4 rename test
llvm-svn: 108622
2010-07-17 16:17:41 +00:00
Benjamin Kramer e2e031ed6f Revert r108617, it broke the build.
llvm-svn: 108621
2010-07-17 13:51:58 +00:00
Zhongxing Xu 8de7966fd5 Fix cmake build.
llvm-svn: 108619
2010-07-17 11:59:16 +00:00
Zhongxing Xu 4ca4a999b1 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.

llvm-svn: 108617
2010-07-17 11:12:42 +00:00
Daniel Dunbar 05474285aa clang -cc1as: Switch to using AsmParser constructor function.
llvm-svn: 108605
2010-07-17 02:26:21 +00:00
Ted Kremenek b32964d02d Fix '<rdar://problem/8202272> __imag passed non-complex should not crash' by removing a bogus assertion.
llvm-svn: 108602
2010-07-17 01:28:55 +00:00
Fariborz Jahanian 6a06144021 Another test case for on demand synthesis of ivars.
llvm-svn: 108600
2010-07-17 01:16:59 +00:00
Fariborz Jahanian 18722981e2 Patch to synthesize property ivars on demand as
part of the new property synthesis by default.
wip.

llvm-svn: 108599
2010-07-17 00:59:30 +00:00
John McCall 36ea3723c0 The GNU-runtime ObjC personality function doesn't let us rethrow with URR for
multiple reasons.  Rethrow with _objc_exception_throw instead.  Fixes PR7656.

llvm-svn: 108595
2010-07-17 00:43:08 +00:00
Ted Kremenek 8b9fd890e3 Fix APFloat assertion failure in IdempotentOperationChecker resulting in having
an APFloat with different "float semantics" than the compared float literal.

llvm-svn: 108590
2010-07-17 00:40:32 +00:00
Sebastian Redl c2e6dbfa19 Teach the PCH reader to load the dependency when encountering a chain metadata record. WIP
llvm-svn: 108578
2010-07-17 00:12:06 +00:00
Anders Carlsson bb4cfdff7e When checking whether to bind an expression to a temporary, don't bind Obj-C message send expressions who call methods that return references.
llvm-svn: 108559
2010-07-16 21:18:37 +00:00
Craig Silverstein e1c6749665 Fix typeid the same way I fixed sizeof. Sad I had missed it before.
Reviewed by chandlerc

llvm-svn: 108557
2010-07-16 21:15:34 +00:00
Ted Kremenek 0030be81f5 Remove unicode quotes characters that somehow made it into a recent commit of mine.
llvm-svn: 108552
2010-07-16 20:49:01 +00:00
Sebastian Redl 2abc0383ce Separate out the initial loading of a PCH so that loading chained PCHs can reuse it.
llvm-svn: 108551
2010-07-16 20:41:52 +00:00
Tom Care 826e6b4023 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

llvm-svn: 108550
2010-07-16 20:41:41 +00:00
Nick Lewycky 725b4e7533 Give the 'self/array-comparison is always true/false' warning a new flag,
"-Wtautological-compare".

llvm-svn: 108546
2010-07-16 18:42:10 +00:00
Ted Kremenek d7b31cc60d Hook up warning for an incomplete scanlist in scanf format strings.
llvm-svn: 108542
2010-07-16 18:28:03 +00:00
Ted Kremenek c618728e8d Tweak zero-field width in scanf format string diagnostic.
llvm-svn: 108541
2010-07-16 18:27:56 +00:00
Sebastian Redl 34522813e7 First baby steps towards PCHReader being able to keep track of multiple PCH files. WIP
llvm-svn: 108537
2010-07-16 17:50:48 +00:00
Chandler Carruth 34833372d1 Make this destructor virtual to placate GCC's warnings.
llvm-svn: 108534
2010-07-16 17:27:32 +00:00
Craig Silverstein 16b7d86ef7 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.

Reviewed by wan and chandlerc.

llvm-svn: 108533
2010-07-16 17:06:12 +00:00
John McCall 934069464e Initialize a couple of fields inherited for our private use.
llvm-svn: 108532
2010-07-16 17:02:45 +00:00
Douglas Gregor fc6c3e73cd 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>.

llvm-svn: 108531
2010-07-16 16:54:17 +00:00
Sebastian Redl 1ea025bef9 Add a little more data to chained PCHs. WIP
llvm-svn: 108528
2010-07-16 16:36:56 +00:00
Douglas Gregor 3a8e0d7d57 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.

llvm-svn: 108527
2010-07-16 15:40:40 +00:00
Douglas Gregor 5692680e0e Suppress the "typedef requires a name" warning in Microsoft-extensions mode
llvm-svn: 108526
2010-07-16 15:18:19 +00:00
John McCall 796c2a52a9 Treat template parameters as part of the declaration-specifiers for the
purpose of access control.  Fixes PR7644.

I can't actually find anything directly justifying this, but it seems obvious.

llvm-svn: 108521
2010-07-16 08:13:16 +00:00
Chandler Carruth eeb3c8419f Make this grossness default to the error it should always be.
llvm-svn: 108511
2010-07-16 05:46:45 +00:00
Daniel Dunbar 84336ba3f8 Sema: Fix a bug with #pragma options align=reset, reset against an empty stack
is well defined, it resets to the default alignment.

llvm-svn: 108508
2010-07-16 04:54:16 +00:00
Chandler Carruth 9339605c35 Butcher a perfectly reasonable diagnostic to pacify old versions of SWIG.
llvm-svn: 108505
2010-07-16 04:32:28 +00:00
Ted Kremenek 5530131bb7 Add initial test cases for scanf format string checking.
llvm-svn: 108503
2010-07-16 02:11:34 +00:00
Ted Kremenek a1ef09407d Add the main scanf-parsing logic that I meant to include in my previous commit.
llvm-svn: 108502
2010-07-16 02:11:31 +00:00
Ted Kremenek 575e89dda1 Add missing header file.
llvm-svn: 108501
2010-07-16 02:11:26 +00:00
Ted Kremenek 0208793e41 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.

llvm-svn: 108500
2010-07-16 02:11:22 +00:00
Ted Kremenek 5932c35138 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.

llvm-svn: 108499
2010-07-16 02:11:15 +00:00
Eli Friedman eca55afea3 Fix for PR3800: make sure not to evaluate the expression for a read-write
asm operand twice.

llvm-svn: 108489
2010-07-16 00:55:21 +00:00
Daniel Dunbar 999daa57c7 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.

llvm-svn: 108487
2010-07-16 00:31:23 +00:00
Daniel Dunbar 3348e2d175 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.

llvm-svn: 108482
2010-07-16 00:00:19 +00:00
Daniel Dunbar 900546d2e3 IRgen: Move blocks runtime interfaces to CodeGenModule.
llvm-svn: 108481
2010-07-16 00:00:15 +00:00
Daniel Dunbar 01ad0a78d0 Suppress !+Asserts warning.
llvm-svn: 108480
2010-07-16 00:00:11 +00:00
John McCall 70013b640f 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

llvm-svn: 108477
2010-07-15 23:40:35 +00:00
Devang Patel 8fd6499a97 Set "optimization is ON" and supply other optional parameters. This helps codegenerator preserve info in case the symbol is deleted.
llvm-svn: 108471
2010-07-15 23:09:46 +00:00
Douglas Gregor c5dded5f99 Improve test case. Thanks Eli
llvm-svn: 108470
2010-07-15 23:04:05 +00:00
Douglas Gregor 8997690ff1 Don't suppress the emission of available_externally functions marked
with always_inline attribute. Thanks to Howard for the tip.

llvm-svn: 108469
2010-07-15 22:58:18 +00:00
Devang Patel b3026df9fa Mark implementation generated methods as artificial.
Tested by namespace.exp and virtfunc.exp from gdb testsuite.

llvm-svn: 108468
2010-07-15 22:57:00 +00:00
John McCall ec624b2d19 After some discussion, the ABI list settled on a much more sensible mangling
for string literals.

llvm-svn: 108464
2010-07-15 21:53:03 +00:00
Douglas Gregor dc9361876c 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.

Fixes <rdar://problem/8193163>.

llvm-svn: 108459
2010-07-15 21:05:01 +00:00
Daniel Dunbar 758f87cb97 build/Darwin: Add missing Info.plist template.
llvm-svn: 108457
2010-07-15 20:26:56 +00:00
Daniel Dunbar 20267fefa2 build/Darwin: Enable version information for clang executable.
llvm-svn: 108445
2010-07-15 19:33:44 +00:00
Douglas Gregor cdb466e58f 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!

Hah hah hah.

llvm-svn: 108443
2010-07-15 18:58:16 +00:00
Douglas Gregor cb2b662283 Make the "unused result" warning a warning about run-time behavior, so
that we don't warn when there isn't going to be any computation anyway.

llvm-svn: 108442
2010-07-15 18:47:04 +00:00
Douglas Gregor 31e225cc90 Revert r108431 and r108433 (the cast-to-const-reference fixes), which
broke nightlytest.

llvm-svn: 108439
2010-07-15 18:41:54 +00:00
Douglas Gregor d9d45838e0 Add test case for PR5290; this bug was fixed with the non-class rvalue
de-cv-qualification fixes.

llvm-svn: 108437
2010-07-15 18:35:15 +00:00
Devang Patel 99c372134d 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.

llvm-svn: 108434
2010-07-15 18:16:09 +00:00
Douglas Gregor 6744cbda03 Spell isPRValue() properly.
llvm-svn: 108433
2010-07-15 18:12:28 +00:00
Douglas Gregor 1bae6a1be9 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.

llvm-svn: 108431
2010-07-15 18:04:13 +00:00
Douglas Gregor cee039093a CK_BitCast is not an lvalue bitcast any longer
llvm-svn: 108428
2010-07-15 16:39:55 +00:00
Daniel Dunbar b2447154e0 Driver/Darwin: Resolve deployment target defaulting to be more predictable;
assume we are targetting OS X unless an explicit option is given.

llvm-svn: 108426
2010-07-15 16:18:06 +00:00
Daniel Dunbar 736406d0dc 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.

llvm-svn: 108425
2010-07-15 15:26:14 +00:00
Daniel Dunbar 1d14dd1dc6 CodeGen: Tweak ABI handling for Minix, patch by Kees van Reeuwijk!
llvm-svn: 108423
2010-07-15 15:02:28 +00:00
Chris Lattner ceefcf0143 see comment.
llvm-svn: 108410
2010-07-15 05:22:46 +00:00
Daniel Dunbar 487a796d50 Driver: Support 'clang -x ir ...'.
llvm-svn: 108391
2010-07-15 00:49:21 +00:00
Chris Lattner deee7a3c0b restrict the && -> & warning to cover a case daniel noted.
Don't warn about "logically bool" expressions on the RHS,
even if they fold to a constant.

llvm-svn: 108388
2010-07-15 00:26:43 +00:00
Sebastian Redl 85b2a6a430 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
llvm-svn: 108383
2010-07-14 23:45:08 +00:00
Daniel Dunbar 6f2e839693 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

llvm-svn: 108379
2010-07-14 23:39:36 +00:00
Sebastian Redl 8b41f30064 There is another implementation of PCHReaderListener around. Update it to the new interface.
llvm-svn: 108377
2010-07-14 23:29:55 +00:00
Douglas Gregor eebe72199e 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.

llvm-svn: 108376
2010-07-14 23:20:53 +00:00
Benjamin Kramer 8d5609b604 Pass StringRefs by value.
llvm-svn: 108375
2010-07-14 23:19:41 +00:00
Douglas Gregor 5f0e252f63 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.

llvm-svn: 108372
2010-07-14 23:14:12 +00:00
Douglas Gregor c357f4121e Add lvalue-bitcast support for complex numbers.
llvm-svn: 108363
2010-07-14 21:35:45 +00:00
Sebastian Redl 409183ff7c Increase the max PCH level for declarations to 7. Add a FromPCH flag to types.
llvm-svn: 108354
2010-07-14 20:26:45 +00:00
Daniel Dunbar 9765b9817d 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).

llvm-svn: 108346
2010-07-14 18:46:27 +00:00
Daniel Dunbar 9c3ed5f4d0 Driver: Remove some unused arguments.
llvm-svn: 108345
2010-07-14 18:46:23 +00:00
Fariborz Jahanian 56a9d54de8 Don't error when doing default property synthesis
and some are already synthesized by user declaration.

llvm-svn: 108341
2010-07-14 18:11:52 +00:00
Sebastian Redl 75fbb3b5e5 Make PCHReader cope with PCH files containing more than one predefines buffer.
llvm-svn: 108340
2010-07-14 17:49:11 +00:00
Douglas Gregor 9f1570d993 Only filter out names reserved for the implementation (e.g., __blah or
_Foo) from code-completion results when they come from a system
header.

llvm-svn: 108338
2010-07-14 17:44:04 +00:00
Fariborz Jahanian c0b0ced477 Consider obective-c pointer arguments as valid sentinel args
as well. Fixes radar 7975788.

llvm-svn: 108333
2010-07-14 16:37:51 +00:00
John McCall 4f3b5f302c Fix the mangling of template template arguments, which do not always
follow <name>;  instead they follow <type>, which has <name> as a subset.

Fixes PR7446.

llvm-svn: 108326
2010-07-14 06:43:17 +00:00
Chandler Carruth cb3b5a483f 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.

llvm-svn: 108325
2010-07-14 06:36:18 +00:00
Douglas Gregor 261793bb73 Add test case that was causing an infinite loop when reading PCH files. The test works with ToT Clang already
llvm-svn: 108318
2010-07-14 04:45:33 +00:00
John McCall afe20780ee 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

llvm-svn: 108317
2010-07-14 04:38:21 +00:00
John McCall 05ddbb80d2 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.

llvm-svn: 108315
2010-07-14 04:20:34 +00:00
Douglas Gregor c3d6cb6543 Fix typo in test program
llvm-svn: 108298
2010-07-14 00:09:17 +00:00
Daniel Dunbar af68a88e68 Driver/Darwin: Pass -pie/-no_pie to the linker when -fpie/-fno-pie and friends
are explicitly given.

llvm-svn: 108297
2010-07-13 23:31:40 +00:00
Douglas Gregor c95a41b510 Add missing testcases for lvalue bitcasts
llvm-svn: 108296
2010-07-13 23:27:15 +00:00
John McCall 11e577b99a Work around an obnoxious GCC warning by changing semantics in a hopefully-
harmless way.

llvm-svn: 108295
2010-07-13 23:19:49 +00:00
Douglas Gregor 51954276cc Introduce a new cast kind for an "lvalue bitcast", which handles
reinterpret_casts (possibly indirectly via C-style/functional casts)
on values, e.g., 

  int i;
  reinterpret_cast<short&>(i);

The IR generated for this is essentially the same as for

  *reinterpret_cast<short*>(&i).

Fixes PR6437, PR7593, and PR7344. 

llvm-svn: 108294
2010-07-13 23:17:26 +00:00
Nick Lewycky cb89a2a150 Add __builtin_snprintf.
llvm-svn: 108290
2010-07-13 22:35:05 +00:00
John McCall 5c0e69ef0e Switch the __cxa_rethrow cleanup to be lazy.
llvm-svn: 108288
2010-07-13 22:24:23 +00:00
John McCall 5c08ab956b Allow for the possibility that __cxa_end_catch might throw for a catch-all block
or a catch of a record type by value or reference.  Also convert this to a
lazy cleanup.

llvm-svn: 108287
2010-07-13 22:12:14 +00:00
Fariborz Jahanian 5848d333b4 Check on property attributes which are declared
in class extensions (radar 8171968).

llvm-svn: 108283
2010-07-13 22:04:56 +00:00
John McCall bb0260139a Switch the __cxa_free_exception cleanup to be lazy.
llvm-svn: 108276
2010-07-13 21:17:51 +00:00
Fariborz Jahanian 714447b2ed Set DeclContext of ParamVarDecl only. No need
to set that of VarDecl for block variables
(they are already set). Per Doug's comment.

llvm-svn: 108273
2010-07-13 21:05:02 +00:00
John McCall 2b7fc3828e Teach IR generation how to lazily emit cleanups. This has a lot of advantages,
mostly in avoiding unnecessary work at compile time but also in producing more
sensible block orderings.

Move the destructor cleanups for local variables over to use lazy cleanups.
Eventually all cleanups will do this;  for now we have some awkward code
duplication.

Tell IR generation just to never produce landing pads in -fno-exceptions.
This is a much more comprehensive solution to a problem which previously was
half-solved by checks in most cleanup-generation spots.

llvm-svn: 108270
2010-07-13 20:32:21 +00:00
Sebastian Redl 117b01b2da Add two small utility functions to PCHReader that the writer will use. WIP.
llvm-svn: 108267
2010-07-13 20:12:07 +00:00
Fariborz Jahanian a6c7efec2b More block instantiation stuff. Set variable/param DeclContext
to block context when first instantiating them.

llvm-svn: 108266
2010-07-13 20:05:58 +00:00
Chris Lattner 8406c5197b Add a warning to catch a bug recently caught by code review, like this:
t2.c:2:12: warning: use of logical && with constant operand; switch to bitwise &
      or remove constant [-Wlogical-bitwise-confusion]
  return x && 4;
           ^  ~

wording improvement suggestions are welcome.

llvm-svn: 108260
2010-07-13 19:41:32 +00:00
Chris Lattner ca9f2a025c 80 column issues.
llvm-svn: 108257
2010-07-13 19:22:31 +00:00
Douglas Gregor a8a089bfd5 Whenever we're creating an expression that is typically an rvalue
(e.g., a call, cast, etc.), immediately adjust the expression's type
to strip cv-qualifiers off of all non-class types (in C++) or all
types (in C). This effectively extends my previous fix for PR7463,
which was restricted to calls, to other kinds of expressions within
similar characteristics. I've audited every use of
getNonReferenceType() in the code base, switching to the newly-renamed
getNonLValueExprType() where necessary. 

Big thanks to Eli for pointing out just how incomplete my original fix
for PR7463 actually was. We've been handling cv-qualifiers on rvalues
wrong for a very, very long time. Fixes PR7463.

llvm-svn: 108253
2010-07-13 18:40:04 +00:00
Chandler Carruth 46e8978c69 Silence Doug's favorite GCC warning.
llvm-svn: 108247
2010-07-13 17:07:17 +00:00
Devang Patel 01c8c100c2 Add volatile qualifiers for "this".
llvm-svn: 108245
2010-07-13 16:23:13 +00:00
Douglas Gregor f39cf26cb5 Properly add to 32
llvm-svn: 108243
2010-07-13 15:57:00 +00:00
Douglas Gregor f2753b3b4e Downgrade the "when type is in parentheses, array cannot have dynamic
size" error for code like 

  new (int [size])

to a warning, add a Fix-It to remove the parentheses, and make this
diagnostic work properly when it occurs in a template
instantiation. <rdar://problem/8018245>.

llvm-svn: 108242
2010-07-13 15:54:32 +00:00
Argyrios Kyrtzidis 36745fda34 Modify the pragma handlers to accept and use StringRefs instead of IdentifierInfos.
When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded).
We can avoid this if we just use StringRefs for the pragmas.

As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified.

llvm-svn: 108237
2010-07-13 09:07:17 +00:00
Douglas Gregor e82f087378 Improve diagnostics for the "type qualifier on return type has no
effect warning" by printing the qualifiers we saw and correctly
pluralizing the message, e.g.,

test/SemaCXX/conditional-expr.cpp:295:3: warning: 'const volatile' type
      qualifiers on return type have no effect
  const volatile Enum g2() {
  ^~~~~ ~~~~~~~~

llvm-svn: 108236
2010-07-13 08:50:30 +00:00
Douglas Gregor f5b160f89c When computing the canonical profile of a DeclRefExpr or MemberExpr,
don't include the nested-name-specifier or template arguments: they
were only relevant when resolving the declaration. Fixes PR7460.

llvm-svn: 108235
2010-07-13 08:37:11 +00:00
Douglas Gregor 603d81bf8d When forming a function call or message send expression, be sure to
strip cv-qualifiers from the expression's type when the language calls
for it: in C, that's all the time, while C++ only does it for
non-class types. 

Centralized the computation of the call expression type in
QualType::getCallResultType() and some helper functions in other nodes
(FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant
callers of getResultType() to getCallResultType().

Fixes PR7598 and PR7463, along with a bunch of getResultType() call
sites that weren't stripping references off the result type (nothing
stripped cv-qualifiers properly before this change).

llvm-svn: 108234
2010-07-13 08:18:22 +00:00
Douglas Gregor d8f446f1b2 Diagnose typedef of an operator name. Fixes PR7462
llvm-svn: 108233
2010-07-13 06:37:01 +00:00
John McCall a15eb737e4 Check in this -Wconversion C++ test case that's been sitting on my machine
for awhile.

llvm-svn: 108232
2010-07-13 06:26:23 +00:00
Douglas Gregor aa8c97262a Complain when an unnamed enumeration has no enumerations (in
C++). Fixes PR7466.

llvm-svn: 108231
2010-07-13 06:24:26 +00:00
Douglas Gregor a700f68828 Reinstate the optimization suppressing available_externally functions
at -O0. The only change from the previous patch is that we don't try
to generate virtual method thunks for an available_externally
function.

llvm-svn: 108230
2010-07-13 06:02:28 +00:00
Devang Patel 0a34e31d81 const qualify debug info for "this" for const methods.
llvm-svn: 108220
2010-07-13 00:24:30 +00:00
Fariborz Jahanian f8681a2a3f Instantiate attributes when first building an instantiated
VarDecl.

llvm-svn: 108218
2010-07-13 00:16:40 +00:00
Douglas Gregor 6cc1df5d3d Provide a special diagnostic for attempts to explicitly specialize
class templates within class scope (which is ill-formed), and recover
by dropping the explicit specialization entirely. Fixes the infinite
loop in PR7622.

llvm-svn: 108217
2010-07-13 00:10:04 +00:00
Douglas Gregor 11cfd9441d Fix a documentation paste-o and eliminate a useless function parameter, both found by Sebastian
llvm-svn: 108214
2010-07-12 23:48:14 +00:00
Craig Silverstein 811d1f8ba1 We should not be recursing over the shadow definitions in UsingDecl --
they're not something the user typed (at least, not here).

llvm-svn: 108212
2010-07-12 23:30:43 +00:00
Sebastian Redl 5467c9fac5 Produce an error on encountering a pointer or reference to a qualified function type. Fixes PR7470.
llvm-svn: 108209
2010-07-12 23:11:43 +00:00
Devang Patel 0aabb1200f While collecting members for a class, always create delcaration entry for methods. Debug info for method definition will be generated while generating code for method body.
Tested by classes.exp in gdb testsuite.

llvm-svn: 108205
2010-07-12 22:54:41 +00:00
Sebastian Redl 143413f8fb Split the normal and chained PCH writing paths and add a tiny bit of implementation to the latter. WIP.
llvm-svn: 108200
2010-07-12 22:02:52 +00:00
Argyrios Kyrtzidis d1d239f35c Remove the check for repeated tok::eofs, we are not supposed to go past eof so this code is
totally unnecessary.

llvm-svn: 108199
2010-07-12 21:41:41 +00:00
Argyrios Kyrtzidis f4cc7dcf9b Simplify code using the new FoldingSetImpl::InsertNode() overload.
llvm-svn: 108198
2010-07-12 21:41:31 +00:00
Fariborz Jahanian 8308585a1e Copy over attributes to instantiated variable.
llvm-svn: 108195
2010-07-12 21:12:19 +00:00
Douglas Gregor 553f3a9b30 Speculatively revert r108156; it appears to be breaking self-host.
llvm-svn: 108194
2010-07-12 21:08:32 +00:00
Argyrios Kyrtzidis c2924de667 If we are past tok::eof and in caching lex mode, avoid caching repeated tok::eofs.
llvm-svn: 108175
2010-07-12 18:49:30 +00:00
Douglas Gregor 47815d5b8c Add a -code-completion-timing= mode to c-index-test, so that we can
test the performance of code-completion without testing the
performance of printf().

llvm-svn: 108172
2010-07-12 18:38:41 +00:00
Fariborz Jahanian c289bce1f5 Compute Type dependent-ness of BlockDeclRefExpr
on the fly when constructing it.

llvm-svn: 108166
2010-07-12 18:12:03 +00:00
Ted Kremenek 424ce75f8d Add test case for <rdar://problem/8177927> (which triggered an assertion failure in SemaChecking).
llvm-svn: 108159
2010-07-12 17:35:39 +00:00
Fariborz Jahanian 70c0b08022 Move setting of Dependent Type to BlockDeclRefExpr's
constructor.

llvm-svn: 108157
2010-07-12 17:26:57 +00:00
Douglas Gregor dbb2806a7b Do not generate LLVM IR for available_externally function bodies at
-O0, since we won't be using the definitions for anything anyway. For
lib/System/Path.o when built in Debug+Asserts mode, this leads to a 4%
improvement in compile time (and suppresses 440 function bodies).

<rdar://problem/7987644>

llvm-svn: 108156
2010-07-12 17:24:55 +00:00
Chandler Carruth 65a38183f0 Fix another aspect of PR7047, macro expansions. Previously, this was hacked
around by exempting enums from the check, but this doesn't handle a lot of
cases. A better approach is to directly check if the operator comes from
a macro expansion.

I've removed a reference to the rdar that originally led to the enum
suppression when removing it's overly contrived test case. Let me know if that
number or a more reasilistic test case involving enums is still needed.

llvm-svn: 108128
2010-07-12 06:23:38 +00:00
Chris Lattner 5a503e9f70 we do in fact have to cache the EOF token returned by the preprocessor.
In the case of backtracking, the cached token lexer will be the only 
lexer on the stack, without this the token stack will be empty and EOF
won't be returned.

This fixes PR7072.

llvm-svn: 108124
2010-07-12 04:25:32 +00:00
Chris Lattner 0931644922 revert a hunk of code that Argiris added in r106213, which is the
root cause of PR7481 and probably more, and has no apparent 
testcases.  I don't understand the logic here so I can't repair it.

llvm-svn: 108119
2010-07-12 01:48:28 +00:00
Chris Lattner 33919e7450 fix PR7280 by making the warning on code like this:
int test1() {
  return;
}

default to an error.

llvm-svn: 108108
2010-07-11 23:34:02 +00:00
Chris Lattner ef74e2b2a8 change the 'invalid token after top level declarator' message to be
'expected ';' after top level declarator' which is much less vague.

llvm-svn: 108106
2010-07-11 22:46:04 +00:00
Chris Lattner 1390134c18 Fix PR7617 by not entering ParseFunctionDefinition when
a function prototype is followed by a declarator if we
aren't parsing a K&R style identifier list.

Also, avoid skipping randomly after a declaration if a
semicolon is missing.  Before we'd get:

t.c:3:1: error: expected function body after function declarator
void bar();
^

Now we get:

t.c:1:11: error: invalid token after top level declarator
void foo()
          ^
          ;

llvm-svn: 108105
2010-07-11 22:42:07 +00:00
Chris Lattner dbb1e93a9f add a const qualifier, refactor some code.
llvm-svn: 108104
2010-07-11 22:24:20 +00:00
Chandler Carruth 62e5e56dad Switch to void-cast for this. Chris prefers that over the attribute, I'll
probably try and switch more of these if I can.

llvm-svn: 108085
2010-07-11 07:42:13 +00:00
Chandler Carruth 32652f3400 Mark assert-only variables as unused.
llvm-svn: 108068
2010-07-11 03:24:05 +00:00
John Thompson 311de2e188 Rename clang.dll to libclang.dll, to fix Windows build.
llvm-svn: 108067
2010-07-11 03:23:30 +00:00
Nick Lewycky d54e2aba6c PrintFunctionNames is a plugin, it should pull in symbols from the clang binary
that loads it, not by linking against them directly.

llvm-svn: 108055
2010-07-10 20:24:23 +00:00
Nick Lewycky 32a168c5f8 Clang do so have plugins, we can't prune exports. Fixes plugin support.
llvm-svn: 108054
2010-07-10 20:19:47 +00:00
Dale Johannesen bde8ee26d0 Fix compile error. Per Fariborz.
llvm-svn: 108051
2010-07-10 19:53:56 +00:00
Chandler Carruth 17773fcd83 Lay the ground work for resoving PR7047. This doesn't actually fix it because
default arguments to template parameters don't have a DeclContext when
instantiated, and so we can't detect that we're in an instantiation context as
opposed to the definition context. However, it fixes the more commonly-occuring
cases in TMP code that use devolve to this type of tautology after
substitution.

llvm-svn: 108044
2010-07-10 12:30:03 +00:00
Argyrios Kyrtzidis b8d77eb300 Add PCH support for the remaining C++ exprs.
llvm-svn: 108042
2010-07-10 11:46:15 +00:00
Peter Collingbourne 9701743b1a Fix CMake build
llvm-svn: 108031
2010-07-09 23:06:34 +00:00
John Thompson c438947242 Hack for dealing with commas until we support multiple alternative constraints, per pr7338.
llvm-svn: 108028
2010-07-09 22:49:34 +00:00
Fariborz Jahanian 4239aa104b BlockDeclRefExpr of a dependent type must
be a dependent expression when its is built.

llvm-svn: 108026
2010-07-09 22:21:32 +00:00
Fariborz Jahanian 2f8bd36bcf Instantiation of byref variable in
block literal expression.

llvm-svn: 108019
2010-07-09 21:27:28 +00:00
Sebastian Redl 3e39272fed Slightly improve the diagnostic when using a qualified function typedef to declare nonmember or static member functions.
llvm-svn: 108018
2010-07-09 21:26:08 +00:00
Argyrios Kyrtzidis 8704057ce9 Reorganize how ClassTemplate[Partial]SpecializationDecls are read/written to avoid the
possibility of adding an unitialized one into the folding set.

llvm-svn: 108016
2010-07-09 21:11:43 +00:00
Argyrios Kyrtzidis dd2061b2cd isMemberSpecialization -> setMemberSpecialization.
llvm-svn: 108015
2010-07-09 21:11:35 +00:00
Sebastian Redl 4d3af3e192 When given the -chained-pch option and a previous PCH file, have the PCHWriter emit a CHAINED_METADATA record instead of METADATA, and write a link to the previous file there.
llvm-svn: 108014
2010-07-09 21:00:24 +00:00
Craig Silverstein 4a5d086b50 Fix a crashing but trying to print a TemplateTemplateParmDecl
for code like this:
   template<template<typename T> class U> class V {};

The problem is that the DeclPrinter assumed all TemplateDecls
have a getTemplatedClass(), but template template params don't
(so we got a NULL dereference).  The solution is to detect if
we're a template template param, and construct the template
class name ('class U') specially in this case.

OKed by dgregor and chandlerc

llvm-svn: 108007
2010-07-09 20:25:10 +00:00
Eli Friedman d8c60e34da Ignore -Wno-main, per PR7269.
llvm-svn: 108006
2010-07-09 20:03:13 +00:00
Chandler Carruth 0b73ccfe20 Rip out the floating point return type handling from the atomic builtin. It's
wrong, and we don't handle floating point value type arguments yet anyways.
Will add correct logic for both when I finish the patch.

llvm-svn: 108004
2010-07-09 19:19:40 +00:00
Chandler Carruth 741e5cea77 Fix PR7600, and correctly convert the result of an atomic builtin to the
expected value type. This is necessary as the builtin is internally represented
as only operating on integral types.

Also, add a FIXME to add support for floating point value types.

llvm-svn: 108002
2010-07-09 18:59:35 +00:00
Fariborz Jahanian 1babe7778d Instantiation of block literal expressions. wip.
llvm-svn: 108000
2010-07-09 18:44:02 +00:00
Douglas Gregor 79edde88ed Document my otherwise-inexplicable change
llvm-svn: 107998
2010-07-09 18:39:07 +00:00
Douglas Gregor 8014df4c21 Refer to implicit "conversions" rather than implicit "casts", which
don't technically exist in the language. <rdar://problem/8085982>

llvm-svn: 107995
2010-07-09 18:18:35 +00:00
Sebastian Redl 60876431b1 Correctly initialize Reader to null.
llvm-svn: 107994
2010-07-09 17:53:32 +00:00
Sebastian Redl f525a30d19 Really respect -chained-pch.
llvm-svn: 107993
2010-07-09 17:40:12 +00:00
Douglas Gregor 8ed0c0b99d Introduce -f{no-}spell-checking options to enable/disable
spell-checking. By default, spell-checking is enabled for Clang
(obviously) but disabled in CIndex for performance reasons.

llvm-svn: 107992
2010-07-09 17:35:33 +00:00
Douglas Gregor 137b27da2e Document -f{no-}color-diagnostics
llvm-svn: 107985
2010-07-09 16:31:58 +00:00
Craig Silverstein 60f8b286ad Move traverseunqualifiedtypeloc over to the 'main' typeloc tree.
Note that this is a move -- we pretend that we were really looking
at the unqualified typeloc all along -- rather than a recursion, so
we don't follow the normal CRTP plan of going through
getDerived().TraverseTypeLoc.  If we did, we'd be traversing twice
for the same type (once as a QualifiedTypeLoc version of the type,
once as an UnqualifiedTypeLoc version of the type), which in effect
means we'd call VisitTypeLoc twice with the 'same' type.  This
solves that problem, at the cost of never seeing the qualified
version of the type (unless the client subclasses
TraverseQualifiedTypeLoc themselves).  It's not a perfect solution.
A perfect solution probably requires making QualifiedTypeLoc a
wrapper around TypeLoc -- like QualType is a wrapper around Type*
-- rather than being its own class in the type hierarchy.

Reviewed by wan.

llvm-svn: 107973
2010-07-09 15:19:34 +00:00
John Thompson ab71ead011 Revert 107953, remove comma ignoring from PPC constraints.
llvm-svn: 107956
2010-07-09 04:53:08 +00:00
John Thompson 7099f0c0d5 Updating PPC target to ignore commas in asm contrains, as apparently that is what gcc does.
llvm-svn: 107953
2010-07-09 02:01:40 +00:00
Sebastian Redl f4b0c4b946 Add a frontend option -chained-pch and don't pass an active PCH reader to the PCH writer if it is not set, preventing creation of chained PCH files. Since the reader is so far unused, effectively no functionality change.
llvm-svn: 107936
2010-07-09 00:00:58 +00:00
Jordy Rose d5d2e50f3e Cleanup in CStringChecker. Now properly bifurcates the state for zero/nonzero sizes.
llvm-svn: 107935
2010-07-08 23:57:29 +00:00
Douglas Gregor 4587969555 Support code completion for parameter names in Objective-C method
declarations.

llvm-svn: 107933
2010-07-08 23:37:41 +00:00
Douglas Gregor 95887f9c5b Introduce a new code-completion point prior to an identifier in the
selector of an Objective-C method declaration, e.g., given

  - (int)first:(int)x second:(int)y;

this code completion point triggers at the location of "second". It
will provide completions that fill out the method declaration for any
known method, anywhere in the translation unit.

llvm-svn: 107929
2010-07-08 23:20:03 +00:00
Sebastian Redl caef9ab03c When looking for an entity's Scope, don't consider scopes that can't contain declarations. Fixes PR7594.
llvm-svn: 107927
2010-07-08 23:07:34 +00:00
Sebastian Redl 595c51342c Some preparatory work for chained PCH. No functionality change.
llvm-svn: 107915
2010-07-08 22:01:51 +00:00
Zhanyong Wan 9870460c84 Makes RecursiveASTVisitor traverse the type of a temporary object
created via T() where T is a class type.  Reviewed by chandlerc and
csilvers.

llvm-svn: 107911
2010-07-08 21:01:29 +00:00
Douglas Gregor 55b037b9f3 During code completion, give the "nil" and "NULL" macros the same
priority as other constants. And, if we're in a place where we prefer
a pointer type, consider "nil" and "NULL" to be close matches.

llvm-svn: 107910
2010-07-08 20:55:51 +00:00
Douglas Gregor eaff2cbbab Allow C-style casts and reinterpret_casts between block pointers and
either integer values or other pointers. Fixes <rdar://problem/8134521>.

llvm-svn: 107905
2010-07-08 20:27:32 +00:00
Eli Friedman 07c89c6b3e PR7588: Fix the _mm_shufflehi_epi16 macro. (The issue was an oversight
involving operator precedence.)

llvm-svn: 107902
2010-07-08 20:09:45 +00:00
Devang Patel 8f3f76f991 Handle forward declarations properly in debug info.
Patch by Alexander Kabaev.
PR 7595.

llvm-svn: 107900
2010-07-08 19:56:29 +00:00
Ted Kremenek 3245003251 Add missing whitespace.
llvm-svn: 107897
2010-07-08 19:43:08 +00:00
Douglas Gregor 9961ce9428 When performing substitution of template arguments within the body of
a template, be sure to include the template arguments from the
injected-class-name. Fixes PR7587.

llvm-svn: 107895
2010-07-08 18:37:38 +00:00
Ted Kremenek 30ae68bd17 Update checker build.
llvm-svn: 107893
2010-07-08 18:08:18 +00:00
Argyrios Kyrtzidis 7e8996c7e6 Introduce PCHReader::GetTranslationUnitDecl() and use it instead of ReadDeclRecord when initializing.
ReadDeclRecord would hit assertion if the translation unit declaration was already loaded during
IdentifierInfo initialization.

llvm-svn: 107885
2010-07-08 17:13:02 +00:00
Argyrios Kyrtzidis 9f2d24a808 Support TemplateTemplateParmDecl for PCH.
llvm-svn: 107884
2010-07-08 17:12:57 +00:00
Douglas Gregor f609386058 Bowing to popular demand, reduce the "comma at end of enumerator list"
ExtWarn to an Extension. Let the broken code propagate!

llvm-svn: 107875
2010-07-08 14:54:42 +00:00
John McCall b5081aff68 Apparently the {{$}} hack doesn't work on Windows; I am saddened but not
surprised.

llvm-svn: 107874
2010-07-08 13:17:29 +00:00
Argyrios Kyrtzidis a4ed18191c For TagType and TemplateSpecializationType, isDependent calculation may be invalid because some decls that the
calculation is using may still be initializing.
Thus, store the isDependent flag to PCH and restore directly to Type.

llvm-svn: 107873
2010-07-08 13:09:53 +00:00
Argyrios Kyrtzidis 1985bb3b10 Read/write the C++ parts of DeclRefExpr and MemberExpr for PCH.
llvm-svn: 107872
2010-07-08 13:09:47 +00:00
Argyrios Kyrtzidis 00dda6accc Fix reading of UsingDecl from PCH.
llvm-svn: 107871
2010-07-08 13:09:41 +00:00
Argyrios Kyrtzidis ab446e1b57 Remove unused protected constructor of DeclRefExpr.
llvm-svn: 107870
2010-07-08 13:09:35 +00:00
Chandler Carruth e51a119fc6 Wrap the new ext-warn on extraneous comma on the last entry of an enumerator
list in a diagnostic group so it can be turned on and off. A terrifying amount
of code, including large chunks of open source code, still do this so it's
important to be able to suppress it when necessary.

Doug, is this a reasonable compromise? I'd lean toward making it a normal
extension, but I don't feel strongly as long as we can turn the warnings off.

llvm-svn: 107865
2010-07-08 10:52:01 +00:00
Chandler Carruth dd1bc0f1b5 Add support for differentiating between attributes ignored when handled and
unknown attributes that we discard. Add a diagnostic group for unknown
attribute warnings to allow turning these off when we don't care. Also
consolidates the tests for this case.

llvm-svn: 107864
2010-07-08 09:42:26 +00:00
Duncan Sands b69d4ce5f3 Tweak documentation to mention Debug+Asserts.
llvm-svn: 107863
2010-07-08 08:31:28 +00:00
John McCall be349def4b Mark calls to 'throw()' functions as nounwind, and mark the functions nounwind
as well.

llvm-svn: 107858
2010-07-08 06:48:12 +00:00
Douglas Gregor 747eb7840a Reinstate the fix for PR7556. A silly use of isTrivial() was
suppressing copies of objects with trivial copy constructors.

llvm-svn: 107857
2010-07-08 06:14:04 +00:00
Chris Lattner 06801d7371 allow this to pass on 32-bit hosts.
llvm-svn: 107845
2010-07-08 00:23:21 +00:00
Chris Lattner cb7696cf35 fix the clang side of PR7437: EmitAggregateCopy
was not producing a memcpy with the right address
spaces because of two places in it doing casts of
the arguments to i8, one of which that didn't
preserve the address space.

There is also an optimizer bug here.

llvm-svn: 107842
2010-07-08 00:07:45 +00:00
Chris Lattner 26b1a19842 filecheckize this test.
llvm-svn: 107841
2010-07-08 00:05:45 +00:00
Sebastian Redl bbace2a63d Fix a few errors in the internals doc.
llvm-svn: 107838
2010-07-07 23:42:27 +00:00
Douglas Gregor e182370eda Revert r107828 and r107827, the fix for PR7556, which seems to be
breaking bootstrap on Linux.

llvm-svn: 107837
2010-07-07 23:37:33 +00:00
Chris Lattner 86851b8a7a fix PR4499, patch by Kyle Dean!
llvm-svn: 107836
2010-07-07 23:24:27 +00:00
Sebastian Redl a771d2239d Rip out the C++0x-specific handling of destructor names. The specification is still in flux and unclear, and our interim workaround was broken. Fixes PR7467.
llvm-svn: 107835
2010-07-07 23:17:38 +00:00
Douglas Gregor 1d9ef840fa A using declaration can redeclare a typedef to the same type. These
typedefs won't have the same canonical declaration (since they are
distinct), so we need to check for this case specifically. Fixes
<rdar://problem/8018262>.

llvm-svn: 107833
2010-07-07 23:08:52 +00:00
Douglas Gregor 6df2b8c3ac Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect its
newly-narrowed scope. No functionality change.

llvm-svn: 107828
2010-07-07 22:43:56 +00:00
Douglas Gregor 442612c285 Do not use CXXZeroValueInitExpr for class types. Instead, use
CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as
appropriate. Fixes PR7556, and provides a slide codegen improvement
when copy-initializing a POD class type from a value-initialized
temporary. Previously, we weren't eliding the copy.

llvm-svn: 107827
2010-07-07 22:35:13 +00:00
Nate Begeman 5da51d38d7 Fix an issue with opencl init list checking.
llvm-svn: 107824
2010-07-07 22:26:56 +00:00
Zhanyong Wan fb617d5365 Changes how the TypeLoc traverser invokes the Type traverser: before,
VisitFooTypeLoc() calls VisitFooType(); now, TraverseFooTypeLoc()
calls WalkUpFromFooType(). This allows clients that override
WalkUpFromFooType() to continue to work.  It also preserves the
property that Visit*() in the base visitor class is a no-op (s.t. a
subclass doesn't have to call Base::Visit*() when overriding
Visit*()).

Also fixes some typos in comments.
         
Also added a missing getDerived() inside
TraverseQualifiedTypeLoc(). The call is needed in case a subclass
overrides TraverseTypeLoc().

Reviewed by nlewycky and csilvers.

llvm-svn: 107816
2010-07-07 21:36:58 +00:00
Douglas Gregor 2530efd3cf When printing statistics for the ASTContext, also print them for its BumpPtrAllocator
llvm-svn: 107790
2010-07-07 16:40:34 +00:00
Chris Lattner 3e2ee147d0 add driver support for minix, patch by Kees van Reeuwijk
from PR7583

llvm-svn: 107788
2010-07-07 16:01:42 +00:00
Argyrios Kyrtzidis ad65c6926b Fix broken reading of NestedNameSpecifiers from PCH.
llvm-svn: 107784
2010-07-07 15:46:30 +00:00
Argyrios Kyrtzidis 903ccd6121 Delay passing InterestingDecls to the Consumer until when we know we are not in recursive loading and the
declarations are fully initialized.

llvm-svn: 107783
2010-07-07 15:46:26 +00:00
Argyrios Kyrtzidis 54fcbc7345 getBody() -> hasBody()
llvm-svn: 107773
2010-07-07 12:24:18 +00:00
Argyrios Kyrtzidis 0b6a06a335 Simplify code and remove comment that is no longer relevant.
llvm-svn: 107772
2010-07-07 12:24:14 +00:00
Argyrios Kyrtzidis 568bc84562 Remove Decl::getCompoundBody().
This has 2 (slight) advantages:
-Make explicit at getBody()'s callsite that we expect/handle only CompoundStmt and not CXXTryStmt.
-Better tracking of Decl::getBody()'s callsites.

llvm-svn: 107771
2010-07-07 11:31:34 +00:00
Argyrios Kyrtzidis 6fbc8fa53e Simplify code. CompoundStmt's RBraceLoc can be found using its SourceRange too.
llvm-svn: 107770
2010-07-07 11:31:27 +00:00
Argyrios Kyrtzidis 46f556d4e5 Simplify code. FunctionDecl and ObjCMethodDecl have some common interfaces.
llvm-svn: 107769
2010-07-07 11:31:23 +00:00
Argyrios Kyrtzidis 36ea322579 Introduce Decl::hasBody() and FunctionDecl::hasBody() and use them instead of getBody() when we are just checking the existence of a body, to avoid de-serialization of the body from PCH.
Makes de-serialization of the function body even more "lazier".

llvm-svn: 107768
2010-07-07 11:31:19 +00:00
Jordy Rose 65136fb669 Add memcmp() and bcmp() to CStringChecker. These check for valid access to the buffer arguments and have a special-case for when the buffer arguments are known to be the same address, or when the size is zero.
llvm-svn: 107761
2010-07-07 08:15:01 +00:00
Duncan Sands 86f86f532a A Release-Asserts build is now called a Release build.
llvm-svn: 107760
2010-07-07 07:49:17 +00:00
Jordy Rose 33c829a6fd Cleanup on CStringChecker and its associated tests. Also check for null arguments...which are allowed if the access length is 0!
llvm-svn: 107759
2010-07-07 07:48:06 +00:00
John McCall b609d3f5f9 Teach function-try-blocks on constructors and destructors to implicitly
rethrow.  Fixes rdar://problem/7696603

llvm-svn: 107757
2010-07-07 06:56:46 +00:00
Chris Lattner 3956106543 implement PR7569, warning about assignment to null, which
people seem to write when they want a deterministic trap.
Suggest instead that they use a volatile pointer or 
__builtin_trap.

llvm-svn: 107756
2010-07-07 06:14:23 +00:00
John McCall 11086fcb65 Don't consider casted non-global pointers to be evaluatable.
Fixes rdar://problem/8154689

llvm-svn: 107755
2010-07-07 05:08:32 +00:00
Craig Silverstein 6f9236e762 Avoid double-traversing for QualifiedTypeLoc -- we were calling
VisitTypeLoc twice for qualified types, once for the qualified form
and once for the unqualified (though they looked the same by the time
we got to visittypeloc).  Now only visit once, which matches previous
behavior.

Reviewed by nlewycky

llvm-svn: 107754
2010-07-07 04:38:11 +00:00
Tom Care ca1f871ff8 Change explicit handling of impossible condition to call llvm_unreachable in IdempotentOperationChecker::PreVisitBinaryOperator.
llvm-svn: 107748
2010-07-07 01:27:17 +00:00
Chandler Carruth 509a9ce9da Silence an annoying GCC warning about use of an uninitialized variable. Even
making the other switch case unreachable, or sinking the 'continue' into it
doesn't silence this.

llvm-svn: 107745
2010-07-07 00:36:56 +00:00
Chandler Carruth dce439d11d Use 'llvm_unreachable' to mark impossible code paths so that GCC doesn't
consider them for warnings.

llvm-svn: 107741
2010-07-07 00:07:37 +00:00
John McCall 09ae03299a Provide a hook for the benefit of clients using clang IR gen as a subroutine:
emit metadata associating allocas and global values with a Decl*.  This feature
is controlled by an option that (intentionally) cannot be enabled on the command
line.

To use this feature, simply set
  CodeGenOptions.EmitDeclMetadata = true;
and then interpret the completely underspecified metadata. :)

llvm-svn: 107739
2010-07-06 23:57:41 +00:00
Ted Kremenek da534381f8 Fix casts in RegionStore to not always assume that bindings are only to SubRegions. Fixes assertion failure
reported in PR 7572.

llvm-svn: 107738
2010-07-06 23:53:29 +00:00
Craig Silverstein 43adffd1d4 Add a const version of a method, to be consistent with other methods
of the same type.  I think this was just an oversight before.

Reviewed by chandlerc.  Submitted as an "obvious" fix.

llvm-svn: 107737
2010-07-06 23:51:34 +00:00
Tom Care 49f1e908b2 Fix idempotent operations test command line arguments.
llvm-svn: 107735
2010-07-06 23:47:26 +00:00
Ted Kremenek 0fc6354f2f Implement dumpToStream() for NonStaticGlobalSpaceRegion and StaticGlobalSpaceRegion.
llvm-svn: 107731
2010-07-06 23:37:21 +00:00
Jordy Rose cf781e5430 Add comment noting VLASizeChecker's duty in defining a VLA's extent.
llvm-svn: 107728
2010-07-06 23:33:54 +00:00
Jordy Rose 134a236a14 Add a new path-sensitive checker for functions in <string.h>, for both null-terminated strings and memory blocks. Currently only checks memcpy(), memmove(), and bcopy(), but this is intended to be expanded soon.
llvm-svn: 107722
2010-07-06 23:11:01 +00:00
Ted Kremenek 128bfb7643 Sort CMake file.
llvm-svn: 107709
2010-07-06 22:03:19 +00:00
Tom Care 3ff08a8e76 Added a path-sensitive idempotent operation checker (-analyzer-idempotent-operation). Finds idempotent and/or tautological operations in a path sensitive context, flagging operations that have no effect or a predictable effect.
Example:
{
int a = 1;
int b = 5;
int c = b / a; // a is 1 on all paths
}

- New IdempotentOperationChecker class
- Moved recursive Stmt functions in r107675 to IdempotentOperationChecker
- Minor refactoring of SVal to allow checking for any integer
- Added command line option for check
- Added basic test cases

llvm-svn: 107706
2010-07-06 21:43:29 +00:00
Nick Lewycky c96c37f6fd Fix multiple emission of the this-> fixit for each instantiation by fixing the
AST during the instantiation. Fixes PR7417!

llvm-svn: 107690
2010-07-06 19:51:49 +00:00
John McCall 189223e222 Make CGBuilderTy a typedef again; its functionality has been rolled back
into IRBuilder.

llvm-svn: 107687
2010-07-06 18:43:48 +00:00
Douglas Gregor ec9c6ae1cb Improve the accuracy of getSourceRange() for DeclaratorDecl and
TagDecl subclasses when out-of-line template declaration information
is available, from Peter Collingbourne!

llvm-svn: 107686
2010-07-06 18:42:40 +00:00
Douglas Gregor d890b734f8 Correctly set the location of the "template" keyword for a class
template specialization, from Peter Collingbourne.

llvm-svn: 107682
2010-07-06 18:33:12 +00:00
Douglas Gregor 6191f6c607 Remove my egregious hack that forced deserialization of visible
declarations when implicitly declaring the default constructor, copy
constructor, destructor, and copy-assignment operators of a
class. Argiris fixed the underlying problem in r107596.

llvm-svn: 107681
2010-07-06 18:29:01 +00:00
Duncan Sands 1614396b15 Pacify versions of gcc that think these variables may be used
uninitialized (which doesn't seem to be the case), by giving
them arbitrary initial values.

llvm-svn: 107679
2010-07-06 18:19:40 +00:00
John McCall 2d605ac1f5 When destroying a cleanup, kill any references to instructions in the entry
block before deleting it.  Fixes PR7575.

This really just a short-term fix before implementing lazy cleanups.

llvm-svn: 107676
2010-07-06 17:35:03 +00:00
Tom Care 4626285dba Added several helper functions to Stmt to recursively check for different elements (macros, enum constants, etc).
llvm-svn: 107675
2010-07-06 17:28:49 +00:00
Argyrios Kyrtzidis 39fdf81b43 Read/write function template specializations for PCH, properly this time.
llvm-svn: 107665
2010-07-06 15:37:09 +00:00
Argyrios Kyrtzidis af2eac2869 Add to PCH missing Sema information about VTable uses and dynamic classes.
llvm-svn: 107664
2010-07-06 15:37:04 +00:00
Argyrios Kyrtzidis 181431cd91 Allow a CXXRecordDecl to get a DefinitionData pointer even when its owner is still initializing.
llvm-svn: 107663
2010-07-06 15:36:58 +00:00
Argyrios Kyrtzidis 282b36b7f6 Read/write instantiated-from-member of EnumDecl for PCH.
llvm-svn: 107662
2010-07-06 15:36:48 +00:00
Zhongxing Xu 2231a920d0 Add skeleton code to make wpa call the analysis engine.
llvm-svn: 107646
2010-07-06 09:18:02 +00:00
Zhongxing Xu 5b488b1e6c Add an assertion.
llvm-svn: 107645
2010-07-06 07:08:47 +00:00
Zhongxing Xu b525bce698 Collect function definitions in the Indexer when indexing through the ASTs.
Add an API to get an Entity associated with a name in the global namespace.

llvm-svn: 107642
2010-07-06 05:55:13 +00:00
John McCall 466e221037 When creating functions to run global initializers and destructors, mark them
as nounwind in -fno-exceptions.  Fixes rdar://problem/8090834.

llvm-svn: 107639
2010-07-06 04:38:10 +00:00
Jordy Rose c7c8c3d66b Remove the now-unused GRState::isEqual method. Instead of asking if an expression equals a certain value, use SValuator::EvalEQ and GRState::Assume to see if it can, must, or must not equal that value.
llvm-svn: 107638
2010-07-06 04:12:24 +00:00
Jordy Rose 4c0a919732 Oops, tabs --> spaces in test.
llvm-svn: 107634
2010-07-06 02:42:09 +00:00
Jordy Rose 40c5c24c06 Improve NULL-checking for CFRetain/CFRelease. We now remember that the argument was non-NULL, and we report where the null assumption came from (like AttrNonNullChecker already did).
llvm-svn: 107633
2010-07-06 02:34:42 +00:00
John McCall 2b6ac78e07 Stop testing for specific basic block numbers in this test.
llvm-svn: 107632
2010-07-06 02:14:28 +00:00
John McCall bd30929e4d Validated by nightly-test runs on x86 and x86-64 darwin, including after
self-host.  Hopefully these results hold up on different platforms.  

I tried to keep the GNU ObjC runtime happy, but it's hard for me to test.
Reimplement how clang generates IR for exceptions.  Instead of creating new
invoke destinations which sequentially chain to the previous destination,
push a more semantic representation of *why* we need the cleanup/catch/filter
behavior, then collect that information into a single landing pad upon request.

Also reorganizes how normal cleanups (i.e. cleanups triggered by non-exceptional
control flow) are generated, since it's actually fairly closely tied in with
the former.  Remove the need to track which cleanup scope a block is associated
with.

Document a lot of previously poorly-understood (by me, at least) behavior.

The new framework implements the Horrible Hack (tm), which requires every
landing pad to have a catch-all so that inlining will work.  Clang no longer
requires the Horrible Hack just to make exceptions flow correctly within
a function, however.  The HH is an unfortunate requirement of LLVM's EH IR.

llvm-svn: 107631
2010-07-06 01:34:17 +00:00
Zhongxing Xu f894cfb44f Local variables have no linkage, make invalid Entities.
llvm-svn: 107630
2010-07-06 01:20:49 +00:00
Chris Lattner ceddafb846 Generate fewer first class aggregate values for other
coerce cases (e.g. {double,int}) which avoids fastisel
bailing out at -O0.

llvm-svn: 107628
2010-07-05 20:41:41 +00:00
Chris Lattner c401de9998 in the "coerce" case, the ABI handling code ends up making the
alloca for an argument.  Make sure the argument gets the proper
decl alignment, which may be different than the type alignment.

This fixes PR7567

llvm-svn: 107627
2010-07-05 20:21:00 +00:00
Chris Lattner 93b2836267 fix a bug I introduced in r107624
llvm-svn: 107626
2010-07-05 19:36:34 +00:00
Chris Lattner 9156f1bdd3 rearrange some logic, no functionality change.
llvm-svn: 107624
2010-07-05 19:17:26 +00:00
Chris Lattner 53b479ff6a fix PR7564 a cast where the bitfield struct init code
wasn't handling array padding elements right.

llvm-svn: 107621
2010-07-05 18:03:30 +00:00
Chris Lattner 9a3459f1a6 AppendBitField really can never fail, so return its return value.
Everyone knows that no bugs are ever possible with bitfields.

llvm-svn: 107620
2010-07-05 17:04:23 +00:00
Argyrios Kyrtzidis a95d019150 Read/write the identifier namespace in PCH for decls that may modify it.
We can now use a PCH'ed <map>.

llvm-svn: 107617
2010-07-05 10:38:01 +00:00
Argyrios Kyrtzidis 927d8e06c1 Read/write some source location for PCH.
llvm-svn: 107616
2010-07-05 10:37:55 +00:00
Jordy Rose 0704a7fe43 Support sizeof for VLA expressions (sizeof(someVLA)). sizeof(int[n]) still unimplemented. A VLA region's sizeof value matches its extent.
llvm-svn: 107611
2010-07-05 04:42:43 +00:00
Zhongxing Xu 1bbbc2e509 Refrase comments.
llvm-svn: 107607
2010-07-05 02:36:16 +00:00
Zhongxing Xu 74458782cc Although in C++ class name has external linkage, usually the definition of the
class is available in the same translation unit when it's needed. So we make 
all of them invalid Entity.

llvm-svn: 107606
2010-07-05 02:35:40 +00:00
Zhongxing Xu 57012ee70d Make FieldDecl an invalid Entity since it has no linkage.
llvm-svn: 107605
2010-07-05 02:31:16 +00:00
Zhongxing Xu 5776d439ca Indexer: make FieldDecl an internal Entity.
llvm-svn: 107604
2010-07-05 01:44:14 +00:00
Jordy Rose e6b999bf9a Track extents for VLAs.
llvm-svn: 107603
2010-07-05 00:50:15 +00:00
Argyrios Kyrtzidis b5fcdc21c2 Fix a regression of a previous commit of mine (rdar://8158953).
Some of the invariant checks for creating Record/Enum types don't hold true during PCH reading.
Introduce more suitable ASTContext::getRecordType() and getEnumType().

llvm-svn: 107598
2010-07-04 21:44:47 +00:00
Argyrios Kyrtzidis 6685e8a747 Read/write more information of ASTContext for PCH. Overriden methods and instantiated-from information.
llvm-svn: 107597
2010-07-04 21:44:35 +00:00
Argyrios Kyrtzidis e51e554a82 When adding a visible decl, deserialize the visible decls and add it.
Before this commit, visible decls added before deserialization were ignored.
This was not an issue since name lookup (that usually comes before the addition) forces deserialization
but it is an issue for lazily declared class implicit members.

We can use a PCH'ed <string> now.

llvm-svn: 107596
2010-07-04 21:44:25 +00:00
Argyrios Kyrtzidis e862cbc5f6 Don't try to install the __[u]int128_t identifier if it is already installed by PCHReader.
Currently, adding it to visible decls of a PCH'ed translation unit has no effect because
adding visible decls before deserialization has no effect (the decls won't be visible).
This will be fixed in a future commit; then it will force deserialization of visible decls, so avoid pointlessly installing it.

llvm-svn: 107595
2010-07-04 21:44:19 +00:00
Argyrios Kyrtzidis ccde6a02c8 Write/read ParmVarDecl's UninstantiatedDefaultArg for PCH.
llvm-svn: 107594
2010-07-04 21:44:07 +00:00
Argyrios Kyrtzidis cdb8b3f7ec Read/write specialization info of static data members for PCH.
llvm-svn: 107593
2010-07-04 21:44:00 +00:00
Nick Lewycky 0bdaf64fd7 Add TypeLoc traversal to the RecursiveASTVisitor! Because the TypeLocs don't
contain all the same information that their Types do, we will fall back to
traversing the Types instead. The default TypeLoc visitor calls the matching
Type visitor so that existing clients should continue to work with no change.

Also adds element traversal to the ExtVectorType.

llvm-svn: 107592
2010-07-04 21:29:45 +00:00
Nick Lewycky b0077deefa Fix ObjCInterfaceTypeLoc to inherit from ObjCObjectTypeLoc so as to match the
Type hierarchy. Without this, TypeLocNodes.def will give you wrong type
hierarchy information (claiming that ObjCObjectTypeLoc is the base of
ObjCInterfaceTypeLoc, which it wasn't).

llvm-svn: 107578
2010-07-04 01:41:30 +00:00
Jordy Rose 674bd55f02 Add a new symbol type, SymbolExtent, to represent the extents of memory regions that may not be known at compile-time (such as those created by malloc). This replaces the old setExtent/getExtent API on Store, which used the GRState's GDM to store SVals.
Also adds a getKnownValue() method to SValuator, which gets the integer value of an SVal if it is known to only have one possible value. There are more places in the code that could be using this, but in general we want to be dealing entirely in SVals, so its usefulness is limited.

The only visible functionality change is that extents are now honored for any DeclRegion, such as fields and Objective-C ivars, rather than just variables. This shows up in bounds-checking and cast-size-checking.

llvm-svn: 107577
2010-07-04 00:00:41 +00:00
Benjamin Kramer ba62bda998 Unbreak test on platforms where size_t != unsigned long.
llvm-svn: 107574
2010-07-03 20:33:13 +00:00
John McCall 1e5d75d73f Mark the operator delete associated with a virtual destructor as referenced.
llvm-svn: 107573
2010-07-03 18:33:00 +00:00
Charles Davis 3babfba597 Mangle Objective-C pointers and block pointers in the Microsoft C++ Mangler.
ObjC pointers were easy enough (as far as the ABI is concerned, they're
just pointers to structs), but I had to invent a new mangling for block
pointers. This is particularly worrying with the Microsoft ABI, because
it is a vendor-specific ABI; extending it could come back to bite us
later when MS extends it on their own (and you know they will).

llvm-svn: 107572
2010-07-03 16:56:59 +00:00
John McCall 1180f8e90f Provide convenience routines to save and restore the current insertion
point.

llvm-svn: 107570
2010-07-03 09:25:20 +00:00
Charles Davis 3b10dd1bec Fix mangling of array dimensions in the Microsoft C++ Mangler.
llvm-svn: 107568
2010-07-03 08:15:16 +00:00