Commit Graph

22908 Commits

Author SHA1 Message Date
Devang Patel 82bbfb58e3 Initialize Column.
llvm-svn: 103448
2010-05-10 23:48:38 +00:00
Fariborz Jahanian eee1669adb Allow static_cast to objective-c pointers.
Fixes radar 7952457.

llvm-svn: 103447
2010-05-10 23:46:53 +00:00
Daniel Dunbar 341db487a8 tests: Avoid spurious use of /dev/null.
llvm-svn: 103446
2010-05-10 23:31:31 +00:00
John McCall 9500760829 Refactor the constant-evaluator so that it only supports a single form
of constant-evaluation.  Formerly you could control whether it accepted
local l-values or not;  now it always evaluates local l-values in the core
routines, but filters them out where consumed by the top-level routines.
This will make it much easier to cache evaluability.

llvm-svn: 103444
2010-05-10 23:27:23 +00:00
Fariborz Jahanian 43a40f9399 Objective-C++ Code gen. Handle code gen. for property
reference dot-syntax notation in a varierty of cases.
Fixes radar 7964490.

llvm-svn: 103440
2010-05-10 22:57:35 +00:00
Ted Kremenek 7e550caf4e Allocate most of DeclarationNamesTable using ASTContext's allcocator. The only things that
aren't allocated this way are the internal FoldingSets.

llvm-svn: 103429
2010-05-10 20:56:10 +00:00
Ted Kremenek 6aead3a051 Start converting pieces of DeclarationNameTable to be allocated using ASTContext's allocator.
While DeclarationNameTable doesn't leak, it uses 'malloc' too often.  Start with having
'CXXLiteralOperatorNames' allocated using ASTContext's allocator and add a 'DoDestroy()' method
to DeclarationNameTable that is called by ~ASTContext.

llvm-svn: 103426
2010-05-10 20:40:08 +00:00
Ted Kremenek a9084c1fb1 Convert CXXTempory[] in CXXExprWithTemporaries to be allocated using ASTContext's allocator. Fixes <rdar://problem/7961605>.
llvm-svn: 103421
2010-05-10 20:06:30 +00:00
Douglas Gregor e5279cea49 Improved -ast-print-xml for C++, from Sebastien Binet!
llvm-svn: 103412
2010-05-10 17:43:18 +00:00
Douglas Gregor 67a587c9e6 Alternative workaround for MSVC compilation failure, from Dimitry Andric
llvm-svn: 103409
2010-05-10 17:28:19 +00:00
Devang Patel b319adec49 If variable location is invalid then use current location.
This fixes radar 7959934.

llvm-svn: 103408
2010-05-10 17:24:58 +00:00
Daniel Dunbar c8a7bdbcc4 Fix refacto in r103387, noticed by Christopher Jefferson.
llvm-svn: 103406
2010-05-10 15:59:37 +00:00
Anders Carlsson 5f1a1704a2 Add an UpdateVBases parameter to UpdateEmptyClassOffsets. Not used just yet.
llvm-svn: 103403
2010-05-10 15:28:59 +00:00
Anders Carlsson d626cb74d1 More work on handling empty classes.
llvm-svn: 103402
2010-05-10 15:26:14 +00:00
Chris Lattner abfb58d1d2 pch'ify CXXNewExpr and CXXZeroInitValueExpr
llvm-svn: 103390
2010-05-10 01:22:27 +00:00
Chandler Carruth 1d59e54dcf Doxygen-ify a comment and add an example of when this AST node is required.
llvm-svn: 103389
2010-05-10 00:56:18 +00:00
Chris Lattner bc7d55d1f0 fix refactor-o
llvm-svn: 103388
2010-05-10 00:45:12 +00:00
Chris Lattner cba86142a4 pchify CXXTemporary, CXXBindTemporaryExpr, and
CXXExprWithTemporaries.

llvm-svn: 103387
2010-05-10 00:25:06 +00:00
Chandler Carruth dab98ccb4b Fix typo.
llvm-svn: 103378
2010-05-09 12:16:11 +00:00
Chris Lattner e2437f4538 pch'ify default argument definitions and uses.
llvm-svn: 103376
2010-05-09 06:40:08 +00:00
Chris Lattner 9826733963 pch'ify 'this' and 'throw'
llvm-svn: 103375
2010-05-09 06:15:05 +00:00
Chris Lattner 13a5ecc6ff pch'ify typeid.
llvm-svn: 103374
2010-05-09 06:03:39 +00:00
Chris Lattner b7e7f722a2 pchify CXXMemberCallExpr correctly. Before it would serialize
and deserialize as a CallExpr which is close, but ends up
deserializing with the wrong stmt class.

llvm-svn: 103371
2010-05-09 05:36:05 +00:00
Anders Carlsson 82828a31f6 Cleanup.
llvm-svn: 103370
2010-05-09 05:03:38 +00:00
Douglas Gregor 62c281a873 Be more careful about picking a template parameter when we fail to substitute explicit template arguments into a function template
llvm-svn: 103369
2010-05-09 01:26:06 +00:00
David Chisnall e0b5b3a1c5 Tweaked selector mangling again (GNU runtime).
llvm-svn: 103368
2010-05-09 01:01:43 +00:00
Douglas Gregor 6d319c62c5 Fix a silly bootstrap-breaking thinko, where we were trying to convert
non-existent condition expressions to boolean values during template
instantiation.

llvm-svn: 103364
2010-05-08 23:34:38 +00:00
Anders Carlsson 15837f8f63 Actually compute the empty subobject sizes. No functionality change yet.
llvm-svn: 103363
2010-05-08 23:06:26 +00:00
Douglas Gregor 14f232ea20 Improve our handling of the -Wunused-variable warning in templates. In
particular, don't complain about unused variables that have dependent
type until instantiation time, so that we can look at the type of the
variable. Moreover, only complain about unused variables that have
neither a user-declared constructor nor a non-trivial destructor.

llvm-svn: 103362
2010-05-08 23:05:03 +00:00
Douglas Gregor 0bbe94d6df Don't complain about an __builtin_va_arg expression's result being
unused, since the operation has side effects.

llvm-svn: 103360
2010-05-08 22:41:50 +00:00
Anders Carlsson 2357bfd9d0 Add a SizeOfLargestEmptySubobject member to ASTRecordLayout. For C++ classes this will hold the largest empty subobject or 0 if the class doesn't have any empty subobjects.
llvm-svn: 103359
2010-05-08 22:35:05 +00:00
Douglas Gregor ffa56e90f8 Attempted workaround for MSVC compile error
llvm-svn: 103358
2010-05-08 22:24:24 +00:00
Douglas Gregor ff73a9e380 When instantiating statements that involve conditions (if, while, do,
for, and switch), be careful to construct the full expressions as soon
as we perform template instantation, so we don't either forget to call
temporary destructors or destroy temporaries at the wrong time. This
is the template-instantiation analogue to r103187, during which I
hadn't realized that the issue would affect the handling of these
constructs differently inside and outside of templates.

Fixes a regression in Boost.Function.

llvm-svn: 103357
2010-05-08 22:20:28 +00:00
David Chisnall 2ec6cff9d0 Fixed linkage problem from last commit (GNU runtime).
llvm-svn: 103355
2010-05-08 21:55:04 +00:00
David Chisnall 0a24fd3744 Tweaked selector generation (GNU runtime). Removed the use of GlobalAliases in the generated bitcode.
llvm-svn: 103353
2010-05-08 20:58:05 +00:00
Douglas Gregor b02d6b3b94 Don't destroy the data associated with an overload resolution candidate; it's ASTContext-allocated now
llvm-svn: 103350
2010-05-08 20:20:05 +00:00
Douglas Gregor 90cf2c98bb Record template argument deduction failures for member function
templates and conversion function templates. 

llvm-svn: 103349
2010-05-08 20:18:54 +00:00
Douglas Gregor d09efd43d3 When printing an overload candidate that failed due to SFINAE, print a
specific message that includes the template arguments, e.g.,

test/SemaTemplate/overload-candidates.cpp:27:20: note: candidate template
      ignored: substitution failure [with T = int *]
  typename T::type get_type(const T&); // expected-note{{candidate ...
                   ^

llvm-svn: 103348
2010-05-08 20:07:26 +00:00
Douglas Gregor 1d72edd7c5 Improve overload-candidate diagnostic for a function template that
failed because the explicitly-specified template arguments did not
match its template parameters, e.g.,

test/SemaTemplate/overload-candidates.cpp:18:8: note: candidate
template
      ignored: invalid explicitly-specified argument for template
      parameter 'I'
  void get(const T&);
       ^
test/SemaTemplate/overload-candidates.cpp:20:8: note: candidate
template
      ignored: invalid explicitly-specified argument for 1st template
      parameter
  void get(const T&);
       ^

llvm-svn: 103344
2010-05-08 19:15:54 +00:00
Douglas Gregor 564767cf39 A leak is better than a double-free while I figure out how to address
this issue.

llvm-svn: 103343
2010-05-08 18:32:25 +00:00
Douglas Gregor 461761d68f Minor cleanup, and ban copying of OverloadCandidateSets. No
functionality change. 

llvm-svn: 103342
2010-05-08 18:20:53 +00:00
Douglas Gregor 02eb4835ce When template argument deduction fails because the call had too
many/too few arguments, use the same diagnostic we use for arity
mismatches in non-templates (but note that it's a function template).

llvm-svn: 103341
2010-05-08 18:13:28 +00:00
Douglas Gregor 3626a5cac2 When printing a non-viable overload candidate that failed due to
conflicting deduced template argument values, give a more specific
reason along with those values, e.g.,

test/SemaTemplate/overload-candidates.cpp:4:10: note: candidate template
      ignored: deduced conflicting types for parameter 'T' ('int' vs. 'long')
const T& min(const T&, const T&); 
         ^

llvm-svn: 103339
2010-05-08 17:41:32 +00:00
Douglas Gregor 14653638de Fix test for Release-Asserts build
llvm-svn: 103337
2010-05-08 16:04:01 +00:00
Daniel Dunbar d43f08d06e Update latest checker build to a local link.
llvm-svn: 103332
2010-05-08 02:03:49 +00:00
Douglas Gregor 5597ab4076 When we encounter a non-dependent type during template instantiation,
mark any declarations we see inside of that type as
"referenced". Fixes PR7079.

llvm-svn: 103323
2010-05-07 23:12:07 +00:00
Devang Patel 67eba80672 If there is not any debug info for type then do not emit debug info for this variable.
A recent change to tightly verify debug info prepared by FE caught this.
This fixes unittest build.

llvm-svn: 103320
2010-05-07 23:05:55 +00:00
Douglas Gregor e0c5497935 Introduce a recursive AST visitor that makes it trivial to recursively
walk an entire AST, including all of the types, declarations,
statements, and expressions, and allowing one to easily override the
behavior of the walk at any particular node kind.

llvm-svn: 103308
2010-05-07 22:11:34 +00:00
John McCall b1fb0d3610 The FP constant evaluator was missing a few cases of unary operators that return floats
but whose operand isn't a float:  specifically, __real__ and __imag__.  Instead
of filtering these out, just implement them.

Fixes <rdar://problem/7958272>.

llvm-svn: 103307
2010-05-07 22:08:54 +00:00
Chris Lattner ca025db769 add PCH support for a bunch of C++ Decls, patch by
Andrew Sutton!

llvm-svn: 103301
2010-05-07 21:43:38 +00:00
John McCall eb3e4f3481 Make that null-dereference fix a little clearer by rearranging some code.
llvm-svn: 103298
2010-05-07 21:34:32 +00:00
John McCall 06f0e09756 Fix a potential null dereference in the pointer-to-bool evaluator; caught by
Eli Friedman.

llvm-svn: 103297
2010-05-07 21:01:17 +00:00
John McCall 45d55e4f26 Change the pointer / lvalue constant evaluators to build into a target reference
and return a bool.

llvm-svn: 103296
2010-05-07 21:00:08 +00:00
Chris Lattner e979e30501 add more types to -ast-print-xml, PR5006
llvm-svn: 103294
2010-05-07 20:45:29 +00:00
Ted Kremenek 37c220c8ed Extend C++ usrs to include type mangling for tag decl arguments, indicating whether a method
is static, and mangling in the qualifers of the method.

llvm-svn: 103289
2010-05-07 20:39:40 +00:00
Chris Lattner a99fa1aee1 clean up isBeforeInTranslationUnit by factoring out some common
code into a MoveUpIncludeHierarchy helper, and use the helper to
fix a case involving macros which regressed from my recent patch.

llvm-svn: 103288
2010-05-07 20:35:24 +00:00
Ted Kremenek dacfc2eee6 Switch USR generation over from NamedDecl::getNameAsString() to NamedDecl::printName().
llvm-svn: 103285
2010-05-07 20:07:23 +00:00
Ted Kremenek c14f5eb3ec Add NamedDecl::printName() for clients that to use getNameAsString() but are already using a raw_ostream.
llvm-svn: 103284
2010-05-07 20:07:19 +00:00
Douglas Gregor 496e8b345c Reapply the reference-binding patch applied below, along with a fix to
ensure that we complete the type when we need to look at constructors
during reference binding.

When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion. 

Re-fixes PR7080.

llvm-svn: 103283
2010-05-07 19:42:26 +00:00
Fariborz Jahanian 7828ab1ed9 Minor mod. to my last patch.
llvm-svn: 103280
2010-05-07 18:59:54 +00:00
Fariborz Jahanian fdf474b05e Fixes a Code gen crash trying to use a dot-syntax for
a property of a c++ class object (radar 7957369).

llvm-svn: 103279
2010-05-07 18:56:13 +00:00
Devang Patel ba4ad7f2fd Avoid use of DIDescriptor::getNode(). Use overloaded operators instead.
llvm-svn: 103273
2010-05-07 18:12:35 +00:00
John McCall 93d91dcdb7 Change the complex constant evaluator to return a bool instead of an APValue.
llvm-svn: 103268
2010-05-07 17:22:02 +00:00
Douglas Gregor dda3f33987 Add missing #include
llvm-svn: 103260
2010-05-07 15:59:09 +00:00
Douglas Gregor 56f14e575d Revert r103220. It seems to be breaking self-host
llvm-svn: 103259
2010-05-07 15:55:52 +00:00
Douglas Gregor 542ad31597 Add a stub frontend action for BoostCon, for next week's workshop.
llvm-svn: 103258
2010-05-07 15:41:56 +00:00
Rafael Espindola a1f9cc1bec Fix PR4386 by implementing gcc's old behaviour (4.2) when initializing
variables with a comparison of a function pointer with 0.

llvm-svn: 103253
2010-05-07 15:18:43 +00:00
Sebastian Redl 872fad8627 Test case for my last fix.
llvm-svn: 103252
2010-05-07 11:15:33 +00:00
Sebastian Redl fa1f70f338 A correct fix for bug 6466.
llvm-svn: 103250
2010-05-07 09:25:11 +00:00
Sebastian Redl 2e702738bb And finally, revert the accidental check-in part of the previous reversion. I'm on a roll.
llvm-svn: 103249
2010-05-07 09:11:09 +00:00
Sebastian Redl 0b4e312566 Revert 103247, it causes lots of test failures.
llvm-svn: 103248
2010-05-07 09:09:23 +00:00
Sebastian Redl 019b5dbc55 Pass the correct type to BuildMemberReferenceExpr. Fixes bug 6466.
llvm-svn: 103247
2010-05-07 09:06:26 +00:00
Chris Lattner 06821c9e90 reimplement the guts of SourceManager::isBeforeInTranslationUnit
to be algorithmically faster and avoid an std::map.  This routine
basically boils down to finding the nearest common ancestor in a
tree, and we (implicitly) have information about nesting depth,
use it!

This wraps up rdar://7948633 - SourceManager::isBeforeInTranslationUnit has poor performance

llvm-svn: 103239
2010-05-07 05:51:13 +00:00
John McCall f0c4f356b8 Change Evaluate* in the constant evaluator to enforce being given an argument of
the right type.  It turns out that the code was already doing this.

llvm-svn: 103238
2010-05-07 05:46:35 +00:00
John McCall 864e396d0b Move CheckICE and isIntegerConstantExpr to ExprConstant.cpp because it seemed
like a good idea at the time.

llvm-svn: 103237
2010-05-07 05:32:02 +00:00
Chris Lattner 46e3b4808f start using the caching now that it appears to work!
llvm-svn: 103236
2010-05-07 05:10:46 +00:00
Chris Lattner 66d2f924b4 reimplement the caching in the SourceManager::isBeforeInTranslationUnit()
method to be correct.  Right now it correctly computes the cache, then
goes ahead and computes the result the hard way, then asserts that they 
match.  Next I'll actually turn it on.

llvm-svn: 103231
2010-05-07 01:17:07 +00:00
Ted Kremenek 586ff60cfc Add initial USR support for mangling in the types of C++ functions and methods.
llvm-svn: 103225
2010-05-07 01:04:32 +00:00
Ted Kremenek b80cba5d7d Add CXCursor support for LinkageSpecDecl (e.g., 'extern "C"').
llvm-svn: 103224
2010-05-07 01:04:29 +00:00
Ted Kremenek fca5afb421 Add USR test case for C++ operator methods.
llvm-svn: 103223
2010-05-07 01:04:23 +00:00
mike-m 9f08a6f1a8 Reverted r103214.
llvm-svn: 103222
2010-05-07 00:42:33 +00:00
Fariborz Jahanian c5158203dd Implement encoding of methods which have instantiated
template arguments.

llvm-svn: 103221
2010-05-07 00:28:49 +00:00
Douglas Gregor d80c0238bb When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion. 

Fixes PR7080.

llvm-svn: 103220
2010-05-07 00:28:31 +00:00
John McCall 7ddbcf4f4b After some discussion, conservatively extend our sentinel check to discard
casts, but still require the (casted) type to be a pointer.  Fixes PR5685.

llvm-svn: 103216
2010-05-06 23:53:00 +00:00
mike-m 9bb682b713 2nd part of: Overhauled llvm/clang docs builds.
llvm-svn: 103214
2010-05-06 23:46:27 +00:00
Ted Kremenek 0b4b46e3e1 Add USR support for C++ namespaces, and unify mangling of location information in USRs
for anonymous symbols.

llvm-svn: 103212
2010-05-06 23:38:28 +00:00
Ted Kremenek bd67fb208d Add CXCursor support for C++ namespaces.
llvm-svn: 103211
2010-05-06 23:38:21 +00:00
Douglas Gregor 4b718ee691 It turns out that we should be allowing redeclarations within function
scope. Thanks to Steven Watanabe for correcting me.

llvm-svn: 103210
2010-05-06 23:31:27 +00:00
Douglas Gregor d8bb3aff76 Do not give implicitly-defined virtual members functions
available_externally linkage, since they may not have been given a
strong definition in another translation unit. Without this patch, the
following test case fails to link with a GCC-compiled libstdc++:

  #include <sstream>
  int main() { std::basic_stringbuf<char> bs; }

Fixes the last problem with the Boost.IO library.

llvm-svn: 103208
2010-05-06 23:13:35 +00:00
Douglas Gregor 1411bb8f76 Fix typo in comment; 80 col violation
llvm-svn: 103204
2010-05-06 22:33:50 +00:00
Douglas Gregor ae498b3211 The global variable for the VTT might not have external linkage; allow
us to find local variables, too. Fixes the last remaining
Boost.Rational failure.

llvm-svn: 103203
2010-05-06 22:18:21 +00:00
Chris Lattner 6eeb221f3b mention that cmake works on unix too. PR7061
llvm-svn: 103202
2010-05-06 21:57:57 +00:00
Chris Lattner cdfd35a429 ignore *.orig when installing, patch by Brooks Davis!
llvm-svn: 103200
2010-05-06 21:49:51 +00:00
Douglas Gregor 12cc7eeb82 Fixed DISABLE_SMART_POINTERS breakage
llvm-svn: 103198
2010-05-06 21:39:56 +00:00
Rafael Espindola 66bfb27545 Handle -ffunction-sections and -fdata-sections in the driver.
llvm-svn: 103197
2010-05-06 21:06:04 +00:00
Daniel Dunbar 0b9729887c Basic: Update getClangRepositoryPath for my change to integration branch layout.
llvm-svn: 103192
2010-05-06 18:39:38 +00:00
John McCall 4fa0d5f2bd Diagnose deprecated/unavailable functions selected by overload resolution.
Fixes rdar://problem/4232969, or at least the clang parts of it.

llvm-svn: 103191
2010-05-06 18:15:07 +00:00
Douglas Gregor 027f8d2b2d Try to work around a Visual C++ bug with copy-assignment.
llvm-svn: 103190
2010-05-06 18:05:52 +00:00
Douglas Gregor e60e41add9 Rework our handling of temporary objects within the conditions of
if/switch/while/do/for statements. Previously, we would end up either:

  (1) Forgetting to destroy temporaries created in the condition (!),
  (2) Destroying the temporaries created in the condition *before*
  converting the condition to a boolean value (or, in the case of a
  switch statement, to an integral or enumeral value), or
  (3) In a for statement, destroying the condition's temporaries at
  the end of the increment expression (!).

We now destroy temporaries in conditions at the right times. This
required some tweaking of the Parse/Sema interaction, since the parser
was building full expressions too early in many places.

Fixes PR7067.

llvm-svn: 103187
2010-05-06 17:25:47 +00:00
Fariborz Jahanian b8993384f3 Code Gen support for Getter/Setter synthesis of
C++ object properties. (still radar 7468090).

llvm-svn: 103182
2010-05-06 15:45:36 +00:00
mike-m b49148807a Reverted part of r103177 (repositioning of clang-builtin include/)
which breaks clang-i686-xp-msvc9 test-clang.

llvm-svn: 103180
2010-05-06 15:23:52 +00:00
mike-m 94ab2902fe Reposition clang-builtin include/ to immediately precede /usr/include/,
matching gcc compiler. Fixes #include_next <...> shenanigans that lead to
file-not-found failures with <cstddef> on libstdc++ 4.3.[012].

Updated C++ include header search paths for various Debian/Ubuntu and Fedora
linux distros.

llvm-svn: 103177
2010-05-06 14:11:13 +00:00
John McCall 0086190d58 Push TypeSourceInfo::getTypeLoc() into a header file so that it's
inlineable.  That header file has to be TypeLoc.h, which means that
TypeLoc.h needs to depend on Decl.h because TypeSourceInfo doesn't
have its own header.  That could be remedied, though.

llvm-svn: 103176
2010-05-06 09:25:57 +00:00
John McCall 31b0b46779 Kill a never-defined, never-used member function. Thanks, Enea.
llvm-svn: 103175
2010-05-06 09:09:08 +00:00
John McCall cc7e5bff5c Rearchitect -Wconversion and -Wsign-compare. Instead of computing them
"bottom-up" when implicit casts and comparisons are inserted, compute them
"top-down" when the full expression is finished.  Makes it easier to
coordinate warnings and thus implement -Wconversion for signedness
conversions without double-warning with -Wsign-compare.  Also makes it possible
to realize that a signedness conversion is okay because the context is
performing the inverse conversion.  Also simplifies some logic that was
trying to calculate the ultimate comparison/result type and getting it wrong.
Also fixes a problem with the C++ explicit casts which are often "implemented"
in the AST with a series of implicit cast expressions.

llvm-svn: 103174
2010-05-06 08:58:33 +00:00
John McCall 9aa35bed45 Remember the number of positive and negative bits used by the enumerators of
an enum in the enum decl itself.  Use some spare bits from TagDecl for this
purpose.

llvm-svn: 103173
2010-05-06 08:49:23 +00:00
Chris Lattner 44456d294c simplify EmitAggMemberInitializer a bit and make it work in 32-bit mode,
fixing PR7063.

llvm-svn: 103171
2010-05-06 06:35:23 +00:00
Chris Lattner 3628326b44 add todos for isinf_sign and isnormal, which I don't intend to implement
in the near future.

llvm-svn: 103169
2010-05-06 06:13:53 +00:00
Chris Lattner dbff4bf5f4 implement codegen support for __builtin_isfinite, part of PR6083
llvm-svn: 103168
2010-05-06 06:04:13 +00:00
Chris Lattner 68784efaf6 optimize builtin_isnan/isinf to not do an extraneous extension from
float -> double (which happens because they are modelled as int(...)
functions), and add a testcase for isinf.

llvm-svn: 103167
2010-05-06 05:50:07 +00:00
Chris Lattner 43660c5bc0 implement part of PR6083: codegen support for isinf. Like isnan,
this is generating correct but suboptimal (extra extend to double)
code for the float case.  Will investigate next.

llvm-svn: 103166
2010-05-06 05:35:16 +00:00
Chandler Carruth 2998b5458d Mark a variable as used in the absence of asserts to silence a GCC warning.
llvm-svn: 103165
2010-05-06 05:28:42 +00:00
Chandler Carruth a77a72734c Remove a dependency on Frontend headers in the Driver library. Also saves
building and passing arguments to cc1 layer when setting values to their
defaults.

llvm-svn: 103162
2010-05-06 04:55:18 +00:00
Zhongxing Xu 1a56a488ed Turn -analyzer-inline-call on for C functions. This also fixed a bug that
after inlining post-call checking shouldn't be done.

llvm-svn: 103161
2010-05-06 03:38:27 +00:00
Zhongxing Xu 9174b2c2f9 Make -analyzer-inline-call not a separate analysis. Instead it's a boolean
flag now, and can be used with other analyses. Only turned it on for C++ 
methods for now.

llvm-svn: 103160
2010-05-06 02:59:29 +00:00
Douglas Gregor e902956f59 Partial and full specializations of a class template may have a
different tag kind ("struct" vs. "class") than the primary template,
which has an affect on access control.

Should fix the last remaining Boost.Accumulors failure.

llvm-svn: 103144
2010-05-06 00:28:52 +00:00
Ted Kremenek 5b0773e201 Workaround a really serious caching bug in SourceManager::isBeforeInTranslationUnit() where the
method will sometimes return different results for the same input SourceLocations.  I haven't
unraveled this method completely yet, so this truly is a workaround until a better fix comes
along.

llvm-svn: 103143
2010-05-06 00:22:25 +00:00
Chandler Carruth f3983652eb Clean up the {} and else placement. This fixes an ambiguous else as well as
picking a more consistent pattern.

llvm-svn: 103142
2010-05-06 00:20:39 +00:00
Chandler Carruth 27c9fe9f8b Silence a pedantic GCC warning by making the grouping of && and || explicit.
llvm-svn: 103141
2010-05-06 00:15:06 +00:00
John McCall eebc832f43 Add IgnoreParenImpCasts() to Expr, which is basically like IgnoreParenCasts
except it only skips implicit casts.

Also fix ObjCImplicitGetterSetterRefExpr's child_begin to skip the base expression
if it's actually a type reference (which you get with static property references).

llvm-svn: 103132
2010-05-05 22:59:52 +00:00
Chris Lattner 3baada6fd7 Pass the globaldecl into GetOrCreateLLVMFunction so that llvm
function attributes like byval get applied to the function 
definition. This fixes PR7058 and makes i386 llvm/clang bootstrap 
pass all the same tests as x86-64 bootstrap for me (the llvmc 
tests still fail in both).

llvm-svn: 103131
2010-05-05 22:55:13 +00:00
Douglas Gregor bf1fb44efa When implicit definition of the copy-assignment operator fails,
provide a note that shows where the copy-assignment operator was
needed. We used to have this, but I broke it during refactoring. 

Finishes PR6999.

llvm-svn: 103127
2010-05-05 22:38:15 +00:00
Fariborz Jahanian 25491a22af This patch deals with Sema Part of Setter/Getter synthesis
of properties which are of C++ objects. Code Gen to follow
(Radar 7468090).

llvm-svn: 103123
2010-05-05 21:52:17 +00:00
Douglas Gregor d450f06ef4 When we emit a non-constant initializer for a global variable of
reference type, make sure that the initializer we build is the
of the appropriate type for the *reference*, not for the thing that it
refers to. Fixes PR7050.

llvm-svn: 103115
2010-05-05 20:15:55 +00:00
mike-m 6fa3cd26e9 Test commit.
llvm-svn: 103090
2010-05-05 17:00:31 +00:00
Douglas Gregor 370eadf38d For thread-safe static initialization of local statics with
destructors, place the __cxa_atexit call after the __cxa_guard_release
call, mimicking GCC/LLVM-GCC behavior. Noticed while debugging
something related.

llvm-svn: 103088
2010-05-05 15:38:32 +00:00
Alexis Hunt 656bb314d9 Reapplying patch to change StmtNodes.def to StmtNodes.td, this time
with no whitespace. This will allow statements to be referred to in
attribute TableGen files.

llvm-svn: 103087
2010-05-05 15:24:00 +00:00
Alexis Hunt a8136cc408 Revert r103072; I accidentally ended up deleting a bunch of trailing
whitespace which makes this patch unreadable. Will recommit without the
whitespace.

llvm-svn: 103086
2010-05-05 15:23:54 +00:00
Douglas Gregor b22ee88652 Support for 'template' as a disambiguator (PR7030)
ParseOptionalCXXScopeSpecifier() only annotates the subset of
    template-ids which are not subject to lexical ambiguity. Add support
    for the more general case in ParseUnqualifiedId() to handle cases
    such as A::template B().

    Also improve some diagnostic locations.

Fixes PR7030, from Alp Toker!

llvm-svn: 103081
2010-05-05 05:58:24 +00:00
Chris Lattner 86ed5b016a add a new --print-diagnostic-categories option, which causes the driver to
print out all of the category numbers with their description.  This is useful
for clients that want to map the numbers produced by 
--fdiagnostics-show-category=id to their human readable string form.  The
output is simple but utilitarian:

$ clang --print-diagnostic-categories
1,Format String
2,Something Else

This implements rdar://7928193

llvm-svn: 103080
2010-05-05 05:53:24 +00:00
Douglas Gregor 94f9a4820a Reimplement code generation for copying fields in the
implicitly-generated copy constructor. Previously, Sema would perform
some checking and instantiation to determine which copy constructors,
etc., would be called, then CodeGen would attempt to figure out which
copy constructor to call... but would get it wrong, or poke at an
uninstantiated default argument, or fail in other ways.

The new scheme is similar to what we now do for the implicit
copy-assignment operator, where Sema performs all of the semantic
analysis and builds specific ASTs that look similar to the ASTs we'd
get from explicitly writing the copy constructor, so that CodeGen need
only do a direct translation.

However, it's not quite that simple because one cannot explicit write
elementwise copy-construction of an array. So, I've extended
CXXBaseOrMemberInitializer to contain a list of indexing variables
used to copy-construct the elements. For example, if we have:

  struct A { A(const A&); };
  
  struct B {
    A array[2][3];
  };

then we generate an implicit copy assignment operator for B that looks
something like this:

  B::B(const B &other) : array[i0][i1](other.array[i0][i1]) { }

CodeGen will loop over the invented variables i0 and i1 to visit all
elements in the array, so that each element in the destination array
will be copy-constructed from the corresponding element in the source
array. Of course, if we're dealing with arrays of scalars or class
types with trivial copy-assignment operators, we just generate a
memcpy rather than a loop.

Fixes PR6928, PR5989, and PR6887. Boost.Regex now compiles and passes
all of its regression tests.

Conspicuously missing from this patch is handling for the exceptional
case, where we need to destruct those objects that we have
constructed. I'll address that case separately.

llvm-svn: 103079
2010-05-05 05:51:00 +00:00
Anders Carlsson 58fe1756fb Use a more appropriate LLVM type for the vtable pointer.
llvm-svn: 103078
2010-05-05 05:47:36 +00:00
Douglas Gregor ecc60b99f9 Unbreak CMake build.
llvm-svn: 103077
2010-05-05 05:41:05 +00:00
Chris Lattner 5561bf3d11 fit in 80 cols
llvm-svn: 103075
2010-05-05 05:28:39 +00:00
Alexis Hunt 620a79f32b Add forgotten CMakeFiles.txt
llvm-svn: 103074
2010-05-05 04:50:38 +00:00
Alexis Hunt b9f408a873 Change StmtNodes.def to StmtNodes.td in anticipation of a rewrite of attributes
llvm-svn: 103072
2010-05-05 04:13:52 +00:00
Chris Lattner 336119f089 document -fdiagnostics-show-category
llvm-svn: 103067
2010-05-05 01:35:28 +00:00
Ted Kremenek 680fe51e2c Rework clang_annotateTokens() to annotate tokens with information that more closely matches
clang_getCursor().  Tokens are now annotated with the cursor (for the matching AST element)
that most closely encompasses that token.

llvm-svn: 103064
2010-05-05 00:55:23 +00:00
Ted Kremenek 15cbc3a8a5 Map Objective-C keywords to CXToken_Keyword.
llvm-svn: 103063
2010-05-05 00:55:20 +00:00
Ted Kremenek 458c2f190a Move post-processing of token annotations to method in AnnotateTokensWorker.
llvm-svn: 103062
2010-05-05 00:55:17 +00:00
Ted Kremenek 63ac5999f1 Refactor visitor logic for clang_annotateTokens() into a worker class. No functionality change yet.
llvm-svn: 103061
2010-05-05 00:55:15 +00:00
Chris Lattner bf6fac8415 add a new -fdiagnostics-show-category=none/id/name option, giving control
over choice of:

t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1]
t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,Format String]

dox to come.

llvm-svn: 103056
2010-05-04 21:55:25 +00:00
Chris Lattner 4531cc5529 When -fdiagnostics-print-source-range-info is specified,
print the diagnostic category number in the [] at the end
of the line.  For example:

$ cat t.c 
#include <stdio.h>
void foo() {
 printf("%s", 4);
}
$  clang t.c -fsyntax-only -fdiagnostics-print-source-range-info
t.c:3:11:{3:10-3:12}{3:15-3:16}: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1]
  printf("%s", 4);
          ~^   ~
1 warning generated.

Clients that want category information can now pick the number 
out of the output, rdar://7928231.

More coming.

llvm-svn: 103053
2010-05-04 21:13:21 +00:00
John McCall 4a39ab8078 Emit the globals, metadata, etc. associated with static variables even when
they're unreachable.  This matters because (if they're POD, or if this is C)
the scope containing the variable might be reachable even if the variable
isn't.  Fixes PR7044.

llvm-svn: 103052
2010-05-04 20:45:42 +00:00
Chris Lattner 216c33beba add the ability to associate 'category' names with diagnostics
and diagnostic groups.  This allows the compiler to group 
diagnostics together (e.g. "Logic Warning", 
"Format String Warning", etc) like the static analyzer does.
This is not exposed through anything in the compiler yet.

llvm-svn: 103051
2010-05-04 20:44:26 +00:00
Fariborz Jahanian 60c7e16b64 Fixes a code gen. crash when ivar object has trivial constructor.
llvm-svn: 103028
2010-05-04 19:29:32 +00:00
Douglas Gregor c8be95274d When instantiating a function that was declared via a typedef, e.g.,
typedef int functype(int, int);
    functype func;

also instantiate the synthesized function parameters for the resulting
function declaration. 

With this change, Boost.Wave builds and passes all of its regression
tests.

llvm-svn: 103025
2010-05-04 18:18:31 +00:00
Fariborz Jahanian eeb233793d Fixes a code gen crash when block is a reference type, etc.
(radar 7495203).

llvm-svn: 103022
2010-05-04 17:59:32 +00:00
Douglas Gregor cd121fb013 Introduce a limit on the depth of the macro instantiation backtrace
printed in a diagnostic, similar to the limit we already have on the
depth of the template instantiation backtrace. The macro instantiation
backtrace is limited to 10 "instantiated from:" diagnostics; when it's
longer than that, we'll show the first half, then say how many were
suppressed, then show the second half. The limit can be changed with
-fmacro-instantiation-limit=N, and turned off with N=0.

This eliminates a lot of note spew with libraries making use of the
Boost.Preprocess library.

llvm-svn: 103014
2010-05-04 17:13:42 +00:00
Douglas Gregor 40c92bbe4f When creating a call to a base subobject's operator= in an
implicitly-defined copy assignment operator, suppress the protected
access check. This eliminates the remaining failure in the
Boost.SmartPtr library (that was a product of the copy-assignment
generation rewrite) and, presumably, the Boost.TR1 library as well.

llvm-svn: 103010
2010-05-04 15:20:55 +00:00
Sebastian Redl 80fecfff45 Let StmtDumper.cpp handle using declarations.
llvm-svn: 103006
2010-05-04 10:20:17 +00:00
John McCall 9720514f3b An access is permitted if the current template instantiates to the appropriate
class.  Add some conservative support for the idea.  Fixes PR 7024.

llvm-svn: 102999
2010-05-04 05:11:27 +00:00
John McCall e61b02bcaf When inheriting a default argument expression, inherit the full expression,
not just the inner expression.  This is important if the expression has any
temporaries.  Fixes PR 7028.

Basically a symptom of really tragic method names.

llvm-svn: 102998
2010-05-04 01:53:42 +00:00
Fariborz Jahanian 751f7bc03c Fixes a Code Gen. Crash when calling destructor on a __block
variabe. Blocks and their construction/destruction is
wip though. 

llvm-svn: 102985
2010-05-04 00:26:07 +00:00
Douglas Gregor 1bd7a94460 When computing the template arguments for the instantiation of a
friend function template, be sure to adjust the computed template
argument lists based on the location of the definition of the function
template: it's possible that the definition we're instantiating with
and the template declaration that we found when creating the
specialization are in different contexts, which meant that we would
end up using the wrong template arguments for instantiation.

Fixes PR7013; all Boost.DynamicBitset tests now pass.

llvm-svn: 102974
2010-05-03 23:29:10 +00:00
John McCall 5828ee7a27 Just bail out immediately when emitting an unreachable function-local static
variable.  Surprisingly, this does seem to be the right way to solve this.

llvm-svn: 102961
2010-05-03 21:39:56 +00:00
Fariborz Jahanian ce7ddf7bf7 Test for my last patch.
llvm-svn: 102956
2010-05-03 21:06:59 +00:00
Fariborz Jahanian 5e5998f014 For the sake of Objective-c++ overload resolution,
treat argument types of objective-c pointer types
which only differ in their protocol qualifiers as
the same type (radar 7925668).

llvm-svn: 102955
2010-05-03 21:06:18 +00:00
Douglas Gregor 70b21be380 When instantiating a function-local variable definition, introduce the
mapping from the declaration in the template to the instantiated
declaration before transforming the initializer, in case some crazy
lunatic decides to use a variable in its own initializer. Fixes PR7016.

llvm-svn: 102945
2010-05-03 20:22:41 +00:00
Ted Kremenek acc59c3ec9 Workaround: Don't add ObjCMethodDecls to the vector of TopLevelDecls since they don't go in
the DeclContext for the translation unit.  This is to workaround a fundamental issue in how
ObjC decls (within an @implementation) are parsed before the ObjCContainerDecl is available.

llvm-svn: 102944
2010-05-03 20:16:35 +00:00
Douglas Gregor aee1f51485 If we're generating code to create a pointer-to-member function
aggregate and the result of the aggregate is unused, bail out
early. Fixes PR7027.

llvm-svn: 102942
2010-05-03 20:00:27 +00:00
Douglas Gregor 3f324d569b Diagnose unused exception parameters under a different warning group
(-Wunused-exception-parameter) than normal variables, since it's more
common to name and then ignore an exception parameter. This warning is
neither enabled by default nor by -Wall. Fixes <rdar://problem/7931045>.

llvm-svn: 102931
2010-05-03 18:51:14 +00:00
Douglas Gregor 50ec46d4af Complain when we try to initialize an object of Objective-C class type
(which is ill-formed) with an initializer list. Also, change the
fallback from an assertion to a generic error message, which is far
friendlier. Fixes <rdar://problem/7730948>.

llvm-svn: 102930
2010-05-03 18:24:37 +00:00
Douglas Gregor cbbf3e3b4a It's okay to reference an enum in a template definition, even though
it's ill-formed to form an enum template. Fixes <rdar://problem/7933063>.

llvm-svn: 102926
2010-05-03 17:48:54 +00:00
Anders Carlsson 3572d44190 When computing the address of a virtual member function pointer, use the pointer width instead of hardcoding for 64-bit.
llvm-svn: 102921
2010-05-03 16:05:06 +00:00
Douglas Gregor df9ae794ca Try to unbreak clang-i686-darawin10 builder
llvm-svn: 102920
2010-05-03 15:51:04 +00:00
Fariborz Jahanian 58f11d6245 Do not issue warning on unimplemented property in the class, if it
conforms to a protocol as one of its super classes does. This is because
conforming super class will implement the property. This implements 
new warning rules for unimplemented properties (radar 7884086).

llvm-svn: 102919
2010-05-03 15:49:20 +00:00
Anders Carlsson f93cb3bacb Get rid of virt.cpp.
llvm-svn: 102918
2010-05-03 15:49:15 +00:00
Anders Carlsson c6bb0e117f The array form of 'new' can never have initializers.
llvm-svn: 102917
2010-05-03 15:45:23 +00:00
Douglas Gregor ed088b7fe7 When creating the declaration reference for implicit copy-construction
of a base class, give it real source-location information. Fixes PR7017.

llvm-svn: 102916
2010-05-03 15:43:53 +00:00
Douglas Gregor 5cf8d67bc9 When declaring a namespace alias, ignore previous declarations that
aren't in scope. Fixes PR7014.

llvm-svn: 102915
2010-05-03 15:37:31 +00:00
Douglas Gregor 95c70ec678 When instantiating a member function declared via a typedef, don't try
to enter the instantiated parameter declarations into the local
instantiation scope; they can't be referenced anyway. Fixes PR7022.

llvm-svn: 102914
2010-05-03 15:32:18 +00:00
Douglas Gregor 456ad1a817 When a class contains a non-empty anonymous union or struct, mark is
as non-empty. Fixes PR7021.

llvm-svn: 102913
2010-05-03 15:18:25 +00:00
Anders Carlsson d040e6b25a Don't build an aggregate constructor loop when the constructor is trivial.
llvm-svn: 102912
2010-05-03 15:09:17 +00:00
Anders Carlsson 604f560c39 Add test case that I forgot to check in.
llvm-svn: 102905
2010-05-03 14:22:40 +00:00
Benjamin Kramer bebee84281 Replace a char*/size pair with stringref.
llvm-svn: 102902
2010-05-03 13:08:54 +00:00
Anders Carlsson c144bc226c Simplify.
llvm-svn: 102896
2010-05-03 02:07:56 +00:00
Anders Carlsson 16e94af67c Don't copy or initialize empty classes. Fixes PR7012.
llvm-svn: 102891
2010-05-03 01:20:20 +00:00
Anders Carlsson 8bdbb5be19 Store the entire base subobject in SubVTTIndices.
llvm-svn: 102890
2010-05-03 00:55:11 +00:00
Anders Carlsson f4da2cf20a Remove OldGetAddressOfBaseClass - bye bye ambiguities.
llvm-svn: 102889
2010-05-03 00:32:27 +00:00
Anders Carlsson c58fb552f3 Get rid of the last caller of OldGetAddressOfBaseClass.
llvm-svn: 102888
2010-05-03 00:29:58 +00:00
Anders Carlsson c4d0d0fed1 More work towards getting rid of OldGetAddressOfBaseClass.
llvm-svn: 102887
2010-05-03 00:07:07 +00:00
Anders Carlsson e089060fd0 Get rid of a call to GetAddressOfDirectBaseInCompleteClass.
llvm-svn: 102886
2010-05-02 23:57:15 +00:00
Anders Carlsson 859b3064cb Have getSubVTTIndex take a BaseSubobject instead of just a base.
llvm-svn: 102885
2010-05-02 23:53:25 +00:00
Anders Carlsson edea1de7c4 Change CXXConstructExpr::Create to take a ConstructionKind.
llvm-svn: 102884
2010-05-02 23:53:04 +00:00
Anders Carlsson 4d205ba87f Pass ForVirtualBase all the way to GetVTTParameter.
llvm-svn: 102883
2010-05-02 23:33:10 +00:00
Anders Carlsson f8a71f08d1 Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.
llvm-svn: 102882
2010-05-02 23:29:11 +00:00
Anders Carlsson e11f9ce9dc Revert my last change and add a 'ForVirtualBase' parameter to EmitCXXConstructorCall instead.
llvm-svn: 102881
2010-05-02 23:20:53 +00:00
Anders Carlsson 4c638f1217 Pass the construction kind down to EmitCXXConstructorCall.
llvm-svn: 102880
2010-05-02 23:01:10 +00:00
Anders Carlsson bcc066b659 Add an enum to CXXConstructExpr so we can determine if the construction expression constructs a non-virtual or virtual base.
llvm-svn: 102879
2010-05-02 22:54:08 +00:00
Anders Carlsson 245820b9d9 Remove another unused function.
llvm-svn: 102871
2010-05-02 18:13:35 +00:00
Anders Carlsson 54eb4843b1 Remove an unused function.
llvm-svn: 102870
2010-05-02 18:12:22 +00:00
Benjamin Kramer 2718b4d757 CodeGen: Shrink RValue. 4 words -> 2 words.
llvm-svn: 102863
2010-05-02 14:59:10 +00:00
David Chisnall ff5f88c38e As per Chris' request, return the Instruction from EmitCall and add the metadata in the caller.
llvm-svn: 102862
2010-05-02 13:41:58 +00:00
Douglas Gregor b139cd5843 Complete reimplementation of the synthesis for implicitly-defined copy
assignment operators. 

Previously, Sema provided type-checking and template instantiation for
copy assignment operators, then CodeGen would synthesize the actual
body of the copy constructor. Unfortunately, the two were not in sync,
and CodeGen might pick a copy-assignment operator that is different
from what Sema chose, leading to strange failures, e.g., link-time
failures when CodeGen called a copy-assignment operator that was not
instantiation, run-time failures when copy-assignment operators were
overloaded for const/non-const references and the wrong one was
picked, and run-time failures when by-value copy-assignment operators
did not have their arguments properly copy-initialized.

This implementation synthesizes the implicitly-defined copy assignment
operator bodies in Sema, so that the resulting ASTs encode exactly
what CodeGen needs to do; there is no longer any special code in
CodeGen to synthesize copy-assignment operators. The synthesis of the
body is relatively simple, and we generate one of three different
kinds of copy statements for each base or member:

  - For a class subobject, call the appropriate copy-assignment
    operator, after overload resolution has determined what that is.
  - For an array of scalar types or an array of class types that have
    trivial copy assignment operators, construct a call to
    __builtin_memcpy.
  - For an array of class types with non-trivial copy assignment
    operators, synthesize a (possibly nested!) for loop whose inner
    statement calls the copy constructor.
  - For a scalar type, use built-in assignment.

This patch fixes at least a few tests cases in Boost.Spirit that were
failing because CodeGen picked the wrong copy-assignment operator
(leading to link-time failures), and I suspect a number of undiagnosed
problems will also go away with this change.

Some of the diagnostics we had previously have gotten worse with this
change, since we're going through generic code for our
type-checking. I will improve this in a subsequent patch.

llvm-svn: 102853
2010-05-01 20:49:11 +00:00
Chris Lattner ef8c6e8ba7 fix a broken link, diagnostickinds.td was fissioned.
llvm-svn: 102851
2010-05-01 17:35:19 +00:00
Anders Carlsson b136e626ea Simplify EmitCopyCtorCall.
llvm-svn: 102849
2010-05-01 17:07:40 +00:00
Anders Carlsson aab3b57359 Simplify EmitClassAggrMemberwiseCopy.
llvm-svn: 102848
2010-05-01 17:02:18 +00:00
Douglas Gregor 1af7cc2830 Bump default template instantiation depth to 1024, as required by C++0x
llvm-svn: 102847
2010-05-01 16:59:21 +00:00
Anders Carlsson ab826ad169 Clean up EmitClassMemberwiseCopy further.
llvm-svn: 102846
2010-05-01 16:54:05 +00:00
Anders Carlsson 820022c55c Get rid of a parameter from EmitClassMemberwiseCopy.
llvm-svn: 102845
2010-05-01 16:49:43 +00:00
Anders Carlsson 7911150a3d When defining implicit copy constructors, use SetBaseOrMemberInitializers to initialize the bases.
llvm-svn: 102842
2010-05-01 16:39:01 +00:00
Douglas Gregor a57478e8f6 Added an RAII object that helps set up/tear down the Sema context
information required to implicitly define a C++ special member
function. Use it rather than explicitly setting CurContext on entry
and exit, which is fragile. 

Use this RAII object for the implicitly-defined default constructor,
copy constructor, copy assignment operator, and destructor.

llvm-svn: 102840
2010-05-01 15:04:51 +00:00
David Chisnall c0cf422d56 Attach message send metadata to the lookup as well as to the call (GNU runtime).
llvm-svn: 102839
2010-05-01 12:56:56 +00:00
David Chisnall ea529a43d4 Make super message lookups cacheable (GNUstep Runtime)
llvm-svn: 102837
2010-05-01 12:37:16 +00:00
David Chisnall 9eecafa480 Tweaked EmitCall() to permit the caller to provide some metadata to attach to the call site.
Used this in CGObjCGNU to attach metadata about message sends to permit speculative inlining.

llvm-svn: 102833
2010-05-01 11:15:56 +00:00
Chris Lattner 036078ca76 with recent optimizer changes, these all get devirtualized.
llvm-svn: 102825
2010-05-01 01:42:06 +00:00
John McCall 0b66eb38c7 It turns out that basically every caller to RequireCompleteDeclContext
already knows what context it's looking in.  Just pass that context in
instead of (questionably) recalculating it.

llvm-svn: 102818
2010-05-01 00:40:08 +00:00
Daniel Dunbar 832fc4a098 Fix NON_ANSI_COMPILE_FLAGS setting, for MSVC.
llvm-svn: 102811
2010-05-01 00:06:42 +00:00
Ted Kremenek bc1416dcad Add null check in CFGBuilder::VisitStmt() to make CFG construction
more resilient to bad code.

llvm-svn: 102793
2010-04-30 22:25:53 +00:00
Daniel Dunbar d5a2a073a0 Rename 'CIndex' to 'libclang', since it has basically become our stable public
(C) API, and will likely grow further in this direction in the future.

llvm-svn: 102779
2010-04-30 21:51:10 +00:00
Ted Kremenek b802192a7e Don't perform AnalysisBasedWarnings in Sema or run the static analyzer when a
fatal error has occurred.

llvm-svn: 102778
2010-04-30 21:49:25 +00:00
Douglas Gregor fabf95d066 After substituting a template argument for a non-type template
parameter with pointer-to-member type, we may have to perform a
qualification conversion, since the pointee type of the parameter
might be more qualified than the pointee type of the argument we form
from the declaration. Fixes PR6986.

llvm-svn: 102777
2010-04-30 21:46:38 +00:00
John McCall 4d4dcc8ed7 When synthesizing Objective C records, give the synthetic fields public
access.  Fixes an assertion.

Fixes rdar://problem/7927811.  Too lazy to reduce a test case.

llvm-svn: 102776
2010-04-30 21:35:41 +00:00
Douglas Gregor 0be628ff64 Fix a thinko that caused us not to compute __builtin_offset as a
constant expression in C. 

llvm-svn: 102762
2010-04-30 20:35:01 +00:00
Douglas Gregor 0925fbc3fd Teach clang_getLocation() to cope with a NULL file argument.
llvm-svn: 102748
2010-04-30 19:45:53 +00:00
Anders Carlsson d6c5391cd9 Remove an unnecessary parameter from EmitClassCopyAssignment.
llvm-svn: 102747
2010-04-30 19:45:28 +00:00
Douglas Gregor 14cf752486 Clean up our handling of local instantiation scopes, which keep track
of the mapping from local declarations to their instantiated
counterparts during template instantiation. Previously, we tried to do
some unholy merging of local instantiation scopes that involved
storing a single hash table along with an "undo" list on the
side... which was ugly, and never handled function parameters
properly.

Now, we just keep separate hash tables for each local instantiation
scope, and "combining" two scopes means that we'll look in each of the
combined hash tables. The combined scope stack is rarely deep, and
this makes it easy to avoid the "undo" issues we were hitting. Also,
I've simplified the logic for function parameters: if we're declaring
a function and we need the function parameters to live longer, we just
push them back into the local instantiation scope where we need them. 

Fixes PR6990.

llvm-svn: 102732
2010-04-30 18:55:50 +00:00
Daniel Dunbar 9f84c7b600 Move include installation steps to better location, inside each include dir instead of at the top-level.
Also, don't set NO_INSTALL=1 for c-index-test.

llvm-svn: 102724
2010-04-30 17:59:38 +00:00
David Chisnall d6a6af6a53 Fixed incorrect type of alloca (GNU runtime).
llvm-svn: 102711
2010-04-30 13:36:12 +00:00
Abramo Bagnara 5009937f47 Add calling convention related attributes to related declaration. Mark attributes invalid on type related checking so to add them to declarations only when everything is ok.
llvm-svn: 102710
2010-04-30 13:10:51 +00:00
Abramo Bagnara b639ab9ffc Attribute noreturn is now put in declaration attributes. Fixed a double warning generation.
llvm-svn: 102705
2010-04-30 09:13:03 +00:00
John McCall 5af1aa6393 An edge from a call expression to the exit block is only an abnormal edge
if *none* of the successors of the call expression is the exit block.
This matters when a call of bool type is the condition of (say) a while
loop in a function with no statements after the loop.  This *can* happen
in C, but it's much more common in C++ because of overloaded operators.

Suppresses some substantial number of spurious -Wmissing-noreturn warnings.

llvm-svn: 102696
2010-04-30 07:10:06 +00:00
Douglas Gregor 8b895228d9 Fix ADL for types declared in transparent decls, from Alp Toker!
llvm-svn: 102695
2010-04-30 07:08:38 +00:00
Douglas Gregor 407e961645 Introduce a sequence number into class template partial
specializations, which keeps track of the order in which they were
originally declared. We use this number so that we can always walk the
list of partial specializations in a predictable order during matching
or template instantiation. This also fixes a failure in Boost.Proto,
where SourceManager::isBeforeInTranslationUnit was behaving
poorly in inconsistent ways.

llvm-svn: 102693
2010-04-30 05:56:50 +00:00
John McCall b3cec96a7c Account for the VTT argument when making an implicit copy constructor for
a class with virtual bases.  Just a patch until Sema starts (correctly) doing
most of this analysis.

Fixes PR 6622.

llvm-svn: 102692
2010-04-30 05:56:45 +00:00
Douglas Gregor 1e13c5a8fb When we start the definition of a class template, set the
InjectedClassNameType's Decl to point at the definition. It's a little
messy, but we do the same thing with classes and their record types,
since much of Clang expects that the TagDecl* one gets out of a type
is the definition. Fixes several Boost.Proto failures.

llvm-svn: 102691
2010-04-30 04:39:27 +00:00
Zhongxing Xu 526f504f06 Remove unused trait.
llvm-svn: 102690
2010-04-30 04:17:33 +00:00
Zhongxing Xu 685a1d818d Refactor the AnalysisConsumer to analyze functions after the whole
translation unit is parsed. This enables us to inline some calls when still
analyzing one function at a time.

Actions are classified into Function, CXXMethod, ObjCMethod, 
ObjCImplementation.

This does not hurt performance much. The analysis time for sqlite3.c:

before:
real    17m52.440s
user    17m49.460s
sys    0m2.010s

after:
real    18m0.500s
user    17m56.900s
sys    0m2.330s

DisplayProgress option is broken now. -inine-call action is removed. It
will be reenabled in another form, perhaps as an indenpendant option.

llvm-svn: 102689
2010-04-30 04:14:20 +00:00
John McCall e7db86ddb0 Fix a tentative-parse error with unqualified template ids in cast expressions.
Also resolve a long-working FIXME in the test case I modified.

llvm-svn: 102688
2010-04-30 03:11:01 +00:00
Douglas Gregor dead00f902 Fix pasto in this test
llvm-svn: 102687
2010-04-30 03:07:23 +00:00
Douglas Gregor 6602c25c0c Add Clang version inspection macros. Fixes PR6681.
llvm-svn: 102686
2010-04-30 02:51:06 +00:00
John McCall 48bf349471 Fix -fno-rtti -fexceptions by forcing the emission of (non-"builtin") RTTI
when used by the exceptions routines.  Fixes PR 6974.

llvm-svn: 102684
2010-04-30 01:15:21 +00:00
Nate Begeman 4a623eed26 logical ops, unary ops, pairwise ops
llvm-svn: 102681
2010-04-30 00:46:57 +00:00
John McCall dac3ea6e8d Teach EHCleanupBlock to deal appropriately with the possibility that there
might not have been an insertion block set at start.  Fixes PR6975.

llvm-svn: 102677
2010-04-30 00:06:43 +00:00
Anders Carlsson 786a3d910e Get the base class addresses before calling EmitClassCopyAssignment.
llvm-svn: 102676
2010-04-30 00:04:01 +00:00
Anders Carlsson 2b4ec8d003 Remove an unnecessary argument to EmitClassCopyAssignment.
llvm-svn: 102674
2010-04-29 23:51:42 +00:00
John McCall 99b2fe5f54 Rebuild the nested name specifiers in member-pointer declarator chunks when
entering the current instantiation.  Set up a little to preserve type location
information for typename types while we're in there.

Fixes a Boost failure.

llvm-svn: 102673
2010-04-29 23:50:39 +00:00
Nate Begeman 723169d8ec Comparisons.
llvm-svn: 102669
2010-04-29 23:36:09 +00:00
Ted Kremenek d8a23f988d Do not enable '-analyze-check-security-syntactic' by default when using '--analyze'. There
are several known issues to address for it should be turned on by default.

llvm-svn: 102664
2010-04-29 22:50:22 +00:00
Douglas Gregor 980fb16f9a When determining a standard conversion sequence involves resolving the
address of an overloaded function (or function template), perform that
resolution prior to determining the implicit conversion
sequence. This resolution is not part of the implicit conversion
sequence itself.

Previously, we would always consider this resolution to be a
function pointer decay, which was a lie: there might be an explicit &
in the expression, in which case decay should not occur. This caused
the CodeGen assertion in PR6973 (where we created a 
pointer to a pointer to a function when we should have had a pointer
to a function), but it's likely that there are corner cases of
overload resolution where this would have failed.

Cleaned up the code involved in determining the type that will
produced afer resolving the overloaded function reference, and added
an assertion to make sure the result is correct. Fixes PR6973.

llvm-svn: 102650
2010-04-29 18:24:40 +00:00
Fariborz Jahanian 9e1a3af030 Properties cannot be synthesized by-dafult in
categories. Issue usual warnings instead of
confusing error message. Radar 7920807

llvm-svn: 102645
2010-04-29 17:52:18 +00:00
Devang Patel dfcd0661a1 Use clang::VarDecl name instead of llvm::GlobalVariable name.
llvm::GLobalVariable name may not match user visibile name for function static variables.

llvm-svn: 102644
2010-04-29 17:48:37 +00:00
Ted Kremenek 3b9ad93a35 Add USR support for 'static inline' functions (which can be declared in header files).
Add USR support for 'static' functions and local variables, which can be handy for resolving named variables within a translation unit.

llvm-svn: 102641
2010-04-29 17:43:29 +00:00
Ted Kremenek 9825536eea Remove USRGenerator::VisitBlockDecl(). We don't need to generate USRs for blocks, since
they have no linkage and by definition are anonymous.

llvm-svn: 102640
2010-04-29 17:43:26 +00:00
Ted Kremenek 772810137a Add test case for __has_feature(objc_weak_class).
llvm-svn: 102639
2010-04-29 17:43:21 +00:00
Nate Begeman 23a2f2ff79 Start stamping out the __builtin_neon stuff.
llvm-svn: 102638
2010-04-29 17:37:19 +00:00
Ted Kremenek 186a074346 Add FunctionDecl::isVariadic() to match BlockDecl::isVariadic() and ObjCMethodDecl::isVariadic().
Do some minor refactoring along the way.

llvm-svn: 102635
2010-04-29 16:49:01 +00:00
Ted Kremenek 8af4f40f4a Rename BlockDecl::IsVariadic() to BlockDecl::isVariadic() to match the casing
for similar methods.  No functionality change.

llvm-svn: 102634
2010-04-29 16:48:58 +00:00
Daniel Dunbar 0c00537583 IRgen/NeXT: Put the synthesized _objc_super, _message_ref_t decls in a valid DeclContext, to satisfy the invariants that should hold on a RecordDecl.
llvm-svn: 102624
2010-04-29 16:29:11 +00:00