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

174 Коммитов

Автор SHA1 Сообщение Дата
Alisdair Meredith f5c209d23b Basic support for C++0x unicode types. Support for literals will follow in an incremental patch
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75622 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 06:30:34 +00:00
Steve Naroff 14108da7f7 This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 23:34:53 +00:00
Douglas Gregor c29f77b769 Make ASTContext explicitly keep track of the declaration for the C
FILE type, rather than using name lookup to find FILE within the
translation unit. Within precompiled headers, FILE is treated as yet
another "special type" (like __builtin_va_list).

This change should provide a performance improvement (not verified),
since the lookup into the translation unit declaration 
forces the (otherwise unneeded) construction of a large hash table.
More importantly, with precompiled headers, the construction
of that table requires deserializing most of the top-level
declarations from the precompiled header, which are then unused.

Fixes PR 4509.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74911 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 16:35:42 +00:00
Douglas Gregor e650c8c3bc Introduce the notion of "Relocatable" precompiled headers, which are built
with a particular system root directory and can be used with a different
system root directory when the headers it depends on have been installed.
Relocatable precompiled headers rewrite the file names of the headers used
when generating the PCH file into the corresponding file names of the 
headers available when using the PCH file.

Addresses <rdar://problem/7001604>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 00:12:59 +00:00
Douglas Gregor d89275bc86 Fix PR 4489, a crash in PCH loading that occurs when loading the name
of a top-level declaration loads another top-level declaration of the
same name whose type depends on the first declaration having been
completed. This commit breaks the circular dependency by delaying
loads of top-level declarations triggered by loading a name until we
are no longer recursively loading types or declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 18:54:52 +00:00
Douglas Gregor 7e7eb3da05 Keep track of the Expr used to describe the size of an array type,
from Enea Zaffanella!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74831 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 15:59:29 +00:00
Douglas Gregor 2e22253e03 Add support for retrieving the Doxygen comment associated with a given
declaration in the AST. 

The new ASTContext::getCommentForDecl function searches for a comment
that is attached to the given declaration, and returns that comment, 
which may be composed of several comment blocks.

Comments are always available in an AST. However, to avoid harming
performance, we don't actually parse the comments. Rather, we keep the
source ranges of all of the comments within a large, sorted vector,
then lazily extract comments via a binary search in that vector only
when needed (which never occurs in a "normal" compile).

Comments are written to a precompiled header/AST file as a blob of
source ranges. That blob is only lazily loaded when one requests a
comment for a declaration (this never occurs in a "normal" compile). 

The indexer testbed now supports comment extraction. When the
-point-at location points to a declaration with a Doxygen-style
comment, the indexer testbed prints the associated comment
block(s). See test/Index/comments.c for an example.

Some notes:
  - We don't actually attempt to parse the comment blocks themselves,
  beyond identifying them as Doxygen comment blocks to associate them
  with a declaration.
  - We won't find comment blocks that aren't adjacent to the
  declaration, because we start our search based on the location of
  the declaration.
  - We don't go through the necessary hops to find, for example,
  whether some redeclaration of a declaration has comments when our
  current declaration does not. Similarly, we don't attempt to
  associate a \param Foo marker in a function body comment with the
  parameter named Foo (although that is certainly possible).
  - Verification of my "no performance impact" claims is still "to be
  done".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74704 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 17:08:52 +00:00
Nate Begeman b9e7e63ae2 Write/Read new Language Options
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74221 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 23:01:11 +00:00
Nate Begeman 69cfb9be9b PCH support for OpenCL language options
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74220 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 22:57:40 +00:00
Anders Carlsson 395b475a44 Add a DecltypeType type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 19:06:50 +00:00
Argyrios Kyrtzidis 5710211845 Fix bug in the new PCHReader constructor. PP and Context should be initialized to 0.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73762 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 07:55:35 +00:00
Argyrios Kyrtzidis 11e5110632 Make changes to PCHReader to allow reading a PCH file without having a pre-initialized Preprocessor.
-Introduce 'PCHReaderListener' which is an abstract interface for getting various information from the PCHReader.
-If PCHReader is constructed without a Preprocessor, it can still load the file and invoke the callbacks of PCHReaderListener.
-If PCHReader is constructed with an initialized Preprocessor, PCHValidator is used as a PCHReaderListener to validate the contents of the PCH file against the given Preprocessor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73741 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 00:03:23 +00:00
Steve Naroff d1b3c2dd5b First step toward fixing <rdar://problem/6613046> refactor clang objc type representation.
Add a type (ObjCObjectPointerType) and remove a type (ObjCQualifiedIdType).

This large/tedious patch is just a first step. Next step is to remove ObjCQualifiedInterfaceType. After that, I will remove the magic TypedefType for 'id' (installed by Sema). This work will enable various simplifications throughout clang (when dealing with ObjC types). 

No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73649 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 22:40:22 +00:00
Chris Lattner d3555ae09f If PCH refers to a file that doesn't exist anymore, emit a nice error
like:
fatal error: could not find file '1.h' referenced by PCH file
instead of aborting with an assertion failure, PR4219



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73371 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 04:35:16 +00:00
Eli Friedman 15b91764d0 Move CharIsSigned from TargetInfo to LangOptions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72928 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 07:05:05 +00:00
Sebastian Redl 465226e23a Reintroduce the home for exception specs, and make Sema fill it. However, keep the spec out of the canonical type this time. Net effect is currently nothing, because the spec isn't checked anywhere.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 22:11:52 +00:00
Douglas Gregor 75fdb23776 Fix lots of PCH crashes caused by the new assertions in
llvm::SmallVector, using data() instead of &[0]. The PCH testsuite now
runs cleanly (again).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72292 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 22:45:36 +00:00
Jay Foad beaaccd8e2 Use v.data() instead of &v[0] when SmallVector v might be empty.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 09:52:38 +00:00
Anders Carlsson a33d9b4ebf Disable access control by default. It can be enabled with the -faccess-control option. When we have better support for it, we can enable it by default again.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71706 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 19:49:53 +00:00
Douglas Gregor b64c19365d Make precompiled headers work with -E. When we're only preprocessing
(with -E), we turn the PCH include into an implicit include of the
file from which the PCH file was generated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71534 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 01:31:05 +00:00
Sebastian Redl 6e8ed16ffe Implement C++0x nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-10 18:38:11 +00:00
Sebastian Redl bfa2fcba54 Back out r70506 (exception spec in AST) again. We won't have exception specs until we've had a lot more discussion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71125 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-06 23:27:55 +00:00
Sebastian Redl 7b9a2ee5a4 Make a home for exception specs in the AST. Now Sema can hook them up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 19:20:55 +00:00
Chris Lattner 2df9ced9fd initial support for __[u]int128_t, which should be basically
compatible with VC++ and GCC.  The codegen/mangling angle hasn't
been fully ironed out yet.  Note that we accept int128_t even in
32-bit mode, unlike gcc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70464 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 02:43:43 +00:00
Douglas Gregor 1ab86ac922 Make all PCH-incompatibility warnings into errors, and abort
compilation if the user requested a PCH file but no such PCH file
exists.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70332 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 22:01:16 +00:00
Douglas Gregor a02b147b66 Make the PCH reader use the diagnostics system for its complaints.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70330 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 21:53:25 +00:00
Douglas Gregor 5998da5c29 Optimize IdentifierInfo storage within the precompiled header. We've
now gotten back about 180k of the 500k we lost.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70326 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 21:32:13 +00:00
Douglas Gregor a92193ebd9 Implement a minor space optimization for the PCH identifier table,
which eliminates the storage for IdentifierInfo in the "uninteresting
identifier" cases. Sadly, this only brought back 7k of the 500k we
lost :(


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70325 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 21:18:29 +00:00
Douglas Gregor af1795be18 Replace a lame fprintf with a slightly-less lame diagnostic
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70322 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 20:36:16 +00:00
Douglas Gregor 92b059ea94 Implement checking for macro definitions that occur on the command
line when using a PCH that were not provided when building the PCH
file. If those names were used as identifiers somewhere in the PCH
file, reject the PCH file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70321 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 20:33:11 +00:00
Douglas Gregor 02fc75169a Revert r70075 and r70078, which reorganized the PCH on-disk hash table
for identifiers to separate "interesting" from "uninteresting"
identifiers. However, to cope with compiler invocations where the
predefines buffers mismatch, we need to be able to search the complete
identifier table. Cocoa.h.pch is now about 500k larger that it used to
be :(


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70320 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 20:01:51 +00:00
Douglas Gregor e721f95069 Allow some differences between the predefines buffer used to build a
PCH file and the predefines buffer used when including the PCH
file. We (explicitly) detect conflicting macro definitions (rejecting
the PCH file) and about missing macro definitions (they'll be
automatically pulled from the PCH file anyway).

We're missing some checking to make sure that new macro definitions
won't have any impact on the PCH file itself (e.g., #define'ing an
identifier that the PCH file used).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 18:58:38 +00:00
Eli Friedman c71133f0cf Remove unused LangOptions NoExtensions and Boolean.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70282 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 03:28:55 +00:00
Douglas Gregor ab41e63821 Add a header containing the Clang version; make the driver use this
Clang version value rather than hard-coding "1.0".

Add PCH and Clang version information into the PCH file. Reject PCH
files with the wrong version information.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70264 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 22:23:34 +00:00
Chris Lattner 6bf690fd46 fix test/PCH/method_pool.m
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70263 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 22:17:41 +00:00
Chris Lattner cc7dea8f32 -E, -Eonly and -parse-noop now work with PCH!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70259 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 22:02:30 +00:00
Chris Lattner d1d64a0275 Teach PCH that ASTContext is optional. Move -parse-noop and -Eonly (so far)
processing to after PCH is loaded.  -Eonly and -parse-noop are close to working
with PCH now but are not quite there yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70257 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 21:45:14 +00:00
Douglas Gregor 2bf1eb09f0 Be more careful in our teardown of the PCHReader after deciding to
ignore a PCH file.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70251 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 21:28:04 +00:00
Douglas Gregor b81c170920 Add Sema::ExtVectorDecls and Sema::ObjCCategoryImpls to the PCH file. Since these vectors are very, very rarely used and, when used in headers, and even when used are relatively small, we load them eagerly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70240 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 20:06:05 +00:00
Chris Lattner 090d9b53e3 shrink SOURCE_LOCATION_OFFSETS to use 4-byte entries instead of 8-byte
entries, shaving 100K off the PCH file for cocoa.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70228 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 19:01:47 +00:00
Douglas Gregor 4fed3f47f6 Implement caching of stat() calls for precompiled headers, which is
essentially the same thing we do with pretokenized headers. stat()
caching improves performance of the Cocoa-prefixed "Hello, World" by
45%.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70223 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 18:38:38 +00:00
Chris Lattner c732f5a4ae encode the type and decl offsets with 32-bits for entry instead
of 64 bits.  This cuts 400KB off the PCH file for cocoa (7.1 -> 
6.7MB):

Before:

	Record Histogram:
		  Count    # Bits   % Abv  Record Kind
		      1     14296          SOURCE_LOCATION_PRELOADS
		      1   1699598  100.00  SOURCE_LOCATION_OFFSETS
		      1   1870766  100.00  METHOD_POOL
		      1    212988  100.00  SELECTOR_OFFSETS
		      1        88          STATISTICS
		      1       106          SPECIAL_TYPES
		      1  18033788  100.00  IDENTIFIER_TABLE
		      1   1806428  100.00  IDENTIFIER_OFFSET
		      1       170  100.00  TARGET_TRIPLE
		      1       268          LANGUAGE_OPTIONS
		      1   5168252  100.00  DECL_OFFSET
		      1    952700  100.00  TYPE_OFFSET

After:

	Record Histogram:
		  Count    # Bits   % Abv  Record Kind
		      1     14296          SOURCE_LOCATION_PRELOADS
		      1   1699598  100.00  SOURCE_LOCATION_OFFSETS
		      1   1870766  100.00  METHOD_POOL
		      1    212988  100.00  SELECTOR_OFFSETS
		      1        88          STATISTICS
		      1       106          SPECIAL_TYPES
		      1  18033788  100.00  IDENTIFIER_TABLE
		      1   1806428  100.00  IDENTIFIER_OFFSET
		      1       170  100.00  TARGET_TRIPLE
		      1       268          LANGUAGE_OPTIONS
		      1   2584156  100.00  DECL_OFFSET
		      1    476380  100.00  TYPE_OFFSET



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70216 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 18:24:17 +00:00
Chris Lattner c47be9e5dd fix a couple more places that should be using the DeclCursor instead
of the normal stream cursor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70198 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 07:35:40 +00:00
Douglas Gregor 7f94b0b0c6 Load most of the source manager's information lazily from the PCH
file. In particular, only eagerly load source location entries for
files and for the predefines buffer. Other buffers and
macro-instantiation source location entries are loaded lazily.

With the Cocoa-prefixed "Hello, World", we only load 815/26555 source
location entities. This halves the amount of user time we spend in
this "Hello, World" program with -fsyntax-only (down to .007s).

This optimization is part 1 of 2 for the source manager. This
eliminates most of the user time in loading a PCH file. We still spend
too much time initialize File structures (especially in the calls to
stat), so we need to either make the loading of source location
entries for files lazy or import the stat cache from the PTH
implementation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 06:38:32 +00:00
Chris Lattner 02602be3cc unclone SavedStreamPosition
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70192 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 06:03:19 +00:00
Chris Lattner 4e3fcc845b move attribute reading to PCHReaderDecl.cpp, remove some
extraneous braces.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70191 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 06:01:06 +00:00
Chris Lattner da93061f56 read all decls (and attributes and stmts/exprs referenced by the decl)
from the DeclsCursor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70190 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 05:58:23 +00:00
Chris Lattner 887e2b375f rename GetStmt -> GetDeclStmt to make it clear that the stmt read
is part of a decl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70189 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 05:46:25 +00:00
Chris Lattner 52e97d1afc change the interface to ReadStmt to force clients to pass a cursor in to read from.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70188 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 05:41:06 +00:00
Chris Lattner 698f925ded split decl reading out to its own PCHReaderDecl.cpp file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70187 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 05:27:42 +00:00