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

515 Коммитов

Автор SHA1 Сообщение Дата
Argyrios Kyrtzidis 0daea7a162 Update CMake files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74864 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:38:29 +00:00
Argyrios Kyrtzidis 818e15b89f Move the 'ResolveLocationInAST' function from the Frontend library to the Index library.
Also, cut down its comments; more comments will be added to ASTLocation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74860 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:35:02 +00:00
Argyrios Kyrtzidis ccbcb70ee9 Move ASTLocation and DeclReferenceMap from the AST library to the Index library.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74859 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:34:47 +00:00
Argyrios Kyrtzidis 874012b1fb Rename 'ASTNode' -> 'ASTLocation'.
ASTLocation is a much better name for its intended purpose which to represent a "point" into the AST.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74858 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:34:20 +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
Argyrios Kyrtzidis 07796e1c52 Avoid re-checking the parameters of a function, when trying to resolve a location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74799 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-05 22:21:46 +00:00
Argyrios Kyrtzidis 49dd5851c4 Make use of ASTNode for return value of clang::ResolveLocationInAST() and in the index-test tool.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74798 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-05 22:21:40 +00:00
Argyrios Kyrtzidis 685477f910 Do an early check for function definition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-05 22:21:17 +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
Douglas Gregor ae4df629dd Fix PR 4489, a PCH crash during de-serialization.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74664 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 23:29:14 +00:00
Owen Anderson 8f1ca78009 Update for changes in LLVM. Hopefully this is the last one for a while.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74657 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 23:14:14 +00:00
Owen Anderson c93f49832d Hold the LLVMContext by reference instead of by pointer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74642 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 21:23:16 +00:00
Sebastian Redl 4d374d4a48 Add header search path for Gentoo stable, x86_64 version.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74626 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 18:59:43 +00:00
Owen Anderson 42253cc3bc Update for LLVMContext+Module change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74615 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 17:00:06 +00:00
Eli Friedman 3c7b6e46c5 Fix for PR4192: fix the definition of int64_t on x86_64 Linux.
Note that I'm guessing that *BSD and Solaris do the same thing as Linux 
here, but it's quite possible I'm wrong; if the following testcase 
gives an error on x86-64 with gcc for any of those operating systems, please
tell me:

#include <stdint.h>

int64_t x; long x;



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74583 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-01 03:36:11 +00:00
Zhongxing Xu 51bbd1b5cf remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74517 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 07:50:26 +00:00
Argyrios Kyrtzidis 17945a0f64 De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:36:12 +00:00
Argyrios Kyrtzidis 6fb0aee4f9 Remove the ASTContext parameter from the getBody() methods of Decl and subclasses.
Timings showed no significant difference before and after the commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74504 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:35:26 +00:00
Argyrios Kyrtzidis f1d60eaf3f Remove the ASTContext parameter from the printing related methods of Decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74503 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:35:04 +00:00
Argyrios Kyrtzidis 40b598eea1 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:34:44 +00:00
Chris Lattner e4f2142d00 Key decisions about 'bool' vs '_Bool' to be based on a new flag in langoptions.
This is simple enough, but then I thought it would be nice to make PrintingPolicy
get a LangOptions so that various things can key off "bool" and "C++" independently.
This spiraled out of control.  There are many fixme's, but I think things are slightly
better than they were before.

One thing that can be improved: CFG should probably have an ASTContext pointer in it,
which would simplify its clients.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74493 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 01:26:17 +00:00
Bill Wendling 4ebe3e4c81 Make the StackProtector bitfield use enums instead of obscure numbers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74414 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-28 23:01:01 +00:00
Bill Wendling 45483f7a1b Add stack protector support to clang. This generates the 'ssp' and 'sspreq'
function attributes. There are predefined macros that are defined when stack
protectors are used: __SSP__=1 with -fstack-protector and __SSP_ALL__=2 with
-fstack-protector-all.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-28 07:36:13 +00:00
Anders Carlsson e89d15944d Implement enough of the 'auto' keyword so we can claim to support N2546.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74307 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 18:41:36 +00:00
Nate Begeman 6f3d838867 OpenCL 1.0 support: attributes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74280 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 06:32:41 +00:00
Ted Kremenek 6c07bdba93 Introduce a new concept to the static analyzer: SValuator.
GRTransferFuncs had the conflated role of both constructing SVals (symbolic
expressions) as well as handling checker-specific logic. Now SValuator has the
role of constructing SVals from expressions and GRTransferFuncs just handles
checker-specific logic. The motivation is by separating these two concepts we
will be able to much more easily create richer constraint-generating logic
without coupling it to the main checker transfer function logic.

We now have one implementation of SValuator: SimpleSValuator.

SimpleSValuator is essentially the SVal-related logic that was in GRSimpleVals
(which is removed in this patch). This includes the logic for EvalBinOp,
EvalCast, etc. Because SValuator has a narrower role than the old
GRTransferFuncs, the interfaces are much simpler, and so is the implementation
of SimpleSValuator compared to GRSimpleVals. I also did a line-by-line review of
SVal-related logic in GRSimpleVals and cleaned it up while moving it over to
SimpleSValuator.

As a consequence of removing GRSimpleVals, there is no longer a
'-checker-simple' option. The '-checker-cfref' did everything that option did
but also ran the retain/release checker. Of course a user may not always wish to
run the retain/release checker, nor do we wish core analysis logic buried in the
checker-specific logic. The next step is to refactor the logic in CFRefCount.cpp
to separate out these pieces into the core analysis engine.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74229 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 00:05:51 +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
Argyrios Kyrtzidis 53d4c14a98 Introduce the ResolveLocationInAST function which takes an ASTContext and a SourceLocation and it resolves it into a <Decl*, Stmt*> pair.
Decl* is the declaration associated with this source location and Stmt* is the statement/expression that the location points to.
If the location does not point to a statement node, Stmt* is null.

ResolveLocationInAST (along with converting a file:line:column triplet to a SourceLocation) will be useful for an IDE client and for clang's test suite.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74197 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 18:22:41 +00:00
Argyrios Kyrtzidis 106c9981f1 Handle PCHReader::IgnorePCH, it gets returned for when the file does not exist.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 18:22:30 +00:00
Douglas Gregor f391e098b2 Add missing dependencies to the CMake build system
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74162 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 05:03:29 +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 9336bcf24e Update CMakeLists.txt
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74011 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 22:01:29 +00:00
Douglas Gregor 3c092bce5f Fix some TableGen-related dependencies for the Clang CMake build
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 18:15:28 +00:00
Chris Lattner 8ea841b115 switch Warnings.cpp to use the diagnostics machinery to print diagnostics, not *fprintf*!
Among other things, this makes the warning about unknown warning options mappable.
For example:

$ clang t.c -Werror -Wfoo
error: unknown warning option '-Wfoo' [-Wunknown-warning-option]

For another thing, they are properly color coded now too :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 01:20:39 +00:00
Chris Lattner 7478bbfea8 __APPLE_CC__ should only be set when building for darwin targets.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73934 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 00:43:21 +00:00
Argyrios Kyrtzidis 4b562cf889 Add the license part to the new source files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73825 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 08:27:14 +00:00
Argyrios Kyrtzidis 8cff90e1f7 Serialize FunctionDecl's EndRangeLoc out to the PCH file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73822 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 08:09:34 +00:00
Argyrios Kyrtzidis 0853a02c3b Introduce the ASTUnit class.
ASTUnit is a helper class to allow easy loading of an ASTContext from a PCH file. No users for now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73819 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 08:08:23 +00:00
Fariborz Jahanian 9b0b57c6f9 Added writing and reading of the ConstQualAdded flag of
BlockDeclRefExpr to PCH.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73800 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 00:02:26 +00:00
Douglas Gregor e0762c9211 Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.

This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73797 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:52:42 +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
Douglas Gregor 68584ed35a Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:11:24 +00:00
Douglas Gregor 0adea828ec Add some missing CMake dependencies
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73700 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 15:05:47 +00:00
Argyrios Kyrtzidis f5cecfbdcd Move CXXMethodDecl::OutOfLineDefinition into Decl::OutOfLine.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73651 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 22:49:50 +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
Douglas Gregor 15e92322a7 Search path for 64-bit Ubuntu Linux, from Anders Johnsen
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73637 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 21:18:36 +00:00
Douglas Gregor 038f75abf5 More XML output support, from Olaf Krzikalla!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73402 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 19:02:54 +00:00
Eli Friedman ae96a9637a PR4388: get rid of an extra # line directive; in addition to being
unnecessary, this was causing issues for assembler-with-cpp mode, which 
doesn't process the directive.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73382 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 09:57:52 +00:00
Chris Lattner 81ebe9bf80 Minor tweak to -fdiagnostics-print-source-range-info to make it print
ranges more similar to the console output.  Consider:

#define FOO(X, Y) X/ Y

void foo(int *P, int *Q) {
  FOO(P, Q);
}

Before we emitted:

t.c:4:3:{4:3-4:6}{4:3-4:6}: error: invalid operands to binary expression ('int *' and 'int *')
   FOO(P, Q);
   ^~~~~~~~~
...

Note that while we underline the macro args that the range info just includes FOO 
without its macros.  This change teaches the printed ranges to include macro args
also so that we get:

t.c:4:3:{4:3-4:12}{4:3-4:12}: error: invalid operands to binary expression ('int *' and 'int *')
   FOO(P, Q);
   ^~~~~~~~~
...

This fixes rdar://6939599


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73378 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 05:18:27 +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
Chris Lattner ed2d7c4ffd no really, add the lines :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73367 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 04:08:28 +00:00
Chris Lattner 3ee211fd15 Fix PR2741 by making our newline tracking be aware of newlines that
can occur in the middle of comment tokens.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73365 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15 01:25:23 +00:00
Chris Lattner 989135901c add the location of the ')' in a do/while statement to DoStmt.
This fixes a source range problem reported by Olaf Krzikalla.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73266 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 23:04:47 +00:00
Anders Carlsson 5e300d1a8e It's an error to use a function declared in a class definition as a default argument before the function has been declared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73234 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-12 16:51:40 +00:00
Eli Friedman b9b7dd6442 PR4371: Reduce the inlining threshold outside of -O3. This makes
the clang inlining threshold consistent with the threshold for llvm-gcc.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73204 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-11 20:33:41 +00:00
Eli Friedman abc4e32603 Misc minor fixes for clang for the Windows target.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73050 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-08 06:11:14 +00:00
Eli Friedman 687abffee4 Don't allow defining a block with a non-prototype type. Remove a
hack which introduces some strange inconsistencies in compatibility 
for block pointers.

Note that unlike an earlier revision proposed on cfe-commits, this patch 
still allows declaring block pointers without a prototype.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73041 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-08 04:24:21 +00:00
Fariborz Jahanian 496b5a894c Use of DeclContext for objc's ivars. No functionality
change. More to follow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72951 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 18:16:35 +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
Eli Friedman 2de4feeef2 Move a couple Darwin-specific defines into getDarwinDefines.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72900 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 23:00:29 +00:00
Chris Lattner 810dc54e1c DefineBuiltinMacro is always passed two args, remove the defaulted third
one.  


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72868 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 16:47:09 +00:00
Torok Edwin 603fca7281 Add ANSI color support for clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72855 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 07:18:23 +00:00
Daniel Dunbar 10d861e00d (llvm up) Switch to using StandardPasses.h
- One functionality change, the LoopIndexSplit pass is now reenabled (it was
   disabled in r60089 but we forgot to reenable it).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72787 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-03 18:01:18 +00:00
Duncan Sands 63682f9c64 Compile fix needed by the solaris system gcc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72772 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-03 14:28:20 +00:00
Zhongxing Xu 51e774d422 emit ORIGINAL_FILE_NAME record ID to blockinfo block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72759 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-03 09:23:28 +00:00
Daniel Dunbar 877db3852e Add clang-cc support for -disable-llvm-optzns.
- Avoids running any LLVM optimizations, even at -O2, etc., while still keeping
   any language changes these optimizations imply.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72742 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-02 22:07:45 +00:00
Eli Friedman 3e753e279d PR4288: Make -dD (dump macros with preprocessed source) play nicely with
# line directives.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72724 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-02 07:55:39 +00:00
Zhongxing Xu 44dfc98b68 Unify coding style.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72682 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-01 00:50:23 +00:00
Zhongxing Xu 0e1081388a Use a reference to modify the DeclIDs map.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72681 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-01 00:49:11 +00:00
Duncan Sands 813a2bb6f3 Unbreak the clang build by applying the same temporary
workaround for machine code emitter changes as was used
in llvm-gcc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72657 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 04:09:57 +00:00
Anders Carlsson a0ab25d280 ActOnReturnStmt should also take a FullExprArg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72641 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:42:34 +00:00
Anders Carlsson f5dcd38858 AddInitializerToDecl needs to take a full expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:37:25 +00:00
Eli Friedman 3a9eb44f29 Pass an ASTContext into Stmt::printPretty.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72611 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 05:19:26 +00:00
Douglas Gregor 4fe0c8e9c7 Refactor and clean up the AST printer, so that it uses a DeclVisitor,
walks through DeclContexts properly, and prints more of the
information available in the AST. The functionality is still available
via -ast-print, -ast-dump, etc., and also via the new member functions
Decl::dump() and Decl::print().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72597 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 00:08:05 +00:00
Douglas Gregor d249e1d1f1 Create a new PrintingPolicy class, which we pass down through the AST
printing logic to help customize the output. For now, we use this
rather than a special flag to suppress the "struct" when printing
"struct X" and to print the Boolean type as "bool" in C++ but "_Bool"
in C.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72590 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 20:38:28 +00:00
Eli Friedman c1dc653b08 If a declarator group declares a type, make sure to add that declaration
to the DeclGroup.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 01:49:24 +00:00
Douglas Gregor 402abb55fc When we parse a tag specifier, keep track of whether that tag
specifier resulted in the creation of a new TagDecl node, which
happens either when the tag specifier was a definition or when the tag
specifier was the first declaration of that tag type. This information
has several uses, the first of which is implemented in this commit:

  1) In C++, one is not allowed to define tag types within a type
  specifier (e.g., static_cast<struct S { int x; } *>(0) is
  ill-formed) or within the result or parameter types of a
  function. We now diagnose this.

  2) We can extend DeclGroups to contain information about any tags
  that are declared/defined within the declaration specifiers of a
  variable, e.g.,

    struct Point { int x, y, z; } p;

  This will help improve AST printing and template instantiation,
  among other things.

  3) For C99, we can keep track of whether a tag type is defined
  within the type of a parameter, to properly cope with cases like,
  e.g.,

    int bar(struct T2 { int x; } y) {
      struct T2 z;
    }

  We can also do similar things wherever there is a type specifier,
  e.g., to keep track of where the definition of S occurs in this
  legal C99 code:

    (struct S { int x, y; } *)0

  



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72555 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-28 23:31:59 +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 8dbc3c6496 Enumeration declarations that were instantiated from an enumeration
within a template now have a link back to the enumeration from which
they were instantiated. This means that we can now find the
instantiation of an anonymous enumeration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72482 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 17:20:35 +00:00
Steve Naroff 446ee4eb4f Convert ObjC qualified type clients over to using iterators.
This allows me to remove some API that I don't want to carry over to ObjCObjectPointerType.

No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72475 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 16:21:00 +00:00
Douglas Gregor 78d1583d0b When evaluating a VarDecl as a constant or determining whether it is
an integral constant expression, maintain a cache of the value and the
is-an-ICE flag within the VarDecl itself. This eliminates
exponential-time behavior of the Fibonacci template metaprogram.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72428 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26 18:54:04 +00:00
Eli Friedman 2665a75c16 Add IEEE quad support to DefineFloatMacros.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-23 03:50:01 +00:00
Eli Friedman bf22be630e PR4247: Widen the buffer slightly so it can hold all the definitions for
PPC double double.

(No testcase because no normal target uses the format at the moment.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72310 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-23 02:03:39 +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
Ted Kremenek 66ef111b16 Fix PCH crash caused by new assertions in llvm::SmallVector. Use
ProtoRefs.data() instead of &ProtoRefs[0] to access the raw buffer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72291 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 22:34:23 +00:00
Fariborz Jahanian 34e65770ad This patch adds support for sender-aware dispatch in Objective-C for the GNU runtime, when
compiled with -fobjc-sender-dependent-dispatch.  This is used in AOP, COP, implementing object 
planes, and a few other things.
Patch by David Chisnall.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72275 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 20:17:16 +00:00
Zhongxing Xu 3d8216a9d3 Pull EmitRecord() out of loop. It should be called only once.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72252 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 08:38:27 +00:00
Douglas Gregor 100bb76aa9 Fix CMake build for AST XML dumper
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72228 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 21:21:53 +00:00
Douglas Gregor ee75c05c1a AST XML dump, from Olaf Krzikalla!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72224 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 20:55:50 +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
Fariborz Jahanian 5b16092767 implementation of format_arg for ObjC methods/functions.
Still more to do.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72173 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 17:41:43 +00:00
Eli Friedman 4df2c42581 Build fixes for r72135.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72136 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 21:16:18 +00:00
Eli Friedman 0ec78fa2c9 Move AnalysisConsumer.h and Analyses.def from tools/clang-cc to
include/clang/Frontend, and move AnalysisConsumer.cpp from 
tools/clang-cc to lib/Frontend.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72135 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 21:10:40 +00:00
Duncan Sands 825511013c Add missing include for stderr and fprintf, needed
when compiling with gcc-4.4.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72109 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 12:06:47 +00:00
Eli Friedman 24200917df Fix a crash with -emit-html from stdin.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72104 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 05:28:52 +00:00
Eli Friedman ac8d6298a8 Clean up some unnecessary includes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72101 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 04:30:57 +00:00
Eli Friedman ba60149b92 CMake updates for r72099; untested, so please tell me if there are any
issues.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72100 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 04:21:30 +00:00
Eli Friedman b09f6e15c5 Move clang-cc.h to lib/Frontend/Utils.h, and move the associated .cpp
files to lib/Frontend.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 04:14:29 +00:00
Eli Friedman 2aa39cd55c Attempted CMake build fixes for r72060; this is untested, so please tell
me if there are any issues.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72063 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 23:06:15 +00:00
Eli Friedman 39d7c4d2d9 Move ASTConsumers.h to include/clang/Frontend, and move the associated
.cpp files to lib/Frontend.  (As proposed on cfe-dev.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72060 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 22:50:54 +00:00
Douglas Gregor 1f0eb56d7c "This patch fixes an obvious buffer overrun in
SelectInterestingSourceRegion()," from Jay Foad!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72049 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 22:09:16 +00:00
Eli Friedman f086e3bef1 Remove unused parameter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71996 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 07:39:39 +00:00
Douglas Gregor 5f1b9e689f Template instantiation for IndirectGotoStmt. Now my life is complete.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71917 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 00:20:29 +00:00
Douglas Gregor dbb26db1d4 Template instantiation for switch statements
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71916 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 23:57:33 +00:00
Douglas Gregor 5831c6a1ef Template instantiation for "for" loops
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71901 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 22:12:32 +00:00
Douglas Gregor 9f3ca2a774 Template instantiation for do-while statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71899 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 21:56:04 +00:00
Douglas Gregor d06f6ca610 Template instantiation for "if" statements. Also:
- Skip semantic analysis of the "if" condition if it is type-dependent.
  - Added the location of the "else" keyword into IfStmt, so that we can
    provide it for type-checking after template instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71875 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 18:53:42 +00:00
Douglas Gregor c95bd4de80 When word-wrapping, be more defensive about a ridiculously small number of columns. Fixes <rdar://problem/6892178>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71870 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 18:05:24 +00:00
Chris Lattner dcdecf4a77 Fix processing of -Ufoo to not inject "#undef foo 1" into the predefines
buffer.  This caused exciting nonsense like this:

$ clang t.c -fsyntax-only -UMACRO
In file included from <built-in>:104:
<command line>:1:14: warning: extra tokens at end of #undef directive [-Wextra-tokens]
#undef MACRO 1
             ^
             //
1 diagnostic generated.

rdar://6891800


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71860 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 16:08:43 +00:00
Anders Carlsson 77b7f1d4fb Check that the function being overridden is virtual.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71802 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 22:15:41 +00:00
Anders Carlsson a75e8534f2 Improvements to the FunctionDecl getters/setters.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71800 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 21:46:00 +00:00
Douglas Gregor 1eee0e753f Link FunctionDecls instantiated from the member functions of a class
template to the FunctionDecls from which they were instantiated. This
is a necessary first step to support instantiation of the definitions
of such functions, but by itself does essentially nothing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 21:06:31 +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
Fariborz Jahanian 5b53005fb9 Some early declarations to support sentinel attribute on
message dispatches (and function calls later). No change in
functionality.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71683 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 18:09:35 +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
Ted Kremenek b71368d285 Add back Parse/Sema support for attributes cf_returns_retained and
ns_returns_retained, but do not include the other ownership attributes
we previously had.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71308 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-09 02:44:38 +00:00
Ted Kremenek 008fc73ac9 Remove experimental ownership attributes from Clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71216 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-08 15:19:25 +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
Douglas Gregor 2cc2b9ca22 Eliminate extra vertical space in Clang diagnostics
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71066 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-06 04:43:47 +00:00
Chris Lattner 037fb7f369 Fix rdar://6849429 - -Wunused-value with deeply nested macro expansion generates untraceable warnings
The "instantiated from" messages coming from the caret diagnostics system are 
basically walking the macro expansion tree, emitting each level as it goes.  However, it was
skipping certain leaves in the tree by skipping up the entire instantiation arm every time
it went up one spelling arm.  This caused it to miss some things.  For example, in this
testcase:

#define M1(x) x
#define M2 1;

void foo() {
 M1(M2)
}

we now print:

/Users/sabre/Desktop/clang-unused-value-macro.c:6:2: warning: expression result unused

 M1(M2)
 ^~~~~~
/Users/sabre/Desktop/clang-unused-value-macro.c:6:5: note: instantiated from:

 M1(M2)
    ^~
/Users/sabre/Desktop/clang-unused-value-macro.c:3:12: note: instantiated from:

#define M2 1;
           ^

Previously we didn't print the last line, so we never emitted the caret pointing to the 1!

Incidentally, the spaces between the lines is really noisy, I think we should reconsider
this heuristic (which adds them when the printed code starts too close to the start of the
line).

The regression test can't use -verify, because -verify doesn't catch notes for macro
instantiation history.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 22:03:18 +00:00
Ted Kremenek 69aa08072d Implement attribute 'ns_autorelease'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70990 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 18:44:20 +00:00
Ted Kremenek e351aa10da Implement attribute 'cf_returns_owned' (mirrors 'ns_returns_owned').
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 00:46:09 +00:00
Ted Kremenek d99b345a1a Remove experimental attribute 'ns_ownership_make_collectable.'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70940 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 23:46:06 +00:00
Ted Kremenek 75494ffb4e Rename attributes 'objc_ownership...' to 'ns_ownership...'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70897 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 19:10:19 +00:00
Ted Kremenek 31c215e620 Rename attributes:
'objc_ownership_cfretain' -> 'cf_ownership_retain'
'objc_ownership_cfrelease' -> 'cf_ownership_release'

Motivation: Core Foundation objects can be used in isolation from Objective-C,
and this forces users to reason about the separate semantics of CF objects. More
Sema support pending.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70884 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 17:29:57 +00:00
Douglas Gregor 2fb3ea3ea4 Simplify the interesting-region code by assimmilating blocks of non-whitespace text with each expansion step. It's easier and seems to have better results.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70833 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 06:45:38 +00:00
Douglas Gregor cfe1f9d86d Tweak the extraction of the "interesting" part of a source range in two ways:
1) First of all, we treat _ as part of an identifier and not as
  punctuation (oops).
  2) Second of all, always make sure that the token that the ^ is
  pointing at is fully within the "interesting" part of the range.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70831 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 06:27:32 +00:00
Daniel Dunbar 1ef29d217e Fix an infinite loop in diagnostic printing.
- The diagnostic is still poor, however. Doug, can you investigate?

 - Improved the test case to not depend on the file name, now it can
   be extended to actually check the formatting of the diagnostics
   (I'm hoping grep -A is portable here).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70807 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 23:04:40 +00:00
Douglas Gregor 2167de4c49 Fix crash in source-line truncation code for diagnostic
printing. Also, when we only need to truncate the line at the end,
make sure there is room for the ellipsis.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70781 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 15:24:25 +00:00
Chris Lattner cb6929bf43 temporary hack to work around PR4128
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70681 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 08:42:09 +00:00
Douglas Gregor 844da34736 When a fix-it hint would span multiple lines, don't print it; half a
fix-it hint is much worse than no fix-it hint. (Fixes PR4084).

When we need to truncate a source line to fix in the terminal, make
sure to take the width of the fix-it information into account, too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70656 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 04:33:32 +00:00
Douglas Gregor 7d101f6fd7 When we truncate a source line to fit it within the terminal width,
show an ellipsis where we have removed text. An example:

/Users/dgregor/Projects/llvm/tools/clang/test/Misc/message-length.c:18:120:
warning: 
      comparison of distinct pointer types ('int *' and 'float *')
  ...a_func_to_call(ip == FloatPointer, ip[ALongIndexName], ...
                    ~~ ^  ~~~~~~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70655 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 04:12:51 +00:00
Douglas Gregor 44cf08ecf6 Respect the COLUMNS environment variable for word-wrapping (so we get
word-wrapping by default in Emacs; yay!). Thanks, Daniel.

Use LLVM's System layer rather than calling isatty() directly.

Fix a thinko in printing the indentation string that was causing some
weird output.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70654 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 03:52:38 +00:00
Douglas Gregor 47f7177880 When printing a source line as part of a diagnostic, the source line
might be wider than we're supposed to print. In this case, we try to
select the "important" subregion of the source line, which contains
everything that we want to show (e.g., with underlining and the caret
itself) and tries to also contain some of the context. 

From the fantastically long line in the test case, we get an error
message that slices down to this:

message-length.c:18:120: warning: comparison of distinct pointer types
      ('int *' and 'float *')
  a_func_to_call(ip == FloatPointer, ip[ALongIndexName], 
                 ~~ ^  ~~~~~~~~~~~~

There are a bunch of gee-it-sounds-good heuristics in here, which seem
to do well on the various simple tests I've thrown at it. However,
we're going to need to look at a bunch more diagnostics to tweak these
heuristics.

This is the second part of <rdar://problem/6711348>. Almost there! 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70597 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 23:32:58 +00:00
Douglas Gregor fffd93f383 Implement -fmessage-length=N, which word-wraps diagnostics to N columns.
Also, put a line of whitespace between the diagnostic and the source
code/caret line when the start of the actual source code text lines up
(or nearly lines up) with the most recent line of the diagnostic. For
example, here it's okay for the last line of the diagnostic to be
(vertically) next to the source line, because there is horizontal
whitespace to separate them:

decl-expr-ambiguity.cpp:12:16: error: function-style cast to a builtin
      type can only take one argument
  typeof(int)(a,5)<<a;

However, here is a case where we need the vertical separation (since
there is no horizontal separation):

message-length.c:10:46: warning: incompatible pointer types initializing 'void
      (int, float, char, float)', expected 'int (*)(int, float, short,
      float)'

      int (*fp1)(int, float, short, float) = f;

This is part one of <rdar://problem/6711348>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70578 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 21:53:04 +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
Ted Kremenek d49967f876 BugReporter/PathDiagnostics:
- Add an (optional) short description for BugReports for clients that want
  to distinguish between long and short descriptions for bugs
- Make the bug report for VLA less obscene for Plist diagnostics by using
  the short description


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 21:58:13 +00:00
Chris Lattner 770dbf04b4 In -fdiagnostics-print-source-range-info mode, print a space before the
lines that clang extracts from the source code so that machine parsing can
easily ignore them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70337 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 22:33:16 +00:00
Ted Kremenek bf20dbdec6 Implement ownership attribute 'objc_ownership_make_collectable'. This allows one
to add 'CFMakeCollectable' semantics to a method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70336 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 22:32:26 +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
Ted Kremenek c6a59e4bf2 Add two new checker-specific attributes: 'objc_ownership_release' and
'objc_ownership_cfrelease'. These are the 'release' equivalents of
'objc_ownership_retain' and 'objc_ownership_cfretain' respectively.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70235 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 19:36:56 +00:00
Chris Lattner 828e18cd80 make these be unsigned now that they are eagerly created.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70229 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 19:03:22 +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
Ted Kremenek 4064de9598 Add new checker-specific attribute 'objc_ownership_cfretain'. This is the same
as 'objc_ownership_cfretain' except that the method acts like a CFRetain instead
of a [... retain] (important in GC modes). Checker support is wired up, but
currently only for Objective-C message expressions (not function calls).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70218 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 18:27:22 +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 ea5ce4705d add an abbreviation for common PARM_VAR_DECL. All but 9 of the
parm var decls in leopard cocoa.h end up using this abbreviation,
which shrinks the bitcode file by about 50K: 7217736->7167120.

Before:
  Block ID #12 (DECLS_BLOCK):
      Num Instances: 1
         Total Size: 2.23595e+07b/2.79494e+06B/698736W
          % of file: 38.7233
      Num SubBlocks: 0
        Num Abbrevs: 0
        Num Records: 139387
      % Abbrev Recs: 0

After:
  Block ID #12 (DECLS_BLOCK):
      Num Instances: 1
         Total Size: 2.02405e+07b/2.53006e+06B/632516W
          % of file: 35.301
      Num SubBlocks: 0
        Num Abbrevs: 1
        Num Records: 139387
      % Abbrev Recs: 19.2902



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 07:35:58 +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 63377d56de split expr/stmt writing out to PCHWriterStmt.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70194 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 06:20:01 +00:00
Chris Lattner 12b1c7615d split decl writing out to its own PCHWriterDecl.cpp file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 06:16:06 +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
Chris Lattner 4c6f952b70 split stmt/expr deserialization out to PCHReaderStmt.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70186 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 05:14:47 +00:00
Chris Lattner 8849e64ad4 remove dead var
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70174 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 01:08:03 +00:00
Chris Lattner 6367f6d063 Set up DeclsCursor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70173 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 01:05:14 +00:00
Chris Lattner 0558df2da8 add stmt/expr names to BlockInfo block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70172 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 00:49:53 +00:00
Chris Lattner 2f4efd10c8 drop the _ID suffixes from block names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70169 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 00:40:25 +00:00
Chris Lattner 0ff8cda444 add the decl names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70167 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 22:32:16 +00:00
Chris Lattner b145b1e9de make llvm-bcanalyzer dump out PCH files symbolically. We should probably
eventually get an option to turn this off, but it is nice for looking at 
statistics.  For example, the types block now prints:

  Block ID #11 (TYPES_BLOCK_ID):
      Num Instances: 1
         Total Size: 895100b/111888B/27971.9W
          % of file: 1.55801
      Num SubBlocks: 0
        Num Abbrevs: 0
        Num Records: 14899
      % Abbrev Recs: 0

        Code Histogram:
                5478    TYPE_FUNCTION_PROTO
                2683    TYPE_TYPEDEF
                2460    TYPE_POINTER
                2047    TYPE_ENUM
                1553    TYPE_RECORD
                283     TYPE_CONSTANT_ARRAY
                274     TYPE_OBJC_INTERFACE
                76      TYPE_INCOMPLETE_ARRAY
                10      TYPE_VECTOR
                9       TYPE_OBJC_QUALIFIED_ID
                5       TYPE_FUNCTION_NO_PROTO
                5       TYPE_EXT_QUAL
                3       TYPE_TYPEOF_EXPR



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70166 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 22:26:21 +00:00
Douglas Gregor 405bad0739 Some fixes for PCH (de-)serialization of Objective-C AST nodes:
- Deal with the Receiver/ClassInfo shared storage in ObjCMessageExpr
  - Implement PCH support for ImplicitParamDecl
  - Fix the handling of the body of an ObjCMethodDecl
  - Several cast -> cast_or_null fixes
  - Make Selector::getIdentifierInfoForSlot work for 1-argument, NULL
  selectors.
  - Make Selector::getAsString() work with NULL selectors.
  - Fix the names of VisitObjCAtCatchStmt and VisitObjCAtFinallyStmt
  in the PCH reader and writer; these were never getting called.

At this point, all of the pch-test tests pass for C and Objective-C.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 22:20:50 +00:00
Chris Lattner b9fa917e90 Adjust to LLVM API changes that went into r70157.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70158 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 20:59:20 +00:00
Steve Naroff 1eb5540760 Add PCH read/write support for ObjC statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70143 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 18:52:16 +00:00
Steve Naroff e1fb77f430 Make sure we have a code in the node:-)
This fixes all the -emit-pch problems discovered by utils/pch-test.pl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70125 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 14:11:39 +00:00
Douglas Gregor 366809a4e9 When writing a PCH file, write multiple type and declaration blocks as
necessary and iterate until all types and declarations have been
written. This reduces the Cocoa.h PCH file size by about 4% (since we
don't write types we don't need), and fixes problems where writing a
declaration generates a new type.

This doesn't seem to have any impact on performance either way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70109 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 03:49:13 +00:00
Chris Lattner 16f0049415 split ObjC and C++ Statements out into their own headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70105 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 01:32:48 +00:00
Chris Lattner 0389e6bd01 implement PCH support for the rest of ExprObjC.h, including
the missing bits of ObjCMessageExpr.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70100 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 00:44:05 +00:00
Douglas Gregor 2eafc1b563 Don't read all of the records in the PCH file's preprocessor block,
most of which are ignored. Instead, move the __COUNTER__ value out to
a PCH-level record (since it is handled eagerly) and move the header
file information into the SourceManager block (which is also,
currently, loaded eagerly).

This results in another 17% performance improvement in the
Cocoa-prefixed "Hello, World" with PCH.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70097 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 00:07:37 +00:00
Douglas Gregor 8c5a760b82 Lazily load the controlling macros for all of the headers known in the
PCH file. In the Cocoa-prefixed "Hello, World" benchmark, this takes
us from reading 503 identifiers down to 37 and from 470 macros down to
4. It also results in an 8% performance improvement.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70094 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 23:30:02 +00:00
Douglas Gregor 17e1c5eba5 Optimize the loading of an identifier from a PCH file when given the
identifier's ID. In this case, we know where the identifier's entry is
located in the hash table (it starts right before the identifier
string itself), so skip the hash table lookup and read the entry
directly. The performance improvement here is, gain, hard to quantify,
but it's the right thing to do.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70078 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 21:21:38 +00:00
Douglas Gregor d6595a40fe PCH optimization for the identifier table, where we separate
"interesting" identifiers (e.g., those where the IdentifierInfo has
some useful information) from "uninteresting" identifiers (where the
IdentifierInfo is just a name). This makes the hash table smaller (so
searching in it should be faster) and, when loading "uninteresting"
identifiers, we skip the lookup in the hash table.

PCH file size is slightly smaller than before (since we don't emit the
contents of the uninteresting IdentifierInfo structures). The
Cocoa.h-prefixed "Hello, World" doesn't show any speedup, although
we're getting to the point where system noise is a bit issue.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70075 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 21:04:17 +00:00
Douglas Gregor 5f8e330224 Revert my changes that try to avoid creating StringMap entries for
identifiers. They don't yet work, but will inhibit future
optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 20:26:24 +00:00
Douglas Gregor 5da8161bdf Start implementing the PTH IdentifierInfo-saving trick in PCH,
allocating IdentifierInfos with a pointer into the string data stored
in the PCH file rather than having an entry in the identifier table's
string map. However, we don't actually get these savings at the
moment, because we go through the IdentifierTable when loading
identifiers from the on-disk hash table.

This commit is for record-keeping purposes only. I'll be reverting
this change (and the PCH layout tweak that preceded it) because it
appears that implementing this optimization will collide with another,
future optimization to reduce the size of the on-disk hash table for
identifiers. That optimization is likely to provide more benefit (with
less voodoo).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 20:21:25 +00:00
Douglas Gregor 1986cadcb3 Tweak the data layout for the on-disk hash table of identifiers in the PCH file so that the key layout matches that of the PTH key layout
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70066 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 19:25:49 +00:00
Douglas Gregor 2b3a5a83ea Write the identifier offsets array into the PCH file as a blob, so
that the PCH reader does not have to decode the VBR encoding at PCH
load time.

Also, reduce the size of the identifier offsets from 64 bits down to
32 bits. The identifier table itself isn't going to grow to more than
4GB :)

Overall, this results in a 13% speedup in the Cocoa-prefixed "Hello,
World" benchmark.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70063 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 19:10:14 +00:00
Douglas Gregor 8f5dc7fe4d Write the declaration and type offset arrays into the bitstream as
blobs, so that we don't need to do any work to get these arrays into
memory at PCH load time.

This gives another 19% performance improvement to the Cocoa-prefixed
"Hello, World!".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70059 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 18:35:21 +00:00
Douglas Gregor 83941df274 Load the selector table lazily from the PCH file.
This results in a 10% speedup on the Cocoa-prefixed "Hello, World!",
all of which is (not surprisingly) user time. There was a tiny
reduction in the size of the PCH file for Cocoa.h, because certain
selectors aren't being written twice.

I'm using two new tricks here that I'd like to replicate elsewhere:
  (1) The selectors not used in the global method pool are packed into
  the blob after the global method pool's on-disk hash table and
  stored as keys, so that all selectors are in the same blob.
  (2) We record the offsets of each selector key when we write it into
  the global method pool (or after it, in the same blob). The offset
  table is written as a blob, so that we don't need to pack/unpack a
  SmallVector with its contents.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70055 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 17:48:32 +00:00