Index: clang/include/clang/Rewrite/Core/HTMLRewrite.h
===================================================================
--- clang/include/clang/Rewrite/Core/HTMLRewrite.h
+++ clang/include/clang/Rewrite/Core/HTMLRewrite.h
@@ -15,6 +15,7 @@
#define LLVM_CLANG_REWRITE_CORE_HTMLREWRITE_H
#include "clang/Basic/SourceLocation.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
#include
namespace clang {
@@ -23,6 +24,8 @@
class RewriteBuffer;
class Preprocessor;
+namespace ento {
+
namespace html {
/// HighlightRange - Highlight a range in the source code with the specified
@@ -65,6 +68,12 @@
void AddHeaderFooterInternalBuiltinCSS(Rewriter &R, FileID FID,
StringRef title);
+ /// AddPopUpNotes - Relex the specified FileID and annotate the HTML with
+ /// pop-up notes (hidden by default, show on mouse-hover event).
+ /// It adds information to given variables similar to 'HighlightMacros()'.
+ void AddPopUpNotes(Rewriter &R, FileID FID, const Preprocessor &PP,
+ const PathPieces &Path);
+
/// SyntaxHighlight - Relex the specified FileID and annotate the HTML with
/// information about keywords, comments, etc.
void SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP);
@@ -76,6 +85,7 @@
void HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP);
} // end html namespace
+} // end ento namespace
} // end clang namespace
#endif
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -365,7 +365,7 @@
class PathDiagnosticPiece: public llvm::FoldingSetNode {
public:
- enum Kind { ControlFlow, Event, Macro, Call, Note };
+ enum Kind { ControlFlow, Event, Macro, Call, Note, PopUp };
enum DisplayHint { Above, Below };
private:
@@ -480,7 +480,7 @@
static bool classof(const PathDiagnosticPiece *P) {
return P->getKind() == Event || P->getKind() == Macro ||
- P->getKind() == Note;
+ P->getKind() == Note || P->getKind() == PopUp;
}
};
@@ -744,7 +744,7 @@
class PathDiagnosticNotePiece: public PathDiagnosticSpotPiece {
public:
PathDiagnosticNotePiece(const PathDiagnosticLocation &Pos, StringRef S,
- bool AddPosRange = true)
+ bool AddPosRange = true)
: PathDiagnosticSpotPiece(Pos, S, Note, AddPosRange) {}
~PathDiagnosticNotePiece() override;
@@ -757,6 +757,22 @@
void Profile(llvm::FoldingSetNodeID &ID) const override;
};
+class PathDiagnosticPopUpPiece: public PathDiagnosticSpotPiece {
+public:
+ PathDiagnosticPopUpPiece(const PathDiagnosticLocation &Pos, StringRef S,
+ bool AddPosRange = true)
+ : PathDiagnosticSpotPiece(Pos, S, PopUp, AddPosRange) {}
+ ~PathDiagnosticPopUpPiece() override;
+
+ static bool classof(const PathDiagnosticPiece *P) {
+ return P->getKind() == PopUp;
+ }
+
+ void dump() const override;
+
+ void Profile(llvm::FoldingSetNodeID &ID) const override;
+};
+
/// File IDs mapped to sets of line numbers.
using FilesToLineNumsMap = std::map>;
Index: clang/lib/Frontend/Rewrite/HTMLPrint.cpp
===================================================================
--- clang/lib/Frontend/Rewrite/HTMLPrint.cpp
+++ clang/lib/Frontend/Rewrite/HTMLPrint.cpp
@@ -21,7 +21,10 @@
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Rewrite/Frontend/ASTConsumers.h"
#include "llvm/Support/raw_ostream.h"
+
using namespace clang;
+using namespace ento;
+
//===----------------------------------------------------------------------===//
// Functional HTML pretty-printing.
Index: clang/lib/Rewrite/HTMLRewrite.cpp
===================================================================
--- clang/lib/Rewrite/HTMLRewrite.cpp
+++ clang/lib/Rewrite/HTMLRewrite.cpp
@@ -21,7 +21,9 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include
+
using namespace clang;
+using namespace ento;
/// HighlightRange - Highlight a range in the source code with the specified
@@ -306,11 +308,15 @@
.keyword { color: blue }
.string_literal { color: red }
.directive { color: darkmagenta }
-/* Macro expansions. */
-.expansion { display: none; }
-.macro:hover .expansion {
+
+/* Macros and variables could have pop-up notes hidden by default.
+ - Macro pop-up: expansion of the macro (by 'HighlightMacros()').
+ - Variable pop-up: value of the variable (by 'AddPopUpNotes()') */
+.macro_popup, .variable_popup { display: none; }
+
+/* Pop-up appears on mouse-hover event */
+.macro:hover .macro_popup, .variable:hover .variable_popup {
display: block;
- border: 2px solid #FF0000;
padding: 2px;
background-color:#FFF0F0;
font-weight: normal;
@@ -323,6 +329,15 @@
left:10em;
z-index: 1
}
+.macro_popup { border: 2px solid red; }
+.variable_popup { border: 2px solid blue; }
+
+/* Pop-up notes needs a relative position as a base where they pops up. */
+.macro, .variable {
+ background-color: PaleGoldenRod;
+ position: relative;
+}
+.macro { color: DarkMagenta; }
#tooltiphint {
position: fixed;
@@ -336,12 +351,6 @@
background-color: #c0c0c0;
z-index: 2;
}
-.macro {
- color: darkmagenta;
- background-color:LemonChiffon;
- /* Macros are position: relative to provide base for expansions. */
- position: relative;
-}
.num { width:2.5em; padding-right:2ex; background-color:#eeeeee }
.num { text-align:right; font-size:8pt }
@@ -419,6 +428,62 @@
R.InsertTextAfter(EndLoc, "