Commit Graph

1380 Commits

Author SHA1 Message Date
Chris Lattner c6684bc0c5 Add a start at a clang internals manual, documenting some
of the more subtle and interesting classes.

llvm-svn: 40615
2007-07-31 05:42:17 +00:00
Chris Lattner bcb22a9c8d add a link
llvm-svn: 40614
2007-07-31 04:52:37 +00:00
Chris Lattner fedeaa3045 Don't use canonical type for sema here. In
void func() {
typedef int foo;
foo *Y;
**Y; // error
}

we now get:
indirection requires pointer operand ('foo' invalid)
instead of:
indirection requires pointer operand ('int' invalid)

llvm-svn: 40597
2007-07-30 18:53:26 +00:00
Steve Naroff 2dc379a7ae Upgrade a comment...
llvm-svn: 40585
2007-07-30 03:52:55 +00:00
Steve Naroff 0d595ca0bb Finish up semantic analysis for vector components.
llvm-svn: 40584
2007-07-30 03:29:09 +00:00
Steve Naroff ddf5a1d7a6 Implement pretty diagnostics when doing on-the-fly vector sizing (for vector component access).
For example, before this commit, the following diagnostics would be emitted...

ocu.c:49:12: error: incompatible types assigning 'float  __attribute__((ocu_vector_type(3)))' to 'float4'
    vec4_2 = vec4.rgb; // shorten
    ~~~~~~ ^ ~~~~~~~~
ocu.c:51:7: error: incompatible types assigning 'float  __attribute__((ocu_vector_type(2)))' to 'float'
    f = vec2.xx; // shorten
    ~ ^ ~~~~~~~

Now, the diagnostics look as you would expect...

ocu.c:49:12: error: incompatible types assigning 'float3' to 'float4'
    vec4_2 = vec4.rgb; // shorten
    ~~~~~~ ^ ~~~~~~~~
ocu.c:51:7: error: incompatible types assigning 'float2' to 'float'
    f = vec2.xx; // shorten
    ~ ^ ~~~~~~~

llvm-svn: 40579
2007-07-29 16:33:31 +00:00
Steve Naroff f7a5da17d9 Added a new expression, OCUVectorComponent.
llvm-svn: 40577
2007-07-28 23:10:27 +00:00
Steve Naroff f8fd09e22b Implement syntax/semantic analysis for OCU Vector Components.
Next step, AST support...

llvm-svn: 40568
2007-07-27 22:15:19 +00:00
Steve Naroff c701ace221 Add Type::isOCUVectorType().
Convert isFunctionType(), isStructureType(), and isUnionType() to the new API.

llvm-svn: 40541
2007-07-26 18:32:01 +00:00
Steve Naroff 49ab97761b Fix the following bogus diagnostic...reported by Jeroen.
#include <stdio.h>

int
main(void) {
        int test = 0;

        printf("Type is %s\n", (test >= 1 ? "short" : "char"));

        return (0);
}

It comes up with a diagnostic that's misleading upon first read.

t.c:7:36: error: incompatible operand types ('char *' and 'char *')
        printf("Type is %s\n", (test >= 1 ? "short" : "char"));
                                          ^ ~~~~~~~   ~~~~~~
1 diagnostic generated.

llvm-svn: 40526
2007-07-26 14:35:56 +00:00
Chris Lattner b50f1e4103 add another link.
llvm-svn: 40512
2007-07-26 06:11:49 +00:00
Chris Lattner 626246e93c don't expect to be able to reparse arbitrary system headers.
llvm-svn: 40511
2007-07-26 05:59:05 +00:00
Steve Naroff 62b35d41cd Forgot a return stmt (oops).
llvm-svn: 40509
2007-07-26 03:18:02 +00:00
Steve Naroff 185616f293 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(). 

llvm-svn: 40508
2007-07-26 03:11:44 +00:00
Steve Naroff b8af1c2bf6 - Fix commit in Parser.h (patch by Kevin Andre).
- Add comment and minor cleanup to yesterday's fix to ParseCallExpr().

llvm-svn: 40492
2007-07-25 20:45:33 +00:00
Chris Lattner 02c0439a44 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.

llvm-svn: 40482
2007-07-25 00:24:17 +00:00
Steve Naroff 44fd8ff400 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.

llvm-svn: 40475
2007-07-24 21:46:40 +00:00
Chris Lattner 0443a76b11 add documentation skeleton
llvm-svn: 40471
2007-07-24 18:03:18 +00:00
Chris Lattner b3aee6e87f add a bare bones web page
llvm-svn: 40470
2007-07-24 17:59:54 +00:00
Chris Lattner 01e4b243c9 Fix a comment, patch by Kevin Andre!
llvm-svn: 40466
2007-07-24 17:03:04 +00:00
Chris Lattner 366727fca1 implement ast building and trivial semantic analysis of stmt exprs.
This implements test/Sema/stmt_exprs.c

llvm-svn: 40465
2007-07-24 16:58:17 +00:00
Chris Lattner 1af0e0116a avoid std::string yet again.
llvm-svn: 40462
2007-07-24 06:59:01 +00:00
Chris Lattner 4c4a245475 Use a smallstring instead of an std::string in FileChanged to avoid some malloc traffic.
This speeds up -E on xalancbmk by 2.4%

llvm-svn: 40461
2007-07-24 06:57:14 +00:00
Chris Lattner 830a77fd65 check in an experiment that didn't work out, to allow for future investigation.
llvm-svn: 40460
2007-07-24 06:43:46 +00:00
Chris Lattner 8996ffffe5 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%

llvm-svn: 40459
2007-07-24 05:57:19 +00:00
Chris Lattner d63c8a5963 Fix two paste-avoidance bugs I introduced last night. Patch
by Neil Booth.  This fixes Preprocessor/output_paste_avoid.c

llvm-svn: 40454
2007-07-23 23:21:34 +00:00
Chris Lattner 49a953ab13 fix bogus warnings about potentially uninit vars Size and Align.
Patch by Neil Booth!

llvm-svn: 40452
2007-07-23 22:46:22 +00:00
Chris Lattner f97dbcb4ba Fix a scoping bug that apple gcc doesn't catch for some reason.
llvm-svn: 40450
2007-07-23 22:23:52 +00:00
Chris Lattner 54f4d2bd57 correctly verify that default and case are in a switchstmt,
this fixes test/Sema/switch.c.

llvm-svn: 40438
2007-07-23 17:05:23 +00:00
Chris Lattner 5cdfebbf10 avoid creating std::strings in MoveToLine
llvm-svn: 40424
2007-07-23 06:31:11 +00:00
Chris Lattner 93c4ea75ec In OutputString, avoid calling memcpy for really tiny strings.
This speeds up -E on 447.dealII by 5.8%

llvm-svn: 40423
2007-07-23 06:23:07 +00:00
Chris Lattner 0af9823e4d 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%

llvm-svn: 40422
2007-07-23 06:14:36 +00:00
Chris Lattner 4418ce1091 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%

llvm-svn: 40421
2007-07-23 06:09:34 +00:00
Chris Lattner e4c566c604 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%

llvm-svn: 40420
2007-07-23 05:18:42 +00:00
Chris Lattner 5f075827bf A minor tweak to -E output, speeding up -E 1.5% on 447.dealII
llvm-svn: 40419
2007-07-23 05:14:05 +00:00
Chris Lattner 43eafb4ed5 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.

llvm-svn: 40418
2007-07-23 04:56:47 +00:00
Chris Lattner 93ab9f134e refactor the interface to Preprocessor::GetIncludeFilenameSpelling,
no functionality changes.

llvm-svn: 40414
2007-07-23 04:15:27 +00:00
Chris Lattner 32e6d64176 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.

llvm-svn: 40410
2007-07-22 22:50:09 +00:00
Chris Lattner 7dd7a1d310 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.

llvm-svn: 40409
2007-07-22 22:33:25 +00:00
Chris Lattner d956fcac86 GCC doesn't set __STDC_VERSION__ usually. It never sets it in
C++ mode, even gnu C++ mode.

llvm-svn: 40408
2007-07-22 22:11:35 +00:00
Chris Lattner a81b336ba8 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%.

llvm-svn: 40396
2007-07-22 20:11:46 +00:00
Chris Lattner 5d1c02748f 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%

llvm-svn: 40394
2007-07-22 18:44:36 +00:00
Chris Lattner 619c174561 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%

llvm-svn: 40393
2007-07-22 18:38:25 +00:00
Chris Lattner d427542a9b 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)

llvm-svn: 40390
2007-07-22 07:28:00 +00:00
Anders Carlsson 51873c22d8 Refactor switch analysis to make it possible to detect duplicate case values
llvm-svn: 40388
2007-07-22 07:07:56 +00:00
Chris Lattner 9c691703ce remove redundant test
llvm-svn: 40386
2007-07-22 06:40:36 +00:00
Chris Lattner 9b7962495f avoid a small bit of string traffic by not storing the ""'s around a string in CurFilename
llvm-svn: 40385
2007-07-22 06:38:50 +00:00
Chris Lattner b9b8597c23 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.

llvm-svn: 40384
2007-07-22 06:29:05 +00:00
Chris Lattner 6b4db176ea 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.

llvm-svn: 40383
2007-07-22 06:05:44 +00:00
Chris Lattner e34b2c298a Catch goto's with a missing identifier, patch by Neil Booth.
llvm-svn: 40381
2007-07-22 04:13:33 +00:00