]> granicus.if.org Git - clang/log
clang
17 years agoForgot a return stmt (oops).
Steve Naroff [Thu, 26 Jul 2007 03:18:02 +0000 (03:18 +0000)]
Forgot a return stmt (oops).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40509 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoVarious improvements to Sema::ParseMemberReferenceExpr().
Steve Naroff [Thu, 26 Jul 2007 03:11:44 +0000 (03:11 +0000)]
Various improvements to Sema::ParseMemberReferenceExpr().

- Added source range support to Diag's.
- Used the new type predicate API to remove dealing with the canonical
type explicitly.
- Added Type::isRecordType().
- Removed some casts.
- Removed a const qualifier from RecordType::getDecl().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40508 91177308-0d34-0410-b5e6-96231b3b80d8

17 years ago- Fix commit in Parser.h (patch by Kevin Andre).
Steve Naroff [Wed, 25 Jul 2007 20:45:33 +0000 (20:45 +0000)]
- Fix commit in Parser.h (patch by Kevin Andre).
- Add comment and minor cleanup to yesterday's fix to ParseCallExpr().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40492 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix a couple of bugs, add some new cool stuff.
Chris Lattner [Wed, 25 Jul 2007 00:24:17 +0000 (00:24 +0000)]
Fix a couple of bugs, add some new cool stuff.

1. Fix a todo in Parser::ParseTag, to recover better.  On code like
   that in test/Sema/decl-invalid.c it causes us to return a single
   error instead of multiple.
2. Fix an error in Sema::ParseDeclarator, where it would crash if the
   declarator didn't have an identifier.  Instead, diagnose the problem.
3. Start adding infrastructure to track the range of locations covered
   by a declspec or declarator.  This is mostly implemented for declspec,
   but could be improved, it is missing for declarator.

Thanks to Neil for pointing out this crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40482 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix Sema::ParseCallExpr()...it wasn't doing the default array/function promotions...
Steve Naroff [Tue, 24 Jul 2007 21:46:40 +0000 (21:46 +0000)]
Fix Sema::ParseCallExpr()...it wasn't doing the default array/function promotions on it's argument types.

This resulted in the following errors when compiling promote_types_in_proto.c test...

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang test/Parser/promote_types_in_proto.c
test/Parser/promote_types_in_proto.c:7:24: error: incompatible types passing 'char *[]' to function expecting 'char *const []'
        arrayPromotion(argv);
        ~~~~~~~~~~~~~~ ^~~~
test/Parser/promote_types_in_proto.c:8:27: error: incompatible types passing 'void (char *const [])' to function expecting 'void (char *const [])'
        functionPromotion(arrayPromotion);
        ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~
2 diagnostics generated.

When fixing this, noticed that both ParseCallExpr() and ParseReturnStmt() were prematurely comparing types for
equivalence. This is incorrect (since the expr. promotions haven't been done yet). To fix this, I moved the
check "down" to Sema::CheckAssignmentConstraints().

I also converted Type::isArrayType() to the modern API (since I needed it). Still more Type predicates to
convert.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40475 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd documentation skeleton
Chris Lattner [Tue, 24 Jul 2007 18:03:18 +0000 (18:03 +0000)]
add documentation skeleton

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40471 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd a bare bones web page
Chris Lattner [Tue, 24 Jul 2007 17:59:54 +0000 (17:59 +0000)]
add a bare bones web page

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40470 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix a comment, patch by Kevin Andre!
Chris Lattner [Tue, 24 Jul 2007 17:03:04 +0000 (17:03 +0000)]
Fix a comment, patch by Kevin Andre!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40466 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement ast building and trivial semantic analysis of stmt exprs.
Chris Lattner [Tue, 24 Jul 2007 16:58:17 +0000 (16:58 +0000)]
implement ast building and trivial semantic analysis of stmt exprs.
This implements test/Sema/stmt_exprs.c

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40465 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoavoid std::string yet again.
Chris Lattner [Tue, 24 Jul 2007 06:59:01 +0000 (06:59 +0000)]
avoid std::string yet again.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40462 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoUse a smallstring instead of an std::string in FileChanged to avoid some malloc traffic.
Chris Lattner [Tue, 24 Jul 2007 06:57:14 +0000 (06:57 +0000)]
Use a smallstring instead of an std::string in FileChanged to avoid some malloc traffic.

This speeds up -E on xalancbmk by 2.4%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40461 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agocheck in an experiment that didn't work out, to allow for future investigation.
Chris Lattner [Tue, 24 Jul 2007 06:43:46 +0000 (06:43 +0000)]
check in an experiment that didn't work out, to allow for future investigation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40460 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd a cache to SourceManager to accellerate line # lookup. This is a
Chris Lattner [Tue, 24 Jul 2007 05:57:19 +0000 (05:57 +0000)]
Add a cache to SourceManager to accellerate line # lookup.  This is a
bottleneck for -E computation, because every token that starts a line needs
to determine *which* line it is on (so -E mode can insert the appropriate
vertical whitespace).  This optimization improves this common case where
it is striding through the line # table.

This speeds up -E on xalancbmk by 3.2%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40459 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix two paste-avoidance bugs I introduced last night. Patch
Chris Lattner [Mon, 23 Jul 2007 23:21:34 +0000 (23:21 +0000)]
Fix two paste-avoidance bugs I introduced last night.  Patch
by Neil Booth.  This fixes Preprocessor/output_paste_avoid.c

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40454 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agofix bogus warnings about potentially uninit vars Size and Align.
Chris Lattner [Mon, 23 Jul 2007 22:46:22 +0000 (22:46 +0000)]
fix bogus warnings about potentially uninit vars Size and Align.

Patch by Neil Booth!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40452 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix a scoping bug that apple gcc doesn't catch for some reason.
Chris Lattner [Mon, 23 Jul 2007 22:23:52 +0000 (22:23 +0000)]
Fix a scoping bug that apple gcc doesn't catch for some reason.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40450 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agocorrectly verify that default and case are in a switchstmt,
Chris Lattner [Mon, 23 Jul 2007 17:05:23 +0000 (17:05 +0000)]
correctly verify that default and case are in a switchstmt,
this fixes test/Sema/switch.c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40438 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoavoid creating std::strings in MoveToLine
Chris Lattner [Mon, 23 Jul 2007 06:31:11 +0000 (06:31 +0000)]
avoid creating std::strings in MoveToLine

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40424 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoIn OutputString, avoid calling memcpy for really tiny strings.
Chris Lattner [Mon, 23 Jul 2007 06:23:07 +0000 (06:23 +0000)]
In OutputString, avoid calling memcpy for really tiny strings.
This speeds up -E on 447.dealII by 5.8%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40423 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAvoid calling getSpelling at all for identifiers, which are
Chris Lattner [Mon, 23 Jul 2007 06:14:36 +0000 (06:14 +0000)]
Avoid calling getSpelling at all for identifiers, which are
trivial to handle and very very common.  This speeds up -E on
447.dealII by 2.5%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40422 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agochange the concatenation avoidance algorithm to be partially table-driven
Chris Lattner [Mon, 23 Jul 2007 06:09:34 +0000 (06:09 +0000)]
change the concatenation avoidance algorithm to be partially table-driven
and avoid computing the spelling of tokens when not needed.  This speeds
up -E on 447.dealII by 2.2%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40421 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoIf a token doesn't need cleaning, we can get its first character
Chris Lattner [Mon, 23 Jul 2007 05:18:42 +0000 (05:18 +0000)]
If a token doesn't need cleaning, we can get its first character
without having to get the whole token.  This speeds up -E on
447.dealII by 1.8%

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40420 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoA minor tweak to -E output, speeding up -E 1.5% on 447.dealII
Chris Lattner [Mon, 23 Jul 2007 05:14:05 +0000 (05:14 +0000)]
A minor tweak to -E output, speeding up -E 1.5% on 447.dealII

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40419 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoimplement a missing feature in the #include handler, where
Chris Lattner [Mon, 23 Jul 2007 04:56:47 +0000 (04:56 +0000)]
implement a missing feature in the #include handler, where
it did not handle <xyz> headers coming from macro expansions.
This requires special treatment, as the include name is lexed
as multiple tokens, which require reassembly before processing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40418 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agorefactor the interface to Preprocessor::GetIncludeFilenameSpelling,
Chris Lattner [Mon, 23 Jul 2007 04:15:27 +0000 (04:15 +0000)]
refactor the interface to Preprocessor::GetIncludeFilenameSpelling,
no functionality changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40414 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agofix a bug getting the spelling of an identifier token
Chris Lattner [Sun, 22 Jul 2007 22:50:09 +0000 (22:50 +0000)]
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

17 years agono need to avoid pasting >* It can't form ->*, because we know the previous
Chris Lattner [Sun, 22 Jul 2007 22:33:25 +0000 (22:33 +0000)]
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

17 years agoGCC doesn't set __STDC_VERSION__ usually. It never sets it in
Chris Lattner [Sun, 22 Jul 2007 22:11:35 +0000 (22:11 +0000)]
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

17 years agoSwitch TargetInfo::getTargetDefines from using an std::map<std::string, ...> to using
Chris Lattner [Sun, 22 Jul 2007 20:11:46 +0000 (20:11 +0000)]
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

17 years agoChange hte lexer to start a start pointer to the underlying
Chris Lattner [Sun, 22 Jul 2007 18:44:36 +0000 (18:44 +0000)]
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

17 years agosplit the slow path out of Lexer::getSourceLocation and do not let the
Chris Lattner [Sun, 22 Jul 2007 18:38:25 +0000 (18:38 +0000)]
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

17 years agoImplement a simple cache in headersearch. This speeds up
Chris Lattner [Sun, 22 Jul 2007 07:28:00 +0000 (07:28 +0000)]
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

17 years agoRefactor switch analysis to make it possible to detect duplicate case values
Anders Carlsson [Sun, 22 Jul 2007 07:07:56 +0000 (07:07 +0000)]
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

17 years agoremove redundant test
Chris Lattner [Sun, 22 Jul 2007 06:40:36 +0000 (06:40 +0000)]
remove redundant test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40386 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoavoid a small bit of string traffic by not storing the ""'s around a string in CurFil...
Chris Lattner [Sun, 22 Jul 2007 06:38:50 +0000 (06:38 +0000)]
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

17 years agoavoid recursion between SkipBCPLComment and SkipWhitespace. In cases like this:
Chris Lattner [Sun, 22 Jul 2007 06:29:05 +0000 (06:29 +0000)]
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

17 years agowhen running in -E mode on multiple files, there is no reason to accumulate
Chris Lattner [Sun, 22 Jul 2007 06:05:44 +0000 (06:05 +0000)]
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

17 years agoCatch goto's with a missing identifier, patch by Neil Booth.
Chris Lattner [Sun, 22 Jul 2007 04:13:33 +0000 (04:13 +0000)]
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

17 years agoFix a really subtle bug in the macro expander caching code, where
Chris Lattner [Sun, 22 Jul 2007 01:16:55 +0000 (01:16 +0000)]
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

17 years agoFix a lexer bug where we incorrectly rejected
Chris Lattner [Sat, 21 Jul 2007 23:43:37 +0000 (23:43 +0000)]
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

17 years agoMinor simplification to Expr::isLvalue().
Steve Naroff [Sat, 21 Jul 2007 13:32:03 +0000 (13:32 +0000)]
Minor simplification to Expr::isLvalue().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40375 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd support for reusing macroid's with negative physical loc deltas. This
Chris Lattner [Sat, 21 Jul 2007 06:41:57 +0000 (06:41 +0000)]
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

17 years agoimplement getSourceRange for ImplicitCast
Chris Lattner [Sat, 21 Jul 2007 06:32:11 +0000 (06:32 +0000)]
implement getSourceRange for ImplicitCast

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40264 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoReturn an exit code of 1 if errors occur, not an exit code equal to the # errors :)
Chris Lattner [Sat, 21 Jul 2007 05:40:53 +0000 (05:40 +0000)]
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

17 years agominor simplifications
Chris Lattner [Sat, 21 Jul 2007 05:33:26 +0000 (05:33 +0000)]
minor simplifications

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40176 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agotestcase from neil
Chris Lattner [Sat, 21 Jul 2007 05:32:22 +0000 (05:32 +0000)]
testcase from neil

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40173 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agorecover from void argument types more nicely.
Chris Lattner [Sat, 21 Jul 2007 05:30:18 +0000 (05:30 +0000)]
recover from void argument types more nicely.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40169 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agobetter wording for an error, suggested by Neil.
Chris Lattner [Sat, 21 Jul 2007 05:26:43 +0000 (05:26 +0000)]
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

17 years agoImplement code generation for __func__, __FUNCTION__ and __PRETTY_FUNCTION__
Anders Carlsson [Sat, 21 Jul 2007 05:21:51 +0000 (05:21 +0000)]
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

17 years agoimprove and simplify error recovery for calls, fix a crash when diagnosing
Chris Lattner [Sat, 21 Jul 2007 05:18:12 +0000 (05:18 +0000)]
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

17 years agofix a warning on some compilers
Chris Lattner [Sat, 21 Jul 2007 04:57:45 +0000 (04:57 +0000)]
fix a warning on some compilers

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40139 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd an evil macro expansion perf test from Neil.
Chris Lattner [Sat, 21 Jul 2007 04:54:14 +0000 (04:54 +0000)]
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

17 years agoFix off-by-one error when emitting diagnostics. Also, make diagnostic
Chris Lattner [Sat, 21 Jul 2007 03:09:58 +0000 (03:09 +0000)]
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

17 years agomove some casts up to the entry of the function for clarity.
Chris Lattner [Sat, 21 Jul 2007 03:03:59 +0000 (03:03 +0000)]
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

17 years agoTwo fixes:
Chris Lattner [Sat, 21 Jul 2007 03:00:26 +0000 (03:00 +0000)]
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

17 years agoFix a valgrind error noticed by Benoit Boissinot
Chris Lattner [Fri, 20 Jul 2007 18:48:28 +0000 (18:48 +0000)]
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

17 years agoremove some old cruft
Chris Lattner [Fri, 20 Jul 2007 18:26:45 +0000 (18:26 +0000)]
remove some old cruft

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40111 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agofix a nasty bug Owen noticed in a gcc warning.
Chris Lattner [Fri, 20 Jul 2007 18:13:33 +0000 (18:13 +0000)]
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

17 years agoimprove comments, implement a trivial single-entry cache in
Chris Lattner [Fri, 20 Jul 2007 18:00:12 +0000 (18:00 +0000)]
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

17 years agoUpdate project for LexerToken.h -> Token.h
Chris Lattner [Fri, 20 Jul 2007 17:01:09 +0000 (17:01 +0000)]
Update project for LexerToken.h -> Token.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40106 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAt one point there were going to be lexer and parser tokens.
Chris Lattner [Fri, 20 Jul 2007 16:59:19 +0000 (16:59 +0000)]
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

17 years agosimplify the lexer ctor to take a SLoc instead of a sloc and a redundant buffer*.
Chris Lattner [Fri, 20 Jul 2007 16:52:03 +0000 (16:52 +0000)]
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

17 years agoReimplement SourceLocation. Instead of having a
Chris Lattner [Fri, 20 Jul 2007 16:37:10 +0000 (16:37 +0000)]
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

17 years agoimplement size/alignment analysis for arrays and vectors. This gets carbon.h working...
Chris Lattner [Thu, 19 Jul 2007 22:06:24 +0000 (22:06 +0000)]
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

17 years agoFinish fixing crasher with compound literals.
Steve Naroff [Thu, 19 Jul 2007 21:32:11 +0000 (21:32 +0000)]
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

17 years agoFix a stringizing bug that Neil noticed. We should preprocess this:
Chris Lattner [Thu, 19 Jul 2007 16:11:58 +0000 (16:11 +0000)]
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

17 years agosilence a warning by treating ocuvectors the same as vectors.
Chris Lattner [Thu, 19 Jul 2007 05:13:51 +0000 (05:13 +0000)]
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

17 years agoWork towards fixing crasher with compound literals...
Steve Naroff [Thu, 19 Jul 2007 01:06:55 +0000 (01:06 +0000)]
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

17 years agoFix a crasher that Neil reported: Sema::GetTypeForDeclarator should never
Chris Lattner [Thu, 19 Jul 2007 00:42:40 +0000 (00:42 +0000)]
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

17 years agoMake sure to initialize an ivar, patch by Benoit Boissinot.
Chris Lattner [Thu, 19 Jul 2007 00:11:19 +0000 (00:11 +0000)]
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

17 years agoCorrectly respect C99 5.1.1.2p4 when searching for the first '(' of
Chris Lattner [Thu, 19 Jul 2007 00:07:36 +0000 (00:07 +0000)]
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

17 years agoimplement i-c-e correct evaluation for sizeof/alignof, remove some obsolete fixme's.
Chris Lattner [Wed, 18 Jul 2007 18:38:36 +0000 (18:38 +0000)]
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

17 years agoimplement sizeof/alignof support for structs, unions and complex.
Chris Lattner [Wed, 18 Jul 2007 18:26:58 +0000 (18:26 +0000)]
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

17 years agoimplement codegen support for sizeof/alignof
Chris Lattner [Wed, 18 Jul 2007 18:12:07 +0000 (18:12 +0000)]
implement codegen support for sizeof/alignof

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40009 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFirst round of extended vector support. Here is an overview...
Steve Naroff [Wed, 18 Jul 2007 18:00:27 +0000 (18:00 +0000)]
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

17 years agoinitial layout support for structures and unions. This isn't actually
Chris Lattner [Wed, 18 Jul 2007 17:52:12 +0000 (17:52 +0000)]
initial layout support for structures and unions.  This isn't actually
hooked up to anything, so it's not very useful yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40006 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd accessors
Chris Lattner [Wed, 18 Jul 2007 17:50:10 +0000 (17:50 +0000)]
add accessors

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40005 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoCast to void is valid, patch by Benoit Boissinot
Chris Lattner [Wed, 18 Jul 2007 16:00:06 +0000 (16:00 +0000)]
Cast to void is valid, patch by Benoit Boissinot

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40003 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoteach -stats about new types
Chris Lattner [Wed, 18 Jul 2007 05:50:59 +0000 (05:50 +0000)]
teach -stats about new types

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39996 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd a note Neil pointed out
Chris Lattner [Wed, 18 Jul 2007 05:21:20 +0000 (05:21 +0000)]
add a note Neil pointed out

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39994 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd initial switch stmt support, patch by Anders Carlsson!
Chris Lattner [Wed, 18 Jul 2007 02:28:47 +0000 (02:28 +0000)]
Add initial switch stmt support, patch by Anders Carlsson!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39989 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agostrtod is more portable than strtof apparently. Instead of making this conditional,
Chris Lattner [Tue, 17 Jul 2007 15:27:33 +0000 (15:27 +0000)]
strtod is more portable than strtof apparently.  Instead of making this conditional,
just always use strtod.  This is temporary code anyway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39972 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agocheap change to fix solaris compilation. I can make this a static inline if desired
Gabor Greif [Tue, 17 Jul 2007 11:05:49 +0000 (11:05 +0000)]
cheap change to fix solaris compilation. I can make this a static inline if desired

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39970 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoUse the correct method for getting the ReferenceType from a QualType.
Bill Wendling [Tue, 17 Jul 2007 05:09:22 +0000 (05:09 +0000)]
Use the correct method for getting the ReferenceType from a QualType.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39960 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoI forgot to check this in earlier
Chris Lattner [Tue, 17 Jul 2007 04:58:06 +0000 (04:58 +0000)]
I forgot to check this in earlier

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39958 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoReturn the correct type from isReferenceType().
Bill Wendling [Tue, 17 Jul 2007 04:47:36 +0000 (04:47 +0000)]
Return the correct type from isReferenceType().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39956 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoChange dyn_cast for reference types to be more like pointers and not need the canonic...
Bill Wendling [Tue, 17 Jul 2007 04:16:47 +0000 (04:16 +0000)]
Change dyn_cast for reference types to be more like pointers and not need the canonical type. Also fix so that we're not expecting a return value from a void function

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39954 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix references:
Bill Wendling [Tue, 17 Jul 2007 03:52:31 +0000 (03:52 +0000)]
Fix references:
    According to the spec (C++ 5p6[expr]), we need to adjust "T&" to
    "T" before further analysis. We do this via the "implicit cast"
    thingy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39953 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoConvert UsualArithmeticConversions to return "void". Now that we synthesize ImplicitC...
Steve Naroff [Tue, 17 Jul 2007 00:58:39 +0000 (00:58 +0000)]
Convert UsualArithmeticConversions to return "void". Now that we synthesize ImplicitCastExpr's,
there is no compelling need to return the converted type. If both expression type's are arithmetic, then
both types will always be the same. If they aren't (for pointer/int types, say), then the
types will be different. The client is responsible for distinguishing...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39947 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoImplement semantic analysis for the cast operator.
Steve Naroff [Mon, 16 Jul 2007 23:25:18 +0000 (23:25 +0000)]
Implement semantic analysis for the cast operator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39943 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoRemove the 2 QualType references to method UsualArithmeticConversions. Last week...
Steve Naroff [Mon, 16 Jul 2007 22:23:01 +0000 (22:23 +0000)]
Remove the 2 QualType references to method UsualArithmeticConversions. Last week, I added these
to quickly fix a regression. Avoiding them entirely is a much cleaner solution. Clients of
UsualArithmeticConversions should simply call getType() on the expression to get the
converted type. In practice, only a small number of routines care about this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39934 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoIn the final step for preserving typedef info better in the AST, upgrade
Chris Lattner [Mon, 16 Jul 2007 22:05:22 +0000 (22:05 +0000)]
In the final step for preserving typedef info better in the AST, upgrade
isPointerType and isVectorType to only look through a single level of typedef
when one is present.  For this invalid code:

typedef float float4 __attribute__((vector_size(16)));
typedef int int4 __attribute__((vector_size(16)));
typedef int4* int4p;
void test(float4 a, int4p result, int i) {
    result[i] = a;
}

we now get:

t.c:5:15: error: incompatible types assigning 'float4' to 'int4'
    result[i] = a;
    ~~~~~~~~~ ^ ~

instead of:

t.c:5:15: error: incompatible types assigning 'float4' to 'int  __attribute__((vector_size(16)))'
    result[i] = a;
    ~~~~~~~~~ ^ ~

The rest of the type predicates should be upgraded to do the same thing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39932 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoChange DefaultFunctionArrayConversions and UsualUnaryConversions to return void....
Steve Naroff [Mon, 16 Jul 2007 21:54:35 +0000 (21:54 +0000)]
Change DefaultFunctionArrayConversions and UsualUnaryConversions to return void. The caller
needs to query the expression for the type. Since both these functions guarantee the expression
contains a valid type, removed old/vacuous asserts (from code calling both of these routines).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39930 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoFix a GCC warning:
Chris Lattner [Mon, 16 Jul 2007 21:39:03 +0000 (21:39 +0000)]
Fix a GCC warning:
SemaExpr.cpp:561: warning: dereferencing type-punned pointer will break strict-aliasing rules

Patch by Benoit Boissinot!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39928 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoImplement break and continue. Patch by Anders Carlsson!
Chris Lattner [Mon, 16 Jul 2007 21:28:45 +0000 (21:28 +0000)]
Implement break and continue.  Patch by Anders Carlsson!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39927 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoavoid requiring people to update from llvm svn.
Chris Lattner [Mon, 16 Jul 2007 21:04:56 +0000 (21:04 +0000)]
avoid requiring people to update from llvm svn.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39925 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoConstify the is*Lvalue() methods.
Bill Wendling [Mon, 16 Jul 2007 07:07:56 +0000 (07:07 +0000)]
Constify the is*Lvalue() methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39907 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoMake octal constant lexing use AdvanceToTokenCharacter to give more
Chris Lattner [Mon, 16 Jul 2007 06:55:01 +0000 (06:55 +0000)]
Make octal constant lexing use AdvanceToTokenCharacter to give more
accurate diagnostics.  For test/Lexer/comments.c we now emit:

int x = 000000080;  /* expected-error {{invalid digit}} */
               ^
constants.c:7:4: error: invalid digit '8' in octal constant
00080;             /* expected-error {{invalid digit}} */
   ^

The last line is due to an escaped newline.  The full line looks like:

int y = 0000\
00080;             /* expected-error {{invalid digit}} */

Previously, we emitted:
constants.c:4:9: error: invalid digit '8' in octal constant
int x = 000000080;  /* expected-error {{invalid digit}} */
        ^
constants.c:6:9: error: invalid digit '8' in octal constant
int y = 0000\
        ^

which isn't too bad, but the new way is better for the user,
regardless of whether there is an escaped newline or not.

All the other lexer-related diagnostics should switch over
to using AdvanceToTokenCharacter where appropriate.  Help
wanted :).

This implements test/Lexer/constants.c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39906 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoAdd a new Preprocessor::AdvanceToTokenCharacter method which, given a sloc
Chris Lattner [Mon, 16 Jul 2007 06:48:38 +0000 (06:48 +0000)]
Add a new Preprocessor::AdvanceToTokenCharacter method which, given a sloc
specifying the start of a token and a logical (phase 3) character number,
returns a sloc representing the input character corresponding to it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39905 91177308-0d34-0410-b5e6-96231b3b80d8

17 years agoadd better comments.
Chris Lattner [Mon, 16 Jul 2007 06:46:50 +0000 (06:46 +0000)]
add better comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39904 91177308-0d34-0410-b5e6-96231b3b80d8