Commit Graph

40 Commits

Author SHA1 Message Date
Ted Kremenek 13747167ca Static Analyzer: When generating plists for errors reports, generate one plist file per translation unit that contains all of the diagnostics.
llvm-svn: 62647
2009-01-21 00:42:24 +00:00
Douglas Gregor 6e6ad602e5 Remove ScopedDecl, collapsing all of its functionality into Decl, so
that every declaration lives inside a DeclContext.

Moved several things that don't have names but were ScopedDecls (and,
therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
store empty DeclarationNames for these things, nor do we try to insert
them into DeclContext's lookup structure.

The serialization tests are temporarily disabled. We'll re-enable them
once we've sorted out the remaining ownership/serialiazation issues
between DeclContexts and TranslationUnion, DeclGroups, etc.

llvm-svn: 62562
2009-01-20 01:17:11 +00:00
Douglas Gregor 020713e308 Replace DeclContext's vector of ScopedDecl pointers with a linked list
of ScopedDecls (using the new ScopedDecl::NextDeclInScope
pointer). Performance-wise:

  - It's a net win in memory utilization, since DeclContext is now one
    pointer smaller than it used to be (std::vectors are typically 3
    pointers; we now use 2 pointers) and 
  - Parsing Cocoa.h with -fsyntax-only (with a Release-Asserts Clang)
    is about 1.9% faster than before, most likely because we no longer
    have the memory allocations and copying associated with the
    std::vector.

I'll re-enable serialization of DeclContexts once I've sorted out the
NextDeclarator/NextDeclInScope question.

llvm-svn: 62001
2009-01-09 19:42:16 +00:00
Douglas Gregor 9ac7a0707d Initial implementation of anonymous unions (and, as a GNU extension,
structures and classes) in C++. Covers name lookup and the synthesis
and member access for the unnamed objects/fields associated with
anonymous unions.

Some C++ semantic checks are still missing (anonymous unions can't
have function members, static data members, etc.), and there is no
support for anonymous structs or unions in C.

llvm-svn: 61840
2009-01-07 00:43:41 +00:00
Douglas Gregor 07665a69e8 Introduce support for "transparent" DeclContexts, which are
DeclContexts whose members are visible from enclosing DeclContexts up
to (and including) the innermost enclosing non-transparent
DeclContexts. Transparent DeclContexts unify the mechanism to be used
for various language features, including C enumerations, anonymous
unions, C++0x inline namespaces, and C++ linkage
specifications. Please refer to the documentation in the Clang
internals manual for more information.

Only enumerations and linkage specifications currently use transparent
DeclContexts.

Still to do: use transparent DeclContexts to implement anonymous
unions and GCC's anonymous structs extension, and, later, the C++0x
features. We also need to tighten up the DeclContext/ScopedDecl link
to ensure that every ScopedDecl is in a single DeclContext, which
will ensure that we can then enforce ownership and reduce the memory
footprint of DeclContext.

llvm-svn: 61735
2009-01-05 19:45:36 +00:00
Douglas Gregor cfc7022a7b Fix an uninitialized-variable warning
llvm-svn: 61700
2009-01-05 17:18:30 +00:00
Fariborz Jahanian a0befc0a6f Finish up saving original parameter type and
using it in ObjC's method parameter encoding.

llvm-svn: 61293
2008-12-20 23:29:59 +00:00
Fariborz Jahanian 7664ffb954 introducing ParmVarWithOriginalTypeDecl class to
keep track of the original parameter decl. types.
This is work in progress.

llvm-svn: 61286
2008-12-20 20:56:12 +00:00
Douglas Gregor 29ff7d0634 Make linkage-specifications hold on to all of their declarations
llvm-svn: 61110
2008-12-16 22:23:02 +00:00
Douglas Gregor 91f84216f7 Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).

llvm-svn: 60878
2008-12-11 16:49:14 +00:00
Douglas Gregor 5101c24f60 Representation of template type parameters and non-type template
parameters, with some semantic analysis:
  - Template parameters are introduced into template parameter scope
  - Complain about template parameter shadowing (except in Microsoft mode)

Note that we leak template parameter declarations like crazy, a
problem we'll remedy once we actually create proper declarations for
templates. 

Next up: dependent types and value-dependent/type-dependent
expressions.

llvm-svn: 60597
2008-12-05 18:15:24 +00:00
Douglas Gregor 163c58502a Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.

Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.

Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.

Extended Declarator to store overloaded operator names. 
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator. 

Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.

llvm-svn: 59526
2008-11-18 14:39:36 +00:00
Douglas Gregor 77324f3854 Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of
languages. DeclarationName is used in NamedDecl to store the name of
the declaration (naturally), and ObjCMethodDecl is now a NamedDecl.

llvm-svn: 59441
2008-11-17 14:58:09 +00:00
Argyrios Kyrtzidis 494d410b32 Use ReadPtr, not ReadUIntPtr through a reinterpret_cast.
Thanks to Sebastian for the suggestion.

llvm-svn: 59330
2008-11-14 23:32:45 +00:00
Argyrios Kyrtzidis 9e59b577d8 Introduce ScopedDecl::getLexicalDeclContext() which is different from ScopedDecl::getDeclContext() when there are nested-names.
e.g.:
  namespace A {
    void f(); // SemanticDC (getDeclContext) == LexicalDC (getLexicalDeclContext) == 'namespace A'
  }
  void A::f(); // SemanticDC == namespace 'A'
               // LexicalDC == global namespace

llvm-svn: 58948
2008-11-09 23:41:00 +00:00
Argyrios Kyrtzidis 3175fa5139 Properly deserialize ParamInfo of FunctionDecl.
When allocating an array for ParamInfo, the "decl->getNumParams()" call was used, but this will return 0 since it checks ParamInfo (which isn't yet defined and is null).
The result was that ParamInfo got an array of zero length to hold the ParmVarDecls.

llvm-svn: 58850
2008-11-07 14:22:23 +00:00
Douglas Gregor 5251f1b283 Preliminary support for function overloading
llvm-svn: 57909
2008-10-21 16:13:35 +00:00
Argyrios Kyrtzidis 88e1b97f16 Simplify handling of struct/union/class tags.
Instead of using two sets of Decl kinds (Struct/Union/Class and CXXStruct/CXXUnion/CXXClass), use one 'Record' and one 'CXXRecord' Decl kind and make tag kind a property of TagDecl.
Cleans up the code a bit and better reflects that Decl class structure.

llvm-svn: 57541
2008-10-15 00:42:39 +00:00
Chris Lattner 79ef843533 silence some release-assert warnings.
llvm-svn: 57391
2008-10-12 00:28:42 +00:00
Steve Naroff 415d3d570a - Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.

This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?).

Still some follow-up work to finish this (forthcoming).

llvm-svn: 57298
2008-10-08 17:01:13 +00:00
Ted Kremenek 47923c7e59 Remove "NextDecl" from RecordDecl. This change touches many files that where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration.
The motivation behind this change is that chaining the RecordDecls is simply unnecessary.  Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType.

llvm-svn: 55821
2008-09-05 01:34:33 +00:00
Ted Kremenek 478f6baf0d RecordDecl serialization:
- Don't serialize out the NextDeclarator field.  It is unused and deprecated.
- Serialize out the NextDecl pointer.

llvm-svn: 55644
2008-09-02 20:42:52 +00:00
Argyrios Kyrtzidis 406fb231f8 -Add DeclChain member to DeclContext.
-ScopedDecls get chained to their DeclContext.
-DeclContext's DeclChain replaces FunctionDecl's DeclChain and EnumDecl's ElementList.

llvm-svn: 52164
2008-06-10 01:32:09 +00:00
Argyrios Kyrtzidis 2951e14520 Added new C++ AST Decl subclasses.
llvm-svn: 52155
2008-06-09 21:05:31 +00:00
Ted Kremenek 878ff6c04d When serializing FunctionDecl, serialize out a reference to the previous declaration.
llvm-svn: 51294
2008-05-20 03:33:58 +00:00
Ted Kremenek 2abde809ce Unbreak build.
llvm-svn: 50980
2008-05-12 17:42:30 +00:00
Ted Kremenek 8322da5fa3 Grammar cleanup in comment.
Remove redundant assignment.

llvm-svn: 50978
2008-05-12 17:40:56 +00:00
Ted Kremenek 92f78f4c04 When reading in the DeclCtx during deserialization, register the DeclCtx of the
ScopedDecl with the backpatcher, and *not* a local variable on the stack. The
value of DeclCtx gets filled in *later* by the backpatcher.

This fixes: http://llvm.org/bugs/show_bug.cgi?id=2308

llvm-svn: 50976
2008-05-12 17:29:34 +00:00
Argyrios Kyrtzidis 081148986a Parsing of namespaces:
-NamespaceDecl for the AST
-Checks for name clashes between namespaces and tag/normal declarations.

This commit doesn't implement proper name lookup for namespaces.

llvm-svn: 50321
2008-04-27 13:50:30 +00:00
Chris Lattner bec41348e2 "This patch renames
DeclContext *CtxDecl -> DeclContext *DeclCtx
DeclContext *CD -> DeclContext *DC

It makes the code more consistent."

Patch by Zhongxing Xu!

llvm-svn: 50105
2008-04-22 18:39:57 +00:00
Argyrios Kyrtzidis c3b69ae815 Addition of TranslationUnitDecl to the AST:
-Added TranslationUnitDecl class to serve as top declaration context
-ASTContext gets a TUDecl member and a getTranslationUnitDecl() function
-All ScopedDecls get the TUDecl as DeclContext when declared at global scope

llvm-svn: 49855
2008-04-17 14:40:12 +00:00
Steve Naroff 08899ff85d Remove FileVarDecl and BlockVarDecl. They are replaced by VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl().
This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it).

llvm-svn: 49748
2008-04-15 22:42:06 +00:00
Sam Bishop 4c088b766d Use the ASTContext allocator when creating deserialized Decl objects.
llvm-svn: 49530
2008-04-11 14:49:10 +00:00
Chris Lattner aa9c7aed0f Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!

llvm-svn: 49369
2008-04-08 04:40:51 +00:00
Sam Bishop e0680b7e7a Pass the ASTContext object around when deserializing Decl and Stmt objects, so
they can be created using the same allocator as in the "from source code" case.

llvm-svn: 49353
2008-04-07 21:55:54 +00:00
Chris Lattner 0a5ff0d34a This patch contains these changes:
-Renamed ContextDecl -> DeclContext
-Removed DeclContext pointer from FieldDecl
-EnumDecl inherits from DeclContext, instead of TagDecl

Patch by Argiris Kirtzidis!

llvm-svn: 49261
2008-04-06 04:47:34 +00:00
Steve Naroff c7d38433cd Rename ScopedDecl::getContext() -> getContextDecl(). Two motivations:
#1: To be consistent with FieldDecl::getContextDecl(), which serves the same purpose.
#2: From my perspective, getContext() is too general (and used by several other classes for different purposes).

llvm-svn: 49224
2008-04-04 18:15:49 +00:00
Chris Lattner c5ffed4a66 Introduce ContextDecl, patch by Argiris Kirtzidis!
-Added ContextDecl (no TranslationUnitDecl)
-ScopedDecl class has a ContextDecl member
-FieldDecl class has a ContextDecl member, so that a Field or a ObjCIvar can be traced back to their RecordDecl/ObjCInterfaceDecl easily
-FunctionDecl, ObjCMethodDecl, TagDecl, ObjCInterfaceDecl inherit from ContextDecl. With TagDecl as ContextDecl, enum constants have a EnumDecl as their context.
-Moved Decl class to a "DeclBase.h" along with ContextDecl class
-CurContext is handled by Sema

llvm-svn: 49208
2008-04-04 06:12:32 +00:00
Chris Lattner ee1284a6e2 switch the rest of the C decl classes to do their
allocation through ASTContext.

llvm-svn: 48403
2008-03-16 00:16:02 +00:00
Chris Lattner 7a51313d8a Make a major restructuring of the clang tree: introduce a top-level
lib dir and move all the libraries into it.  This follows the main
llvm tree, and allows the libraries to be built in parallel.  The
top level now enforces that all the libs are built before Driver,
but we don't care what order the libs are built in.  This speeds
up parallel builds, particularly incremental ones.

llvm-svn: 48402
2008-03-15 23:59:48 +00:00