Commit Graph

131 Commits

Author SHA1 Message Date
Chris Lattner 16a0de468f Push the rewriting APIs along. Build a trivial client that replaces tabs
with x's for now.  The APIs are all unimplemented, so it doesn't do 
anything yet! :)

llvm-svn: 42868
2007-10-11 18:38:32 +00:00
Chris Lattner d2b8ce4259 avoid accessing off the end of identifiers.
llvm-svn: 42841
2007-10-10 20:59:57 +00:00
Chris Lattner ef6b136781 move IdentifierTable.h from liblex to libbasic.
llvm-svn: 42730
2007-10-07 08:58:51 +00:00
Chris Lattner b2d486a357 speed up clang startup another 28% by avoiding std::vector<std::string>
for holding builtin target-specific macros.

llvm-svn: 42689
2007-10-06 06:57:34 +00:00
Chris Lattner b5fc6fbcfc speed up clang startup time by about 23% by avoiding lots of
stringmap operations when there are no secondary targets.

llvm-svn: 42688
2007-10-06 06:29:41 +00:00
Chris Lattner c2d09cfe75 work around bugs and missing features in apfloat.
llvm-svn: 42235
2007-09-22 18:38:30 +00:00
Chris Lattner ec0a6d9be5 Use APFloat for the representation of FP immediates, ask the target
for *which* apfloat to use for a particular type.

llvm-svn: 42234
2007-09-22 18:29:59 +00:00
Hartmut Kaiser 0249104aa5 Removed clang solution file for VC++, which didn't work properly because of hard coded paths in the llvm project files.
Changed windows detection to use LLVM pp constant.

llvm-svn: 41878
2007-09-12 15:39:04 +00:00
Chris Lattner 542a440062 remove the FATAL classifier.
llvm-svn: 41736
2007-09-06 00:16:35 +00:00
Chris Lattner ff3fa8b624 VC++ doesn't define S_ISDIR
llvm-svn: 41688
2007-09-03 18:37:14 +00:00
Chris Lattner cd1e8d2c9d Add #ifdefs to make the source portable to windows. Patch contributed
by Hartmut Kaiser!

llvm-svn: 41684
2007-09-03 18:24:56 +00:00
Chris Lattner 257fa2ae22 constify a method.
llvm-svn: 41600
2007-08-30 05:59:30 +00:00
Chris Lattner 6a340b4351 Fix a bug in my previous commit
llvm-svn: 40719
2007-08-02 04:22:39 +00:00
Chris Lattner 04e3d20a51 Increase the macro id cache to look up several recent entries, not just the last one.
This is important in insane cases like the one dannyb sent me recently:

#define F0(a) void a(){}
#define F1(a) F0(a##0) F0(a##1) F0(a##2) F0(a##3) F0(a##4) F0(a##5) F0(a##6) F0(a##7)
#define F2(a) F1(a##0) F1(a##1) F1(a##2) F1(a##3) F1(a##4) F1(a##5) F1(a##6) F1(a##7)
#define F3(a) F2(a##0) F2(a##1) F2(a##2) F2(a##3) F2(a##4) F2(a##5) F2(a##6) F2(a##7)
#define F4(a) F3(a##0) F3(a##1) F3(a##2) F3(a##3) F3(a##4) F3(a##5) F3(a##6) F3(a##7)
#define F5(a) F4(a##0) F4(a##1) F4(a##2) F4(a##3) F4(a##4) F4(a##5) F4(a##6) F4(a##7)
#define F6(a) F5(a##0) F5(a##1) F5(a##2) F5(a##3) F5(a##4) F5(a##5) F5(a##6) F5(a##7)
F6(f)

cpp is great.  :)

llvm-svn: 40715
2007-08-02 03:55:37 +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 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 2e380893e3 Add support for reusing macroid's with negative physical loc deltas. This
keeps the MacroInfo table more compact.

llvm-svn: 40281
2007-07-21 06:41:57 +00:00
Chris Lattner e60b21c0b5 remove some old cruft
llvm-svn: 40111
2007-07-20 18:26:45 +00:00
Chris Lattner ca8ebc095b 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

llvm-svn: 40108
2007-07-20 18:00:12 +00:00
Chris Lattner dc5c055fd1 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.

llvm-svn: 40103
2007-07-20 16:37:10 +00:00
Chris Lattner bb1b44f004 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.

llvm-svn: 39906
2007-07-16 06:55:01 +00:00
Chris Lattner 3fc74e2468 Change SourceManager::getInstantiationLoc to take virtual locations, doing its
virtual->physical mapping explicitly.

llvm-svn: 39867
2007-07-15 06:35:27 +00:00
Chris Lattner 4481b428db A significant refactoring of the type size stuff to also
compute type alignment.  This info is needed for struct layout.

llvm-svn: 39850
2007-07-14 01:29:45 +00:00
Gabor Greif ffc337b1e1 add missing header
(needed on Solaris)

llvm-svn: 39781
2007-07-12 16:00:00 +00:00
Chris Lattner f033c147c9 remove location tracking for target info
llvm-svn: 39671
2007-06-22 19:05:19 +00:00
Chris Lattner 23b7eb677d Finally bite the bullet and make the major change: split the clang namespace
out of the llvm namespace.  This makes the clang namespace be a sibling of
llvm instead of being a child.

The good thing about this is that it makes many things unambiguous.  The
bad things is that many things in the llvm namespace (notably data structures
like smallvector) now require an llvm:: qualifier.  IMO, libsystem and libsupport
should be split out of llvm into their own namespace in the future, which will fix
this issue.

llvm-svn: 39659
2007-06-15 23:05:46 +00:00
Bill Wendling 314ae547a1 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Added a method "IgnoreDiagnostic" so that the diagnostic client can
  tell the diagnostic object that it doesn't want to handle a particular
  diagnostic message. In which case, it won't be counted as either a
  diagnostic or error.

llvm-svn: 39641
2007-06-10 04:13:42 +00:00
Bill Wendling 344b92e993 Submitted by: Bill Wendling
- Say! why don't we increment the NumDiagnostics variable too?

llvm-svn: 39616
2007-06-08 19:21:50 +00:00
Bill Wendling da0c8a9641 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Make the counting of errors and diagnostic messages sane. Place them into the
  Diagnostic class instead of in the DiagnosticClient class.

llvm-svn: 39615
2007-06-08 19:17:38 +00:00
Chris Lattner c49b9051f4 track whether an error has been emitted.
llvm-svn: 39502
2007-05-28 00:46:44 +00:00
Chris Lattner beeb9bc51d improve const correctness
llvm-svn: 39460
2007-05-19 08:07:42 +00:00
Steve Naroff 71ce2e061d Bug #:
Submitted by:
Reviewed by:
An important, but truly mind numbing change.

Added 6 flavors of Sema::Diag() that take 1 or two SourceRanges. Considered
adding 3 flavors (using default args), however this wasn't as clear.

Removed 2 flavors of Sema::Diag() that took LexerToken's (they weren't used).

Changed all the typechecking routines to pass the appropriate range(s).

Hacked the diagnostic machinery and driver to acccommodate the new data.

What's left? A FIXME in clang.c to use the ranges. Chris offered to do the
honors:-) Which includes taking us to the end of an identifier:-)

llvm-svn: 39456
2007-05-18 22:53:50 +00:00
Chris Lattner 36982e4367 Add support for inserting up to 10 strings in a diagnostic, with %0, %1, %2,
etc.

llvm-svn: 39447
2007-05-16 17:49:37 +00:00
Chris Lattner 776050e9a5 Adjust to change in MemoryBuffer interface
llvm-svn: 39434
2007-05-06 23:34:12 +00:00
Chris Lattner 739e739b81 Remove the clang::SourceBuffer class, switch to the llvm::MemoryBuffer class.
llvm-svn: 39426
2007-04-29 07:12:06 +00:00
Chris Lattner e92976d8ee Refactor the SourceBuffer code so that it is safe to move to the LLVM
support library, where it can be used by other LLVM clients.  There are
some ugly fixme's in the short-term.

llvm-svn: 39425
2007-04-29 06:44:41 +00:00
Chris Lattner 35f9985817 minor cleanups
llvm-svn: 39424
2007-04-29 06:08:57 +00:00
Chris Lattner 34d1f5a8de adjust to CStringMap interface change.
llvm-svn: 39333
2007-02-08 19:08:49 +00:00
Chris Lattner 720f576f8d Optimize #define analysis for the common case of a single target.
llvm-svn: 39331
2007-01-30 06:01:31 +00:00
Chris Lattner 10a5b387cc Add support for target-specific builtins, including detecting nonportability
of source code.  For example:

$ clang INPUTS/carbon_h.c -arch i386 -arch ppc
prints:
...
/usr/lib/gcc/i686-apple-darwin8/4.0.1/include/mmintrin.h:51:3: note: use of a target-specific builtin function, source is not 'portable'
  __builtin_ia32_emms ();
  ^

because carbon.h pulls in xmmintrin.h, and __builtin_ia32_emms isn't a builtin on ppc.

Though clang now supports target-specific builtins, the full table isn't implemented yet.

llvm-svn: 39328
2007-01-29 05:24:35 +00:00
Chris Lattner 69c7ee2d51 allow getTokenName to work for keywords.
llvm-svn: 39243
2006-12-04 07:45:05 +00:00
Chris Lattner cf6bc66421 silence some warnings when asserts are disabled.
llvm-svn: 39127
2006-11-05 07:59:08 +00:00
Chris Lattner 9c59bdace4 simplify logic, eliminate a copy of string data.
llvm-svn: 39086
2006-10-30 04:34:28 +00:00
Chris Lattner 2f4a89a5e8 Switch the FileManager::FileEntries map over to using a CStringMap. This
speeds up preprocessing Cocoa.h 16% (from 0.99 to 0.85s).

llvm-svn: 39085
2006-10-30 03:55:17 +00:00
Chris Lattner 43fd42e4d9 Wean LookupSubframeworkHeader off std::strings, use the new SmallString
class instead.  SmallString allows to code to avoid hitting malloc in
the normal case (or will, when some other stuff is converted over).

llvm-svn: 39084
2006-10-30 03:40:58 +00:00
Chris Lattner a85cbe28a0 Avoid storing a directory name in both the DirEntries map keys and in the
UniqueDirs value.  Instead, just have the UniqueDirs value contain a pointer
to the key in the DirEntries map.

llvm-svn: 39083
2006-10-30 03:11:40 +00:00
Chris Lattner af65375944 Switch DirEntries over to using a CStringMap. This speeds it up
'clang -Eonly INPUTS/Cocoa_h.m' by about 4%.

llvm-svn: 39082
2006-10-30 03:06:54 +00:00
Chris Lattner 8b1e848a04 Avoid some mallocs, and avoid leaking some memory, by making the
UniqueDirs/UniqueFiles maps own the memory for the FileEntry and DirEntries.

llvm-svn: 39081
2006-10-30 02:45:16 +00:00
Chris Lattner 480434865d change FileEntry::getName to return a const char*.
llvm-svn: 39065
2006-10-27 05:12:36 +00:00
Chris Lattner 05646c7f0e Fix these to allow clang to be in any dir.
llvm-svn: 39055
2006-10-26 04:56:55 +00:00
Chris Lattner b19f796e97 llvm has no EH by default, no need for these flags.
llvm-svn: 39047
2006-10-25 05:09:05 +00:00
Chris Lattner 2a904d0aba Add assertions for out-of-fileid error case
llvm-svn: 39028
2006-10-22 06:33:42 +00:00
Chris Lattner 0b9bdd9a74 Use read to open small files so we don't run out of file descriptors as easily.
llvm-svn: 39027
2006-10-20 06:53:51 +00:00
Chris Lattner 2194ddc83d Add new TargetInfo hooks for getting the set of target-specific #defines.
llvm-svn: 38979
2006-10-14 18:32:26 +00:00
Chris Lattner 1e27fe165c Add new TargetInfo class to clang.
llvm-svn: 38971
2006-10-14 07:06:20 +00:00
Chris Lattner 051df7bfc4 Make this work with llvm cvs
llvm-svn: 38952
2006-08-27 07:12:21 +00:00
Chris Lattner 7fa8c889e2 Add a single-entry cache for macro instantation locations. This significantly
reduces the number of FileID's made and tracked.

llvm-svn: 38752
2006-07-20 06:48:52 +00:00
Chris Lattner 81500bc3ae cleanups, add some code for instrumenting stat
llvm-svn: 38728
2006-07-19 03:40:07 +00:00
Chris Lattner 351050bcf5 Add a check that the physloc for a macro instantiation is not another macro.
llvm-svn: 38722
2006-07-16 18:05:08 +00:00
Chris Lattner ae41157ee5 Implement support for arbitrarily mapping non-error diagnostics to be either
ignored, warned about, or error'd.  Use this to implement the -Wunused_macros
command line option.

llvm-svn: 38676
2006-07-05 00:55:08 +00:00
Chris Lattner d3a15f7f4e Add a fast-path in getSpelling for identifiers.
llvm-svn: 38672
2006-07-04 23:01:03 +00:00
Chris Lattner d5da3ea58d This matters for -E.
llvm-svn: 38664
2006-07-04 21:11:41 +00:00
Chris Lattner 040a4ab71e Compile without rtti or exceptions.
llvm-svn: 38629
2006-07-03 05:01:42 +00:00
Chris Lattner a85a9d2db3 Tolerate conditions where there is no line #
llvm-svn: 38604
2006-07-02 20:07:52 +00:00
Chris Lattner 4c37a8c353 Eliminate SourceManager::createFileIDForMacroExp, inlining it into its single use.
llvm-svn: 38599
2006-06-30 06:15:08 +00:00
Chris Lattner 7d6a4f6746 Expose a useful helper method.
llvm-svn: 38596
2006-06-30 06:10:08 +00:00
Chris Lattner 2dffd2b445 Factor logical line lookup better.
llvm-svn: 38594
2006-06-29 16:44:08 +00:00
Chris Lattner dc9f9bf80e Due to generated tokens expanded by macros, there can be multiple MacroExpansion fileid's, loop over them until we get to something real.
llvm-svn: 38590
2006-06-29 06:33:42 +00:00
Chris Lattner ec43eaf07a Add a new SourceBuffer::getNewMemBuffer method.
llvm-svn: 38587
2006-06-28 06:35:31 +00:00
Chris Lattner f6fd68add5 Fix Preprocessor/macro_expandloc2.c
llvm-svn: 38579
2006-06-26 01:48:23 +00:00
Chris Lattner 685730f964 To not treat macro invocation locations as part of the include stack
when reporting a diagnostic.

llvm-svn: 38577
2006-06-26 01:36:22 +00:00
Chris Lattner 269c232e67 implement #pragma GCC dependency
llvm-svn: 38574
2006-06-25 06:23:00 +00:00
Chris Lattner 9a13bde643 Implement a new SourceManager::getSourceName method
llvm-svn: 38560
2006-06-21 04:57:09 +00:00
Chris Lattner bb893c3d67 Update SourceManager::getLineNumber to return the correct line # for macro
instantiations.

llvm-svn: 38558
2006-06-21 03:27:29 +00:00
Chris Lattner 30709b038d Implement a new type of FileID: FileIDInfo::MacroExpansion. For tokens that
came from a macro expansion, this allows us to keep track of both where the
character data came from and where the logical position of the token is (at
the expansion site).  This implements Preprocessor/indent_macro.c, and
reduces the number of cpp iostream -E diffs vs GCC from 2589 to 2297.

llvm-svn: 38557
2006-06-21 03:01:55 +00:00
Chris Lattner 5f4b1ff9fd Modify SourceManager to make way for future macro locations and #line support
no functionality change yet

llvm-svn: 38556
2006-06-20 05:02:40 +00:00
Chris Lattner d01e291332 Make a fundamental change to the way we represent the location of LexerToken's.
Now, instead of keeping a pointer to the start of the token in memory, we keep the
start of the token as a SourceLocation node.  This means that each LexerToken knows
the full include stack it was created with, and means that the LexerToken isn't
reliant on a "CurLexer" member to be around (lexer tokens would previously go out of
scope when their lexers were deallocated).

This simplifies several things, and forces good cleanup elsewhere.  Now the
Preprocessor is the one that knows how to dump tokens/macros and is the one that
knows how to get the spelling of a token (it has all the context).

llvm-svn: 38551
2006-06-18 16:22:51 +00:00
Chris Lattner cb28334ea4 Remove manual conditional error handling code.
llvm-svn: 38540
2006-06-18 06:48:37 +00:00
Chris Lattner 22eb972f38 Initial checkin of c-language parser
llvm-svn: 38539
2006-06-18 05:43:12 +00:00