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

875 Коммитов

Автор SHA1 Сообщение Дата
Sebastian Redl 9770ef0eea When checking the namespace of a redeclaration or definition, look through linkage specs. Fixes PR5430.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86461 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 11:36:54 +00:00
Anders Carlsson f7613d5361 Don't treat variables with non-trivial ctors or dtors as unused. Fixes PR5407.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86352 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 07:26:56 +00:00
Anders Carlsson 99a000e3ca Cleanup, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86351 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 07:18:14 +00:00
Douglas Gregor 4912c347ce Make sure that EnumConstantDecls always get a type, even when they have type-dependent initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86197 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 00:03:12 +00:00
Sebastian Redl 6e82475568 Don't allow definitions of array variables without some size information in C++. Fixed PR5401
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86165 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 19:47:47 +00:00
John McCall 54abf7d4fa Change our basic strategy for avoiding deprecation warnings when the decl use
appears in a deprecated context.  In the new strategy, we emit the warnings
as usual unless we're currently parsing a declaration, where "declaration" is
restricted to mean a decl group or a few special cases in Objective C.  If
we *are* parsing a declaration, we queue up the deprecation warnings until
the declaration has been completely parsed, and then emit them only if the
decl is not deprecated.
We also standardize the bookkeeping for deprecation so as to avoid special cases.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85998 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 02:18:39 +00:00
Douglas Gregor 02a24ee67c Use ParseUnqualifiedId when parsing id-expressions. This eliminates
yet another copy of the unqualified-id parsing code.

Also, use UnqualifiedId to simplify the Action interface for building
id-expressions. ActOnIdentifierExpr, ActOnCXXOperatorFunctionIdExpr,
ActOnCXXConversionFunctionExpr, and ActOnTemplateIdExpr have all been
removed in favor of the new ActOnIdExpression action.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85904 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 16:56:39 +00:00
Douglas Gregor 3f9a0566e6 Introduce a new class, UnqualifiedId, that provides a parsed
representation of a C++ unqualified-id, along with a single parsing
function (Parser::ParseUnqualifiedId) that will parse all of the
various forms of unqualified-id in C++.

Replace the representation of the declarator name in Declarator with
the new UnqualifiedId class, simplifying declarator-id parsing
considerably and providing more source-location information to
Sema. In the future, I hope to migrate all of the other
unqualified-id-parsing code over to this single representation, then
begin to merge actions that are currently only different because we
didn't have a unqualified notion of the name in the parser.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85851 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 01:35:08 +00:00
Anders Carlsson 0ebb6d391d Make sure to call CompleteConstructorCall for bases and members that are initialized implicitly in constructors so that default arguments etc are set correctly. Fixes PR5283.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 15:46:07 +00:00
John McCall 833ca991c1 Track source information for template arguments and template specialization
types.  Preserve it through template instantiation.  Preserve it through PCH,
although TSTs themselves aren't serializable, so that's pretty much meaningless.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 08:12:44 +00:00
Fariborz Jahanian 680a3f3581 Use array's base element type in getting to its
constructor. WIP.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85420 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 19:04:36 +00:00
Fariborz Jahanian c0fcce4614 Removed an unnecessary arguement passed to InitializeVarWithConstructor
which should come from the variable and wasn't correct for arrays in any case.
No change in functionality.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 18:41:06 +00:00
Douglas Gregor 0130f3cc4c Rename FunctionDecl::isInline/setInline to
FunctionDecl::isInlineSpecified/setInlineSpecified.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85305 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 21:01:01 +00:00
Mike Stump cf57d61525 Almost missed this one... Doc update for last change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 02:07:23 +00:00
Mike Stump 1d7e767dc8 Refine noreturn handling. Fixes -Wmissing-noreturn so that it doesn't
complain that functions that have a return statement should be
declared noreturn.  Fixed PR5286.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85195 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 01:59:05 +00:00
Ted Kremenek 7762291803 Use a pred_iterator instead of a succ_iterator (wrong typedef).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 01:07:53 +00:00
Chris Lattner 7a128e8400 Fix PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
declared noreturn.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85075 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:43:07 +00:00
Sebastian Redl 38fd4d0011 Make sure we actually have a definition before asking if it is implicit. Fixes PR4674.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:31:45 +00:00
Chris Lattner d451f836be When parsing a top level struct declaration, make sure to
process decl attributes instead of dropping them on the floor.
This allows us to diagnose cases like the testcase.  Also don't
diagnose deprecated stuff in ActOnTag: not all uses of tags
may be 'uses', and SemaType does this now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:21:57 +00:00
Chris Lattner a64ef0ab5c move calls to DiagnoseUseOfDecl (which warns about deprecated/unavailable
types) out of Sema::getTypeName into ConvertDeclSpecToType.  getTypeName
is sometimes used as a predicate in the parser, so it could cause redundant
diags to be emitted.  This is also needed by two upcoming enhancements.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 22:09:09 +00:00
Sebastian Redl 8ce35b095e Remove the Skip parameter from GetTypeForDeclarator and dependents. Take the opportunity to improve an error message and fix PR4498.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85068 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 21:45:37 +00:00
Chris Lattner 10ca337b1e simplify Sema::getTypeName a bit: if control gets out of the switch,
IIDecl cannot be null.  There is no need to check for both C++ mode and
presence of CXXRecordDecl.  ObjC interfaces can't have ScopeSpecs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85057 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:16:46 +00:00
Chris Lattner b7c3fd7b49 In objc mode, every identifier in a cast expression was using doing a
type looking using getTypeName() and every property access was using
NextToken() to do lookahead to see if the identifier is followed by
a '.'.  Rearrange this code to not need lookahead and only do the
type lookup if we have "identifier." in the token stream.  Also
improve a diagnostic a bit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85056 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:04:48 +00:00
Sebastian Redl 9994a34f6c Audit the code for places where it is assumed that every base specifier refers to a RecordType. Add assertions or conditions as appropriate. This fixes another crash in the Apache stdlib vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85055 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 17:03:50 +00:00
John McCall ba6a9bd384 Preserve type source information in TypedefDecls. Preserve it across
template instantiation.  Preserve it through PCH.  Show it off to the indexer.

I'm healthily ignoring the vector type cases because we don't have a sensible
TypeLoc implementation for them anyway.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84994 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 08:00:42 +00:00
John McCall 58e4677a94 Remove OriginalTypeParmDecl; the original type is the one specified
in the DeclaratorInfo, if one is present.

Preserve source information through template instantiation.  This is made
more complicated by the possibility that ParmVarDecls don't have DIs, which
is possibly worth fixing in the future.

Also preserve source information for function parameters in ObjC method
declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84971 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 21:48:59 +00:00
John McCall eb692e07c7 Preserve source information for anonymous struct/union declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 23:31:08 +00:00
Ted Kremenek cd6cdeb7d1 Add FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84696 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 23:48:29 +00:00
Eli Friedman 73c39abdbb Remove default argument for ImpCastExprToType. Add appropriate argument
to all callers.  Switch a few other users of CK_Unknown to proper cast 
kinds.

Note that there are still some situations where we end up with 
CK_Unknown; they're pretty easy to find with grep. There 
are still a few missing conversion kinds, specifically 
pointer/int/float->bool and the various combinations of real/complex 
float/int->real/complex float/int.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 08:27:19 +00:00
Daniel Dunbar 01eb9b9683 PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients
are updated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84447 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 21:17:35 +00:00
Daniel Dunbar 5ffe14ca96 Move misc clients to IdentifierInfo StringRef API.
- strcmp -> ==
 - OS.write(II->getName() ...) -> OS << II->getNameStr()
 - Avoid std::string concatenation
 - Use getNameStr().str() when an std::string is really needed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84437 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 20:26:27 +00:00
Sebastian Redl d75191f0d1 In some dependent contexts, incomplete array types persist into FinalizeDeclaratorGroup. Don't require them to have a complete type. This allows us to compile Hello World with the Apache stdcxx library. If you don't use endl, it even links and runs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84347 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 19:37:06 +00:00
Daniel Dunbar 5460d2b519 Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 03:28:56 +00:00
John McCall 46a617a792 Remove the ConstantArrayType subtypes. This information is preserved in the
TypeLoc records for declarations;  it should not be necessary to represent it
directly in the type system.

Please complain if you were using these classes and feel you can't replicate
previous functionality using the TypeLoc API.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84222 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-16 00:14:28 +00:00
Douglas Gregor a786fdbf6c Improve diagnostics when the parser encounters a declarator with an
unknown type name, e.g.,

  foo::bar x;

when "bar" does not refer to a type in "foo". 

With this change, the parser now calls into the action to perform
diagnostics and can try to recover by substituting in an appropriate
type. For example, this allows us to easily diagnose some missing
"typename" specifiers, which we now do:

  test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename'
        prior to dependent type name 'A<T>::type'
  A<T>::type A<T>::f() { return type(); }
  ^~~~~~~~~~
  typename 

Fixes PR3990.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84053 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 23:27:22 +00:00
Douglas Gregor 3f09327b26 Unify our diagnostic printing for errors of the form, "we didn't like
what we found when we looked into <blah>", where <blah> is a
DeclContext*. We can now format DeclContext*'s in nice ways, e.g.,
"namespace N", "the global namespace", "'class Foo'".

This is part of PR3990, but we're not quite there yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84028 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 21:16:44 +00:00
Douglas Gregor fd056bc86a When explicitly specializing a member that is a template, mark the
template as a specialization. For example, this occurs with:

  template<typename T>
  struct X {
    template<typename U> struct Inner { /* ... */ };
  };

  template<> template<typename T>
  struct X<int>::Inner {
    T member;
  };

We need to treat templates that are member specializations as special
in two contexts:

  - When looking for a definition of a member template, we look
    through the instantiation chain until we hit the primary template
    *or a member specialization*. This allows us to distinguish
    between the primary "Inner" definition and the X<int>::Inner
    definition, above.
  - When computing all of the levels of template arguments needed to
    instantiate a member template, don't add template arguments
    from contexts outside of the instantiation of a member
    specialization, since the user has already manually substituted
    those arguments.

Fix up the existing test for p18, which was actually wrong (but we
didn't diagnose it because of our poor handling of member
specializations of templates), and add a new test for member
specializations of templates.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83974 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 16:30:37 +00:00
Douglas Gregor a735b206fd Improve the internal representation and semantic analysis of friend
function templates.

This commit ensures that friend function templates are constructed as
FunctionTemplateDecls rather than partial FunctionDecls (as they
previously were). It then implements template instantiation for friend
function templates, injecting the friend function template only when
no previous declaration exists at the time of instantiation. 

Oh, and make sure that explicit specialization declarations are not
friends.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83970 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 14:39:41 +00:00
Douglas Gregor 37d6818508 Permit explicit specialization of member functions of class templates
that are declarations (rather than definitions). Also, be sure to set
the access specifiers properly when instantiating the declarations of
member function templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83911 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-12 22:27:17 +00:00
Douglas Gregor b3ae4fcd43 Diagnose the declaration of explicit specializations after an implicit
instantiation has already been required. To do so, keep track of the
point of instantiation for anything that can be instantiated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83890 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-12 20:18:28 +00:00
John McCall 6e24726524 Qualified lookup through using declarations. Diagnose a new type of ambiguity.
Split the various ambiguous result enumerators into their own enum.  Tests
for most of C++ [namespace.qual].



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83700 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-10 05:48:19 +00:00
John McCall f36e02d4af Refactor the LookupResult API to simplify most common operations. Require users to
pass a LookupResult reference to lookup routines.  Call out uses which assume a single
result.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83674 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-09 21:13:30 +00:00
Douglas Gregor b5352cf949 Implement support for -Wunused-variable, from Oscar Bonilla!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83577 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 21:35:42 +00:00
Douglas Gregor 9916a047c5 Add more testing for the properties of explicit specialization.
Also, eliminate a redundant diagnostic by marking a variable declared
with incomplete type as an invalid declaration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83553 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 16:41:22 +00:00
Douglas Gregor 741fab6157 Don't complain about out-of-line explicit specializations of member
function and member function templates that are not definitions. Add
more tests to ensure that explicit specializations of member function
templates prevent instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 15:54:21 +00:00
Douglas Gregor f6b1185f0a Improve checking for specializations of member classes of class
templates, and keep track of how those member classes were
instantiated or specialized. 

Make sure that we don't try to instantiate an explicitly-specialized
member class of a class template, when that explicit specialization
was a declaration rather than a definition.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83547 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 15:14:33 +00:00
Douglas Gregor 251b4ff257 For instantiations of static data members of class templates, keep
track of the kind of specialization or instantiation. Also, check the
scope of the specialization and ensure that a specialization
declaration without an initializer is not a definition.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83533 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-08 07:24:58 +00:00
John McCall e3af0235ce Refactoring around friend class templates. Better error message for friend enums.
Don't create a new declaration for friend classes if a declaration already exists.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83505 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-07 23:34:25 +00:00
Douglas Gregor 1fef4e60e7 Type checking for specializations of member functions of class
templates. Previously, these weren't handled as specializations at
all. The AST for representing these as specializations is still a work
in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-07 22:35:40 +00:00
Douglas Gregor a8f32e0965 Refactor the code that walks a C++ inheritance hierarchy, searching
for bases, members, overridden virtual methods, etc. The operations
isDerivedFrom and lookupInBases are now provided by CXXRecordDecl,
rather than by Sema, so that CodeGen and other clients can use them
directly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-06 17:59:45 +00:00
Douglas Gregor 1be8aee874 When the return type of a function is dependent, don't perform any
of the flow-control checks for falling off the end of a function,
since the return type may instantiate to void. Similarly, if a
return statement has an expression and the return type of the function
is void, don't complain if the expression is type-dependent, since
that type could instantiate to void.

Fixes PR5071.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83222 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-01 23:25:31 +00:00
Tanya Lattner 27a84d0161 Add an error for function parameters that have a qualified address space since this is not allowed by the embedded c extension spec.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83165 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-30 20:47:43 +00:00
Douglas Gregor 9a8c9a2eac Provide a custom diagnostic when code tries to use an unknown builtin
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83014 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 21:14:19 +00:00
Douglas Gregor d04b1be7d3 Make sure that out-of-line function and variable definitions are not
pushed into scope. Fixes PR5056.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83003 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 18:41:37 +00:00
Douglas Gregor 2531c2d2f1 Teach Sema::isDeclInScope to handle overload sets constructed from
functions that occur in multiple declaration contexts, e.g., because
some were found via using declarations. Now, isDeclInScope will build
a new overload set (when needed) containing only those declarations
that are actually in scope. This eliminates a problem found with
libstdc++'s <iostream>, where the presence of using 

In the longer term, I'd like to eliminate Sema::isDeclInScope in favor
of better handling of the RedeclarationOnly flag in the name-lookup
routines. That way, name lookup only returns the entities that matter,
rather than taking the current two-pass approach of producing too many
results and then filtering our the wrong results. It's not efficient,
and I'm sure that we aren't filtering everywhere we should be.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82954 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 00:47:05 +00:00
Douglas Gregor d85bea2aff Rework the Parse-Sema interaction for friends to better support friend
class templates. We now treat friend class templates much more like
normal class templates, except that they still get special name lookup
rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in
<iostream>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82848 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 06:47:28 +00:00
Douglas Gregor 0b60d9e009 Use explicitly-specified template argument lists to help naming
explicit template specializations, when available.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82824 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 23:53:26 +00:00
Douglas Gregor db422dffb7 Declarators can now properly represent template-ids, e.g., for
template void f<int>(int);
                ~~~~~~
Previously, we silently dropped the template arguments. With this
change, we now use the template arguments (when available) as the
explicitly-specified template arguments used to aid template argument
deduction for explicit template instantiations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82806 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 21:45:23 +00:00
Douglas Gregor b9aa6b214c WIP implementation of explicit function template specialization. This
first implementation recognizes when a function declaration is an
explicit function template specialization (based on the presence of a
template<> header), performs template argument deduction + ambiguity
resolution to determine which template is being specialized, and hooks

There are many caveats here:
  - We completely and totally drop any explicitly-specified template
  arguments on the floor
  - We don't diagnose any of the extra semantic things that we should
  diagnose. 
  - I haven't looked to see that we're getting the right linkage for
  explicit specializations

On a happy note, this silences a bunch of errors that show up in
libstdc++'s <iostream>, although Clang still can't get through the
entire header.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82728 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 23:14:47 +00:00
John McCall 0953e767ff Refactor the representation of qualifiers to bring ExtQualType out of the
Type hierarchy.  Demote 'volatile' to extended-qualifier status.  Audit our
use of qualifiers and fix a few places that weren't dealing with qualifiers
quite right;  many more remain.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82705 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 19:53:00 +00:00
John McCall 183700f494 Change all the Type::getAsFoo() methods to specializations of Type::getAs().
Several of the existing methods were identical to their respective
specializations, and so have been removed entirely.  Several more 'leaf'
optimizations were introduced.

The getAsFoo() methods which imposed extra conditions, like
getAsObjCInterfacePointerType(), have been left in place.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 23:43:11 +00:00
Douglas Gregor d85cef5a54 Merge uninstantiated default arguments more carefully, and try not to
complain about specializations of member functions that are not
definitions. Fixes PR4995.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82159 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-17 19:51:30 +00:00
John McCall dd4a3b0065 Improved representation and support for friend class templates. Angst about same.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82088 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-16 22:47:08 +00:00
Douglas Gregor 7adb10fa31 When implicitly declaring operators new, new[], delete, and delete[],
give them the appropriate exception specifications. This,
unfortunately, requires us to maintain and/or implicitly generate
handles to namespace "std" and the class "std::bad_alloc". However,
every other approach I've come up with was more hackish, and this
standard requirement itself is quite the hack.

Fixes PR4829.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81939 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 22:30:29 +00:00
Anders Carlsson 2c59d3c197 Perform the C++ specific semantic checks of a function declaration after it's been merged with the previous declaration. This ensures that getPreviousDecl() will have the right value when ActOnConversionDeclarator is called.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81720 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-13 21:33:06 +00:00
Douglas Gregor 1fc09a92d0 Rework the way we determine whether an externally visible symbol is
generated for an inline function definition, taking into account C99
and GNU inline/extern inline semantics. This solution is simpler,
cleaner, and fixes PR4536.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81670 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-13 07:46:26 +00:00
Douglas Gregor 7814e6d664 Remove unnecessary ASTContext parameter from FunctionDecl::isBuiltinID
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81590 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-12 00:22:50 +00:00
Douglas Gregor 48a83b5e7a Remove unnecessary ASTContext parameters from isMain and isExternC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81589 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-12 00:17:51 +00:00
John McCall c4e7019d5c Support elaborated dependent types and diagnose tag mismatches.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81504 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-11 04:59:25 +00:00
Douglas Gregor f8d8d1a99b Don't bother to perform any initialization for a variable declaration
of class type whose default constructor is trivial. Should un-break
testing on x86_64-pc-linux-gnu.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 23:58:28 +00:00
Douglas Gregor 39da0b8145 Improve handling of initialization by constructor, by ensuring that
such initializations properly convert constructor arguments and fill
in default arguments where necessary. This also makes the ownership
model more clear.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81394 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 23:08:42 +00:00
Mike Stump 1eb4433ac4 Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 15:08:12 +00:00
Douglas Gregor 8dfb7ec475 Fix a thinko
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81317 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 06:04:29 +00:00
Douglas Gregor 3dab34a7cb Allow a declaration of an array to complete a prior, incomplete
declaration of that array in C++.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81309 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 01:45:28 +00:00
Chris Lattner 63d65f873f Fix PR4922, where Sema would complete tentative definitions in nondeterminstic
order because it was doing so while iterating over a densemap.

There are still similar problems in other places, for example 
WeakUndeclaredIdentifiers is still written to the PCH file in a nondeterminstic
order, and we emit warnings about #pragma weak in nondeterminstic order.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81236 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-08 18:19:27 +00:00
Anders Carlsson f47511ab05 BuildCXXConstructExpr now takes a MultiExprArg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81160 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-07 22:23:31 +00:00
John McCall 2191b20bfb Start emitting ElaboratedTypes in C++ mode. Support the effort in various
ways:  remove elab types during desugaring, enhance pretty-printing to allow
tags to be suppressed without suppressing scopes, look through elab types
when associating a typedef name with an anonymous record type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81065 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-05 06:31:47 +00:00
John McCall f1bbbb49f0 Correctly handle elaborated template ids. Still not handled properly for friends.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80977 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-04 01:14:41 +00:00
Fariborz Jahanian 34374e6ce5 Patch to instantiate destructors used to destruct
base and data members when they are needed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80967 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 23:18:17 +00:00
John McCall 82b9fb8e7a Borrow a friend class's previous declaration's access specifier regardless of
whether the current context is dependent.

Thanks to Anders for pointing this out.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80828 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-02 19:32:14 +00:00
John McCall 53489322f6 When adding a friend class declaration to the lookup tables, use the access specifier
of any previous declaration in case we replace it in a class's declaration table.
Fixes bug 4858.  This sort of thing makes me reconsider putting friend declarations in
declaration lists.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80750 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-02 02:15:17 +00:00
John McCall d7eff68dbb Ensure that the tag decls of friend decls aren't added to the friending class's
decl list, and remove some workarounds that were due to this.  Thanks to Eli for
pointing this out and providing the test case.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80745 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-02 00:55:30 +00:00
John McCall ab88d97734 Fix bug 4784 and allow friend declarations to properly extend
existing declaration chains.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80636 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-31 22:39:49 +00:00
Anders Carlsson f4d84b663e Improve diagnostics for missing members. This renames the err_typecheck_no_member to err_typecheck_no_member_deprecated. The idea is that err_typecheck_no_member_deprecated should be phased out and any call sites that reference it should call DiagnoseMissingMember instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80469 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-30 00:54:35 +00:00
Anders Carlsson 203cb71998 Add another check for UnresolvedUsingDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80412 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-29 00:56:38 +00:00
Douglas Gregor fdc39199c9 Make sure we actually found a redeclaration before complaining about attributes added to a redeclaration in C++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80403 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 22:54:55 +00:00
Anders Carlsson 36ef078753 Check for UnresolvedUsingDecl when determining if a declaration is a redeclaration or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80383 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 17:57:07 +00:00
John McCall 02cace78cf Omnibus friend decl refactoring. Instead of cloning AST classes for friend
declarations of same, introduce a single AST class and add appropriate bits
(encoded in the namespace) for whether a decl is "real" or not.  Much hackery
about previously-declared / not-previously-declared, but it's essentially
mandated by the standard that friends alter lookup, and this is at least
fairly non-intrusive.

Refactor the Sema methods specific to friends for cleaner flow and less nesting.

Incidentally solve a few bugs, but I remain confident that we can put them back.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80353 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 07:59:38 +00:00
Eli Friedman 56bea43ac1 Back out bad piece of r80272. Will look at fixing this a different way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80273 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 18:44:04 +00:00
Eli Friedman c5c54f2c7b PR4794: Make instantiating friend class decls not crash.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80272 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 18:38:56 +00:00
Douglas Gregor d60e105e6d Implement instantiation of the declarations of member function
templates within class templates, producing a member function template
of a class template specialization. If you can parse that, I'm
sorry. Example:

  template<typename T>
  struct X {
    template<typename U> void f(T, U);
  };

When we instantiate X<int>, we now instantiate the declaration
X<int>::f, which looks like this:

  template<typename U> void X<int>::f(int, U);

The path this takes through
TemplateDeclInstantiator::VisitCXXMethodDecl is convoluted and
ugly, but I don't know how to improve it yet. I'm resting my hopes on
the multi-level substitution required to instantiate definitions of
nested templates, which may simplify this code as well.

More testing to come...



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80252 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-27 16:57:43 +00:00
Anders Carlsson b790661a15 Bye-bye old RequireCompleteType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80182 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-26 23:45:07 +00:00
Douglas Gregor 42c39f3918 When we know that we are parsing a class-name, implicitly construct a
TypenameType if getTypeName is looking at a member of an unknown
specialization. This allows us to properly parse class templates that
derived from type that could only otherwise be described by a typename type, 
e.g.,

  template<class T> struct X {};
  template<typename T> struct Y : public X<T>::X { }; 

Fixes PR4381.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80123 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-26 18:27:52 +00:00
Douglas Gregor dacd434c49 Improve diagnostics and recovery when the nested-name-specifier of a
qualified name does not actually refer into a class/class
template/class template partial specialization. 

Improve printing of nested-name-specifiers to eliminate redudant
qualifiers. Also, make it possible to output a nested-name-specifier
through a DiagnosticBuilder, although there are relatively few places
that will use this leeway.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80056 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-26 00:04:55 +00:00
Douglas Gregor 495c35d291 Improve support for out-of-line definitions of nested templates and
their members, including member class template, member function
templates, and member classes and functions of member templates.

To actually parse the nested-name-specifiers that qualify the name of
an out-of-line definition of a member template, e.g.,

  template<typename X> template<typename Y>
  X Outer<X>::Inner1<Y>::foo(Y) {
    return X();
  }

we need to look for the template names (e.g., "Inner1") as a member of
the current instantiation (Outer<X>), even before we have entered the
scope of the current instantiation. Since we can't do this in general
(i.e., we should not be looking into all dependent
nested-name-specifiers as if they were the current instantiation), we
rely on the parser to tell us when it is parsing a declaration
specifier sequence, and, therefore, when we should consider the
current scope specifier to be a current instantiation.

Printing of complicated, dependent nested-name-specifiers may be
somewhat broken by this commit; I'll add tests for this issue and fix
the problem (if it still exists) in a subsequent commit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 22:51:20 +00:00
John McCall 91cf4199cc Modify an assert to capture the restriction on friend declarations more
accurately.  Prevents the assert from triggering incorrectly when friending 
functions first declared in extern "C" contexts.  Fixes bug 4757.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80016 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 17:53:59 +00:00
Douglas Gregor 05396e20d6 Implement out-of-line definitions of nested class templates. Most of
the logic is there for out-of-line definitions with multiple levels of
nested templates, but this is still a work-in-progress: we're having
trouble determining when we should look into a dependent
nested-name-specifier. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80003 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 17:23:04 +00:00
Anders Carlsson fe2de492d0 InitializeVarWithConstructor now returns true on failure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 05:18:00 +00:00
Douglas Gregor d83d04041f Implement delayed parsing for member function templates. Fixes PR4608.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79709 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-22 00:34:47 +00:00
Sanjiv Gupta f6d6a228b0 Reversing part of 79544.
Need to find a new way to do target specific semanitc checking.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79596 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 04:58:03 +00:00
Argyrios Kyrtzidis a5d82000f7 Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use DeclaratorInfo to get this information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-21 00:31:54 +00:00
Sanjiv Gupta da3e03ec5d Issue an error if the user specifies parameters in a function marked as ISR.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79544 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-20 17:48:52 +00:00
Argyrios Kyrtzidis 82bf01061b Keep track of the right paren ')' source location in a function declarator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79489 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 23:14:54 +00:00
Argyrios Kyrtzidis e8661906d4 Use Sema's LocInfoType to pass and preserve type source info through the Parser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79395 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 01:28:28 +00:00
Argyrios Kyrtzidis a1d5662d96 Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema interfaces.
DeclaratorDecl contains a DeclaratorInfo* to keep type source info.
Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl.
EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo.

Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79392 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 01:27:57 +00:00
John McCall 88232aadbe Teach Sema how to pop out of friend function definitions in nested classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79291 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-18 00:00:49 +00:00
David Chisnall 0f43656064 Initial patch to support definitions of id and Class from headers in Objective-C code.
This currently breaks test/SemaObjC/id-isa-ref.m and issues some spurious warnings when you attempt to assign a struct objc_class* value to a Class variable.  The test case probably should fail as it's written, because without the definition of Class the compiler should not assume struct objc_class* is a valid receiver type, but it's left broken because it would be nice if we could get that passing too for the special case of isa.

Approved by snaroff.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-17 16:35:33 +00:00
Anders Carlsson 9abf2aedae AddInitializerToDecl can't take a FullExprArg. Make it take an ExprArg, and create the CXXExprWithTemporaries before setting the initializer on the VarDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-16 05:13:48 +00:00
Eli Friedman 1d954f6a00 Implement __is_empty. Patch by Sean Hunt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79143 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 21:55:26 +00:00
John McCall 07a5c22bb6 Disable all recognition of main() in -ffreestanding. Addresses bug #4720.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 02:09:25 +00:00
John McCall 3f9a8a6061 Argument-dependent lookup for friend declarations. Add a new decl type,
FriendFunctionDecl, and create instances as appropriate.

The design of FriendFunctionDecl is still somewhat up in the air;  you can
befriend arbitrary types of functions --- methods, constructors, etc. ---
and it's not clear that this representation captures that very well.
We'll have a better picture when we start consuming this data in access
control.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78653 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-11 06:59:38 +00:00
Anders Carlsson 3b2e16b3d2 Refactor some code and implement support for global destructors for static variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78507 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-08 21:45:14 +00:00
Anders Carlsson a860e755f1 Introduce a new PragmaPack attribute, and use it for #pragma pack. The PackedAttr now only represents __attribute__((packed)).
This is necessary because #pragma pack and __attribute__((packed)) have different semantics. No functionality change yet, but this lays the groundwork for fixing a record layout bug.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78483 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-08 18:23:56 +00:00
Edward O'Callaghan fee1381969 Patch should implement packed enums - PR4098. Credit to Anders Johnsen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78471 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-08 14:36:57 +00:00
Douglas Gregor 4a959d8788 When we encounter a dependent type that was parsed before we know that
we were going to enter into the scope of a class template or class
template partial specialization, rebuild that type so that it can
refer to members of the current instantiation, as in code like

  template<typename T>
  struct X {
    typedef T* pointer;
    pointer data();
  };

  template<typename T>
  typename X<T>::pointer X<T>::data() { ... }

Without rebuilding the return type of this out-of-line definition, the
canonical return type of the out-of-line definition (a TypenameType)
will not match the canonical return type of the declaration (the
canonical type of T*).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 16:20:37 +00:00
John McCall 67d1a67f3d First pass at friend semantics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78274 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-06 02:15:43 +00:00
Douglas Gregor 50d62d1b4a Introduce the canonical type smart pointers, and use them in a few places to
tighten up the static type system.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 05:36:45 +00:00
Mike Stump 11b3a95d16 Remove an unused header.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78140 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:22:47 +00:00
Mike Stump ac5fc7c6bc Canonicalize else.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-04 21:02:39 +00:00
John McCall fec54013fc Refactor methods on DeclSpec to take a diagnostic& parameter, and reflect this
elsewhere.  Very slightly decouples DeclSpec users from knowing the exact
diagnostics to report, and makes it easier to provide different diagnostics in
some places.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77990 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-03 20:12:06 +00:00
Fariborz Jahanian a83f7ed3de Minor renaming/refactoring. No change in functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77985 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-03 19:13:25 +00:00
Ryan Flynn 7b1fdbda27 PR3679 - enable #pragma weak aliasing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77660 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 02:52:19 +00:00
John McCall 0f434ecbea Rename Action::TagKind to Action::TagUseKind, which removes both a misnomer
and a name collision.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77658 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 02:45:11 +00:00
Anders Carlsson cdef2b75aa Add a CastKind enum to CastExpr. Right now it's not used for much but it will be :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77650 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 00:48:10 +00:00
Ryan Flynn e25ff83fb7 PR3679 - handle #pragma weak
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77573 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-30 03:15:39 +00:00
Ted Kremenek 6217b80b7a Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77510 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 21:53:49 +00:00
Mike Stump f711c41dd9 Some minor cleanups, thanks Chris.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77402 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 23:57:15 +00:00
Mike Stump 4d9d51ae3b Add support for -Wmissing-noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 23:11:12 +00:00
Mike Stump 5692586ae5 Add noreturn support for blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77377 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 22:04:01 +00:00
Mike Stump 782fa308a7 Make longjmp a real builtin.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77291 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 02:25:19 +00:00
John McCall 0cfeb63f53 Allow functions to be marked "implicit return zero" and so mark main().
Codegen by initializing the return value with its LLVM type's null value.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77288 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 01:00:58 +00:00
Mike Stump 523a8fddef Make sure to move the comment with the code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77279 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 00:07:08 +00:00
Mike Stump 773db1d4b5 Add knowledge about _longjmp being noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77254 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 21:45:16 +00:00
Mike Stump fd350b5b4a Add builtin knowledge about longjmp being noreturn. Add printing for
the noreturn attribute.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77253 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 21:33:40 +00:00
Mike Stump 0feecbb316 Add noreturn for exit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77237 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 19:14:18 +00:00
Ryan Flynn 478fbc68b1 PR3575 - warn on declared variable or function attributes after a definition, which are currently ignored.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77095 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-25 22:29:44 +00:00
Mike Stump 2455636163 Add noreturn as a type attribute, handle printing for them and handle
calls to noreturn function pointers when CFG building.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77089 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-25 21:26:53 +00:00
John McCall 13591ed054 Semantic checking for main().
Fix some invalid main() methods in the test suite that were nicely
exposed by the new checks.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77047 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-25 04:36:53 +00:00
John McCall 8c4859ad8a Test commit: make a little stub routine for semantic checking of main().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76934 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-24 03:03:21 +00:00
Mike Stump 5f28a1edf6 Implement new warning for functions declared 'noreturn' when they fall off the end.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76932 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-24 02:49:01 +00:00
Douglas Gregor 5e03f9ea81 This patch fixes the implementations of the __has_trivial_destructor
and __has_trivial_constructor builtin pseudo-functions and
additionally implements __has_trivial_copy and __has_trivial_assign,
from John McCall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76916 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 23:49:00 +00:00
Mike Stump 79a1411a4c Some cleanups suggested by Daniel.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76906 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 22:40:11 +00:00
Douglas Gregor bd1099efde Clean up the ActOnTag action, so that there is only a single entry
point that covers templates and non-templates. This should eliminate
the flood of warnings I introduced yesterday.

Removed the ActOnClassTemplate action, which is no longer used.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76881 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 16:36:45 +00:00
Daniel Dunbar 1f15e76898 Use llvm::BitVector instead of managing memory by hand.
- As it happens, this also fixes a use-of-uninitialized memory that was causing
   non-deterministic test failures.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76857 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 05:01:54 +00:00
Mike Stump 10e975c9a3 Fix case, apparently some people still build on case sensitive
filesystems.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76824 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23 00:20:25 +00:00
Mike Stump b1682c50d2 Add warning for falling off the end of a function that should return a
value.  This is on by default, and controlled by -Wreturn-type (-Wmost
-Wall).  I believe there should be very few false positives, though
the most interesting case would be:

  int() { bar(); }

when bar does:

  bar() { while (1) ; }

Here, we assume functions return, unless they are marked with the
noreturn attribute.  I can envision a fixit note for functions that
never return normally that don't have a noreturn attribute to add a
noreturn attribute.

If anyone spots other false positives, let me know!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76821 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 23:56:57 +00:00
Douglas Gregor 7cdbc58320 Implement support for out-of-line definitions of the class members of class
templates, e.g.,

  template<typename T>
  struct Outer {
    struct Inner;
  };

  template<typename T>
  struct Outer<T>::Inner {
    // ...
  };

Implementing this feature required some extensions to ActOnTag, which
now takes a set of template parameter lists, and is the precursor to
removing the ActOnClassTemplate function from the parser Action
interface. The reason for this approach is simple: the parser cannot
tell the difference between a class template definition and the
definition of a member of a class template; both have template
parameter lists, and semantic analysis determines what that template
parameter list means.

There is still some cleanup to do with ActOnTag and
ActOnClassTemplate. This commit provides the basic functionality we
need, however.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76820 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 23:48:44 +00:00
Douglas Gregor 27eeb5ef46 Calls to Sema::MatchTemplateParametersToScopeSpecifier should not depend on the order of evaluation of their arguments to be correct.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76804 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 22:05:02 +00:00
Douglas Gregor 1f2023ab8b "This patch implements the restrictions on union members detailed in
[class.union]p1", from John McCall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76766 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 18:25:24 +00:00
Douglas Gregor dfe3f2d8ba Implement parsing and semantic analysis for out-of-line definitions of static
data members of class templates. We don't instantiate the definitions yet,
however.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76756 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 17:18:37 +00:00