Commit Graph

5570 Commits

Author SHA1 Message Date
Daniel Dunbar fe66bf79a0 Add FIXME.
llvm-svn: 84379
2009-10-17 23:52:58 +00:00
Daniel Dunbar cfae9d53a5 StringRefize some parts of Diagnostic API.
llvm-svn: 84377
2009-10-17 23:52:43 +00:00
Daniel Dunbar 4a1669853f Remove unused BernsteinHash functions.
llvm-svn: 84376
2009-10-17 23:52:36 +00:00
Douglas Gregor 0b3d95ae64 Fix a crash with qualified member access into a non-type, from Sean Hunt!
llvm-svn: 84370
2009-10-17 22:37:54 +00:00
Daniel Dunbar 98dd6d2927 Add IdentifierTable::CreateIdentifierInfo(StringRef).
llvm-svn: 84361
2009-10-17 20:44:06 +00:00
Edward O'Callaghan 93135aad29 Fix for PR5190, Credit to Zhanyong Wan.
llvm-svn: 84346
2009-10-17 19:32:54 +00:00
Daniel Dunbar 19a203965f Remove a FIXME that doesn't belong, there are numerous other places that use
alignment in bits in clang. If we really want to fix this, it should be a bugzilla.

llvm-svn: 84328
2009-10-17 09:38:57 +00:00
Daniel Dunbar cc2f79b44b Add IdentiferInfo::getNameStr() -> StringRef.
Also, add getNameStart as a synonym for getName(). getName() is now deprecated,
when all clients are updated then getNameStr() should be renamed to
getName(). PR5218.

llvm-svn: 84306
2009-10-17 03:28:48 +00:00
Ted Kremenek 8bcb1c6883 Add 'UseBumpPtrAllocator' flag to ASTUnit::LoadFromPCHFile() to cause the created ASTContext to use
its own BumpPtrAllocator to allocate ASTs.

Change clang_createTranslationUnit (CIndex) to pass 'UseBumpPtrAllocator = true' to
ASTUnit::LoadFromPCHFile().

llvm-svn: 84296
2009-10-17 00:34:24 +00:00
Douglas Gregor 12bfa3859d Merge the "types" and "declarations" blocks in the precompiled header
format, so that we don't end up with multiple declaration and types
blocks. Also, fix a few obscure bugs with PCH loading and generation:

  - If the DeclIDs DenseMap reallocates while we are writing a
    declaration (due to recursively writing other declarations), we
    could end up writing a bad ID to ExternalDefinitions.
  - When loading an ArrayLoc (part of DeclaratorInfo), we need to set
    the size expression to NULL if no size expression was provided.

PCH -> AST rewriting is still partly broken, unfortunately.

llvm-svn: 84293
2009-10-17 00:13:19 +00:00
Fariborz Jahanian 956127de22 Patch to clean up and improve visual display of
builtin function ambiguity.

llvm-svn: 84289
2009-10-16 23:25:02 +00:00
Douglas Gregor 8655e88603 While writing source-location entries to a PCH file, go through an
interface that can load those source-location entries on demand (from
another PCH file).

llvm-svn: 84287
2009-10-16 22:46:09 +00:00
John McCall 1f1a097f66 Allow TypeLocs to be fully initialized with a single SourceLocation. This
will be the keystone of converting existing rewrites to be rewrites on TypeLocs.

llvm-svn: 84286
2009-10-16 22:31:57 +00:00
John McCall 8f115c6b45 Factor out routines to encode/decode DeclaratorInfos and move them into the
core PCH reader/writer implementation files.

llvm-svn: 84278
2009-10-16 21:56:05 +00:00
John McCall ff47031601 Add an accessor to extra the type directly from a DeclaratorInfo
without an opaque call.

llvm-svn: 84277
2009-10-16 21:42:04 +00:00
Douglas Gregor d3d923a0f2 Make CIndex and c-index-test a little bit more robust. The only
substantive change is that clang_getCursorSource() now returns the
file in which a macro was instantiated when the cursor points into a
macro instantiation, rather than crashing.

llvm-svn: 84275
2009-10-16 21:24:31 +00:00
Ted Kremenek 31fcde13ac Provide 'static' version of BinaryOperator::isShiftOp().
llvm-svn: 84268
2009-10-16 20:45:04 +00:00
Douglas Gregor 16bef857d9 Keep track of whether declararions were loaded from a precompiled
header or not via a new "PCHLevel" field in Decl. We currently use
this information to help CIndex filter out declarations that came from
a precompiled header (rather than from an AST file). Further down the
road, it can be used to help implement multi-level precompiled
headers.

llvm-svn: 84267
2009-10-16 20:01:17 +00:00
Douglas Gregor d2eb58abac Add support for a chain of stat caches in the FileManager, rather than
only supporting a single stat cache. The immediate benefit of this
change is that we can now generate a PCH/AST file when including
another PCH file; in the future, the chain of stat caches will likely
be useful with multiple levels of PCH files.

llvm-svn: 84263
2009-10-16 18:18:30 +00:00
Anders Carlsson 43d70f874d Add CK_VectorSplat and use it for casting non-pointer scalars to ExtVectors.
llvm-svn: 84245
2009-10-16 05:23:41 +00:00
Anders Carlsson ef918ac840 Add a ToVoid cast kind and start using it.
llvm-svn: 84241
2009-10-16 02:35:04 +00:00
Ted Kremenek 1eb68096a2 retain/release checker: Stop tracking reference counts for any symbols touched by StoreManager::InvalidateRegion().
This fixes <rdar://problem/7257223> and <rdar://problem/7283470>.

llvm-svn: 84223
2009-10-16 00:30:49 +00:00
John McCall c5b8225285 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.

llvm-svn: 84222
2009-10-16 00:14:28 +00:00
John McCall a614915632 ConcreteTypeLoc subclasses which call getInnerTypeLoc() should get a
compile-time error now;  moreover, remove the need for an explicit hasInnerType()
call.  Thanks to Doug Gregor for the metaprogramming approach.

llvm-svn: 84215
2009-10-15 22:37:38 +00:00
Steve Naroff 44cd60eebe Make sure temporary files get unlinked.
llvm-svn: 84208
2009-10-15 22:23:48 +00:00
Steve Naroff 7781daa4e0 Implement <rdar://problem/7303432> [Clang/Index] In-memory-style AST generation API (initial API implementation).
Added clang_createTranslationUnitFromSourceFile().
Changed clang_createIndex() to lookup the location of clang (using dladdr).

llvm-svn: 84198
2009-10-15 20:04:39 +00:00
Douglas Gregor 3d7e69f2c9 Simplify checking of explicit template specialization/explicit
instantiation redeclaration semantics for function template
specializations and member functions of class template
specializations. Also, record the point of instantiation for
explicit-instantiated functions and static data members.

llvm-svn: 84188
2009-10-15 17:21:20 +00:00
Douglas Gregor d6ba93dc6e Check the interactions between explicit instantiations and template
specializations. Work in progress; there's more cleanup required to
actually use the new CheckSpecializationInstantiationRedecl checker
uniformly.

llvm-svn: 84185
2009-10-15 15:54:05 +00:00
Douglas Gregor a8b89d2622 Diagnose explicit instantiations of function templates and member
functions/static data members of class template specializations that
do not have definitions. This is the latter part of [temp.explicit]p4;
the former part still needs more testing.

llvm-svn: 84182
2009-10-15 14:05:49 +00:00
Douglas Gregor 68edf13213 More explicit template instantiation. Now we're checking for more
cases where an explicit instantiation requires a definition; the
remainder of these checks will come with the implementation of
paragraph 4 of [temp.explicit].

llvm-svn: 84181
2009-10-15 12:53:22 +00:00
John McCall 9f49103ece Complete some unfinished comments.
llvm-svn: 84169
2009-10-15 04:01:40 +00:00
John McCall 33815690af Better living through metaprogramming. Create a base class which abstracts
most of the unsafe boilerplate out of TypeLoc.  Create a QualifiedLoc class
to represent the idea that we *might* start representing source locations
of qualifiers.  Dealing with qualifiers explicitly like this also lets us
efficiently ignore them in all the concrete cases.

This should make it obvious and easy to add new TypeLoc subclasses.

llvm-svn: 84168
2009-10-15 03:50:32 +00:00
Douglas Gregor ba8e1ac3a1 CheckTemplateSpecializationScope isn't going to be used for explicit
instantiations, since the requirements are too different from those
for template specializations. Simplify it slightly.

llvm-svn: 84156
2009-10-14 23:50:59 +00:00
Douglas Gregor e47f5a76cc Additional semantic checking for explicit template instantiations,
focusing on the scope- and qualifier-related semantic requirements in
C++ [temp.explicit]p2.

llvm-svn: 84154
2009-10-14 23:41:34 +00:00
Douglas Gregor 3cc3cdeea9 Give explicit and implicit instantiations of static data members of
class templates the proper linkage. 

Daniel, please look over the CodeGenModule bits.

llvm-svn: 84140
2009-10-14 21:29:40 +00:00
Douglas Gregor 3c74d41d27 Testing and some minor fixes for explicit template instantiation.
llvm-svn: 84129
2009-10-14 20:14:33 +00:00
Rafael Espindola 0a1ac331a3 Add support for having different c++ search dirs with -m32 and -m64. So far
this is only used in darwin10, 64 bit ubuntu 9.10 and 64 bit openSUSE 11.1.

llvm-svn: 84115
2009-10-14 17:09:44 +00:00
Sebastian Redl a44822fdb6 Have the exception specification checkers take partial diagnostics. Use this to merge two diagnostics.
llvm-svn: 84105
2009-10-14 16:09:29 +00:00
Sebastian Redl 7eb5d377d7 Use partial diagnostics properly in call to RequireCompleteType. Among other things, this means we get a note on the declaration of the incomplete type when it is used in an exception specification.
llvm-svn: 84099
2009-10-14 14:59:48 +00:00
Zhongxing Xu 8679481408 Now StoreManager::CastRegion() takes a MemRegion, returns a MemRegion.
llvm-svn: 84081
2009-10-14 06:55:01 +00:00
Chris Lattner 4f8a2e22c0 fix some cfstring related issues:
1) -fwritable-string does affect the non-utf16 version of cfstrings
   just not the utf16 ones.
2) utf16 strings should always be marked constant, as the __TEXT segment
   is readonly.
3) The name of the global doesn't matter, remove it from TargetInfo.
4) Trust the asmprinter to drop cstrings into the right section, like llvmgcc does now.

This fixes rdar://7115750

llvm-svn: 84077
2009-10-14 05:55:45 +00:00
Zhongxing Xu 7d6387bb24 * Remove unused GRState* parameter
* Make all Base value the last argument.

llvm-svn: 84071
2009-10-14 03:33:08 +00:00
Fariborz Jahanian 31481d8b22 Handle ambiguity of reference initialization.
Removes a FIXME.

llvm-svn: 84068
2009-10-14 00:52:43 +00:00
Douglas Gregor 15e5602e59 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.

llvm-svn: 84053
2009-10-13 23:27:22 +00:00
Douglas Gregor e40876a50c 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.

llvm-svn: 84028
2009-10-13 21:16:44 +00:00
John McCall 04f531238d Turn -Wparentheses on by default.
llvm-svn: 83993
2009-10-13 17:57:23 +00:00
Douglas Gregor 62e10f0bdc Diagnose attempts to add default function arguments to a
specialization. This completes C++ [temp.expl.spec]!

llvm-svn: 83980
2009-10-13 17:02:54 +00:00
Douglas Gregor cf91555cb8 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.

llvm-svn: 83974
2009-10-13 16:30:37 +00:00
Douglas Gregor 3a88c1d784 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.

llvm-svn: 83970
2009-10-13 14:39:41 +00:00
Zhongxing Xu e02b89566a Return the original state by default.
llvm-svn: 83949
2009-10-13 06:07:58 +00:00