summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Various minor fixes to PCH reading and writing, with generalDouglas Gregor2009-04-101-0/+10
| | | | | | | cleanup. Aside from a minor tweak to the PCH file format, no functionality change. llvm-svn: 68793
* Implementation of pre-compiled headers (PCH) based on lazyDouglas Gregor2009-04-091-0/+6
| | | | | | | | | | | | | | | | | | | de-serialization of abstract syntax trees. PCH support serializes the contents of the abstract syntax tree (AST) to a bitstream. When the PCH file is read, declarations are serialized as-needed. For example, a declaration of a variable "x" will be deserialized only when its VarDecl can be found by a client, e.g., based on name lookup for "x" or traversing the entire contents of the owner of "x". This commit provides the framework for serialization and (lazy) deserialization, along with support for variable and typedef declarations (along with several kinds of types). More declarations/types, along with important auxiliary structures (source manager, preprocessor, etc.), will follow. llvm-svn: 68732
* Propagate the ASTContext to various AST traversal and lookup functions.Douglas Gregor2009-04-091-10/+10
| | | | | | No functionality change (really). llvm-svn: 68726
* Add some FIXMEs for missing checks.Eli Friedman2009-04-091-0/+7
| | | | llvm-svn: 68725
* -Wmissing-prototypes shouldn't complain about main() missing a prototype.Douglas Gregor2009-04-081-1/+2
| | | | | | Fixes <rdar://problem/6759522> llvm-svn: 68611
* Diagnose uses of function specifiers on declarations which don't declareEli Friedman2009-04-071-12/+25
| | | | | | functions. Fixes PR3941. llvm-svn: 68541
* Clean up -fixit output slightlyDouglas Gregor2009-04-021-3/+4
| | | | llvm-svn: 68278
* Add some more code modification hintsDouglas Gregor2009-04-011-9/+31
| | | | llvm-svn: 68261
* Make parsing a semantic analysis a little more robust following SemaDouglas Gregor2009-04-011-3/+28
| | | | | | | | | | | | | | | | failures that involve malformed types, e.g., "typename X::foo" where "foo" isn't a type, or "std::vector<void>" that doens't instantiate properly. Similarly, be a bit smarter in our handling of ambiguities that occur in Sema::getTypeName, to eliminate duplicate error messages about ambiguous name lookup. This eliminates two XFAILs in test/SemaCXX, one of which was crying out to us, trying to tell us that we were producing repeated error messages. llvm-svn: 68251
* Implement -Wmissing-prototypes. Fixes PR3911.Douglas Gregor2009-03-311-0/+22
| | | | llvm-svn: 68110
* Push DeclGroup much farther throughout the compiler. Now the variousChris Lattner2009-03-291-46/+32
| | | | | | | | | | | | | | | | | | | | | | | | | productions (except the already broken ObjC cases like @class X,Y;) in the parser that can produce more than one Decl return a DeclGroup instead of a Decl, etc. This allows elimination of the Decl::NextDeclarator field, and exposes various clients that should look at all decls in a group, but which were only looking at one (such as the dumper, printer, etc). These have been fixed. Still TODO: 1) there are some FIXME's in the code about potentially using DeclGroup for better location info. 2) ParseObjCAtDirectives should return a DeclGroup due to @class etc. 3) I'm not sure what is going on with StmtIterator.cpp, or if it can be radically simplified now. 4) I put a truly horrible hack in ParseTemplate.cpp. I plan to bring up #3/4 on the mailing list, but don't plan to tackle #1/2 in the short term. llvm-svn: 68002
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-100/+100
| | | | | | | | | | | | | | | | | | | | pointer. Its purpose in life is to be a glorified void*, but which does not implicitly convert to void* or other OpaquePtr's with a different UID. Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This makes the C++ compiler enforce that these aren't convertible to other opaque types. We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc, but I don't plan to do that in the short term. The one outstanding known problem with this patch is that we lose the bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to bitmangle the success bit into the low bit of DeclPtrTy. I will rectify this with a subsequent patch. llvm-svn: 67952
* Improve recovery when a constructor fails to type-check. Test case from AndersDouglas Gregor2009-03-271-1/+1
| | | | llvm-svn: 67818
* Factor the member access specifier setting code into its own function. No ↵Anders Carlsson2009-03-261-27/+2
| | | | | | intended functionality change. llvm-svn: 67725
* Check that the access specifier of a member redeclaration is the same as the ↵Anders Carlsson2009-03-261-3/+26
| | | | | | original declaration. llvm-svn: 67722
* The injected-class-name of class templates and class templateDouglas Gregor2009-03-261-0/+2
| | | | | | | | | | | | | | | | | | specializations can be treated as a template. Finally, we can parse and process the first implementation of Fibonacci I wrote! Note that this code does not handle all of the cases where injected-class-names can be treated as templates. In particular, there's an ambiguity case that we should be able to handle (but can't), e.g., template <class T> struct Base { }; template <class T> struct Derived : Base<int>, Base<char> { typename Derived::Base b; // error: ambiguous typename Derived::Base<double> d; // OK }; llvm-svn: 67720
* Tighten the setAccess assert. We now allow AS_none if the decl contex is not ↵Anders Carlsson2009-03-251-1/+3
| | | | | | | | a C++ record decl. Also, fix fallout from the change. llvm-svn: 67717
* Implement template instantiation for static data members of classDouglas Gregor2009-03-251-64/+86
| | | | | | | | | | | | | | | | | | templates, including in-class initializers. For example: template<typename T, T Divisor> class X { public: static const T value = 10 / Divisor; }; instantiated with, e.g., X<int, 5>::value to get the value '2'. llvm-svn: 67715
* Pass access specifiers through to member classes and member enums.Douglas Gregor2009-03-251-1/+4
| | | | llvm-svn: 67710
* Instantiation for member classes of class templates. Note that onlyDouglas Gregor2009-03-251-1/+2
| | | | | | | | | | | the declarations of member classes are instantiated when the owning class template is instantiated. The definitions of such member classes are instantiated when a complete type is required. This change also introduces the injected-class-name into a class template specialization. llvm-svn: 67707
* Predicate to detect when a RecordDecl is really the injected-class-nameDouglas Gregor2009-03-251-0/+2
| | | | llvm-svn: 67687
* Make sure to use RequireCompleteType rather than testing forDouglas Gregor2009-03-241-33/+32
| | | | | | | incomplete types. RequireCompleteType is needed when the type may be completed by instantiating a template. llvm-svn: 67643
* More work on diagnosing abstract classes. We can now handle cases likeAnders Carlsson2009-03-241-7/+13
| | | | | | | | | | | | class C { void g(C c); virtual void f() = 0; }; In this case, C is not known to be abstract when doing semantic analysis on g. This is done by recursively traversing the abstract class and checking the types of member functions. llvm-svn: 67594
* Template instantiation for the declarations of member functions withinDouglas Gregor2009-03-231-132/+136
| | | | | | | | | | | | | | | | | | | | | | a class template. At present, we can only instantiation normal methods, but not constructors, destructors, or conversion operators. As ever, this contains a bit of refactoring in Sema's type-checking. In particular: - Split ActOnFunctionDeclarator into ActOnFunctionDeclarator (handling the declarator itself) and CheckFunctionDeclaration (checking for the the function declaration), the latter of which is also used by template instantiation. - We were performing the adjustment of function parameter types in three places; collect those into a single new routine. - When the type of a parameter is adjusted, allocate an OriginalParmVarDecl to keep track of the type as it was written. - Eliminate a redundant check for out-of-line declarations of member functions; hide more C++-specific checks on function declarations behind if(getLangOptions().CPlusPlus). llvm-svn: 67575
* More improvements to abstract type checking. Handle arrays correctly, and ↵Anders Carlsson2009-03-231-6/+7
| | | | | | make sure to check parameter types before they decay. llvm-svn: 67550
* It's an error to try to allocate an abstract object using new.Anders Carlsson2009-03-231-2/+7
| | | | llvm-svn: 67542
* Fix PR3855. When we encounter an incompatible redeclaration of aDouglas Gregor2009-03-231-2/+5
| | | | | | | | library function, accept this declaration and pretend that we do not know that this is a library function. autoconf depends on this (broken) behavior. llvm-svn: 67541
* Tighten up the determination of whether a function declaration has aDouglas Gregor2009-03-231-1/+1
| | | | | | prototype. Thanks Eli! llvm-svn: 67533
* Thanks to Eli for pointing out my misreading of 6.2.2p5Douglas Gregor2009-03-231-2/+1
| | | | llvm-svn: 67530
* Disallow abstract types where appropriate.Anders Carlsson2009-03-221-2/+25
| | | | llvm-svn: 67476
* Keep track of whether a class is abstract or not. This is currently only ↵Anders Carlsson2009-03-221-2/+5
| | | | | | used for the __is_abstract type trait. llvm-svn: 67461
* Variables marked as "extern" can actually have internal linkage ifDouglas Gregor2009-03-191-3/+14
| | | | | | there is a previous declaration marked "static". This fixes PR3645. llvm-svn: 67336
* Add a clarifying comment about HasPrototype's computationDouglas Gregor2009-03-191-0/+6
| | | | llvm-svn: 67316
* If a function is declared as, e.g.,Douglas Gregor2009-03-191-2/+3
| | | | | | | | | | F f; where F is a typedef of a function type, then the function "f" has a prototype. This is a slight tweak to Chris's suggested fix in PR3817. Fixes PR3817 and PR3840. llvm-svn: 67313
* Introduce a new expression type, UnresolvedDeclRefExpr, that describesDouglas Gregor2009-03-191-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | dependent qualified-ids such as Fibonacci<N - 1>::value where N is a template parameter. These references are "unresolved" because the name is dependent and, therefore, cannot be resolved to a declaration node (as we would do for a DeclRefExpr or QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to DeclRefExprs, QualifiedDeclRefExprs, etc. Also, be a bit more careful about keeping only a single set of specializations for a class template, and instantiating from the definition of that template rather than a previous declaration. In general, we need a better solution for this for all TagDecls, because it's too easy to accidentally look at a declaration that isn't the definition. We can now process a simple Fibonacci computation described as a template metaprogram. llvm-svn: 67308
* Extend the use of QualifiedNameType to the creation of class templateDouglas Gregor2009-03-191-7/+2
| | | | | | | | | | | specialization names. This way, we keep track of sugared types like std::vector<Real> I believe we are now using QualifiedNameTypes everywhere we can. Next step: QualifiedDeclRefExprs. llvm-svn: 67268
* Introduce a representation for types that we referred to via aDouglas Gregor2009-03-191-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qualified name, e.g., foo::x so that we retain the nested-name-specifier as written in the source code and can reproduce that qualified name when printing the types back (e.g., in diagnostics). This is PR3493, which won't be complete until finished the other tasks mentioned near the end of this commit. The parser's representation of nested-name-specifiers, CXXScopeSpec, is now a bit fatter, because it needs to contain the scopes that precede each '::' and keep track of whether the global scoping operator '::' was at the beginning. For example, we need to keep track of the leading '::', 'foo', and 'bar' in ::foo::bar::x The Action's CXXScopeTy * is no longer a DeclContext *. It's now the opaque version of the new NestedNameSpecifier, which contains a single component of a nested-name-specifier (either a DeclContext * or a Type *, bitmangled). The new sugar type QualifiedNameType composes a sequence of NestedNameSpecifiers with a representation of the type we're actually referring to. At present, we only build QualifiedNameType nodes within Sema::getTypeName. This will be extended to other type-constructing actions (e.g., ActOnClassTemplateId). Also on the way: QualifiedDeclRefExprs will also store a sequence of NestedNameSpecifiers, so that we can print out the property nested-name-specifier. I expect to also use this for handling dependent names like Fibonacci<I - 1>::value. llvm-svn: 67265
* The scope representation can now be either a DeclContext pointer or aDouglas Gregor2009-03-181-2/+2
| | | | | | | | | | Type pointer. This allows our nested-name-specifiers to retain more information about the actual spelling (e.g., which typedef did the user name, or what exact template arguments were used in the template-id?). It will also allow us to have dependent nested-name-specifiers that don't map to any DeclContext. llvm-svn: 67140
* pull a nested conditional + comment out into its own variable,Chris Lattner2009-03-171-5/+5
| | | | | | no functionality change. llvm-svn: 67128
* Implement instantiation of enums within class templates. This isn'tDouglas Gregor2009-03-171-38/+55
| | | | | | | | | | | | | | | quite as great as it sounds, because, while we can refer to the enumerator values outside the template, e.g., adder<long, 3, 4>::value we can't yet refer to them with dependent names, so no Fibonacci (yet). InstantiateClassTemplateSpecialization is getting messy; next commit will put it into a less-ugly state. llvm-svn: 67092
* Check signedness of bitfield sizes.Anders Carlsson2009-03-161-1/+1
| | | | llvm-svn: 67045
* Remove ActiveScope (revert ↵Steve Naroff2009-03-131-21/+6
| | | | | | | | http://llvm.org/viewvc/llvm-project?view=rev&revision=65694 and http://llvm.org/viewvc/llvm-project?view=rev&revision=66741). Will replace with something better today... llvm-svn: 66893
* Implement template instantiation for builtin binary operatorsDouglas Gregor2009-03-121-1/+2
| | | | llvm-svn: 66835
* API fix: All "bodies" for functions, Objective-C methods, blocks, are assumed toTed Kremenek2009-03-121-2/+2
| | | | | | | | be CompoundStmts. I think this is a valid assumption, and felt that the API should reflect it. Others please validate this assumption to make sure I didn't break anything. llvm-svn: 66814
* Fix various problems with matching out-of-line definitions of staticDouglas Gregor2009-03-111-29/+55
| | | | | | | | | class members to the corresponding in-class declaration. Diagnose the erroneous use of 'static' on out-of-line definitions of class members. llvm-svn: 66740
* Move most of the checking from ActOnCXXMemberDeclarator to other, more ↵Douglas Gregor2009-03-111-5/+130
| | | | | | general routines. This is a step toward separating the checking logic from Declarators, which in turn is required for template instantiation. llvm-svn: 66734
* Make sure that we set the access specifier for an instantiated FieldDecl, ↵Douglas Gregor2009-03-111-4/+19
| | | | | | and that the aggregate and POD flags for an instantiated class template are updated based on instantiation of a FieldDecl llvm-svn: 66701
* Eliminate CXXClassVarDecl. It doesn't add anythingDouglas Gregor2009-03-111-19/+12
| | | | llvm-svn: 66696
* Implement basic template instantiation for fields. Reshuffle checkingDouglas Gregor2009-03-111-46/+82
| | | | | | | for FieldDecls so that the parser and the template instantiation make use of the same semantic checking module. llvm-svn: 66685
* Add basic, hackish support for instantiation of typedefs in a classDouglas Gregor2009-03-111-0/+2
| | | | | | | | | template. More importantly, start to sort out the issues regarding complete types and nested-name-specifiers, especially the question of: when do we instantiate a class template specialization that occurs to the left of a '::' in a nested-name-specifier? llvm-svn: 66662
OpenPOWER on IntegriCloud