Граф коммитов

1072 Коммитов

Автор SHA1 Сообщение Дата
Fariborz Jahanian 4fb20533ba Patch to fix a crash on incomplete class declaration.
Radar 7923673.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103812 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-14 21:35:02 +00:00
Douglas Gregor 6fb745bdf1 Rework when and how vtables are emitted, by tracking where vtables are
"used" (e.g., we will refer to the vtable in the generated code) and
when they are defined (i.e., because we've seen the key function
definition). Previously, we were effectively tracking "potential
definitions" rather than uses, so we were a bit too eager about emitting
vtables for classes without key functions. 

The new scheme:
  - For every use of a vtable, Sema calls MarkVTableUsed() to indicate
  the use. For example, this occurs when calling a virtual member
  function of the class, defining a constructor of that class type,
  dynamic_cast'ing from that type to a derived class, casting
  to/through a virtual base class, etc.
  - For every definition of a vtable, Sema calls MarkVTableUsed() to
  indicate the definition. This happens at the end of the translation
  unit for classes whose key function has been defined (so we can
  delay computation of the key function; see PR6564), and will also
  occur with explicit template instantiation definitions.
 - For every vtable defined/used, we mark all of the virtual member
 functions of that vtable as defined/used, unless we know that the key
 function is in another translation unit. This instantiates virtual
 member functions when needed.
  - At the end of the translation unit, Sema tells CodeGen (via the
  ASTConsumer) which vtables must be defined (CodeGen will define
  them) and which may be used (for which CodeGen will define the
  vtables lazily). 

From a language perspective, both the old and the new schemes are
permissible: we're allowed to instantiate virtual member functions
whenever we want per the standard. However, all other C++ compilers
were more lazy than we were, and our eagerness was both a performance
issue (we instantiated too much) and a portability problem (we broke
Boost test cases, which now pass).

Notes:
  (1) There's a ton of churn in the tests, because the order in which
  vtables get emitted to IR has changed. I've tried to isolate some of
  the larger tests from these issues.
  (2) Some diagnostics related to
  implicitly-instantiated/implicitly-defined virtual member functions
  have moved to the point of first use/definition. It's better this
  way.
  (3) I could use a review of the places where we MarkVTableUsed, to
  see if I missed any place where the language effectively requires a
  vtable.

Fixes PR7114 and PR6564.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103718 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-13 16:44:06 +00:00
Abramo Bagnara 465d41b92b Merged Elaborated and QualifiedName types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103517 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 21:36:43 +00:00
Douglas Gregor 5764f613e6 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103362 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-08 23:05:03 +00:00
John McCall 1b5a618c59 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103173 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06 08:49:23 +00:00
Douglas Gregor 5f970eee81 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103025 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-04 18:18:31 +00:00
Douglas Gregor 324b54d3f6 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102931 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 18:51:14 +00:00
Douglas Gregor fe60f84c4f When a class contains a non-empty anonymous union or struct, mark is
as non-empty. Fixes PR7021.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102913 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 15:18:25 +00:00
John McCall 77bb1aa78b 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102818 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 00:40:08 +00:00
John McCall 63b4385822 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102673 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 23:50:39 +00:00
Abramo Bagnara b21b405325 Written storage class for declarations inside linkage specifications without braces is none.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102496 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-28 13:11:54 +00:00
Douglas Gregor c8fd2dae17 When checking the redeclaration context of a typedef that refers to a
tag of the same name, compare the lookup contexts rather than the
actual contexts. Fixes PR6923.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102437 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-27 16:26:47 +00:00
Douglas Gregor a6a292b4dc Don't look into incomplete types when trying to warn about unused
variables. Fixes PR6948.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102436 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-27 16:20:13 +00:00
Fariborz Jahanian 0b7bc8e937 Diagnose declaration of reference typed ivars.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102390 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26 22:07:03 +00:00
Anders Carlsson f1b48b7014 CastExpr should not hold a pointer to the base path. More cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102249 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 16:57:13 +00:00
Douglas Gregor 48c89f4aa7 Be more careful around dependent nested-name-specifiers, complaining
when they are not complete (since we could not match them up to
anything) and ensuring that enum parsing can cope with dependent
elaborated-type-specifiers. Fixes PR6915 and PR6649.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102247 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 16:38:41 +00:00
Douglas Gregor 107de90451 Keep track of when DependentNameTypes have no associated keyword
(e.g., no typename, enum, class, etc.), e.g., because the context is
one that is known to refer to a type. Patch from Enea Zaffanella!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102243 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 15:35:55 +00:00
John McCall 76d326448d Recommit r102215, this time being more careful to only set the "principal
declaration" (i.e. the only which will actually be looked up) to have the
non-member-operator bit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102231 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 01:30:58 +00:00
Devang Patel f0bf4d554f Revert r102215. This causes clang crash while compiling a test case from gdb testsuite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102224 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 00:40:35 +00:00
Douglas Gregor 4e6c0d19b7 Rework Parser-Sema interface for Objective-C @catch exception object
arguments. Rather than having the parser call ActOnParamDeclarator
(which is a bit of a hack), call a new ActOnObjCExceptionDecl
action. We'll be moving more functionality into this handler to
perform earlier checking of @catch.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102222 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 23:01:43 +00:00
Anders Carlsson 88465d3e99 Add an InheritancePath parameter to the ImplicitCastExpr constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102218 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 22:18:37 +00:00
John McCall f88b0d6c99 Transition the last acceptable-result filter kind in LookupResult over to use
a simple IDNS mask by introducing a namespace for non-member operators.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102215 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 21:37:18 +00:00
John McCall 0d6b1640eb Recommit my change to how C++ does elaborated type lookups, now with
two bugfixes which fix selfhost and (hopefully) the nightly tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102198 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 18:46:30 +00:00
Daniel Dunbar 00b40d3f2f Revert "C++ doesn't really use "namespaces" for different kinds of names the same", which seems to break most C++ nightly test apps.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102174 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 13:07:39 +00:00
John McCall d04efc98d0 C++ doesn't really use "namespaces" for different kinds of names the same
way that C does.  Among other differences, elaborated type specifiers
are defined to skip "non-types", which, as you might imagine, does not
include typedefs.  Rework our use of IDNS masks to capture the semantics
of different kinds of declarations better, and remove most current lookup
filters.  Removing the last remaining filter is more complicated and will
happen in a separate patch.

Fixes PR 6885 as well some spectrum of unfiled bugs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102164 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 02:41:41 +00:00
Douglas Gregor 66dd939499 When checking whether to diagnose an initialized "extern" variable,
look for the const on the base type rather than on the top-level
type. Fixes PR6495 properly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102066 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 14:36:26 +00:00
Anders Carlsson 3b8c53b619 Re-land the patch that merges two diagnostics into one now that it passes self-host :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102050 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 05:40:53 +00:00
Daniel Dunbar d4b2853cec Revert "Unify two diagnostics into one.", it breaks with an assertion failure on bootstrap.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102043 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 02:35:33 +00:00
Anders Carlsson 792898b58a Unify two diagnostics into one.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102040 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22 01:17:32 +00:00
Anders Carlsson 10dc0f8c35 Remove an unused parameter from isImplicitlyDefined.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101962 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 23:32:58 +00:00
Douglas Gregor 16573fa970 Keep track of the actual storage specifier written on a variable or
function declaration, since it may end up being changed (e.g.,
"extern" can become "static" if a prior declaration was static). Patch
by Enea Zaffanella and Paolo Bolzoni.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101826 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 22:54:31 +00:00
Douglas Gregor 63c323d758 Only suppress the "extern variable has an initializer" warning when the extern entity being initialized is const.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101821 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 22:34:40 +00:00
Douglas Gregor 41b1d6ba40 Disable the "'extern' variable has an initializer" warning in C++,
since it makes sense there to have const extern variables. Fixes
PR6495.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101818 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 21:31:25 +00:00
Anders Carlsson 72468ecb98 Start working on handling wide bitfields in C++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101464 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16 15:16:32 +00:00
Douglas Gregor c83c6874e3 Feed proper source-location information into Sema::LookupSingleResult,
in case it ends up doing something that might trigger diagnostics
(template instantiation, ambiguity reporting, access
reporting). Noticed while working on PR6831.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101412 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 22:33:43 +00:00
Anders Carlsson c75d6ccf16 Improve the bit-field too wide error message.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101384 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 18:47:32 +00:00
Douglas Gregor af68d4ed6d Fix a few cases where enum constant handling was using
ASTContext::getTypeSize() rather than ASTContext::getIntWidth() for
the width of an integral type. The former includes padding for bools
(to the target's size) while the latter does not, so we woud end up
zero-extending bools to the target width when we shouldn't. Fixes a
crash-on-valid in the included test.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101372 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 15:53:31 +00:00
Douglas Gregor aaf87162c5 Teach typo correction about various language keywords. We can't
generally recover from typos in keywords (since we would effectively
have to mangle the token stream). However, there are still benefits to
typo-correcting with keywords:
  - We don't make stupid suggestions when the user typed something
  that is similar to a keyword. 
  - We can suggest the keyword in a diagnostic (did you mean
  "static_cast"?), even if we can't recover and therefore don't have
  a fix-it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101274 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14 20:04:41 +00:00
John McCall f19de1ce44 Mark a function declaration invalid if any of its parameter declarations
are invalid.  Prevents a crash-on-invalid during template instantiation.
I... really don't understand how this wasn't already present.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101203 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14 01:27:20 +00:00
John McCall 77e8b11524 Support befriending members of class template specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101173 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13 20:37:33 +00:00
John McCall 3d04336baf Allow classes to befriend implicitly-declared members. Fixes PR6207 for
members of non-templated classes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101122 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13 07:45:41 +00:00
John McCall ba9d853bec Parse constructor names in friend declarations. Part of the fix for
PR6207.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101119 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13 06:39:49 +00:00
John McCall 9ea6397bf4 Don't try to find a scope corresponding to the search DC for an unfound
friend declaration;  this used to be important but is now just a waste of time
plus an unreasonable assertion.  Fixes PR6174.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101112 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13 01:44:10 +00:00
Douglas Gregor 57265e3529 Fix a crash-on-invalid involving name lookup of tag names, where we
ended up finding a function template that we didn't expect. Recover
more gracefully, and fix a similar issue for class templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101040 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 16:00:01 +00:00
Douglas Gregor cb27b0f70d Be sure to instantiate the parameters of a function, even when the
function's type is (strictly speaking) non-dependent. This ensures
that, e.g., default function arguments get instantiated properly.

And, since I couldn't resist, collapse the two implementations of
function-parameter instantiation into calls to a single, new function
(Sema::SubstParmVarDecl), since the two had nearly identical code (and
each had bugs the other didn't!). More importantly, factored out the
semantic analysis of a parameter declaration into
Sema::CheckParameter, which is called both by
Sema::ActOnParamDeclarator (when parameters are parsed) and when a
parameter is instantiated. Previously, we were missing some
Objective-C and address-space checks on instantiated function
parameters.

Fixes PR6733.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101029 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 07:48:19 +00:00
Chris Lattner 1a4221cbe1 Don't warn about unused static functions if they are marked with
attr constructor or destructor.  Patch by Jean-Daniel Dupas!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100870 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-09 17:25:05 +00:00
Douglas Gregor cb821d045f Downgrade the "declaration does not declare anything" error to a
warning. It's not harmful to have such pointless declarations, and GCC
does not diagnose this issue consistently.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100814 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 21:33:23 +00:00
Jeffrey Yasskin c173be2aa7 Explain that a template needs arguments to make it into a type, for
variable declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100809 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 21:04:54 +00:00
Jeffrey Yasskin 9ab1454171 Make CXXScopeSpec invalid when incomplete, and propagate that into any
Declarator that depends on it.  This fixes several redundant errors and bad
recoveries.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100779 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 16:38:48 +00:00
John McCall af2094e7ce Implement dependent friend function template specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100753 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 09:05:18 +00:00
Jeffrey Yasskin edc287751a Fix some redundant errors by changing CXXScopeSpec::isSet calls into
isNotEmpty calls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100722 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-07 23:29:58 +00:00
Fariborz Jahanian 0bd04596e4 Patch to not build ivar ASTs when they are ilegally
declared in categories.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100577 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-06 22:43:48 +00:00
Daniel Dunbar a19331f156 Sema/Obj-C: Simplify -- eliminate dead casts & provable asserts, and narrow type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100197 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-02 18:29:09 +00:00
Douglas Gregor 1eabb7d0c3 Improve diagnostics when an elaborated-type-specifer containing a
nested-name-specifier (e.g., "class T::foo") fails to find a tag
member in the scope nominated by the
nested-name-specifier. Previously, we gave a bland

  error: 'Nested' does not name a tag member in the specified scope

which didn't actually say where we were looking, which was rather
horrible when the nested-name-specifier was instantiated. Now, we give
something a bit better:

  error: no class named 'Nested' in 'NoDepBase<T>'




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100060 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 23:17:41 +00:00
Douglas Gregor 4a2023f501 Extend DependentNameType with a keyword enum that specifies whether
this was parsed as a typename-specifier, elaborated-type-specifier
(including the kind), or just a dependent qualified type name.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100039 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 20:19:30 +00:00
Douglas Gregor 849b243d40 Reinstate my CodeModificationHint -> FixItHint renaming patch, without
the C-only "optimization".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100022 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 17:46:05 +00:00
Douglas Gregor 4714c12a1a Rename TypenameType to DependentNameType in anticipation of some
refactoring work in this area.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100019 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 17:34:00 +00:00
Douglas Gregor 275313cbb0 Revert r100008, which inexplicably breaks the clang-i686-darwin10 builder
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100018 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 17:25:35 +00:00
Douglas Gregor d0ebe080ee Rename CodeModificationHint to FixItHint, since we've been using the
term "fix-it" everywhere and even *I* get tired of long names
sometimes. No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100008 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 15:31:50 +00:00
John McCall aec586056d Support __attribute__((unused)) on types. This suddenly started firing
a lot for me on selfhosts, I dunno why.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99981 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 02:47:45 +00:00
John McCall 7727acf243 Fix PR6327: restore invariants when there's a parse error in an initializer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99980 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 02:13:20 +00:00
Rafael Espindola 264ba48dc9 the big refactoring bits of PR3782.
This introduces FunctionType::ExtInfo to hold the calling convention and the
noreturn attribute. The next patch will extend it to include the regparm
attribute and fix the bug.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 20:24:48 +00:00
John McCall b0cb022dae Implement method friends in class templates and fix a few related problems.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99708 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-27 05:57:59 +00:00
John McCall 90f97892eb When finishing a function definition, leave the function definition *after*
doing all the cleanup tasks and checks.  This gives us the proper context for
checking access to base and member destructors.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99559 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-25 22:08:03 +00:00
John McCall 9c86b513cb Handle simple friend-class decls in class templates better by ensuring that
we look for shadow friend decls in the appropriate scope before injecting
a new declaration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99552 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-25 21:28:06 +00:00
Fariborz Jahanian f3c0bd5840 Improve diagnostics when ivar added to class
extension (radar 6812436).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99408 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 18:08:23 +00:00
Douglas Gregor 036ada215d Silently drop dependent friend function template specializations,
since we have absolutely no way to match them when they are declared
nor do we have a way to represent these parsed-but-not-checked friend
declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99407 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 17:31:23 +00:00
John McCall 5fd378bd9b Correct that last fixit: if the user wrote
template <> friend void foo(int);
we need to change it to
  friend void foo<>(int);
or else the user won't get the template specialization they obviously want.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99390 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 08:27:58 +00:00
John McCall 7ad650f88e Support friend function specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99389 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 07:46:06 +00:00
Douglas Gregor 9de672f6eb When recovering from a qualified typedef name, don't clear out the
DeclContext because we don't want a NULL DeclContext. Instead, use the
current context.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99281 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23 15:26:55 +00:00
Ted Kremenek d064fdc4b7 Only perform CFG-based warnings on 'static inline' functions that
are called (transitively) by regular functions/blocks within a
translation untion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99233 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23 00:13:23 +00:00
John McCall 053f4bddcb -Wshadow should only warn about parameter declarations when we're
entering a function or block definition, not on every single declaration.
Unfortunately we don't have previous-lookup results around when it's time
to make this decision, so we have to redo the lookup.  The alternative is
to use delayed diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99172 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-22 09:20:08 +00:00
Rafael Espindola 0162070430 Fix PR6618.
If a struct has an invalid field, mark it as invalid. Also avoid producing
errors about incomplete types that are invalid.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99150 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-21 22:56:43 +00:00
Ted Kremenek dbdbaaf34f Refactor CFG-based warnings in Sema to be run by a worked object called AnalysisBasedWarnings.
This object controls when the warnings are executed, allowing the client code
in Sema to selectively disable warnings as needed.

Centralizing the logic for analysis-based warnings allows us to optimize
when and how they are run.

Along the way, remove the redundant logic for the 'check fall-through' warning
for blocks; now the same logic is used for both blocks and functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99085 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-20 21:06:02 +00:00
John McCall a369a95f75 Implement -Wshadow for parameter declarations as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99037 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-20 04:12:52 +00:00
John McCall 10f2873c0d Redeclaration lookups for parameter names should be flagged as redeclaration lookups
so they don't trigger diagnostics like (say) access control.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98806 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 06:42:38 +00:00
John McCall a8cab015e5 ActOnTagDefinitionError is supposed to 'unwind' ActOnTagStartDefinition, not
ActOnStartCXXMemberDeclaration.  We haven't started the field collector on this
class yet, so don't stop it.  Fixes a crash in the VS buildbot and a memory error
on all the others.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98760 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 19:25:57 +00:00
Douglas Gregor c48c916b8c Remove warning about shadowing a built-in; built-ins aren't actually
considered to be a part of the translation unit unless they're named
in a way that brings them into existence.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98729 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 16:03:44 +00:00
John McCall db7bb4a4e7 Clean up after ourselves when there's an error parsing the base clause.
Fixes the crash-on-invalid in PR6629.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98698 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 00:38:33 +00:00
John McCall 8472af4df9 Implement -Wshadow. Based on a patch by Mike M.!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98684 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16 21:48:18 +00:00
John McCall ef027fe748 Perform access control for the implicit calls to base and member destructors
that occur in constructors (on the unwind path).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98681 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16 21:39:52 +00:00
John McCall b6217665c6 Remember declaration scope qualifiers in the AST. Imposes no memory overhead
on unqualified declarations.

Patch by Enea Zaffanella!  Minimal adjustments:  allocate the ExtInfo nodes
with the ASTContext and delete them during Destroy().  I audited a bunch of
Destroy methods at the same time, to ensure that the correct teardown was
being done.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98540 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-15 10:12:16 +00:00
Ted Kremenek 4c9f709fc9 Use llvm::SmallVector instead of std::vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98397 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-12 22:22:36 +00:00
John McCall 21ef0fa27b Maintain type source information for functions through template
instantiation.  Based on a patch by Enea Zaffanella!  I found a way to
reduce some of the redundancy between TreeTransform's "standard"
FunctionProtoType transformation and TemplateInstantiator's override,
and I killed off the old SubstFunctionType by adding type source info
for the last cases where we were creating FunctionDecls without TSI
(at least that get passed through template instantiation).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98252 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 09:03:00 +00:00
John McCall 3cb0ebd5f7 Create a new InjectedClassNameType to represent bare-word references to the
injected class name of a class template or class template partial specialization.
This is a non-canonical type;  the canonical type is still a template 
specialization type.  This becomes the TypeForDecl of the pattern declaration,
which cleans up some amount of code (and complicates some other parts, but
whatever).

Fixes PR6326 and probably a few others, primarily by re-establishing a few
invariants about TypeLoc sizes.     



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 03:28:59 +00:00
Douglas Gregor 516a6bc399 In C++98/03, an uninitialized variable that has POD class type will be
uninitialized. This seems not to be the case in C++0x, where we still
call the (trivial) default constructor for a POD class
(!). Previously, we had implemented only the C++0x rules; now we
implement both. Fixes PR6536.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97928 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-08 02:45:10 +00:00
Eli Friedman d6a9324e9b Fix for PR6294: we should only delay recording nested dynamic classes if they
are lexically nested.  Othewise, we never end up recording semantically nested
classes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97900 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-07 05:49:51 +00:00
Douglas Gregor 9b9edd619a Diagnose the declaration of enum templates. Also, be a bit more
careful about value-dependent enumerators. Fixes PR5786.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97570 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02 17:53:14 +00:00
Douglas Gregor 9ea9bdbc14 Keep an explicit stack of function and block scopes, each element of
which has the label map, switch statement stack, etc. Previously, we
had a single set of maps in Sema (for the function) along with a stack
of block scopes. However, this lead to funky behavior with nested
functions, e.g., in the member functions of local classes.

The explicit-stack approach is far cleaner, and we retain a 1-element
cache so that we're not malloc/free'ing every time we enter a
function. Fixes PR6382.

Also, tweaked the unused-variable warning suppression logic to look at
errors within a given Scope rather than within a given function. The
prior code wasn't looking at the right number-of-errors count when
dealing with blocks, since the block's count would be deallocated
before we got to ActOnPopScope. This approach works with nested
blocks/functions, and gives tighter error recovery.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97518 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 23:15:13 +00:00
Chandler Carruth 7bf3600f56 Fix the lookup of names used in a friend declaration to not attempt to
re-declare them. This fixes PR6317. Also add the beginnings of an interesting
test case for p1 of [class.friend] which also covers PR6317.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97499 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 21:17:36 +00:00
Chris Lattner e6794974b7 fix PR5933: don't warn about unused variables if a function has other errors in it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 21:06:03 +00:00
Chris Lattner 6d97e5e4b7 Implement jump checking for initialized c++ variables, implementing
a fixme and PR6451.

Only perform jump checking if the containing function has no errors,
and add the infrastructure needed to do this.

On the testcase in the PR, we produce:

t.cc:6:3: error: illegal goto into protected scope
  goto later;
  ^
t.cc:7:5: note: jump bypasses variable initialization
  X x;
    ^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97497 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 20:59:53 +00:00
Chandler Carruth 78bd771b27 Fix a really trivial crasher and begin fleshing out one of the namespace test
cases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 09:32:59 +00:00
Fariborz Jahanian f914b9782a More Sema check for ivars in class continuation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97002 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 23:41:11 +00:00
Fariborz Jahanian 83c481ade7 Early support for declaring ivars in class extensions. wip.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96819 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 23:04:20 +00:00
Chris Lattner d84aac1718 Add 'previous declaration is here' note for param redefinition
errors, e.g.:

t.c:1:21: error: redefinition of parameter 'x'
int test(int x, int x);
                    ^
t.c:1:14: note: previous declaration is here
int test(int x, int x);
             ^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96769 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 00:40:25 +00:00
Douglas Gregor ce056bcaa1 Eliminate the default arguments to ASTContext::getFunctionType(),
fixing up a few callers that thought they were propagating NoReturn
information but were in fact saying something about exception
specifications.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96766 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 22:15:06 +00:00
Chandler Carruth 8761d680ea Make Decl::isOutOfLine() virtual, and use that to determine when definitions
are for out of line declarations more easily. This simplifies the logic and
handles the case of out-of-line class definitions correctly. Fixes PR6107.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96729 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 07:08:09 +00:00
Ted Kremenek 12911a85b2 Don't warn about functions redeclared without the dllimport attribute when
-fms-extensions is enabled.  Fixes <rdar://problem/7669559>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96721 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 05:12:53 +00:00
Fariborz Jahanian 11062e1123 Patch removes IVars list from ObjCInterfaceDecl and
instead relies on their DeclContext for iteration, etc.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96638 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 00:31:17 +00:00