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

5403 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 0f67032078 fix a bug getting the spelling of an identifier token
that required cleaning.  If the token required cleaning,
don't include the cleaned tokens in the returned length.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40410 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 22:50:09 +00:00
Chris Lattner 349b42aed2 no need to avoid pasting >* It can't form ->*, because we know the previous
token was not -> and if the token before it was -, the - and > would avoid pasting.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40409 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 22:33:25 +00:00
Chris Lattner 94fea5a956 GCC doesn't set __STDC_VERSION__ usually. It never sets it in
C++ mode, even gnu C++ mode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40408 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 22:11:35 +00:00
Chris Lattner e36751b12c Switch TargetInfo::getTargetDefines from using an std::map<std::string, ...> to using
a llvm::StringMap.  This dramatically reduces the startup time of the preprocessor,
speeding up -Eonly on xalankbmk by 2.2%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40396 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 20:11:46 +00:00
Chris Lattner 448cec4c1c Change hte lexer to start a start pointer to the underlying
memorybuffer instead of a pointer to the memorybuffer itself.  This
reduces coupling and eliminates a pointer dereference on a hot path.
This speeds up -Eonly on 483.xalancbmk by 2.1%


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40394 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 18:44:36 +00:00
Chris Lattner 409a036712 split the slow path out of Lexer::getSourceLocation and do not let the
compiler inline it.  This speeds up -Eonly on 483.xalancbmk by about 1%


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40393 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 18:38:25 +00:00
Chris Lattner 9960ae8ecf Implement a simple cache in headersearch. This speeds up
preprocessing 483.xalancbmk by about 10%, reducing the number
of file lookup queries from 2139411 to 199466 (over 10x)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40390 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 07:28:00 +00:00
Anders Carlsson c1fcb77626 Refactor switch analysis to make it possible to detect duplicate case values
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40388 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 07:07:56 +00:00
Chris Lattner 83769abea9 remove redundant test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40386 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 06:40:36 +00:00
Chris Lattner 0cbc4b593c avoid a small bit of string traffic by not storing the ""'s around a string in CurFilename
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40385 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 06:38:50 +00:00
Chris Lattner 8133cfcc0b avoid recursion between SkipBCPLComment and SkipWhitespace. In cases like this:
// foo
   // bar
   // baz

we'd get two levels of call (bcpl & whitespace) for each line, leading to some
seriously deep stacks in some cases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40384 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 06:29:05 +00:00
Chris Lattner bd24776a82 when running in -E mode on multiple files, there is no reason to accumulate
fileid's and macroid's across files.  Clearing between files keeps the tables
smaller and slightly speeds up compilation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40383 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 06:05:44 +00:00
Chris Lattner 95cfb85ad1 Catch goto's with a missing identifier, patch by Neil Booth.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40381 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 04:13:33 +00:00
Chris Lattner 9c68306275 Fix a really subtle bug in the macro expander caching code, where
redefinition of a macro could cause invalid memory to be deleted.
Found preprocessing 253.perlbmk.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40380 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 01:16:55 +00:00
Chris Lattner 8146b6851e Fix a lexer bug where we incorrectly rejected
int i = /*/ */ 1;

Thanks to Neil for pointing this out.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40379 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 23:43:37 +00:00
Steve Naroff 731ec57bd3 Minor simplification to Expr::isLvalue().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40375 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 13:32:03 +00:00
Chris Lattner d1623a8199 Add support for reusing macroid's with negative physical loc deltas. This
keeps the MacroInfo table more compact.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40281 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 06:41:57 +00:00
Chris Lattner aa4166c6c8 implement getSourceRange for ImplicitCast
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40264 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 06:32:11 +00:00
Chris Lattner 96f1a6403d Return an exit code of 1 if errors occur, not an exit code equal to the # errors :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40189 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:40:53 +00:00
Chris Lattner cb4f9a6d0b minor simplifications
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40176 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:33:26 +00:00
Chris Lattner 4fc37c5158 testcase from neil
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40173 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:32:22 +00:00
Chris Lattner 78c75fb3d2 recover from void argument types more nicely.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40169 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:30:18 +00:00
Chris Lattner 4565d4e83c better wording for an error, suggested by Neil.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40163 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:26:43 +00:00
Anders Carlsson 227426661b Implement code generation for __func__, __FUNCTION__ and __PRETTY_FUNCTION__
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40162 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:21:51 +00:00
Chris Lattner 2ff5426cd8 improve and simplify error recovery for calls, fix a crash when diagnosing
invalid arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40161 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:18:12 +00:00
Chris Lattner eddbe03075 fix a warning on some compilers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40139 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 04:57:45 +00:00
Chris Lattner a84538ea2b add an evil macro expansion perf test from Neil.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40138 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 04:54:14 +00:00
Chris Lattner d472b31d80 Fix off-by-one error when emitting diagnostics. Also, make diagnostic
a bit nicer for people who pass lots of extra arguments to calls by 
selecting them all instead of just the first one:

arg-duplicate.c:13:13: error: too many arguments to function
  f3 (1, 1, 2, 3, 4);   // expected-error {{too many arguments to function}}
            ^~~~~~~

This implements test/Sema/arg-duplicate.c, thanks to Neil for pointing
out this crash.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40136 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 03:09:58 +00:00
Chris Lattner 74c469fef4 move some casts up to the entry of the function for clarity.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40135 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 03:03:59 +00:00
Chris Lattner 0fa152e72b Two fixes:
1) fix a crash on test/Sema/default.c by making
   sure that the switch scope is non-null.
2) if there is an error sema'ing a default or case stmt,
   make sure to return the substmt up, so that the error
   recovery code has more acurate info to continue with.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40134 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 03:00:26 +00:00
Chris Lattner 942cfd3729 Fix a valgrind error noticed by Benoit Boissinot
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40113 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 18:48:28 +00:00
Chris Lattner 45011cf25e remove some old cruft
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40111 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 18:26:45 +00:00
Chris Lattner b1c2df99ba fix a nasty bug Owen noticed in a gcc warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40110 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 18:13:33 +00:00
Chris Lattner 31bb8be680 improve comments, implement a trivial single-entry cache in
SourceManager::getInstantiationLoc.  With this change, every token
expanded from a macro doesn't get its own MacroID.  :)

This reduces # macro IDs in carbon.h from 16805 to 9197



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40108 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 18:00:12 +00:00
Chris Lattner 60c3a1ba7a Update project for LexerToken.h -> Token.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40106 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 17:01:09 +00:00
Chris Lattner d217773f10 At one point there were going to be lexer and parser tokens.
Since that point is now long gone, we should rename LexerToken to
Token, as it is the only kind of token we have.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40105 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 16:59:19 +00:00
Chris Lattner 25bdb51276 simplify the lexer ctor to take a SLoc instead of a sloc and a redundant buffer*.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40104 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 16:52:03 +00:00
Chris Lattner 9dc1f530c0 Reimplement SourceLocation. Instead of having a
fileid/offset pair, it now contains a bit discriminating between
mapped locations and file locations.  This separates the tables for
macros and files in SourceManager, and allows better separation of
concepts in the rest of the compiler.  This allows us to have *many*
macro instantiations before running out of 'addressing space'.

This is also more efficient, because testing whether something is a
macro expansion is now a bit test instead of a table lookup (which
also used to require having a srcmgr around, now it doesn't).

This is fully functional, but there are several refinements and
optimizations left.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40103 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 16:37:10 +00:00
Chris Lattner 030d8846c7 implement size/alignment analysis for arrays and vectors. This gets carbon.h working again.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40068 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 22:06:24 +00:00
Steve Naroff aff1edd84a Finish fixing crasher with compound literals.
We still need to do sematic analysis (and implement initializers), however this 
should complete the parsing & ast building for compound literals.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40067 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 21:32:11 +00:00
Chris Lattner 2b64fdc499 Fix a stringizing bug that Neil noticed. We should preprocess this:
#define t(x) #x
t(a
c)

to "a c", not "ac".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40060 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 16:11:58 +00:00
Chris Lattner a87b63b492 silence a warning by treating ocuvectors the same as vectors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40037 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 05:13:51 +00:00
Steve Naroff 4aa88f8d84 Work towards fixing crasher with compound literals...
Before this commit, we crashed in ParseBinOp...

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c
SemaExpr.cpp:1298: failed assertion `(rhs != 0) && "ParseBinOp(): missing right expression"'

With this commit, we still crash in the newly added action ParseCompoundLiteral (which is progress:-)

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c
SemaExpr.cpp:478: failed assertion `(Op != 0) && "ParseCompoundLiteral(): missing expression"'

The crash go away once the actions return AST nodes. I will do this in a separate commit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40032 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 01:06:55 +00:00
Chris Lattner 5265af5b55 Fix a crasher that Neil reported: Sema::GetTypeForDeclarator should never
return a null type.  If there is an error parsing the type, pick a new type
for error recovery purposes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40029 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 00:42:40 +00:00
Chris Lattner 938867c6cf Make sure to initialize an ivar, patch by Benoit Boissinot.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40027 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 00:11:19 +00:00
Chris Lattner 0ea793e5e3 Correctly respect C99 5.1.1.2p4 when searching for the first '(' of
a function-like macro invocation.  Patch contributed by Neil Booth.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40026 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 00:07:36 +00:00
Chris Lattner 76e773a443 implement i-c-e correct evaluation for sizeof/alignof, remove some obsolete fixme's.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40012 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 18:38:36 +00:00
Chris Lattner 5d2a630346 implement sizeof/alignof support for structs, unions and complex.
This allows us to compile this:

struct abc { char A; double D; };

int foo() {
  return sizeof(struct abc);
  return __alignof__(struct abc);
}

Into:

        ret i32 16
        ret i32 8



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40010 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 18:26:58 +00:00
Chris Lattner 5e3fbe503a implement codegen support for sizeof/alignof
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40009 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 18:12:07 +00:00
Steve Naroff 7332292412 First round of extended vector support. Here is an overview...
- added ocu_vector_type attribute, Sema::HandleOCUVectorTypeAttribute(). 
- added new AST node, OCUVectorType, a subclass of VectorType.
- added ASTContext::getOCUVectorType.
- changed ASTContext::convertToVectorType() to ASTContext::getVectorType(). This is 
unrelated to extended vectors, however I was in the vicinity and it was on my todo list.
Added a FIXME to Sema::HandleVectorTypeAttribute to deal with converting complex types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40007 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-18 18:00:27 +00:00