Commit Graph

79 Commits

Author SHA1 Message Date
Zhongxing Xu b562444cf8 adjust indentation.
llvm-svn: 79236
2009-08-17 14:13:14 +00:00
Ted Kremenek 6dec002981 Patch by Stefan Bühler: Escape text in macro expansion when emitting HTML in the HTMLRewriter.
This fixes PR 4602.

llvm-svn: 76647
2009-07-21 21:16:46 +00:00
Chris Lattner 184e65d363 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.

llvm-svn: 69099
2009-04-14 23:22:57 +00:00
Chris Lattner e07ea35817 fix PR3798 by ignoring all diagnostics generated while repreprocessing a file in rewrite macros.
llvm-svn: 66961
2009-03-13 21:44:46 +00:00
Ted Kremenek a039a62299 Adjust HTML diagnostics CSS to not use "smaller" for font size and instead use
specific point sizes.

llvm-svn: 66523
2009-03-10 05:14:32 +00:00
Ted Kremenek 6c6a098a83 Tighten message bubble height.
Make bubble number decoration look more like circles than ovals.

llvm-svn: 65921
2009-03-03 03:00:21 +00:00
Ted Kremenek ccca5c3f00 Adjust CSS to make message bubble numbers less gaudy.
llvm-svn: 65903
2009-03-02 23:39:27 +00:00
Ted Kremenek c62af6c4cf Adjust HTML message bubbles to utilize information from PathDiagnosticPiece::Kind.
llvm-svn: 65891
2009-03-02 23:05:40 +00:00
Ted Kremenek e780823fac Update HTML diagnostics to honor the different between 'event' and 'control-flow' diagnostics.
llvm-svn: 65877
2009-03-02 21:42:01 +00:00
Douglas Gregor 87f95b0a6a 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).

llvm-svn: 65570
2009-02-26 21:00:50 +00:00
Chris Lattner 59da739613 Fix PR3635 by handling ## magically
llvm-svn: 65374
2009-02-24 05:29:33 +00:00
Chris Lattner 8cad67b8a4 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.

llvm-svn: 64710
2009-02-17 00:51:07 +00:00
Chris Lattner 20cf43010a 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.

llvm-svn: 64607
2009-02-15 21:32:34 +00:00
Chris Lattner 9ef847be12 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.

llvm-svn: 64480
2009-02-13 19:33:24 +00:00
Chris Lattner 837b990c53 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.

llvm-svn: 64421
2009-02-13 00:51:30 +00:00
Chris Lattner c360bf2e48 rename getFullFilePos -> getFileOffset.
llvm-svn: 63097
2009-01-27 06:27:13 +00:00
Chris Lattner 4fa23625ab 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.

llvm-svn: 62978
2009-01-26 00:43:02 +00:00
Chris Lattner cbc35ecb04 Rename SourceManager::getCanonicalFileID -> getFileID. There is
no longer such thing as a non-canonical FileID.

llvm-svn: 62499
2009-01-19 07:46:45 +00:00
Chris Lattner 08354fef13 add a simplified lexer ctor that sets up the lexer to raw-lex an
entire file.

llvm-svn: 62414
2009-01-17 07:35:14 +00:00
Chris Lattner d32480d3db 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.

llvm-svn: 62407
2009-01-17 06:22:33 +00:00
Chris Lattner 8a42586c54 more SourceLocation lexicon change: instead of referring to the
"logical" location, refer to the "instantiation" location.

llvm-svn: 62316
2009-01-16 07:36:28 +00:00
Chris Lattner 50c9050037 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. 

llvm-svn: 57393
2008-10-12 01:15:46 +00:00
Ted Kremenek 2d470fc0ba 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."

llvm-svn: 56185
2008-09-13 05:16:45 +00:00
Ted Kremenek afe2a9fe77 Patch by Kovarththanan Rajaratnam!
"This minor patch adds markup of string literals with a red colour."

llvm-svn: 55589
2008-08-31 16:37:56 +00:00
Nico Weber 0b79bfe501 honor EscapeSpaces in 2nd overload of EscapeText()
llvm-svn: 54854
2008-08-16 22:24:33 +00:00
Ted Kremenek ba1196298a Add CSS for word wrapping of long message bubbles.
llvm-svn: 53492
2008-07-11 23:13:22 +00:00
Ted Kremenek 79ab0fa913 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

llvm-svn: 53184
2008-07-07 18:31:05 +00:00
Chris Lattner 1e517a78a8 replace form feeds with an <hr> tag.
llvm-svn: 49975
2008-04-19 23:56:30 +00:00
Ted Kremenek a960be4bd4 Provide a version of html::HighlightMacros that takes a Preprocessor&.
llvm-svn: 49896
2008-04-18 05:34:33 +00:00
Chris Lattner 4bbd164a7a Make tab insertion really right: the number of spaces inserted
depends on the column number of the start of the tab.

llvm-svn: 49891
2008-04-18 04:54:20 +00:00
Ted Kremenek a3d02636ef Use HTML5 doctype when generating HTML.
llvm-svn: 49888
2008-04-18 03:37:38 +00:00
Ted Kremenek a821e087de Updated CSS colors. Patch by Cedric Venet!
llvm-svn: 49886
2008-04-18 02:12:39 +00:00
Chris Lattner 54349c5f4d Fix a problem noticed by Nuno, where we wouldn't escape characters in
macro expansions.

llvm-svn: 49877
2008-04-17 23:03:14 +00:00
Ted Kremenek f42f3fb47d 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.

llvm-svn: 49875
2008-04-17 22:31:54 +00:00
Chris Lattner 6929bd8047 don't give macros a background
llvm-svn: 49871
2008-04-17 21:32:46 +00:00
Chris Lattner f219126107 Make sure popup is on top over other spans. wrap long line.
llvm-svn: 49870
2008-04-17 21:28:41 +00:00
Ted Kremenek c2c08caf9c 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!

llvm-svn: 49865
2008-04-17 19:57:27 +00:00
Chris Lattner f1c70d79b8 insert macro expansions into floating divs. For now, they are always displayed,
but we want some javascript or something toggle their display.

llvm-svn: 49836
2008-04-17 00:40:45 +00:00
Chris Lattner 775fdd3618 correctly hilight multi-line macro definitions and other
preprocessor directives.

llvm-svn: 49828
2008-04-16 23:21:17 +00:00
Chris Lattner 10dbbb0c5a Make HighlightRange correctly handle multi-line ranges. This causes us to
correctly handle multi-line comments.

llvm-svn: 49827
2008-04-16 23:06:45 +00:00
Chris Lattner 8e3006a4e3 add a new HighlightRange API, it doesn't handle multiline ranges
yet, but it will soon...

llvm-svn: 49825
2008-04-16 22:45:51 +00:00
Chris Lattner e9786c3199 reenable highlighting of (the first line of) comments
llvm-svn: 49816
2008-04-16 20:54:51 +00:00
Chris Lattner 0bb0e7ee8a switch from relexing with the preprocessor to do syntax highlighting to relexing
with the Lexer.  This is cheaper and gives us some advantages.  For now we start
highlighting preprocessor directives (which need improvement), and disable 
comments.  Comments to be restored later.

llvm-svn: 49815
2008-04-16 20:51:51 +00:00
Chris Lattner 03b8fcc247 Take a stab at highlighting #defines and #includes. This doesn't work yet.
llvm-svn: 49781
2008-04-16 06:53:09 +00:00
Chris Lattner 5e69a2dd9a Syntax highlight keywords. I assume someone else will pick less appaling colors.
llvm-svn: 49780
2008-04-16 06:35:07 +00:00
Chris Lattner a5a75e7a10 split syntax highlighting of macros from keywords and comments,
allowing us to use a cheaper means to highlight keywords and making
it so that comments won't foul up macro expansions.

Start highlighting macro expansions.

llvm-svn: 49779
2008-04-16 06:32:08 +00:00
Chris Lattner 060d8aa2ed Add a mode of hackily syntax highlighting comments. This has a number of
problems, including the fact that it doesn't work well with multi-line 
comments due to Ted's crazy table.  However, that could be fixed, and it
does work with single-line ones :).

llvm-svn: 49778
2008-04-16 06:11:58 +00:00
Chris Lattner c326f7e860 Switch AddLineNumbers to hack on a rewritebuffer instead of on a
rewriter, getting sourcelocations out of the picture.

llvm-svn: 49775
2008-04-16 04:37:29 +00:00
Chris Lattner e7d696ec7f In html::EscapeText, instead of going through the rewriter with
a SourceLocation to get a RewriteBuffer, poke the RewriteBuffer
with an offset directly.  THis is no faster, but results in 
cleaner code.

llvm-svn: 49774
2008-04-16 04:33:23 +00:00
Chris Lattner 05e5310ad8 switch AddLineNumber to use a SmallString instead of sstream. This
speeds up -emit-html on ted's testcase by 29% (.138 -> 0.107s) in a
release build.

llvm-svn: 49767
2008-04-16 04:11:35 +00:00