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

110 Коммитов

Автор SHA1 Сообщение Дата
Eli Friedman a0978c2482 Fix for PR2386: distinguish between insertion and replacements in the
delta tree.

The issue is roughly a conflict in ReplaceText between two kinds of 
uses. One, it should be possible to replace a replacement: for example, the
ObjC rewriter calls ReplaceStmt for an expression, then replaces the resulting
expression with another expression.  Two, it should be possible to 
replace text that already has text inserted before it: for example, the 
HTML rewriter inserts a bunch of tags at the beginning of the line, then 
tries to escape the first character on the line.  This patch 
distinguishes the two cases by storing the deltas separately; 
essentially, replacements and insertions no longer interfere with 
each other.

Another possibility would be to add some sort of flag to ReplaceText, but
this seems a bit more intuitive and flexible.

There are a few downsides to the current solution: one is that there isn't
any way to remove/replace an insertion without touching additional
surrounding text; if such an operation turns out to be useful, an
additional method or flag can be added.  Another is that an insertion 
and replacing a string of length zero are distinct operations; I'm not 
sure how to resolve this, or whether it will be confusing in practice.

This is relatively sensitive code, so please test and tell me if 
anything breaks.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 13:56:52 +00:00
Chris Lattner 2c78b873f4 Change Lexer::MeasureTokenLength to take a LangOptions reference.
This allows it to accurately measure tokens, so that we get:

t.cpp:8:13: error: unknown type name 'X'
static foo::X  P;
       ~~~~~^

instead of the woefully inferior:

t.cpp:8:13: error: unknown type name 'X'
static foo::X  P;
       ~~~~ ^

Most of this is just plumbing to push the reference around.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 23:22:57 +00:00
Douglas Gregor a393e9eedc Build system changes to use TableGen to generate the various
diagnostics. This builds on the patch that Sebastian committed and
then revert. Major differences are:

  - We don't remove or use the current ".def" files. Instead, for now,
    we just make sure that we're building the ".inc" files.
  - Fixed CMake makefiles to run TableGen and build the ".inc" files
    when needed. Tested with both the Xcode and Makefile generators
    provided by CMake, so it should be solid.
  - Fixed normal makefiles to handle out-of-source builds that involve
    the ".inc" files.

I'll send a separate patch to the list with Sebastian's changes that
eliminate the use of the .def files.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67058 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 23:06:59 +00:00
Chris Lattner 7c175fb196 fix PR3798 by ignoring all diagnostics generated while repreprocessing a file in rewrite macros.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66961 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 21:44:46 +00:00
Ted Kremenek 2223622d11 Adjust HTML diagnostics CSS to not use "smaller" for font size and instead use
specific point sizes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66523 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 05:14:32 +00:00
Ted Kremenek 3c59823096 Tighten message bubble height.
Make bubble number decoration look more like circles than ovals.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65921 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-03 03:00:21 +00:00
Ted Kremenek 00f01e4405 Adjust CSS to make message bubble numbers less gaudy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65903 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 23:39:27 +00:00
Ted Kremenek 80bae763da Adjust HTML message bubbles to utilize information from PathDiagnosticPiece::Kind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65891 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 23:05:40 +00:00
Ted Kremenek 2f10398814 Update HTML diagnostics to honor the different between 'event' and 'control-flow' diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65877 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 21:42:01 +00:00
Douglas Gregor 4b2d3f7bcc Introduce code modification hints into the diagnostics system. When we
know how to recover from an error, we can attach a hint to the
diagnostic that states how to modify the code, which can be one of:

  - Insert some new code (a text string) at a particular source
    location
  - Remove the code within a given range
  - Replace the code within a given range with some new code (a text
    string)

Right now, we use these hints to annotate diagnostic information. For
example, if one uses the '>>' in a template argument in C++98, as in
this code:

  template<int I> class B { };
  B<1000 >> 2> *b1;

we'll warn that the behavior will change in C++0x. The fix is to
insert parenthese, so we use code insertion annotations to illustrate
where the parentheses go:

test.cpp:10:10: warning: use of right-shift operator ('>>') in template
argument will require parentheses in C++0x
  B<1000 >> 2> *b1;
         ^
    (        )


Use of these annotations is partially implemented for HTML
diagnostics, but it's not (yet) producing valid HTML, which may be
related to PR2386, so it has been #if 0'd out.

In this future, we could consider hooking this mechanism up to the
rewriter to actually try to fix these problems during compilation (or,
after a compilation whose only errors have fixes). For now, however, I
suggest that we use these code modification hints whenever we can, so
that we get better diagnostics now and will have better coverage when
we find better ways to use this information.

This also fixes PR3410 by placing the complaint about missing tokens
just after the previous token (rather than at the location of the next
token).




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65570 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 21:00:50 +00:00
Chris Lattner f0b26b1d9d Fix PR3635 by handling ## magically
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65374 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 05:29:33 +00:00
Chris Lattner e9e6cb93af simplify this code and make it use highlight range. This
makes -emit-html do nice things for code like:

#define FOO(X) y

int FOO(4
);

highlighting the FOO instance as well as the ) on the next line properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64710 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17 00:51:07 +00:00
Chris Lattner b7949a9a91 fix a fixme in -emit-html output: highlight the entire range of a macro
instantiation, which highlights the arguments of a function like macro
as well as its identifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64607 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 21:32:34 +00:00
Chris Lattner 05db4278ec Fix rdar://6562329, a static analyzer crash Ted noticed on
wine sources.  This was happening because HighlightMacros was 
calling EnterMainFile multiple times on the same preprocessor
object and getting an assert due to the new #line stuff (the
file in question was bison output with #line directives).

The fix for this is to not reenter the file.  Instead, 
relex the tokens in raw mode, swizzle them a bit and repreprocess
the token stream.  An added bonus of this is that rewrite macros
will now hilight the macro definition as well as its uses.  Woo.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 19:33:24 +00:00
Chris Lattner 867924dbec make "floating macro bubble" output of -emit-html much prettier:
only insert spaces between tokens if the code had them or if they 
are actually required to avoid pasting.  This reuses the same
logic as -E mode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64421 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 00:51:30 +00:00
Chris Lattner 52c2908128 rename getFullFilePos -> getFileOffset.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63097 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 06:27:13 +00:00
Chris Lattner 47246be8ac This change refactors some of the low-level lexer interfaces a bit.
Token now has a class of kinds for "literals", which include 
numeric constants, strings, etc.  These tokens can optionally have
a pointer to the start of the token in the lexer buffer.  This 
makes it faster to get spelling and do other gymnastics, because we
don't have to go through source locations.

This change is performance neutral, but will make other changes
more feasible down the road.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63028 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 19:29:26 +00:00
Chris Lattner de7aeefc55 Check in the long promised SourceLocation rewrite. This lays the
ground work for implementing #line, and fixes the "out of macro ID's" 
problem.

There is nothing particularly tricky about the code, other than the
very performance sensitive SourceManager::getFileID() method.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62978 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 00:43:02 +00:00
Chris Lattner a11d617933 Rename SourceManager::getCanonicalFileID -> getFileID. There is
no longer such thing as a non-canonical FileID.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 07:46:45 +00:00
Chris Lattner 025c3a6640 add a simplified lexer ctor that sets up the lexer to raw-lex an
entire file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62414 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 07:35:14 +00:00
Chris Lattner 2b2453a7d8 this massive patch introduces a simple new abstraction: it makes
"FileID" a concept that is now enforced by the compiler's type checker
instead of yet-another-random-unsigned floating around.

This is an important distinction from the "FileID" currently tracked by
SourceLocation.  *That* FileID may refer to the start of a file or to a
chunk within it.  The new FileID *only* refers to the file (and its 
#include stack and eventually #line data), it cannot refer to a chunk.

FileID is a completely opaque datatype to all clients, only SourceManager
is allowed to poke and prod it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62407 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 06:22:33 +00:00
Chris Lattner f7cf85b330 more SourceLocation lexicon change: instead of referring to the
"logical" location, refer to the "instantiation" location.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 07:36:28 +00:00
Oscar Fuentes d2f4e5ea6e CMake: Builds and installs clang binary and libs (no docs yet). It
must be under the `tools' subdirectory of the LLVM *source* tree.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58180 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-26 00:56:18 +00:00
Chris Lattner 99bd46c018 make the -rewrite-test a bit more interesting: it now
wraps comments in <i> tags.  Extend rewrite tokens to support
this minimal functionality.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57409 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 06:09:52 +00:00
Chris Lattner cff9cc95de start implementing a token rewriter. At this point, it just reads in a file
and lets a client iterate over it. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57407 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 05:44:03 +00:00
Chris Lattner 590f0cc643 Change how raw lexers are handled: instead of creating them and then
using LexRawToken, create one and use LexFromRawLexer.  This avoids
twiddling the RawLexer flag around and simplifies some code (even 
speeding raw lexing up a tiny bit).

This change also improves the token paster to use a Lexer on the stack
instead of new/deleting it. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57393 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 01:15:46 +00:00
Ted Kremenek 2c3352b5d1 Add #include (introduced by dependence on DeclGroup)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57274 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 23:08:39 +00:00
Chris Lattner b5cd09a2bf add a new Rewriter::getRewritenText method that returns the text for a range
that includes any edits in the range.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57037 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 23:31:16 +00:00
Zhongxing Xu 3f61c18dd7 Fixed an offset calculation error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56242 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-16 07:58:21 +00:00
Ted Kremenek a95d375044 Patch by Csaba Hruska!
"Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch
covers the AST library, but ignores Analysis lib."


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56185 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-13 05:16:45 +00:00
Ted Kremenek cc1b8532a1 Patch by Kovarththanan Rajaratnam!
"This minor patch adds markup of string literals with a red colour."


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55589 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-31 16:37:56 +00:00
Nico Weber 63366303f6 honor EscapeSpaces in 2nd overload of EscapeText()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54854 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-16 22:24:33 +00:00
Ted Kremenek 170db7c38d Add CSS for word wrapping of long message bubbles.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53492 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-11 23:13:22 +00:00
Ted Kremenek f6f593fae2 In a report-XXXXX.html, make the title include the name of the file with the bug. Patch by Jean-Daniel Dupas!
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-July/002166.html



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53184 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-07 18:31:05 +00:00
Chris Lattner 3d2e8c7b70 Fix rewrite rope to keep the leaf list up-to-date as it erases leaves
from the rope.  rdar://5952468


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51651 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-28 18:45:56 +00:00
Chris Lattner 54bd7cb491 add an assertion
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51645 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-28 16:35:02 +00:00
Chris Lattner 514b24cb53 fix a nasty off-by-one error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51519 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 23:29:33 +00:00
Chris Lattner 9ed7cfd351 fix an inconsistency computing offsets that caused a crash on rewrite-nest.m
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51514 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 23:06:56 +00:00
Chris Lattner b6403af3e6 Fix rdar://5919567: assertion failure: split didn't occur before erase!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50839 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-08 03:23:46 +00:00
Chris Lattner c66d0aa934 fix a rewriter crash on zero length files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50126 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-23 03:21:50 +00:00
Chris Lattner f3d8d19caf replace form feeds with an <hr> tag.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49975 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-19 23:56:30 +00:00
Ted Kremenek fb58609c5b Provide a version of html::HighlightMacros that takes a Preprocessor&.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49896 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 05:34:33 +00:00
Chris Lattner 5c176f7a9b Make tab insertion really right: the number of spaces inserted
depends on the column number of the start of the tab.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49891 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 04:54:20 +00:00
Ted Kremenek 38941b5b54 Use HTML5 doctype when generating HTML.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49888 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 03:37:38 +00:00
Ted Kremenek f501626052 Updated CSS colors. Patch by Cedric Venet!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49886 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 02:12:39 +00:00
Chris Lattner 9227c69534 Fix a problem noticed by Nuno, where we wouldn't escape characters in
macro expansions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49877 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 23:03:14 +00:00
Ted Kremenek 339b9c2775 class Preprocessor: Now owns the "predefines" char*; it deletes [] it in its dstor.
clang.cpp: InitializePreprocessor now makes a copy of the contents of PredefinesBuffer and
  passes it to the preprocessor object.
  
clang.cpp: DriverPreprocessorFactory now calls "InitializePreprocessor" instead of this being done in main().

html::HighlightMacros() now takes a PreprocessorFactory, allowing it to conjure up a new
Preprocessor to highlight macros.

class HTMLDiagnostics now takes a PreprocessorFactory* that it can use for html::HighlightMacros().
Updated clients of HTMLDiagnostics to use this new interface.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49875 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 22:31:54 +00:00
Chris Lattner dc5be47542 don't give macros a background
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49871 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 21:32:46 +00:00
Chris Lattner 8aa06aca8b Make sure popup is on top over other spans. wrap long line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49870 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 21:28:41 +00:00
Ted Kremenek 07339a63b4 Add support in HTML macro expansion for hovering over a macro and automatically
expanding its definition.  This is a pure CSS solution.

Tested on IE7, Firefox 3b4, and Safari 3.1.

Patch by Cedric Venet!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49865 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 19:57:27 +00:00