├── .gitignore ├── BUGS ├── COMMANDS ├── FEATURES ├── LICENSE ├── MACRO ├── NOTES ├── README.md ├── SEO ├── VALIDATOR ├── server ├── .gitignore ├── Makefile ├── db │ ├── binarysymbols.go │ ├── binarysymbols_test.go │ ├── common.go │ ├── strings.go │ ├── tagset.go │ └── tree.go ├── http.go ├── http_test.go ├── main.go ├── scripts │ ├── create-random-metrics.sh │ ├── metric-get-offset.sh │ ├── metric-list.sh │ ├── symbol-search.sh │ └── test.sh ├── structs │ ├── json.go │ └── structs.go └── templates │ ├── .gitignore │ ├── about.qtpl │ ├── about.qtpl.go │ ├── base.qtpl │ ├── base.qtpl.go │ ├── css.qtpl │ ├── css.qtpl.go │ ├── directory.qtpl │ ├── directory.qtpl.go │ ├── globals.js.qtpl │ ├── globals.js.qtpl.go │ ├── help.qtpl │ ├── help.qtpl.go │ ├── javascript.qtpl │ ├── javascript.qtpl.go │ ├── navbar.qtpl │ ├── navbar.qtpl.go │ ├── source.qtpl │ ├── source.qtpl.go │ ├── symbol.qtpl │ └── symbol.qtpl.go ├── sitemap ├── .gitignore ├── Makefile └── main.go ├── src ├── .depend ├── Makefile ├── ast.cc ├── ast.h ├── base.h ├── cache.cc ├── cache.h ├── cindex.h ├── common.cc ├── common.h ├── counters.cc ├── counters.h ├── indexer.cc ├── indexer.h ├── json-helpers.h ├── mempool.cc ├── mempool.h ├── pp-tracker.cc ├── pp-tracker.h ├── printer.h ├── renderer.cc ├── renderer.h ├── rewriter.cc ├── rewriter.h ├── sbexr.cc ├── wrapping.cc └── wrapping.h ├── static ├── animated-modal │ ├── LICENSE │ ├── animate.min.css │ └── animatedModal.js ├── bootstrap │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── bootstrap.min.css.map │ │ └── dropdowns-enhancement.min.css │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── dropdowns-enhancement.js │ │ └── npm.js ├── font-awesome │ ├── css │ │ ├── font-awesome.css │ │ └── font-awesome.min.css │ └── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 ├── graphs │ ├── d3.v4.min.js │ ├── metricsgraphics.css │ ├── metricsgraphics.js │ └── metricsgraphics.min.js ├── jquery.autocomplete.js ├── jquery.autocomplete.min.js ├── jquery.min.js ├── js.cookie.js ├── local.js ├── metrics.css ├── metrics.html ├── metrics.js ├── news.json └── style.css ├── test ├── .gitignore ├── Makefile ├── README ├── include-all.h ├── metrics │ ├── bear-build-rss-00000001.data │ ├── bear-build-rss-00000001.labels │ ├── bear-build-time-00000001.data │ ├── bear-build-time-00000001.labels │ ├── sbexr-run-rss-00000001.data │ ├── sbexr-run-rss-00000001.labels │ ├── sbexr-run-time-00000001.data │ └── sbexr-run-time-00000001.labels ├── output │ ├── index.output.files.json │ ├── index.output.symbols.json │ ├── sources │ │ ├── 11 │ │ │ └── d2796f2851903a.jhtml │ │ ├── 19 │ │ │ └── 901c5d9478e5ce.jhtml │ │ ├── 23 │ │ │ └── 32e20e89ff3dae.jhtml │ │ ├── 24 │ │ │ └── f5ced826dbe9a5.jhtml │ │ ├── 29 │ │ │ └── 15508da39cdcce.jhtml │ │ ├── 41 │ │ │ └── e28fc1cdef774c.jhtml │ │ ├── 44 │ │ │ ├── 7afd378fb9bef7.jhtml │ │ │ └── abbd7f05c3bb64.jhtml │ │ ├── 50 │ │ │ └── 6c0d28222dde39.jhtml │ │ ├── 57 │ │ │ └── 27d4eb0ac27416.jhtml │ │ ├── 60 │ │ │ └── 7abc7e1c17ae25.jhtml │ │ ├── 67 │ │ │ └── 481f5ed307a09b.jhtml │ │ ├── 77 │ │ │ └── 97ec9572248ea4.jhtml │ │ ├── 81 │ │ │ ├── 3a8befd5338881.png │ │ │ └── d9c49f99af3d0a.jhtml │ │ ├── 83 │ │ │ └── 9c78609ba8228b.jhtml │ │ ├── 91 │ │ │ ├── 38a7b144866997.jhtml │ │ │ └── 8bbaed7fe58735.jhtml │ │ ├── 92 │ │ │ └── 0259119a2aa95d.jhtml │ │ ├── 97 │ │ │ └── 537cbc7aefc4ad.jhtml │ │ ├── 00 │ │ │ └── eb21e8e066d2fe.jhtml │ │ ├── 06 │ │ │ └── 416cc91f3e3d90.jhtml │ │ ├── 08 │ │ │ └── 80fafb6e566ce0.jhtml │ │ ├── 0a │ │ │ └── 9de303fcf49f53.jhtml │ │ ├── 0c │ │ │ └── a8a47b0c4f7800.jhtml │ │ ├── 0d │ │ │ └── 97c98f8e7f311c.jhtml │ │ ├── 2b │ │ │ └── f7ba919473f734.jhtml │ │ ├── 6a │ │ │ ├── 77ce5d776029cb.jhtml │ │ │ └── d3db15bf642751.jhtml │ │ ├── 6b │ │ │ └── 0d1083ea424d53.jhtml │ │ ├── 6f │ │ │ └── 078dbcc264af74.jhtml │ │ ├── 7c │ │ │ └── 1572fe148af43d.jhtml │ │ ├── a2 │ │ │ └── d30e2ef9ad247b.jhtml │ │ ├── a3 │ │ │ └── 5161b30e4c9c85.jhtml │ │ ├── b2 │ │ │ └── 5867ddc3014e6a.jhtml │ │ ├── b4 │ │ │ └── 1f7b6f8bf83afb.jhtml │ │ ├── b9 │ │ │ └── 1a03c8e3d833c6.jhtml │ │ ├── bc │ │ │ └── 764de7984141e0.jhtml │ │ ├── be │ │ │ ├── b21853bfd529ee.jhtml │ │ │ └── e2916b98dcf1fc.jhtml │ │ ├── c6 │ │ │ └── 5145c887253142.jhtml │ │ ├── c8 │ │ │ └── b5fc81b5bf752b.jhtml │ │ ├── c9 │ │ │ └── 859e7aa7cc3530.jhtml │ │ ├── cf │ │ │ └── 341b97b05a5692.jhtml │ │ ├── d2 │ │ │ ├── b0f1e1540e4279.jhtml │ │ │ └── c60e58c28f84da.jhtml │ │ ├── de │ │ │ └── 54dd5925795da2.jhtml │ │ ├── e0 │ │ │ └── 389d8d16166a86.jhtml │ │ ├── e1 │ │ │ └── 6f60ab16e47e49.jhtml │ │ ├── e5 │ │ │ └── 66fd4ef5cee94a.jhtml │ │ ├── f0 │ │ │ └── 212845f8a256c3.jhtml │ │ ├── f9 │ │ │ └── 72a0e406b846b3.jhtml │ │ ├── fa │ │ │ └── 0a0d3d8e7cc07c.jhtml │ │ ├── fc │ │ │ └── dade3d7f7bb00d.jhtml │ │ ├── fd │ │ │ ├── abf26b4f65020a.jhtml │ │ │ └── cacc45a9906e85.jhtml │ │ └── meta │ │ │ ├── counters.json │ │ │ ├── globals.json │ │ │ └── index.jhtml │ └── validator.report ├── static ├── tags ├── templates ├── test-clang.html ├── test-multiple-file-0.cc ├── test-multiple-file-0.h ├── test-multiple-file-1.cc ├── test-multiple-file-1.h ├── test-single-file.c ├── test-single-file.h ├── test.html ├── test2-clang.htm └── tux.png ├── utils ├── .gitignore ├── Makefile ├── kernel └── publish └── validator ├── .gitignore ├── Makefile └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | start 3 | massif* 4 | ast 5 | rewriter 6 | sbexr 7 | output/sources 8 | libs/*.o 9 | compile_commands.json 10 | .*.swp 11 | .*.swo 12 | output/*.json 13 | output/tree.txt 14 | output/globals.js 15 | indexes/ 16 | examples/ 17 | static/news.json 18 | src/tags 19 | backup/ 20 | run/ 21 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | SBEXR PARSING 2 | ============= 3 | 4 | - scanner should skip some files, like .swp files from vim. 5 | 6 | - in typedef, the target type should be linked to its definition. 7 | 8 | - weird types should link back to their definition. 9 | 10 | - add metadata in the file indicating how it was rendered. Eg, full indexing, 11 | or partial. 12 | 13 | - // WHEN CLICKING ON A LINK, if points with the same page, 14 | // IF POINTS WITHIN THE SAME WINDOW, do not change scrolling. 15 | // Rather, just highlight the target. 16 | 17 | - when passed the --scan=false flag, root directory entry is not generated, although 18 | it probably exists in memory (it has a hash!) 19 | 20 | - names in all-symbols.json... don't have namespace identifier. They should! 21 | namespace is important. 22 | 23 | - pinctrl-palmas.c:354, problem: 24 | - There is a macro that defines a list of elements, like: 25 | # define ELEMENTS \ 26 | DECLARE_ELEMENT(foo) \ 27 | DECLARE_ELEMENT(bar) 28 | 29 | And in different places, we have things like: 30 | 31 | 32 | enum { 33 | # undef DECLARE_ELEMENT 34 | # define DECLARE_ELEMENT(value) EnumConstant##value 35 | }; 36 | 37 | End result: all those symbols, eg, EnumConstantfoo, EnumConstantbar, 38 | have exactly the same source line/column and expansion line/column 39 | 40 | 41 | in global-symbols database: 42 | 43 | - all entries that have no name that I manually verified were 44 | prototype definitions, eg, things like: 45 | 46 | atoi(const char*); 47 | ^^^^^^^^^^^-> declaration has no name!! 48 | 49 | plan: in the database, provide not only the name, but the type of the 50 | declaration. and then the context. 51 | 52 | in this case: 53 | 54 | context: atoi(const char*) 55 | type: const char* 56 | name: "" 57 | 58 | kernel handler: 59 | 60 | ================== 61 | When there is something like: 62 | 63 | struct sk_buff *skb, *tmp_skb; 64 | 65 | struct sk_buff is surrounded by span and a twice, creating nested a links. 66 | 67 | RENDERING - JAVSACRIPT / server 68 | ====================== 69 | - In firefox, clicking on the same link covers the text highlighted under the search bar, 70 | making the interface almost unusable! 71 | 72 | - server could do a bit of a better job at redirecting to the right places without 73 | too much effort. Eg, when entering partial links manually. 74 | 75 | 76 | -------------------------------------------------------------------------------- /COMMANDS: -------------------------------------------------------------------------------- 1 | sg network "git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git" 2 | sg network "git pull" 3 | 4 | make mrproper 5 | make allmodconfig 6 | make -j4 all 7 | 8 | -------------------------------------------------------------------------------- /FEATURES: -------------------------------------------------------------------------------- 1 | LXR: 2 | 3 | problems: 4 | 5 | - "defined in file ..." 6 | considers forward declarations as well 7 | as real definitions. 8 | 9 | - variable links 10 | find all variables with the same name 11 | does not understand scoping 12 | 13 | 14 | important features: 15 | 16 | - understand scope of variables. 17 | Specifically: 18 | - function variables, show where that variable is used. 19 | - struct attributes, show where that struct attribute is used. 20 | - global variables, show where those globals are used. 21 | 22 | - understand function pointers use and invocation. 23 | Given a function pointer, is able to tell where that is invoked. 24 | Or given a function pointer, is able to tell which functions it 25 | may invoke. 26 | 27 | - distinguishes between forward declarations and not. 28 | 29 | - understands macros. 30 | 31 | - can tell where a variable is modified. 32 | 33 | - syntax coloring. 34 | - cut and paste without line numbers getting in the way. 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are 26 | those of the authors and should not be interpreted as representing official 27 | policies, either expressed or implied, of Carlo Contavalli. 28 | -------------------------------------------------------------------------------- /MACRO: -------------------------------------------------------------------------------- 1 | #define FOO(a, b) printf("test " ## a, b) 2 | 3 | void test(int a, b) { 4 | FOO("%d", a); 5 | FOO("%d", b); 6 | } 7 | 8 | In the AST, I will see: 9 | - call expression 10 | - parameter defined 11 | 12 | In terms of features: 13 | - user should see what hides under FOO - there should be a way to get the final expanded code 14 | - user should be able to go see the definition of FOO 15 | - index should track correctly the dependency of the source code on FOO, and the dependencies the macro is bringing in (printf, in the example) 16 | 17 | Proposal: 18 | - hijack macro use - turn that into a link to the macro itself. 19 | - when AST appears in the macro - silence the addition of links or wrapping, but still add them to the index. 20 | 21 | Unsolved: 22 | - showing the expanded macro in the code there. 23 | 24 | APIs 25 | ==== 26 | - pp-tracker is invoked when a macro is defined, and when a macro expands. Can track dependencies across macros. 27 | - a SourceLocation, can be turned into a FID, which in turn can be looked up in the source manager via getSLocEntry, which in turn returns a SrcMgr::SLocEntry, which is either a macro expansion (isExpansion()) or a file (isFile), and returns either an ExpansionInfo or a FileInfo. SourceLocation immediately returns isMacroID or isFileID. 28 | 29 | - maybe querying the lexer for the text in between a sourcerange will just work? see https://stackoverflow.com/questions/11083066/getting-the-source-behind-clangs-ast 30 | 31 | -------------------------------------------------------------------------------- /NOTES: -------------------------------------------------------------------------------- 1 | Find library containing symbol: 2 | 3 | cd /usr/lib/llvm-3.9/lib 4 | for file in `find . -type f -name '*.so' -o -name '*.a'`; do objdump -C -t "$file" |grep -v UND |grep clang::RewriteBuffer::write && echo "====== $file"; done; 5 | 6 | $ clang-3.8 -Xclang -ast-dump -fsyntax-only ./test.c |less -r 7 | 8 | Use: 9 | 10 | twitter typeahead.js instead of devbridge autocomplete plugin. 11 | twitter typeahead.js is unmaintained, consider corejavascript/typeahead.js instead. 12 | 13 | grantlee 14 | ctpp 15 | libwt 16 | libctemplate2 17 | libctemplate3 18 | 19 | indexes: 20 | 21 | go get github.com/google/codesearch/cmd/... 22 | + regex search. 23 | + index is about 100 Mb. 24 | - requires access to the original source files. 25 | - it's in the form of a tool, needs to be turned into a library 26 | 27 | 28 | SCORING 29 | ======= 30 | - # of uses or references? 31 | - # of files that include header or definition? 32 | 33 | 34 | FUNCTION 35 | ======== 36 | - "link to body" 37 | 38 | - Comments on top 39 | - Prototype 40 | 41 | - link to body 42 | 43 | - Callers 44 | - Callees 45 | 46 | - is it called under lock? 47 | does it lock any resource? 48 | 49 | - link to indexed files that contain the function name. 50 | 51 | 52 | TYPE 53 | ==== 54 | - "link to body" 55 | 56 | - if complex type, comment. 57 | - where it comes from 58 | (eg, typedefs, auto, ...) 59 | - which functions modify it, with some context. (at least, top functions) 60 | (private, protected, public) 61 | 62 | - which functions take it, with some context. 63 | 64 | - inheritance 65 | 66 | FOR FUNCTION POINTERS: 67 | ===================== 68 | - which functions implement that interface? 69 | - which functions are assigned to that field? 70 | 71 | 72 | 73 | 74 | ========== 75 | Each token / declaration / ... has a Location. 76 | 77 | Each location, has a place where the characters there have been typed. This is the SpellingLocation. 78 | 79 | Additionally, there is a location where this code is effectively running. This is the ExpansionLocation. 80 | 81 | Example: 82 | # define FOO extern "C" { 83 | # define BAR }; 84 | 85 | 86 | FOO // ORIGINAL LOCATION AND EXPANSION LOCATION 87 | test 88 | BAR // ORIGINAL LOCAITON AND EXPANSION LOCATION 89 | 90 | ==== SEARCH PRIORITIZATION 91 | 92 | - local symbols (eg, same file and include unit as currently viewed file?) 93 | 94 | - perfect matches first (or matches with fewest extra characters?) 95 | - prefer most used functions 96 | -------------------------------------------------------------------------------- /SEO: -------------------------------------------------------------------------------- 1 | Add meta tags: 2 | https://support.google.com/webmasters/answer/79812?hl=en 3 | 4 | DONE Add breadcrumbs: 5 | https://developers.google.com/search/docs/data-types/breadcrumbs 6 | 7 | DONE Create sitemap: 8 | - USE XML, and specified time / date modified 9 | https://developers.google.com/search/docs/guides/create-URLs 10 | https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190 11 | 12 | Create list of functions? 13 | - https://developers.google.com/search/docs/guides/mark-up-listings 14 | 15 | Add searchbox directly? 16 | - https://developers.google.com/search/docs/guides/enhance-site#add-a-sitelinks-searchbox-for-your-site 17 | 18 | DONE Mark with structured data? 19 | - https://schema.org/SoftwareSourceCode 20 | 21 | Mark with facebook opengraph? 22 | - http://ogp.me/ 23 | 24 | Search examples: 25 | https://github.com/google/search-samples/ 26 | 27 | -------------------------------------------------------------------------------- /VALIDATOR: -------------------------------------------------------------------------------- 1 | - all href are valid. [DONE] 2 | - no weird nesting of tags 3 | - opening / closing tag should match [DONE] 4 | - no nesting of tag [DONE] 5 | - no consecutive equivalent tags 6 | 7 | - #ifdef / #ifndef at start of file, should not be obscured, ever. 8 | - statistics on files fully parsed vs tokenized. 9 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | server 2 | testindex 3 | tags 4 | -------------------------------------------------------------------------------- /server/Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: update-templates 3 | 4 | all: update-templates 5 | go build 6 | 7 | update-templates: 8 | cd templates && ~/gopath/bin/qtc 9 | 10 | test-index: 11 | make -C ../src VERBOSE= test-gen 12 | 13 | test-run: test test-index all 14 | ./server --metrics=../test/metrics --web-root=../test --index-dir=../test/indexes --listen=:10000 15 | 16 | test: test-index all 17 | go test 18 | cd db && go test 19 | 20 | clean: 21 | rm -f server 22 | 23 | format: 24 | go fmt 25 | cd db && go fmt 26 | cd structs && go fmt 27 | 28 | -------------------------------------------------------------------------------- /server/db/binarysymbols_test.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "bytes" 5 | "github.com/stretchr/testify/assert" 6 | "testing" 7 | ) 8 | 9 | /* 10 | func TestOutputAscii(t *testing.T) { 11 | for i := 0; i <= 127; i++ { 12 | fmt.Printf("0x%02x, ", int(bytes.ToLower([]byte{byte(i)})[0])) 13 | } 14 | for i := 128; i <= 255; i++ { 15 | fmt.Printf("0x%02x, ", i) 16 | } 17 | }*/ 18 | 19 | func TestCaseContains(t *testing.T) { 20 | assert := assert.New(t) 21 | 22 | assert.False(CaseContains([]byte(""), []byte("foo"))) 23 | assert.False(CaseContains([]byte("f"), []byte("foo"))) 24 | assert.False(CaseContains([]byte("fo"), []byte("foo"))) 25 | assert.True(CaseContains([]byte("foo"), []byte("foo"))) 26 | assert.True(CaseContains([]byte(" foo"), []byte("foo"))) 27 | assert.True(CaseContains([]byte("foo "), []byte("foo"))) 28 | assert.True(CaseContains([]byte(" foo "), []byte("foo"))) 29 | assert.False(CaseContains([]byte(" fofo "), []byte("foo"))) 30 | assert.True(CaseContains([]byte(" fofoo "), []byte("foo"))) 31 | 32 | assert.True(CaseContains([]byte("foobar"), []byte("foo"))) 33 | assert.False(CaseContains([]byte("foobar"), []byte("blah"))) 34 | assert.True(CaseContains([]byte("foobar"), []byte("bar"))) 35 | assert.True(CaseContains([]byte("bababarba"), []byte("bar"))) 36 | } 37 | 38 | var sentences [][]byte = [][]byte{ 39 | []byte("Daric mohock unautomatic palpitant diptych. Order divisiveness shanghaiing monochromatism mongo. Alberti bolyai flintiness ronco eternalized."), 40 | []byte("Personating specialising inigo emasculator nitrogenise. Traceries periodicalist frustrate tye palaearctic. Culch penetrometer ballpark biformity unloosed."), 41 | []byte("Sigmate hemagogue hardwall flatulently interparliamentary. Impetuosity defiling gownsman malpractice saunciest. Overexuberance maundy tunic ploce topsail."), 42 | []byte("Francisco instigatingly unveridical convenances crabeater. Unextruded petrolatum repellingly unspelled denature. Recarrying unbinned asphaltic microfarad subadministrative."), 43 | []byte("Alkalinization rsa lea infamousness venturer. Liberalised parchisi dividable covertly unhedged. Robot unsectionalized riparian rooty asset."), 44 | } 45 | var words [][]byte = [][]byte{ 46 | []byte(""), 47 | []byte("z"), 48 | []byte("be"), 49 | []byte("is"), 50 | []byte("iod"), 51 | []byte("pet"), 52 | []byte("daric"), 53 | []byte("asphalt"), 54 | []byte("topsail."), 55 | []byte("frustrate"), 56 | []byte("unextruded"), 57 | } 58 | 59 | func BenchmarkContains(b *testing.B) { 60 | for n := 0; n < b.N; n++ { 61 | for _, word := range words { 62 | for _, sentence := range sentences { 63 | bytes.Contains(sentence, word) 64 | } 65 | } 66 | } 67 | } 68 | 69 | func BenchmarkCaseContains(b *testing.B) { 70 | for n := 0; n < b.N; n++ { 71 | for _, word := range words { 72 | for _, sentence := range sentences { 73 | // bytes.Contains(sentence, word) 74 | CaseContains(sentence, word) 75 | } 76 | } 77 | } 78 | } 79 | func BenchmarkToLowerContains(b *testing.B) { 80 | for n := 0; n < b.N; n++ { 81 | for _, word := range words { 82 | for _, sentence := range sentences { 83 | sentence = bytes.ToLower(sentence) 84 | bytes.Contains(sentence, word) 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /server/db/common.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "encoding/json" 5 | // "io/ioutil" 6 | "log" 7 | "os" 8 | ) 9 | 10 | const kMaxResults = 30 11 | 12 | type JsonRequest struct { 13 | Q string `json:"q"` 14 | S uint64 `json:"s"` 15 | P bool `json:"p"` 16 | } 17 | 18 | func LoadJson(fullpath string, destination interface{}) error { 19 | fd, err := os.Open(fullpath) 20 | if err != nil { 21 | log.Printf("ERROR: OPEN FAILED FOR %s\n", fullpath) 22 | return err 23 | } 24 | 25 | decoder := json.NewDecoder(fd) 26 | err = decoder.Decode(destination) 27 | if err != nil { 28 | log.Printf("ERROR: could not parse: %s - %s\n", fullpath, err) 29 | return err 30 | } 31 | log.Printf("LOADED: %s\n", fullpath) 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /server/db/strings.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | var conversion_table []byte = []byte{ 4 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff} 5 | 6 | func CaseContains(base, tofind []byte) bool { 7 | tofind_len := len(tofind) 8 | base_len := len(base) 9 | base_max := base_len - tofind_len 10 | 11 | if tofind_len <= 0 { 12 | return true 13 | } 14 | 15 | separator := tofind[0] 16 | istart := 0 17 | 18 | for { 19 | for { 20 | if istart > base_max { 21 | return false 22 | } 23 | 24 | if conversion_table[base[istart]] == separator { 25 | break 26 | } 27 | 28 | istart++ 29 | } 30 | 31 | j := 1 32 | for { 33 | if j >= tofind_len { 34 | return true 35 | } 36 | 37 | if conversion_table[base[istart+j]] != tofind[j] { 38 | istart += 1 39 | break 40 | } 41 | 42 | j++ 43 | } 44 | } 45 | 46 | return false 47 | } 48 | -------------------------------------------------------------------------------- /server/db/tree.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "net/http" 5 | "path/filepath" 6 | "strings" 7 | "time" 8 | ) 9 | 10 | type TreeData struct { 11 | Data []TreeObject `json:"data"` 12 | } 13 | type TreeObject struct { 14 | Dir string `json:"dir,omitempty"` 15 | File string `json:"file,omitempty"` 16 | Href string `json:"href"` 17 | Parent string `json:"parent,omitempty"` 18 | } 19 | 20 | func LoadJsonTree(root, tag string) (ApiHandler, error) { 21 | var symbol TreeData 22 | err := LoadJson(filepath.Join(root, "index."+tag+".files.json"), &symbol) 23 | return &symbol, err 24 | } 25 | 26 | func (data *TreeData) Delete() { 27 | } 28 | 29 | func (data *TreeData) HandleSearch(resp http.ResponseWriter, query *JsonRequest) (interface{}, *Stats) { 30 | stats := Stats{} 31 | 32 | result := TreeData{} 33 | q := strings.ToLower(query.Q) 34 | 35 | for count := range data.Data { 36 | stats.scanned += 1 37 | 38 | object := &data.Data[count] 39 | dir := strings.ToLower(object.Dir) 40 | file := strings.ToLower(object.File) 41 | 42 | if !strings.Contains(dir, q) && !strings.Contains(file, q) { 43 | continue 44 | } 45 | 46 | stats.matched += 1 47 | if stats.matched > query.S { 48 | startbuild := time.Now() 49 | stats.returned += 1 50 | result.Data = append(result.Data, *object) 51 | stats.buildresulttime += time.Since(startbuild) 52 | 53 | if stats.matched >= kMaxResults+query.S { 54 | break 55 | } 56 | } 57 | } 58 | 59 | return result, &stats 60 | } 61 | -------------------------------------------------------------------------------- /server/http_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | //"bytes" 5 | "github.com/stretchr/testify/assert" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "path" 10 | "strings" 11 | "testing" 12 | ) 13 | 14 | func IsValidPage(assert *assert.Assertions, body string) { 15 | assert.Regexp("^", body) 16 | assert.Regexp("$", body) 17 | // Verify various component of the web page - to check that template 18 | // expansion worked as expected. 19 | assert.Regexp("optional\\.js", body) 20 | assert.Regexp("style\\.css", body) 21 | assert.Regexp("analytics\\.js", body) 22 | assert.Regexp("searchbox-", body) 23 | 24 | // TODO: check absence of {{ or {% or things like BasePage, JNavData 25 | // (template parameters that have not expanded!) 26 | assert.NotRegexp("{{", body) 27 | assert.NotRegexp("{%", body) 28 | assert.NotRegexp("%}", body) 29 | assert.NotRegexp("}}", body) 30 | assert.NotRegexp(">[ ]*[a-zA-Z]{4,}\\(", body) 31 | } 32 | 33 | func TestHandlers(t *testing.T) { 34 | assert := assert.New(t) 35 | index := NewIndex("../test/indexes", "../test") 36 | assert.NotNil(index) 37 | 38 | t.Logf("tagmap %+v", index.Sources.tagsmap) 39 | assert.Equal(1, len(index.Sources.tagsmap)) 40 | 41 | resp := httptest.NewRecorder() 42 | req, err := http.NewRequest("GET", "/foo/bar.html", nil) 43 | assert.Nil(err) 44 | index.Sources.ServeHTTP(resp, req) 45 | assert.Equal(http.StatusNotFound, resp.Code) 46 | 47 | resp = httptest.NewRecorder() 48 | req, err = http.NewRequest("GET", "/output/sources/meta/globals.js", nil) 49 | assert.Nil(err) 50 | index.Sources.ServeHTTP(resp, req) 51 | assert.Equal(http.StatusOK, resp.Code) 52 | body, _ := ioutil.ReadAll(resp.Result().Body) 53 | assert.Regexp("\"output\"", string(body)) 54 | assert.Regexp("\"test\"", string(body)) 55 | assert.Regexp("\"[^\"]*../.*\\.html\"", string(body)) 56 | 57 | resp = httptest.NewRecorder() 58 | req, err = http.NewRequest("GET", "/output/sources/meta/globals.json", nil) 59 | assert.Nil(err) 60 | index.Sources.ServeHTTP(resp, req) 61 | assert.Equal(http.StatusOK, resp.Code) 62 | body, _ = ioutil.ReadAll(resp.Result().Body) 63 | assert.Regexp("\"output\"", string(body)) 64 | assert.Regexp("\"test\"", string(body)) 65 | assert.Regexp("\"[^\"]*../.*\\.html\"", string(body)) 66 | 67 | root := strings.TrimPrefix(index.Sources.tagsmap["output"].Root, "../") 68 | root = strings.TrimSuffix(root, path.Ext(root)) 69 | for _, url := range []string{"meta/", "meta/index.html", "meta/index.jhtml", "meta/about", "meta/about.html", "meta/help", "meta/help.html", "meta/help.jhtml", root, root + ".html", root + ".jhtml"} { 70 | url = "/output/sources/" + url 71 | t.Logf("TESTING URL: %s", url) 72 | 73 | resp = httptest.NewRecorder() 74 | req, err = http.NewRequest("GET", url, nil) 75 | assert.Nil(err) 76 | index.Sources.ServeHTTP(resp, req) 77 | assert.Equal(http.StatusOK, resp.Code) 78 | body, _ = ioutil.ReadAll(resp.Result().Body) 79 | 80 | IsValidPage(assert, string(body)) 81 | assert.Regexp("[^<]*output[^<]*", string(body)) 82 | assert.Regexp("[^<]*test[^<]*", string(body)) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "github.com/ccontavalli/goutils/misc" 6 | "github.com/ccontavalli/goutils/tsdb/server" 7 | "github.com/ccontavalli/sbexr/server/db" 8 | "github.com/gorilla/handlers" 9 | "gopkg.in/natefinch/lumberjack.v2" 10 | "io" 11 | "log" 12 | "net/http" 13 | "net/http/fcgi" 14 | "os" 15 | "path/filepath" 16 | "runtime" 17 | "time" 18 | ) 19 | 20 | //import _ "net/http/pprof" 21 | 22 | const kMaxResults = 30 23 | 24 | var listen = flag.String("listen", "", "Address to listen on - if unspecified, use fcgi. Example: 0.0.0.0:9000.") 25 | var indexdir = flag.String("index-dir", "", "Directory with indexes to load.") 26 | var webroot = flag.String("web-root", "", "Directory with pages to serve.") 27 | var indexfiles = misc.MultiString("web-index-files", []string{ 28 | "NEWS", "README", "README.md", "00-INDEX", "CHANGES", 29 | "Changes", "ChangeLog", "changelog", "Kconfig"}, "Files to display when rendering a directory.") 30 | var logdir = flag.String("logdir", "", "Where to keep logs. If not specified, stdout/stderr are used.") 31 | var metrics = flag.String("metrics", "", "Where metrics to be served are stored.") 32 | 33 | type Index struct { 34 | Tree db.TagSet 35 | BinSymbol db.TagSet 36 | 37 | Sources *SourceServer 38 | } 39 | 40 | func NewIndex(indexroot, sourcesroot string) Index { 41 | return Index{ 42 | Tree: db.NewTagSet("tree", db.NewSingleDirTagSetHandler(indexroot, ".files.json", db.LoadJsonTree)), 43 | BinSymbol: db.NewTagSet("symbol", db.NewSingleDirTagSetHandler(indexroot, ".symbols.json", db.LoadSymbols)), 44 | Sources: NewSourceServer(sourcesroot), 45 | } 46 | } 47 | 48 | func init() { 49 | runtime.GOMAXPROCS(runtime.NumCPU() - 1) 50 | } 51 | 52 | func Updater(index *Index) { 53 | for { 54 | index.Tree.Update() 55 | index.BinSymbol.Update() 56 | 57 | index.Tree.AddHandlers() 58 | index.BinSymbol.AddHandlers() 59 | 60 | index.Sources.Update() 61 | 62 | runtime.GC() 63 | time.Sleep(10 * time.Second) 64 | } 65 | } 66 | 67 | func main() { 68 | flag.Parse() 69 | if len(*indexdir) <= 0 { 70 | log.Fatal("Must supply flag --index-dir - to match the one used with sbexr") 71 | } 72 | if len(*webroot) <= 0 { 73 | log.Fatal("Must supply flag --webroot - to match the one used with sbexr") 74 | } 75 | 76 | var writer io.Writer 77 | writer = os.Stdout 78 | if *logdir != "" { 79 | log.SetOutput(&lumberjack.Logger{ 80 | Filename: filepath.Join(*logdir, "errors.log"), 81 | MaxSize: 500, 82 | MaxBackups: 12, 83 | MaxAge: 30, 84 | Compress: true, 85 | }) 86 | writer = &lumberjack.Logger{ 87 | Filename: filepath.Join(*logdir, "access.log"), 88 | MaxSize: 500, 89 | MaxBackups: 12, 90 | MaxAge: 30, 91 | Compress: true, 92 | } 93 | } 94 | 95 | index := NewIndex(*indexdir, *webroot) 96 | go Updater(&index) 97 | 98 | if *webroot != "" { 99 | http.Handle("/", index.Sources) 100 | } 101 | if *metrics != "" { 102 | ms, err := server.New(*metrics) 103 | if err != nil { 104 | log.Fatal("Metrics error", err) 105 | } 106 | ms.Register("/metrics/api", http.DefaultServeMux) 107 | } 108 | 109 | var err error 110 | if *listen != "" { 111 | err = http.ListenAndServe(*listen, handlers.CombinedLoggingHandler(writer, handlers.CompressHandler(http.DefaultServeMux))) // set listen port 112 | } else { 113 | err = fcgi.Serve(nil, nil) 114 | } 115 | if err != nil { 116 | log.Fatal("ListenAndServe: ", err) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /server/scripts/create-random-metrics.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | METRICS=${METRICS-../test/metrics/random-value} 4 | MAXLABELS=${MAXLABELS-4} 5 | NUMBER=${NUMBER-100} 6 | LABELS=(pippo pluto topolino gastone paperino paperone brigitta paperoga paperina priscilla orazio clarabella topolina) 7 | 8 | time=`date +%s`; 9 | for i in `seq 1 $NUMBER`; do 10 | labels=$(( RANDOM % MAXLABELS )) 11 | addlabel="" 12 | for (( i = 0; i < labels; i++ )); do 13 | elements=${#LABELS[@]} 14 | which=$(( RANDOM % elements )) 15 | addlabel="$addlabel -label=${LABELS[$which]}" 16 | done 17 | 18 | tsdb-cli --serie ../test/metrics/random-value --labelsperentry=$MAXLABELS --time=$(( time + i * 10 )) --value=$RANDOM $addlabel; 19 | done; 20 | 21 | -------------------------------------------------------------------------------- /server/scripts/metric-get-offset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | METRIC=${METRIC-random-value} 4 | PORT=${PORT-10000} 5 | curl -H "Content-Type: application/json" -X POST -d '{}' http://127.0.0.1:$PORT/metrics/api/get/offset/${METRIC} 6 | -------------------------------------------------------------------------------- /server/scripts/metric-list.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PORT=${PORT-10000} 4 | curl -H "Content-Type: application/json" -X POST -d '{}' http://127.0.0.1:$PORT/metrics/api/list 5 | -------------------------------------------------------------------------------- /server/scripts/symbol-search.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QUERY=${QUERY-fuffa} 4 | PORT=${PORT-10000} 5 | TYPE=${TYPE-symbol} 6 | curl -H "Content-Type: application/json" -X POST -d '{"q": "'$QUERY'"}' http://127.0.0.1:$PORT/api/output/${TYPE} 7 | -------------------------------------------------------------------------------- /server/scripts/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | METRIC=${METRIC-random-value} 4 | PORT=${PORT-10000} 5 | curl -H "Content-Type: application/json" -X POST -d '{}' http://127.0.0.1:$PORT/metrics/api/get/offset/${METRIC} 6 | -------------------------------------------------------------------------------- /server/structs/json.go: -------------------------------------------------------------------------------- 1 | package structs 2 | 3 | type JLink struct { 4 | Name string `json:"name"` 5 | Href string `json:"href"` 6 | } 7 | 8 | type JNavData struct { 9 | Name string `json:"name"` 10 | Path string `json:"path"` 11 | Root string `json:"root"` 12 | 13 | Project string `json:"project"` 14 | Tag string `json:"tag"` 15 | Tags []string `json:"tags"` 16 | 17 | Parents []JLink `json:"parents"` 18 | } 19 | 20 | type JFile struct { 21 | JLink 22 | Type string `json:"type"` 23 | Mtime string `json:"mtime"` 24 | Size int `json:"size"` 25 | } 26 | 27 | type JDir struct { 28 | JNavData 29 | Files []JFile `json:"files"` 30 | Dirs []JFile `json:"dirs"` 31 | } 32 | -------------------------------------------------------------------------------- /server/structs/structs.go: -------------------------------------------------------------------------------- 1 | package structs 2 | 3 | type SymbolData struct { 4 | Data []*SymbolObject `json:"data"` 5 | Error string `json:"error,omitempty"` 6 | } 7 | type SymbolProvider struct { 8 | Href string `json:"href"` 9 | Location string `json:"location"` 10 | Snippet string `json:"snippet"` 11 | } 12 | 13 | type SymbolKindLinkage struct { 14 | Linkage int `json:"linkage"` 15 | Access int `json:"access"` 16 | Kind string `json:"kind"` 17 | Details string `json:"details"` 18 | Defs []SymbolProvider `json:"defs"` 19 | Decls []SymbolProvider `json:"decls"` 20 | } 21 | type SymbolObject struct { 22 | Name string `json:"name"` 23 | Hash string `json:"hash"` 24 | Kinds []SymbolKindLinkage `json:"kinds"` 25 | } 26 | -------------------------------------------------------------------------------- /server/templates/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/server/templates/.gitignore -------------------------------------------------------------------------------- /server/templates/about.qtpl: -------------------------------------------------------------------------------- 1 | {% code 2 | type AboutPage struct { 3 | BasePage 4 | } 5 | %} 6 | 7 | {% func (page *AboutPage) GetBody() %} 8 |
9 |

What is this?

10 | 11 |

12 | You are looking at a code browser for {%s page.Project %}. 13 |

14 | 15 |

16 | By using this web interface, you can navigate the source code of {%s page.Project %} by following simple links, search it by using the box in the navigation bar, or use vi inspired key bindings to move within files. 17 |

18 | 19 |

20 | It should all be pretty intuitive, but to get started, here are a few things you may want to try: 21 |

26 |

27 | 28 |

29 | This site was generated via sbexr, which uses LLVM and clang to parse and index the code. 30 |

31 | 32 |

33 | sbexr is free software (as in "free speech"), under heavy development. sbexr.rabexc.org and the Linux kernel source code are used as a playground to test new features, observe bugs, and gather feedback. Check there often if you want to see new features in action. 34 |

35 | 36 |

37 | As of today, the best way to know more about the project or participate in the development is to join the mailing list, 38 | and follow the project on github. 39 |

40 | 41 |
42 | {% endfunc %} 43 | -------------------------------------------------------------------------------- /server/templates/about.qtpl.go: -------------------------------------------------------------------------------- 1 | // This file is automatically generated by qtc from "about.qtpl". 2 | // See https://github.com/valyala/quicktemplate for details. 3 | 4 | //line about.qtpl:1 5 | package templates 6 | 7 | //line about.qtpl:1 8 | import ( 9 | qtio422016 "io" 10 | 11 | qt422016 "github.com/valyala/quicktemplate" 12 | ) 13 | 14 | //line about.qtpl:1 15 | var ( 16 | _ = qtio422016.Copy 17 | _ = qt422016.AcquireByteBuffer 18 | ) 19 | 20 | //line about.qtpl:2 21 | type AboutPage struct { 22 | BasePage 23 | } 24 | 25 | //line about.qtpl:7 26 | func (page *AboutPage) StreamGetBody(qw422016 *qt422016.Writer) { 27 | //line about.qtpl:7 28 | qw422016.N().S(` 29 |
30 |

What is this?

31 | 32 |

33 | You are looking at a code browser for `) 34 | //line about.qtpl:12 35 | qw422016.E().S(page.Project) 36 | //line about.qtpl:12 37 | qw422016.N().S(`. 38 |

39 | 40 |

41 | By using this web interface, you can navigate the source code of `) 42 | //line about.qtpl:16 43 | qw422016.E().S(page.Project) 44 | //line about.qtpl:16 45 | qw422016.N().S(` by following simple links, search it by using the box in the navigation bar, or use vi inspired key bindings to move within files. 46 |

47 | 48 |

49 | It should all be pretty intuitive, but to get started, here are a few things you may want to try: 50 |

55 |

56 | 57 |

58 | This site was generated via sbexr, which uses LLVM and clang to parse and index the code. 59 |

60 | 61 |

62 | sbexr is free software (as in "free speech"), under heavy development. sbexr.rabexc.org and the Linux kernel source code are used as a playground to test new features, observe bugs, and gather feedback. Check there often if you want to see new features in action. 63 |

64 | 65 |

66 | As of today, the best way to know more about the project or participate in the development is to join the mailing list, 67 | and follow the project on github. 68 |

69 | 70 |
71 | `) 72 | //line about.qtpl:42 73 | } 74 | 75 | //line about.qtpl:42 76 | func (page *AboutPage) WriteGetBody(qq422016 qtio422016.Writer) { 77 | //line about.qtpl:42 78 | qw422016 := qt422016.AcquireWriter(qq422016) 79 | //line about.qtpl:42 80 | page.StreamGetBody(qw422016) 81 | //line about.qtpl:42 82 | qt422016.ReleaseWriter(qw422016) 83 | //line about.qtpl:42 84 | } 85 | 86 | //line about.qtpl:42 87 | func (page *AboutPage) GetBody() string { 88 | //line about.qtpl:42 89 | qb422016 := qt422016.AcquireByteBuffer() 90 | //line about.qtpl:42 91 | page.WriteGetBody(qb422016) 92 | //line about.qtpl:42 93 | qs422016 := string(qb422016.B) 94 | //line about.qtpl:42 95 | qt422016.ReleaseByteBuffer(qb422016) 96 | //line about.qtpl:42 97 | return qs422016 98 | //line about.qtpl:42 99 | } 100 | -------------------------------------------------------------------------------- /server/templates/base.qtpl: -------------------------------------------------------------------------------- 1 | {% import "github.com/ccontavalli/sbexr/server/structs" %} 2 | 3 | {% interface 4 | Page { 5 | GetBody() 6 | GetTitle() 7 | GetPath() 8 | } 9 | %} 10 | 11 | {% stripspace %} 12 | {% func PageTemplate(page Page) %} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | {%= page.GetTitle() %} 21 | {%= AddCss() %} 22 | 23 | 24 | 25 | 26 |
27 | {%= AddNavBar(page) %} 28 | {%= AddFastJs() %} 29 |
30 | 31 |
32 | {%= page.GetBody() %} 33 |
34 | 35 | {%= AddSlowJs() %} 36 | 37 | 38 | {% endfunc %} 39 | 40 | {% code type BasePage structs.JNavData %} 41 | 42 | {% func (page *BasePage) GetBody() %}NO BODY{% endfunc %} 43 | 44 | {% func (page *BasePage) GetPath() %}{% endfunc %} 45 | 46 | {% func GetParentsPath(data *structs.JNavData) %} 47 | {% for _, parent := range data.Parents %} 48 | {%s parent.Name %}/ 49 | {% endfor %} 50 | {%s data.Name %} 51 | {% endfunc %} 52 | 53 | {% func GetJnavTitle(data *structs.JNavData) %}{% if data.Project != "" %}{%s data.Project %}{% space %}{% endif %}{% if data.Tag != "" %}{%s data.Tag %}{% space %}{% endif %}{% if (data.Tag != "" || data.Project != "") && (data.Name != "" || data.Path != "") %}-{% space %}{% endif %}{% if data.Path != "" %}{%s data.Path %}{% elseif data.Name != "" %}{%s data.Name %}{% endif %}{% endfunc %} 54 | 55 | {% func (page *BasePage) GetTitle() %} 56 | {%= GetJnavTitle((*structs.JNavData)(page)) %} 57 | {% endfunc %} 58 | {% endstripspace %} 59 | -------------------------------------------------------------------------------- /server/templates/css.qtpl: -------------------------------------------------------------------------------- 1 | {% stripspace %} 2 | {% func AddCss() %} 3 | 4 | 5 | 6 | 7 | 8 | {% endfunc %} 9 | {% endstripspace %} 10 | -------------------------------------------------------------------------------- /server/templates/css.qtpl.go: -------------------------------------------------------------------------------- 1 | // This file is automatically generated by qtc from "css.qtpl". 2 | // See https://github.com/valyala/quicktemplate for details. 3 | 4 | //line css.qtpl:2 5 | package templates 6 | 7 | //line css.qtpl:2 8 | import ( 9 | qtio422016 "io" 10 | 11 | qt422016 "github.com/valyala/quicktemplate" 12 | ) 13 | 14 | //line css.qtpl:2 15 | var ( 16 | _ = qtio422016.Copy 17 | _ = qt422016.AcquireByteBuffer 18 | ) 19 | 20 | //line css.qtpl:2 21 | func StreamAddCss(qw422016 *qt422016.Writer) { 22 | //line css.qtpl:2 23 | qw422016.N().S(``) 24 | //line css.qtpl:8 25 | } 26 | 27 | //line css.qtpl:8 28 | func WriteAddCss(qq422016 qtio422016.Writer) { 29 | //line css.qtpl:8 30 | qw422016 := qt422016.AcquireWriter(qq422016) 31 | //line css.qtpl:8 32 | StreamAddCss(qw422016) 33 | //line css.qtpl:8 34 | qt422016.ReleaseWriter(qw422016) 35 | //line css.qtpl:8 36 | } 37 | 38 | //line css.qtpl:8 39 | func AddCss() string { 40 | //line css.qtpl:8 41 | qb422016 := qt422016.AcquireByteBuffer() 42 | //line css.qtpl:8 43 | WriteAddCss(qb422016) 44 | //line css.qtpl:8 45 | qs422016 := string(qb422016.B) 46 | //line css.qtpl:8 47 | qt422016.ReleaseByteBuffer(qb422016) 48 | //line css.qtpl:8 49 | return qs422016 50 | //line css.qtpl:8 51 | } 52 | -------------------------------------------------------------------------------- /server/templates/directory.qtpl: -------------------------------------------------------------------------------- 1 | {% import "github.com/ccontavalli/sbexr/server/structs" %} 2 | {% import "github.com/dustin/go-humanize" %} 3 | 4 | {% code 5 | type DirectoryPage struct { 6 | structs.JDir 7 | Index []byte 8 | } 9 | %} 10 | 11 | {% func (page *DirectoryPage) GetPath() %}{%= GetParentsPath(&page.JDir.JNavData) %}{% endfunc %} 12 | {% func (page *DirectoryPage) GetTitle() %}{%= GetJnavTitle(&page.JDir.JNavData) %}{% endfunc %} 13 | {% func (page *DirectoryPage) GetBody() %} 14 |
15 | 16 |
17 | 18 | {% if len(page.Dirs) > 0 %} 19 | 20 | 21 | 22 | 23 | {% for _, dir := range page.Dirs %} 24 | 25 | 26 | 27 | 28 | 29 | {% endfor %} 30 | {% if len(page.Files) > 0 %} 31 | 32 | 33 | 34 | {% endif %} 35 | {% endif %} 36 | 37 | {% if len(page.Files) > 0 %} 38 | 39 | 40 | 41 | 42 | {% for _, file := range page.Files %} 43 | 44 | 52 | 53 | 54 | 55 | {% endfor %} 56 | {% endif %} 57 |
DirectoryFiles
{%s dir.Name %}{%d dir.Size %}
FileSize
45 | {% switch file.Type %} 46 | {% case "parsed" %} 47 | {% case "blob" %} 48 | {% case "text" %} 49 | {% default %} 50 | {% endswitch %} 51 | {%s file.Name %}{%s= humanize.Bytes(uint64(file.Size)) %}
58 |
59 | 60 | {% if len(page.Index) > 0 %} 61 |
62 |

{%s page.Project %} {%s page.Tag %} - {%s page.Name %}

63 |
{%z= page.Index %}
64 |
65 | {% endif %} 66 | 67 |
68 | 69 | {% endfunc %} 70 | -------------------------------------------------------------------------------- /server/templates/globals.js.qtpl: -------------------------------------------------------------------------------- 1 | {% import "github.com/ccontavalli/sbexr/server/structs" %} 2 | {% collapsespace %} 3 | {% func GlobalsJs(data structs.JNavData) %} 4 | var globalTag = "{%s data.Tag %}"; 5 | var globalProject = "{%s data.Project %}"; 6 | var globalRoot = "{%s data.Root %}"; 7 | var globalServerTags = [{% for _, tag := range data.Tags %}"{%j tag %}",{% endfor %}];{% endfunc %}{% endcollapsespace %} 8 | -------------------------------------------------------------------------------- /server/templates/globals.js.qtpl.go: -------------------------------------------------------------------------------- 1 | // This file is automatically generated by qtc from "globals.js.qtpl". 2 | // See https://github.com/valyala/quicktemplate for details. 3 | 4 | //line globals.js.qtpl:1 5 | package templates 6 | 7 | //line globals.js.qtpl:1 8 | import "github.com/ccontavalli/sbexr/server/structs" 9 | 10 | //line globals.js.qtpl:3 11 | import ( 12 | qtio422016 "io" 13 | 14 | qt422016 "github.com/valyala/quicktemplate" 15 | ) 16 | 17 | //line globals.js.qtpl:3 18 | var ( 19 | _ = qtio422016.Copy 20 | _ = qt422016.AcquireByteBuffer 21 | ) 22 | 23 | //line globals.js.qtpl:3 24 | func StreamGlobalsJs(qw422016 *qt422016.Writer, data structs.JNavData) { 25 | //line globals.js.qtpl:3 26 | qw422016.N().S(` var globalTag = "`) 27 | //line globals.js.qtpl:4 28 | qw422016.E().S(data.Tag) 29 | //line globals.js.qtpl:4 30 | qw422016.N().S(`"; var globalProject = "`) 31 | //line globals.js.qtpl:5 32 | qw422016.E().S(data.Project) 33 | //line globals.js.qtpl:5 34 | qw422016.N().S(`"; var globalRoot = "`) 35 | //line globals.js.qtpl:6 36 | qw422016.E().S(data.Root) 37 | //line globals.js.qtpl:6 38 | qw422016.N().S(`"; var globalServerTags = [`) 39 | //line globals.js.qtpl:7 40 | for _, tag := range data.Tags { 41 | //line globals.js.qtpl:7 42 | qw422016.N().S(`"`) 43 | //line globals.js.qtpl:7 44 | qw422016.E().J(tag) 45 | //line globals.js.qtpl:7 46 | qw422016.N().S(`",`) 47 | //line globals.js.qtpl:7 48 | } 49 | //line globals.js.qtpl:7 50 | qw422016.N().S(`];`) 51 | //line globals.js.qtpl:7 52 | } 53 | 54 | //line globals.js.qtpl:7 55 | func WriteGlobalsJs(qq422016 qtio422016.Writer, data structs.JNavData) { 56 | //line globals.js.qtpl:7 57 | qw422016 := qt422016.AcquireWriter(qq422016) 58 | //line globals.js.qtpl:7 59 | StreamGlobalsJs(qw422016, data) 60 | //line globals.js.qtpl:7 61 | qt422016.ReleaseWriter(qw422016) 62 | //line globals.js.qtpl:7 63 | } 64 | 65 | //line globals.js.qtpl:7 66 | func GlobalsJs(data structs.JNavData) string { 67 | //line globals.js.qtpl:7 68 | qb422016 := qt422016.AcquireByteBuffer() 69 | //line globals.js.qtpl:7 70 | WriteGlobalsJs(qb422016, data) 71 | //line globals.js.qtpl:7 72 | qs422016 := string(qb422016.B) 73 | //line globals.js.qtpl:7 74 | qt422016.ReleaseByteBuffer(qb422016) 75 | //line globals.js.qtpl:7 76 | return qs422016 77 | //line globals.js.qtpl:7 78 | } 79 | -------------------------------------------------------------------------------- /server/templates/help.qtpl: -------------------------------------------------------------------------------- 1 | {% code 2 | type HelpPage struct { 3 | BasePage 4 | } 5 | %} 6 | 7 | {% func (page *HelpPage) GetBody() %} 8 |
9 | 10 |

KEY Bindings

11 |
12 |
ESC
CLOSE this help screen
13 |
?
Toggle the help screen
14 |
a
Toggle the about page
15 |
16 | 17 |
18 |
j
Scroll down a few lines
19 |
k
Scroll up a few lines
20 |
g
Scroll to the top of the file
21 |
G
Scroll to the bottom of the file
22 |
23 | 24 |
25 |
:
Go to the specified line number
(press :, type number, enter)
26 |
f
Go to the specified file
(press f, autocomplete, enter)
27 |
s
Find the specified symbol
(press s, autocomplete, enter)
28 |
t
Find the specified text
(press t, write terms, enter)
29 |
30 | 31 |

With your mouse

32 |
33 |
click
on objects or links to go to their best definition
34 |
drag
on objects or links to open a context menu
35 |
36 | 37 |
38 | {% endfunc %} 39 | -------------------------------------------------------------------------------- /server/templates/help.qtpl.go: -------------------------------------------------------------------------------- 1 | // This file is automatically generated by qtc from "help.qtpl". 2 | // See https://github.com/valyala/quicktemplate for details. 3 | 4 | //line help.qtpl:1 5 | package templates 6 | 7 | //line help.qtpl:1 8 | import ( 9 | qtio422016 "io" 10 | 11 | qt422016 "github.com/valyala/quicktemplate" 12 | ) 13 | 14 | //line help.qtpl:1 15 | var ( 16 | _ = qtio422016.Copy 17 | _ = qt422016.AcquireByteBuffer 18 | ) 19 | 20 | //line help.qtpl:2 21 | type HelpPage struct { 22 | BasePage 23 | } 24 | 25 | //line help.qtpl:7 26 | func (page *HelpPage) StreamGetBody(qw422016 *qt422016.Writer) { 27 | //line help.qtpl:7 28 | qw422016.N().S(` 29 |
30 | 31 |

KEY Bindings

32 |
33 |
ESC
CLOSE this help screen
34 |
?
Toggle the help screen
35 |
a
Toggle the about page
36 |
37 | 38 |
39 |
j
Scroll down a few lines
40 |
k
Scroll up a few lines
41 |
g
Scroll to the top of the file
42 |
G
Scroll to the bottom of the file
43 |
44 | 45 |
46 |
:
Go to the specified line number
(press :, type number, enter)
47 |
f
Go to the specified file
(press f, autocomplete, enter)
48 |
s
Find the specified symbol
(press s, autocomplete, enter)
49 |
t
Find the specified text
(press t, write terms, enter)
50 |
51 | 52 |

With your mouse

53 |
54 |
click
on objects or links to go to their best definition
55 |
drag
on objects or links to open a context menu
56 |
57 | 58 |
59 | `) 60 | //line help.qtpl:38 61 | } 62 | 63 | //line help.qtpl:38 64 | func (page *HelpPage) WriteGetBody(qq422016 qtio422016.Writer) { 65 | //line help.qtpl:38 66 | qw422016 := qt422016.AcquireWriter(qq422016) 67 | //line help.qtpl:38 68 | page.StreamGetBody(qw422016) 69 | //line help.qtpl:38 70 | qt422016.ReleaseWriter(qw422016) 71 | //line help.qtpl:38 72 | } 73 | 74 | //line help.qtpl:38 75 | func (page *HelpPage) GetBody() string { 76 | //line help.qtpl:38 77 | qb422016 := qt422016.AcquireByteBuffer() 78 | //line help.qtpl:38 79 | page.WriteGetBody(qb422016) 80 | //line help.qtpl:38 81 | qs422016 := string(qb422016.B) 82 | //line help.qtpl:38 83 | qt422016.ReleaseByteBuffer(qb422016) 84 | //line help.qtpl:38 85 | return qs422016 86 | //line help.qtpl:38 87 | } 88 | -------------------------------------------------------------------------------- /server/templates/javascript.qtpl: -------------------------------------------------------------------------------- 1 | {% stripspace %} 2 | {% func AddFastJs() %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {% endfunc %} 13 | 14 | {% func AddSlowJs() %} 15 | 24 | {% endfunc %} 25 | {% endstripspace %} 26 | -------------------------------------------------------------------------------- /server/templates/javascript.qtpl.go: -------------------------------------------------------------------------------- 1 | // This file is automatically generated by qtc from "javascript.qtpl". 2 | // See https://github.com/valyala/quicktemplate for details. 3 | 4 | //line javascript.qtpl:2 5 | package templates 6 | 7 | //line javascript.qtpl:2 8 | import ( 9 | qtio422016 "io" 10 | 11 | qt422016 "github.com/valyala/quicktemplate" 12 | ) 13 | 14 | //line javascript.qtpl:2 15 | var ( 16 | _ = qtio422016.Copy 17 | _ = qt422016.AcquireByteBuffer 18 | ) 19 | 20 | //line javascript.qtpl:2 21 | func StreamAddFastJs(qw422016 *qt422016.Writer) { 22 | //line javascript.qtpl:2 23 | qw422016.N().S(``) 24 | //line javascript.qtpl:12 25 | } 26 | 27 | //line javascript.qtpl:12 28 | func WriteAddFastJs(qq422016 qtio422016.Writer) { 29 | //line javascript.qtpl:12 30 | qw422016 := qt422016.AcquireWriter(qq422016) 31 | //line javascript.qtpl:12 32 | StreamAddFastJs(qw422016) 33 | //line javascript.qtpl:12 34 | qt422016.ReleaseWriter(qw422016) 35 | //line javascript.qtpl:12 36 | } 37 | 38 | //line javascript.qtpl:12 39 | func AddFastJs() string { 40 | //line javascript.qtpl:12 41 | qb422016 := qt422016.AcquireByteBuffer() 42 | //line javascript.qtpl:12 43 | WriteAddFastJs(qb422016) 44 | //line javascript.qtpl:12 45 | qs422016 := string(qb422016.B) 46 | //line javascript.qtpl:12 47 | qt422016.ReleaseByteBuffer(qb422016) 48 | //line javascript.qtpl:12 49 | return qs422016 50 | //line javascript.qtpl:12 51 | } 52 | 53 | //line javascript.qtpl:14 54 | func StreamAddSlowJs(qw422016 *qt422016.Writer) { 55 | //line javascript.qtpl:14 56 | qw422016.N().S(``) 57 | //line javascript.qtpl:24 58 | } 59 | 60 | //line javascript.qtpl:24 61 | func WriteAddSlowJs(qq422016 qtio422016.Writer) { 62 | //line javascript.qtpl:24 63 | qw422016 := qt422016.AcquireWriter(qq422016) 64 | //line javascript.qtpl:24 65 | StreamAddSlowJs(qw422016) 66 | //line javascript.qtpl:24 67 | qt422016.ReleaseWriter(qw422016) 68 | //line javascript.qtpl:24 69 | } 70 | 71 | //line javascript.qtpl:24 72 | func AddSlowJs() string { 73 | //line javascript.qtpl:24 74 | qb422016 := qt422016.AcquireByteBuffer() 75 | //line javascript.qtpl:24 76 | WriteAddSlowJs(qb422016) 77 | //line javascript.qtpl:24 78 | qs422016 := string(qb422016.B) 79 | //line javascript.qtpl:24 80 | qt422016.ReleaseByteBuffer(qb422016) 81 | //line javascript.qtpl:24 82 | return qs422016 83 | //line javascript.qtpl:24 84 | } 85 | -------------------------------------------------------------------------------- /server/templates/navbar.qtpl: -------------------------------------------------------------------------------- 1 | {% func AddNavBar(page Page) %} 2 |
3 | 70 |
71 | {% endfunc %} 72 | -------------------------------------------------------------------------------- /server/templates/source.qtpl: -------------------------------------------------------------------------------- 1 | {% import "github.com/ccontavalli/sbexr/server/structs" %} 2 | 3 | {% code 4 | type SourcePage struct { 5 | structs.JDir 6 | Content []byte 7 | } 8 | %} 9 | 10 | {% func (page *SourcePage) GetPath() %}{%= GetParentsPath(&page.JDir.JNavData) %}{% endfunc %} 11 | {% func (page *SourcePage) GetTitle() %}{%= GetJnavTitle(&page.JDir.JNavData) %}{% endfunc %} 12 | {% func (page *SourcePage) GetBody() %}
{%z= page.Content%}
{% endfunc %} 13 | -------------------------------------------------------------------------------- /server/templates/source.qtpl.go: -------------------------------------------------------------------------------- 1 | // This file is automatically generated by qtc from "source.qtpl". 2 | // See https://github.com/valyala/quicktemplate for details. 3 | 4 | //line source.qtpl:1 5 | package templates 6 | 7 | //line source.qtpl:1 8 | import "github.com/ccontavalli/sbexr/server/structs" 9 | 10 | //line source.qtpl:3 11 | import ( 12 | qtio422016 "io" 13 | 14 | qt422016 "github.com/valyala/quicktemplate" 15 | ) 16 | 17 | //line source.qtpl:3 18 | var ( 19 | _ = qtio422016.Copy 20 | _ = qt422016.AcquireByteBuffer 21 | ) 22 | 23 | //line source.qtpl:4 24 | type SourcePage struct { 25 | structs.JDir 26 | Content []byte 27 | } 28 | 29 | //line source.qtpl:10 30 | func (page *SourcePage) StreamGetPath(qw422016 *qt422016.Writer) { 31 | //line source.qtpl:10 32 | StreamGetParentsPath(qw422016, &page.JDir.JNavData) 33 | //line source.qtpl:10 34 | } 35 | 36 | //line source.qtpl:10 37 | func (page *SourcePage) WriteGetPath(qq422016 qtio422016.Writer) { 38 | //line source.qtpl:10 39 | qw422016 := qt422016.AcquireWriter(qq422016) 40 | //line source.qtpl:10 41 | page.StreamGetPath(qw422016) 42 | //line source.qtpl:10 43 | qt422016.ReleaseWriter(qw422016) 44 | //line source.qtpl:10 45 | } 46 | 47 | //line source.qtpl:10 48 | func (page *SourcePage) GetPath() string { 49 | //line source.qtpl:10 50 | qb422016 := qt422016.AcquireByteBuffer() 51 | //line source.qtpl:10 52 | page.WriteGetPath(qb422016) 53 | //line source.qtpl:10 54 | qs422016 := string(qb422016.B) 55 | //line source.qtpl:10 56 | qt422016.ReleaseByteBuffer(qb422016) 57 | //line source.qtpl:10 58 | return qs422016 59 | //line source.qtpl:10 60 | } 61 | 62 | //line source.qtpl:11 63 | func (page *SourcePage) StreamGetTitle(qw422016 *qt422016.Writer) { 64 | //line source.qtpl:11 65 | StreamGetJnavTitle(qw422016, &page.JDir.JNavData) 66 | //line source.qtpl:11 67 | } 68 | 69 | //line source.qtpl:11 70 | func (page *SourcePage) WriteGetTitle(qq422016 qtio422016.Writer) { 71 | //line source.qtpl:11 72 | qw422016 := qt422016.AcquireWriter(qq422016) 73 | //line source.qtpl:11 74 | page.StreamGetTitle(qw422016) 75 | //line source.qtpl:11 76 | qt422016.ReleaseWriter(qw422016) 77 | //line source.qtpl:11 78 | } 79 | 80 | //line source.qtpl:11 81 | func (page *SourcePage) GetTitle() string { 82 | //line source.qtpl:11 83 | qb422016 := qt422016.AcquireByteBuffer() 84 | //line source.qtpl:11 85 | page.WriteGetTitle(qb422016) 86 | //line source.qtpl:11 87 | qs422016 := string(qb422016.B) 88 | //line source.qtpl:11 89 | qt422016.ReleaseByteBuffer(qb422016) 90 | //line source.qtpl:11 91 | return qs422016 92 | //line source.qtpl:11 93 | } 94 | 95 | //line source.qtpl:12 96 | func (page *SourcePage) StreamGetBody(qw422016 *qt422016.Writer) { 97 | //line source.qtpl:12 98 | qw422016.N().S(`
`)
 99 | 	//line source.qtpl:12
100 | 	qw422016.N().Z(page.Content)
101 | 	//line source.qtpl:12
102 | 	qw422016.N().S(`
`) 103 | //line source.qtpl:12 104 | } 105 | 106 | //line source.qtpl:12 107 | func (page *SourcePage) WriteGetBody(qq422016 qtio422016.Writer) { 108 | //line source.qtpl:12 109 | qw422016 := qt422016.AcquireWriter(qq422016) 110 | //line source.qtpl:12 111 | page.StreamGetBody(qw422016) 112 | //line source.qtpl:12 113 | qt422016.ReleaseWriter(qw422016) 114 | //line source.qtpl:12 115 | } 116 | 117 | //line source.qtpl:12 118 | func (page *SourcePage) GetBody() string { 119 | //line source.qtpl:12 120 | qb422016 := qt422016.AcquireByteBuffer() 121 | //line source.qtpl:12 122 | page.WriteGetBody(qb422016) 123 | //line source.qtpl:12 124 | qs422016 := string(qb422016.B) 125 | //line source.qtpl:12 126 | qt422016.ReleaseByteBuffer(qb422016) 127 | //line source.qtpl:12 128 | return qs422016 129 | //line source.qtpl:12 130 | } 131 | -------------------------------------------------------------------------------- /server/templates/symbol.qtpl: -------------------------------------------------------------------------------- 1 | {% import "github.com/ccontavalli/sbexr/server/structs" %} 2 | {% import "strings" %} 3 | {% code 4 | type SymbolPage struct { 5 | BasePage 6 | Symbol *structs.SymbolObject 7 | } 8 | %} 9 | 10 | {% stripspace %} 11 | {% func GetHumanLinkage(value int) %} 12 | {% switch value %} 13 | {% case 1 %} 14 | local 15 | {% case 2 %} 16 | local 17 | {% case 3 %} 18 | global 19 | {% case 4 %} 20 | global 21 | {% default %} 22 | {% endswitch %} 23 | {% endfunc %} 24 | {% endstripspace %} 25 | 26 | {% stripspace %} 27 | {% func GetHumanAccess(value int) %} 28 | {% switch value %} 29 | {% case 0 %} 30 | public 31 | {% case 1 %} 32 | protected 33 | {% case 2 %} 34 | private 35 | {% default %} 36 | {% endswitch %} 37 | {% endfunc %} 38 | {% endstripspace %} 39 | 40 | {% stripspace %} 41 | {% func GetHumanKind(kind string) %} 42 | {% if kind == "ParmVar" %} 43 | function parameter 44 | {% elseif kind == "Var" %} 45 | variable 46 | {% elseif kind == "CXXRecord" %} 47 | struct or class 48 | {% elseif kind == "CXXMethod" %} 49 | method 50 | {% elseif kind == "EnumConstant" %} 51 | enum value 52 | {% else %} 53 | {%s strings.ToLower(kind) %} 54 | {% endif %} 55 | {% endfunc %} 56 | {% endstripspace %} 57 | 58 | 59 | {% func (page *SymbolPage) AddProvider(provider *structs.SymbolProvider) %} 60 | {%s provider.Location %}: {%s provider.Snippet %} 61 | {% endfunc %} 62 | 63 | {% collapsespace %} 64 | {% func (page *SymbolPage) GetBody() %} 65 |

Symbol: {%s page.Symbol.Name %}

66 | 67 | 89 | {% endfunc %} 90 | {% endcollapsespace %} 91 | 92 | {% stripspace %} 93 | {% func (page *SymbolPage) GetTitle() %} 94 | {%= page.BasePage.GetTitle() %}symbol:{% space %}{%s page.Symbol.Name %} 95 | {% endfunc %} 96 | {% endstripspace %} 97 | -------------------------------------------------------------------------------- /sitemap/.gitignore: -------------------------------------------------------------------------------- 1 | sitemap 2 | sitemap*.gz 3 | -------------------------------------------------------------------------------- /sitemap/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: sitemap 3 | 4 | sitemap: main.go 5 | go build 6 | 7 | test: sitemap 8 | ./sitemap --json-file ../test/indexes/index.output.json --source-url "http://sbexr.rabexc.org/latest/sources" --tree-dir ../test/output/sources/ --sitemap-url "http://sbexr.rabexc.org" --output ./test 9 | 10 | .PHONY: clean 11 | 12 | clean: 13 | rm -f sitemap* 14 | rm -f ./test/sitemap* 15 | -------------------------------------------------------------------------------- /src/.depend: -------------------------------------------------------------------------------- 1 | mempool.o: mempool.cc \ 2 | mempool.h \ 3 | base.h \ 4 | common.h 5 | renderer.o: renderer.cc \ 6 | renderer.h \ 7 | base.h \ 8 | common.h \ 9 | json-helpers.h \ 10 | mempool.h \ 11 | rewriter.h \ 12 | wrapping.h \ 13 | cache.h \ 14 | counters.h 15 | common.o: common.cc \ 16 | common.h \ 17 | base.h 18 | indexer.o: indexer.cc \ 19 | indexer.h \ 20 | base.h \ 21 | cache.h \ 22 | common.h \ 23 | counters.h \ 24 | renderer.h \ 25 | json-helpers.h \ 26 | mempool.h \ 27 | rewriter.h \ 28 | cindex.h 29 | wrapping.o: wrapping.cc \ 30 | wrapping.h \ 31 | base.h \ 32 | cache.h \ 33 | common.h \ 34 | counters.h \ 35 | renderer.h \ 36 | json-helpers.h \ 37 | mempool.h \ 38 | rewriter.h 39 | sbexr.o: sbexr.cc \ 40 | ast.h \ 41 | base.h \ 42 | cache.h \ 43 | common.h \ 44 | counters.h \ 45 | renderer.h \ 46 | json-helpers.h \ 47 | mempool.h \ 48 | rewriter.h \ 49 | indexer.h \ 50 | cindex.h \ 51 | printer.h \ 52 | wrapping.h \ 53 | pp-tracker.h 54 | counters.o: counters.cc \ 55 | counters.h \ 56 | common.h \ 57 | base.h \ 58 | json-helpers.h \ 59 | mempool.h 60 | pp-tracker.o: pp-tracker.cc \ 61 | ast.h \ 62 | base.h \ 63 | cache.h \ 64 | common.h \ 65 | counters.h \ 66 | renderer.h \ 67 | json-helpers.h \ 68 | mempool.h \ 69 | rewriter.h \ 70 | indexer.h \ 71 | cindex.h \ 72 | printer.h \ 73 | wrapping.h 74 | cache.o: cache.cc \ 75 | cache.h \ 76 | base.h \ 77 | common.h \ 78 | counters.h \ 79 | renderer.h \ 80 | json-helpers.h \ 81 | mempool.h \ 82 | rewriter.h 83 | rewriter.o: rewriter.cc \ 84 | rewriter.h \ 85 | common.h \ 86 | base.h \ 87 | mempool.h 88 | ast.o: ast.cc \ 89 | ast.h \ 90 | base.h \ 91 | cache.h \ 92 | common.h \ 93 | counters.h \ 94 | renderer.h \ 95 | json-helpers.h \ 96 | mempool.h \ 97 | rewriter.h \ 98 | indexer.h \ 99 | cindex.h \ 100 | printer.h \ 101 | wrapping.h 102 | .depend: \ 103 | mempool.h \ 104 | base.h \ 105 | common.h \ 106 | mempool.cc \ 107 | renderer.h \ 108 | json-helpers.h \ 109 | rewriter.h \ 110 | wrapping.h \ 111 | cache.h \ 112 | counters.h \ 113 | renderer.cc \ 114 | common.cc \ 115 | indexer.h \ 116 | cindex.h \ 117 | indexer.cc \ 118 | wrapping.cc \ 119 | ast.h \ 120 | printer.h \ 121 | pp-tracker.h \ 122 | sbexr.cc \ 123 | counters.cc \ 124 | pp-tracker.cc \ 125 | cache.cc \ 126 | rewriter.cc \ 127 | ast.cc \ 128 | Makefile 129 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | LLVMVERSION := 8 2 | LLVMCONFIG := llvm-config-$(LLVMVERSION) 3 | LIBS := $(shell $(LLVMCONFIG) --libs) 4 | DEBUG := -ggdb3 -O0 5 | BASEFLAGS := $(shell $(LLVMCONFIG) --cxxflags) 6 | CXXFLAGS := $(BASEFLAGS) $(DEBUG) 7 | LDFLAGS := $(shell $(LLVMCONFIG) --ldflags) 8 | TIME := time --format='MEM: unshared process size=%D, average total=%K, max resident=%M\nTIME: total wall time=%e, user time=%U, kernel time=%S' 9 | VERBOSE := --verbose 10 | EXTRA := 11 | #CXX := clang-$(LLVMVERSION) 12 | 13 | EXTRALIBS := -lclangFrontend \ 14 | -lclangParse \ 15 | -lclangSema \ 16 | -lclangAnalysis \ 17 | -lclangAST \ 18 | -lclangEdit \ 19 | -lclangLex \ 20 | -lclangBasic \ 21 | -lclangDriver \ 22 | -lclangTooling \ 23 | -lclangToolingCore \ 24 | -lclangSerialization \ 25 | -lclangRewrite \ 26 | -lLLVMMC \ 27 | -lLLVMSupport 28 | 29 | all: sbexr 30 | 31 | opt: DEBUG := 32 | opt: CXXFLAGS := $(BASEFLAGS) -s -O2 -flto 33 | opt: sbexr 34 | 35 | DEPS := sbexr.o indexer.o renderer.o wrapping.o rewriter.o cache.o mempool.o common.o counters.o ast.o pp-tracker.o 36 | 37 | sbexr: .depend $(DEPS) 38 | $(CXX) -lclang-$(LLVMVERSION) -lLLVM-$(LLVMVERSION) $(CXXFLAGS) $(LDFLAGS) $(LIBS) $(LIBDIR) -o sbexr $(DEPS) $(EXTRALIBS) 39 | 40 | validator: 41 | $(MAKE) -C ../validator 42 | 43 | test-run: 44 | $(MAKE) -C ../server test-run 45 | 46 | test-gen: validator sbexr test-multi 47 | cd ../test && rm -rf output/ && rm -rf indexes/ && ln -sfT ../static ./static \ 48 | && $(TIME) ../src/sbexr $(VERBOSE) $(EXTRA) --index=indexes -x "metrics|output|indexes|\\.swp" --jsondb . \ 49 | && ../validator/validator --root ./output |tee ./output/validator.report \ 50 | && cp -a ./indexes/*.json ./output/ 51 | 52 | 53 | test-dump: test-dump-multi 54 | 55 | test-single: 56 | cd ../test && bear $(MAKE) clean test-single-file 57 | 58 | test-multi: 59 | cd ../test && bear $(MAKE) clean test-multiple-file 60 | 61 | test-dump-multi: 62 | cd .. && $(MAKE) -C ./test dump-multi 63 | 64 | clean-test: 65 | $(MAKE) -C ../test clean 66 | 67 | dump: 68 | clang-$(LLVMVERSION) -Xclang -ast-dump -fsyntax-only $(CXXFLAGS) $(LIBS) $(LIBDIR) ./sbexr.cc 69 | 70 | .PHONY: server test format 71 | 72 | format: 73 | clang-format-$(LLVMVERSION) --style=google -i *.cc *.h 74 | 75 | SOURCES := $(wildcard *.cc) 76 | 77 | .depend: 78 | fastdep --extraremakedep=Makefile \ 79 | --remakedeptarget=.depend $(SOURCES) > .depend 2>/dev/null 80 | 81 | -include .depend 82 | 83 | clean: 84 | rm -f sbexr 85 | rm -f *.o 86 | -------------------------------------------------------------------------------- /src/ast.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #include "ast.h" 30 | 31 | Counter& c_discarded_tags_macro = MakeCounter( 32 | "wrapping/discarded/macro", 33 | "TAGS that have not been applied because the range contains a MacroID"); 34 | Counter& c_use_of_builtin_fns = MakeCounter( 35 | "info/ast/ignored-uses-of-builtin-functions", 36 | "USES that have not been recorded because they refer to builtin things"); 37 | -------------------------------------------------------------------------------- /src/base.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef BASE_H 30 | #define BASE_H 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | #include "clang/AST/ASTConsumer.h" 50 | #include "clang/AST/ASTContext.h" 51 | #include "clang/AST/RecursiveASTVisitor.h" 52 | #include "clang/Basic/Diagnostic.h" 53 | #include "clang/Basic/FileManager.h" 54 | #include "clang/Basic/SourceManager.h" 55 | #include "clang/Basic/TargetInfo.h" 56 | #include "clang/Basic/TargetOptions.h" 57 | #include "clang/Frontend/CompilerInstance.h" 58 | #include "clang/Frontend/FrontendAction.h" 59 | #include "clang/Frontend/TextDiagnosticPrinter.h" 60 | #include "clang/Lex/HeaderSearch.h" 61 | #include "clang/Lex/Preprocessor.h" 62 | #include "clang/Parse/ParseAST.h" 63 | #include "clang/Rewrite/Core/HTMLRewrite.h" 64 | #include "clang/Rewrite/Core/Rewriter.h" 65 | #include "clang/Rewrite/Frontend/Rewriters.h" 66 | #include "clang/Sema/Sema.h" 67 | #include "clang/Tooling/CommonOptionsParser.h" 68 | #include "clang/Tooling/Tooling.h" 69 | #include "llvm/Support/CommandLine.h" 70 | #include "llvm/Support/Host.h" 71 | #include "llvm/Support/TargetSelect.h" 72 | #include "llvm/Support/raw_ostream.h" 73 | 74 | using namespace llvm; 75 | using namespace clang; 76 | using namespace clang::tooling; 77 | 78 | #endif /* BASE_H */ 79 | -------------------------------------------------------------------------------- /src/cache.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #include "cache.h" 30 | 31 | Counter& c_begin_end_different_files = 32 | MakeCounter("cache/nullreturn/begin-end-different-files", 33 | "Returned a nullptr because a source and dest location were in " 34 | "different files"); 35 | Counter& c_internal_buffer = MakeCounter( 36 | "cache/nullreturn/internal-buffer", 37 | "Returned a nullptr because a location referred to an internal buffer"); 38 | Counter& c_no_content_cache = 39 | MakeCounter("cache/nullreturn/no-content-cache", 40 | "Returned a nullptr because the SourceManager had no content " 41 | "associated to the file"); 42 | Counter& c_no_sloc_entry = 43 | MakeCounter("cache/nullreturn/no-sloc-entry", 44 | "Returned a nullptr because the SourceManager had no SLocEntry " 45 | "associated to the file"); 46 | Counter& c_empty_path = MakeCounter( 47 | "cache/nullreturn/empty-path", 48 | "Returned a nullptr because an empty path was passed to GetFileFor"); 49 | Counter& c_invalid_fid = MakeCounter( 50 | "cache/nullreturn/invalid-fid", 51 | "Returned a nullptr because an invalid FileID was passed to GetFileFor"); 52 | -------------------------------------------------------------------------------- /src/counters.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #include "counters.h" 30 | #include "json-helpers.h" 31 | 32 | Register& GlobalRegister() { 33 | static auto* counters = new Register(); 34 | return *counters; 35 | } 36 | 37 | std::ostream* NullStream() { 38 | static auto* nullstream = new std::ofstream; 39 | return nullstream; 40 | } 41 | 42 | Counter& MakeCounter(const char* path, const char* description) { 43 | return GlobalRegister().MakeCounter(path, description); 44 | } 45 | 46 | Counter& Register::MakeCounter(const char* path, const char* description) { 47 | auto result = counters_.emplace( 48 | std::pair(path, {path, description, NullStream()})); 49 | return result.first->second; 50 | } 51 | 52 | int Register::Capture(const std::string& match, std::ostream* stream) { 53 | std::regex regex(match); 54 | int matched = 0; 55 | for (auto& it : counters_) { 56 | const auto& name = it.first; 57 | auto& counter = it.second; 58 | 59 | if (!std::regex_search(name, regex)) continue; 60 | 61 | matched++; 62 | if (stream != nullptr) { 63 | (*stream) << "COUNTER - enabling capture of '" << name << "'" 64 | << std::endl; 65 | counter.Capture(stream); 66 | } else { 67 | counter.Capture(NullStream()); 68 | } 69 | } 70 | return matched; 71 | } 72 | 73 | bool Register::OutputJson(const std::string& path) const { 74 | if (!MakeDirs(path, 0777)) { 75 | return false; 76 | } 77 | std::ofstream myfile; 78 | myfile.open(path); 79 | 80 | json::OStreamWrapper osw(myfile); 81 | json::PrettyWriter writer(osw); 82 | 83 | auto values = MakeJsonArray(&writer); 84 | for (const auto& it : counters_) { 85 | const auto& name = it.first; 86 | const auto& value = it.second; 87 | auto obj = MakeJsonObject(&writer); 88 | 89 | WriteJsonKeyValue(&writer, "metric", name); 90 | WriteJsonKeyValue(&writer, "value", value.Value()); 91 | } 92 | return true; 93 | } 94 | 95 | DebugStream Counter::Add(SourceRange range) { 96 | return Add(range.getBegin(), range.getEnd()); 97 | } 98 | 99 | DebugStream Counter::Add(SourceLocation begin, SourceLocation end) { 100 | return Add(); 101 | } 102 | 103 | void Counter::Capture(std::ostream* capture) { capture_ = capture; } 104 | 105 | DebugStream Counter::Add() { 106 | counter_++; 107 | 108 | *capture_ << "COUNTER - " << name_ << ": "; 109 | return DebugStream(*capture_); 110 | } 111 | -------------------------------------------------------------------------------- /src/counters.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef COUNTERS_H 30 | #define COUNTERS_H 31 | 32 | #include "common.h" 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | class DebugStream { 39 | public: 40 | explicit DebugStream(std::ostream& stream) : stream_(stream) {} 41 | ~DebugStream() { stream_ << "\n"; } 42 | 43 | DebugStream(const DebugStream& other) = delete; 44 | DebugStream& operator=(const DebugStream& other) = delete; 45 | 46 | DebugStream(DebugStream&& other) : stream_(other.stream_) {} 47 | 48 | std::ostream& GetStream() const { return stream_; } 49 | 50 | private: 51 | std::ostream& stream_; 52 | }; 53 | 54 | // Allows a DebugStream to be used as a plain stream, with the usual << fun. 55 | template 56 | std::ostream& operator<<(DebugStream&& dstream, Whatever value) { 57 | dstream.GetStream() << value; 58 | return dstream.GetStream(); 59 | } 60 | 61 | class Counter { 62 | public: 63 | Counter(const char* name, const char* description, std::ostream* capture) 64 | : name_(name), description_(description), capture_(capture) {} 65 | 66 | DebugStream Add(); 67 | DebugStream Add(SourceRange range); 68 | DebugStream Add(SourceLocation begin, SourceLocation end); 69 | 70 | void Capture(std::ostream* capture); 71 | 72 | uint64_t Value() const { return counter_; } 73 | 74 | private: 75 | const std::string name_; 76 | const std::string description_; 77 | std::ostream* capture_; 78 | uint64_t counter_ = 0; 79 | }; 80 | 81 | class Register { 82 | public: 83 | typedef std::map CounterMap; 84 | 85 | Counter& MakeCounter(const char* path, const char* description); 86 | const CounterMap& GetCounters() const { return counters_; } 87 | int Capture(const std::string& match, std::ostream* stream); 88 | 89 | bool OutputJson(const std::string& path) const; 90 | 91 | private: 92 | CounterMap counters_; 93 | }; 94 | 95 | Register& GlobalRegister(); 96 | Counter& MakeCounter(const char* path, const char* description); 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /src/json-helpers.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef JSON_HELPERS_H 30 | #define JSON_HELPERS_H 31 | 32 | #include "mempool.h" 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | namespace json = rapidjson; 40 | 41 | // RAII Wrappers around some of the common rapidjson constructs. 42 | template 43 | class JsonArray { 44 | public: 45 | JsonArray(Writer* writer, const char* key = nullptr) : writer_(writer) { 46 | if (key) writer->Key(key); 47 | writer->StartArray(); 48 | } 49 | ~JsonArray() { writer_->EndArray(); } 50 | 51 | private: 52 | Writer* writer_; 53 | }; 54 | template 55 | inline JsonArray MakeJsonArray(Writer* writer, 56 | const char* key = nullptr) { 57 | return JsonArray(writer, key); 58 | } 59 | 60 | template 61 | class JsonObject { 62 | public: 63 | JsonObject(Writer* writer, const char* key = nullptr) : writer_(writer) { 64 | if (key) writer->Key(key); 65 | writer->StartObject(); 66 | } 67 | ~JsonObject() { writer_->EndObject(); } 68 | 69 | private: 70 | Writer* writer_; 71 | }; 72 | template 73 | inline JsonObject MakeJsonObject(Writer* writer, 74 | const char* key = nullptr) { 75 | return JsonObject(writer, key); 76 | } 77 | 78 | template 79 | void WriteJsonString(Writer* writer, const std::string& str) { 80 | writer->String(str.c_str(), str.length()); 81 | } 82 | 83 | template 84 | void WriteJsonString(Writer* writer, 85 | const ConstStringBase& str) { 86 | writer->String(str.data(), str.size()); 87 | } 88 | 89 | template 90 | void WriteJsonKeyValue(Writer* writer, const char* key, 91 | const std::string& str) { 92 | writer->Key(key); 93 | writer->String(str.data(), str.size()); 94 | } 95 | 96 | template 97 | void WriteJsonKeyValue(Writer* writer, const char* key, int value) { 98 | writer->Key(key); 99 | writer->Uint(value); 100 | } 101 | 102 | template 103 | void WriteJsonKeyValue(Writer* writer, const char* key, uint64_t value) { 104 | writer->Key(key); 105 | writer->Uint64(value); 106 | } 107 | 108 | inline void AddJHtmlSeparator(std::ostream* stream) { (*stream) << "\n---\n"; } 109 | 110 | #endif /* JSON_HELPERS_H */ 111 | -------------------------------------------------------------------------------- /src/mempool.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #include "mempool.h" 30 | #include 31 | 32 | MemoryPrinter::PrinterList* MemoryPrinter::printers_ = nullptr; 33 | 34 | void MemoryPrinter::OutputStats() { 35 | std::cerr << "********************" << std::endl; 36 | malloc_stats(); 37 | for (const auto& printer : *printers_) { 38 | std::cerr << " + [" << printer.first << "] "; 39 | printer.second(); 40 | std::cerr << std::endl; 41 | } 42 | std::cerr << "********************" << std::endl; 43 | } 44 | -------------------------------------------------------------------------------- /src/pp-tracker.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #include "ast.h" 30 | 31 | auto& c_pp_file_not_found = 32 | MakeCounter("preprocessor/include/not-found", 33 | "The PreProcessor invoked the FileNotFound callback, as a file " 34 | "could not be found"); 35 | auto& c_pp_file_failed_inclusion = 36 | MakeCounter("preprocessor/include/failed-inclusion", 37 | "The PreProcessor tried to include a file that does not exist"); 38 | -------------------------------------------------------------------------------- /src/rewriter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef REWRITER_H 30 | #define REWRITER_H 31 | 32 | #include "common.h" 33 | #include "mempool.h" 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | extern const char _kTagString[]; 40 | using TagString = UniqString; 41 | static_assert(sizeof(TagString) == sizeof(uint32_t), 42 | "String is using more space than expected"); 43 | 44 | struct Tag { 45 | Tag(Tag&& other) = default; 46 | Tag(const Tag& other) = default; 47 | 48 | Tag(const char* tag, const std::string& attrs) 49 | : tag(tag), attributes(attrs) {} 50 | 51 | void Drop() { attributes.Drop(); } 52 | bool operator==(const Tag& other) { 53 | return (tag == other.tag || !strcmp(tag, other.tag)) && 54 | open == other.open && close == other.close && 55 | attributes == other.attributes; 56 | } 57 | 58 | const char* tag = nullptr; 59 | int open = -1; 60 | int close = -1; 61 | 62 | TagString attributes; 63 | }; 64 | 65 | static inline std::ostream& operator<<(std::ostream& stream, const Tag& tag) { 66 | stream << "<" << (tag.tag ? tag.tag : "-null-") << " " << tag.attributes 67 | << "> opened at " << tag.open << ", closed at " << tag.close; 68 | return stream; 69 | } 70 | 71 | inline Tag MakeTag(const char* tag, std::initializer_list classes, 72 | std::initializer_list attributes) { 73 | std::string elements; 74 | if (classes.size()) { 75 | elements.append("class='"); 76 | int i = 0; 77 | for (const auto& aclass : classes) { 78 | if (i++) elements.append(" "); 79 | elements.append(aclass.data(), aclass.size()); 80 | } 81 | 82 | if (attributes.size()) 83 | elements.append("' "); 84 | else 85 | elements.append("'"); 86 | } 87 | 88 | int i = 0; 89 | for (const auto& attr : attributes) { 90 | if (i % 2) { 91 | elements.append("='"); 92 | elements.append(attr); 93 | elements.append("'"); 94 | } else { 95 | if (i) elements.append(" "); 96 | elements.append(attr); 97 | } 98 | ++i; 99 | } 100 | 101 | auto rtag = Tag(tag, elements); 102 | return std::move(rtag); 103 | } 104 | 105 | class HtmlRewriter { 106 | public: 107 | void Add(Tag tag); 108 | std::string Generate(const StringRef& filename, const StringRef& body); 109 | 110 | private: 111 | std::vector tags_; 112 | }; 113 | 114 | #endif /* REWRITER_H */ 115 | -------------------------------------------------------------------------------- /src/wrapping.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #include "wrapping.h" 30 | #include "counters.h" 31 | 32 | auto& c_discarded_tags_file = 33 | MakeCounter("wrapping/discarded/file", 34 | "TAGS that have not been applied because no corresponding file " 35 | "could be found"); 36 | 37 | void WrapWithTag(FileRenderer::ParsedFile* file, Tag tag) { 38 | file->rewriter.Add(std::move(tag)); 39 | } 40 | 41 | void WrapWithTag(FileRenderer::ParsedFile* file, int bo, int eo, Tag tag) { 42 | tag.open = bo; 43 | tag.close = eo; 44 | WrapWithTag(file, std::move(tag)); 45 | } 46 | 47 | bool WrapWithTag(const CompilerInstance& ci, FileCache* cache, 48 | const SourceLocation& obegin, const SourceLocation& oend, 49 | Tag tag) { 50 | SourceManager& sm = ci.getSourceManager(); 51 | 52 | auto begin = sm.getExpansionLoc(obegin); 53 | auto end = sm.getExpansionLoc(oend); 54 | 55 | auto* file = cache->GetFileFor(sm, begin, end); 56 | if (!file) { 57 | c_discarded_tags_file.Add(begin, end) << tag; 58 | return false; 59 | } 60 | 61 | unsigned bo = sm.getFileOffset(begin); 62 | unsigned eo = sm.getFileOffset(end); 63 | 64 | // Include the whole end token in the range. 65 | // This was taken from the WrapRange implementation in clang. 66 | eo += Lexer::MeasureTokenLength(end, sm, ci.getLangOpts()); 67 | WrapWithTag(file, bo, eo, std::move(tag)); 68 | return true; 69 | } 70 | 71 | bool WrapWithTag(const CompilerInstance& ci, FileCache* cache, 72 | const SourceRange& to_wrap, Tag tag) { 73 | return WrapWithTag(ci, cache, to_wrap.getBegin(), to_wrap.getEnd(), 74 | std::move(tag)); 75 | } 76 | 77 | bool WrapEolSol(const SourceManager& sm, FileCache* cache, SourceLocation start, 78 | SourceLocation end, Tag tag) { 79 | auto* file = cache->GetFileFor(sm, start, end); 80 | if (!file) { 81 | c_discarded_tags_file.Add(start, end) << tag; 82 | } 83 | 84 | // FIXME FIXME FIXME: don't use sm.getBufferData(), get the data from the 85 | // cache. 86 | bool invalid = false; 87 | const auto& buffer = sm.getBufferData(sm.getFileID(start), &invalid); 88 | const char* data = buffer.data(); 89 | const auto size = buffer.size(); 90 | assert(!invalid); 91 | 92 | // Find end of line, take \\ in consideration. 93 | auto start_offset = sm.getFileOffset(start); 94 | while (start_offset < size) { 95 | if ((data[start_offset] == '\n' || data[start_offset] == '\r') && 96 | (start_offset == 0 || data[start_offset - 1] != '\\')) 97 | break; 98 | ++start_offset; 99 | } 100 | 101 | // Find start of line, by looking for previous \n. 102 | auto end_offset = sm.getFileOffset(end); 103 | for (; end_offset > 0 && data[end_offset] != '\n' && data[end_offset] != '\r'; 104 | --end_offset) 105 | ; 106 | 107 | WrapWithTag(file, start_offset, end_offset, std::move(tag)); 108 | return true; 109 | } 110 | 111 | bool WrapEolSol(const CompilerInstance& ci, FileCache* cache, 112 | SourceLocation start, SourceLocation end, Tag tag) { 113 | return WrapEolSol(ci.getSourceManager(), cache, start, end, std::move(tag)); 114 | } 115 | -------------------------------------------------------------------------------- /src/wrapping.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef WRAPPING_H 30 | #define WRAPPING_H 31 | 32 | #include "base.h" 33 | #include "cache.h" 34 | #include "common.h" 35 | #include "renderer.h" 36 | 37 | extern void WrapWithTag(FileRenderer::ParsedFile* file, Tag tag); 38 | extern void WrapWithTag(FileRenderer::ParsedFile* file, int bo, int eo, 39 | Tag tag); 40 | 41 | extern bool WrapWithTag(const CompilerInstance& ci, FileCache* cache, 42 | const SourceLocation& obegin, 43 | const SourceLocation& oend, Tag tag); 44 | extern bool WrapWithTag(const CompilerInstance& ci, FileCache* cache, 45 | const SourceRange& to_wrap, Tag tag); 46 | 47 | extern bool WrapEolSol(const SourceManager& sm, FileCache* cache, 48 | SourceLocation start, SourceLocation end, Tag tag); 49 | extern bool WrapEolSol(const CompilerInstance& ci, FileCache* cache, 50 | SourceLocation start, SourceLocation end, Tag tag); 51 | 52 | #endif /* WRAPPING_H */ 53 | -------------------------------------------------------------------------------- /static/animated-modal/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 João Pereira 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /static/animated-modal/animatedModal.js: -------------------------------------------------------------------------------- 1 | /*========================================= 2 | * animatedModal.js: Version 1.0 3 | * author: João Pereira 4 | * website: http://www.joaopereira.pt 5 | * email: joaopereirawd@gmail.com 6 | * Licensed MIT 7 | =========================================*/ 8 | 9 | (function ($) { 10 | $.fn.animatedModal = function(options) { 11 | var modal = $(this); 12 | 13 | //Defaults 14 | var settings = $.extend({ 15 | modalTarget:'animatedModal', 16 | position:'fixed', 17 | height:'100%', 18 | right: '0px', 19 | zIndexIn: '9999', 20 | zIndexOut: '-9999', 21 | color: '#f8f8f8', 22 | opacityIn:'0.9', 23 | opacityOut:'0', 24 | animatedIn:'zoomIn', 25 | animatedOut:'zoomOut', 26 | animationDuration:'.6s', 27 | overflow:'auto', 28 | }, options); 29 | 30 | var href = modal.attr('href'); 31 | var id = modal.attr('id'); 32 | var added = null; 33 | 34 | var overlay = $("
"); 35 | overlay.addClass('animated'); 36 | overlay.addClass(settings.modalTarget+'-off'); 37 | 38 | //Init styles 39 | var initStyles = { 40 | 'dispaly': 'hidden', 41 | 'position':settings.position, 42 | 'width':settings.width, 43 | 'height':settings.height, 44 | 'top':settings.top, 45 | 'right':settings.right, 46 | 'background-color':settings.color, 47 | 'overflow-y':settings.overflow, 48 | 'z-index':settings.zIndexOut, 49 | 'opacity':settings.opacityOut, 50 | '-webkit-animation-duration':settings.animationDuration, 51 | '-moz-animation-duration':settings.animationDuration, 52 | '-ms-animation-duration':settings.animationDuration, 53 | 'animation-duration':settings.animationDuration 54 | }; 55 | //Apply stles 56 | overlay.css(initStyles); 57 | 58 | var loaded = false; 59 | var opened = false; 60 | 61 | var close = function(ev) { 62 | if (ev) ev.preventDefault(); 63 | 64 | if (overlay.hasClass(settings.modalTarget+'-on')) { 65 | overlay.removeClass(settings.modalTarget+'-on'); 66 | overlay.addClass(settings.modalTarget+'-off'); 67 | } 68 | if (overlay.hasClass(settings.modalTarget+'-off')) { 69 | overlay.removeClass(settings.animatedIn); 70 | overlay.addClass(settings.animatedOut); 71 | overlay.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterClose); 72 | }; 73 | } 74 | 75 | var show = function(data) { 76 | modal.addClass("active"); 77 | 78 | var css = {} 79 | var navbar = $('#navbar'); 80 | css.top = navbar.position().top + navbar.outerHeight(true); 81 | if ($(window).width() < 600) { 82 | var clickhandler = function (e) { 83 | console.log("clicked on", e.target) 84 | if ($(e.target).is("a")) { 85 | overlay.one('click', clickhandler); 86 | return; 87 | } 88 | close(e); 89 | }; 90 | overlay.one('click', clickhandler); 91 | css.width = "100%"; 92 | css["padding-left"] = "10px !important"; 93 | } else { 94 | css.width = "400px"; 95 | } 96 | overlay.css(css); 97 | 98 | added = overlay.appendTo("body"); 99 | 100 | if (overlay.hasClass(settings.modalTarget+'-off')) { 101 | overlay.removeClass(settings.animatedOut); 102 | overlay.removeClass(settings.modalTarget+'-off'); 103 | overlay.addClass(settings.modalTarget+'-on'); 104 | } 105 | if (overlay.hasClass(settings.modalTarget+'-on')) { 106 | overlay.css({'opacity':settings.opacityIn,'z-index': settings.zIndexIn}); 107 | overlay.addClass(settings.animatedIn); 108 | overlay.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterOpen); 109 | } 110 | 111 | // FIXME: remove escape code handler? 112 | $(document).on('keyup', function(e) { 113 | if (e.keyCode == 27) close(e); 114 | }); 115 | } 116 | 117 | var open = function () { 118 | if (loaded) { 119 | opened = true; 120 | show(); 121 | return; 122 | } 123 | $.get(href, function (data) { 124 | var temp = $('').append($.parseHTML(data)); 125 | var parsed = temp.find("#" + id + "-data"); 126 | 127 | parsed.appendTo(overlay); 128 | loaded = true; 129 | opened = true; 130 | show(); 131 | }); 132 | }; 133 | 134 | var toggle = function() { 135 | if (opened) { close(); return; } 136 | open(); 137 | }; 138 | 139 | 140 | modal.click(function (ev) { 141 | if (ev) ev.preventDefault(); 142 | toggle(); 143 | }); 144 | function afterOpen() { 145 | } 146 | function afterClose() { 147 | opened = false; 148 | added.remove(); 149 | modal.removeClass("active"); 150 | modal.blur(); 151 | } 152 | 153 | return { toggle: toggle }; 154 | }; 155 | }(jQuery)); 156 | -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /static/bootstrap/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/bootstrap/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /static/bootstrap/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /static/font-awesome/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/font-awesome/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /static/font-awesome/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/font-awesome/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /static/font-awesome/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/font-awesome/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /static/font-awesome/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/font-awesome/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /static/font-awesome/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/static/font-awesome/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /static/js.cookie.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * JavaScript Cookie v2.1.2 3 | * https://github.com/js-cookie/js-cookie 4 | * 5 | * Copyright 2006, 2015 Klaus Hartl & Fagner Brack 6 | * Released under the MIT license 7 | */ 8 | ;(function (factory) { 9 | if (typeof define === 'function' && define.amd) { 10 | define(factory); 11 | } else if (typeof exports === 'object') { 12 | module.exports = factory(); 13 | } else { 14 | var OldCookies = window.Cookies; 15 | var api = window.Cookies = factory(); 16 | api.noConflict = function () { 17 | window.Cookies = OldCookies; 18 | return api; 19 | }; 20 | } 21 | }(function () { 22 | function extend () { 23 | var i = 0; 24 | var result = {}; 25 | for (; i < arguments.length; i++) { 26 | var attributes = arguments[ i ]; 27 | for (var key in attributes) { 28 | result[key] = attributes[key]; 29 | } 30 | } 31 | return result; 32 | } 33 | 34 | function init (converter) { 35 | function api (key, value, attributes) { 36 | var result; 37 | if (typeof document === 'undefined') { 38 | return; 39 | } 40 | 41 | // Write 42 | 43 | if (arguments.length > 1) { 44 | attributes = extend({ 45 | path: '/' 46 | }, api.defaults, attributes); 47 | 48 | if (typeof attributes.expires === 'number') { 49 | var expires = new Date(); 50 | expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); 51 | attributes.expires = expires; 52 | } 53 | 54 | try { 55 | result = JSON.stringify(value); 56 | if (/^[\{\[]/.test(result)) { 57 | value = result; 58 | } 59 | } catch (e) {} 60 | 61 | if (!converter.write) { 62 | value = encodeURIComponent(String(value)) 63 | .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 64 | } else { 65 | value = converter.write(value, key); 66 | } 67 | 68 | key = encodeURIComponent(String(key)); 69 | key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); 70 | key = key.replace(/[\(\)]/g, escape); 71 | 72 | return (document.cookie = [ 73 | key, '=', value, 74 | attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE 75 | attributes.path ? '; path=' + attributes.path : '', 76 | attributes.domain ? '; domain=' + attributes.domain : '', 77 | attributes.secure ? '; secure' : '' 78 | ].join('')); 79 | } 80 | 81 | // Read 82 | 83 | if (!key) { 84 | result = {}; 85 | } 86 | 87 | // To prevent the for loop in the first place assign an empty array 88 | // in case there are no cookies at all. Also prevents odd result when 89 | // calling "get()" 90 | var cookies = document.cookie ? document.cookie.split('; ') : []; 91 | var rdecode = /(%[0-9A-Z]{2})+/g; 92 | var i = 0; 93 | 94 | for (; i < cookies.length; i++) { 95 | var parts = cookies[i].split('='); 96 | var cookie = parts.slice(1).join('='); 97 | 98 | if (cookie.charAt(0) === '"') { 99 | cookie = cookie.slice(1, -1); 100 | } 101 | 102 | try { 103 | var name = parts[0].replace(rdecode, decodeURIComponent); 104 | cookie = converter.read ? 105 | converter.read(cookie, name) : converter(cookie, name) || 106 | cookie.replace(rdecode, decodeURIComponent); 107 | 108 | if (this.json) { 109 | try { 110 | cookie = JSON.parse(cookie); 111 | } catch (e) {} 112 | } 113 | 114 | if (key === name) { 115 | result = cookie; 116 | break; 117 | } 118 | 119 | if (!key) { 120 | result[name] = cookie; 121 | } 122 | } catch (e) {} 123 | } 124 | 125 | return result; 126 | } 127 | 128 | api.set = api; 129 | api.get = function (key) { 130 | return api.call(api, key); 131 | }; 132 | api.getJSON = function () { 133 | return api.apply({ 134 | json: true 135 | }, [].slice.call(arguments)); 136 | }; 137 | api.defaults = {}; 138 | 139 | api.remove = function (key, attributes) { 140 | api(key, '', extend(attributes, { 141 | expires: -1 142 | })); 143 | }; 144 | 145 | api.withConverter = init; 146 | 147 | return api; 148 | } 149 | 150 | return init(function () {}); 151 | })); 152 | -------------------------------------------------------------------------------- /static/metrics.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 18px; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /static/metrics.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Metrics 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /static/metrics.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function secondsToHms(d) { 4 | d = Number(d); 5 | var h = Math.floor(d / 3600); 6 | var m = Math.floor(d % 3600 / 60); 7 | var s = Math.floor(d % 3600 % 60); 8 | 9 | var H = h > 0 ? `${h}H `: ""; 10 | var M = m > 0 ? `${m}M `: ""; 11 | var S = s > 0 ? `${s}S` : ""; 12 | return H + M + S; 13 | } 14 | 15 | function ShowLabels(selector, data) { 16 | var labels = {}; 17 | var restricted = {}; 18 | 19 | for (const point of data) { 20 | for (const label of point.label) { 21 | elements = label.split(":", 1); 22 | if (!labels[elements[0]]) { 23 | labels[elements[0]] = {} 24 | } 25 | labels[elements[0]][label] = true; 26 | } 27 | } 28 | if (labels.size <= 0) return; 29 | 30 | var categories = Object.keys(labels); 31 | categories.sort(); 32 | 33 | for (const category of categories) { 34 | var toggled = {}; 35 | var id = `${selector}-${category}-labels`; 36 | var buttons = $(`#${selector}`).append( 37 | `
${category}:
`); 38 | var elements = Object.keys(labels[category]); 39 | elements.sort(); 40 | for (const label of elements) { 41 | var hlabel = label.slice(category.length + 1); 42 | $(`#${id}`).append(``); 43 | } 44 | 45 | $(`#${id} button`).click(function() { 46 | var label = $(this).data('label'); 47 | if (toggled[label]) { 48 | toggled[label] = false; 49 | delete restricted[label]; 50 | } else { 51 | toggled[label] = true; 52 | restricted[label] = true; 53 | } 54 | 55 | var filtered = data; 56 | if (Object.keys(restricted).length > 0) { 57 | filtered = data.filter(function (element) { 58 | if (!element.label) return false; 59 | 60 | for (const label of element.label) { 61 | if (restricted[label]) return true; 62 | } 63 | return false; 64 | }); 65 | } 66 | ShowGraph(selector, filtered); 67 | }); 68 | } 69 | } 70 | 71 | function PrepareData(selector, data) { 72 | // %Q -> milliseconds since epoch, %s -> seconds since epoch. 73 | // https://github.com/d3/d3-time-format/blob/master/README.md#timeFormat 74 | var converter = d3.timeParse('%Q'); 75 | if (selector.endsWith("-rss")) { 76 | data = data.map(function(t) { t.time = converter(t.time); t.value = t.value * 1024; return t; }); 77 | } else if (selector.endsWith("-time")) { 78 | data = data.map(function(t) { t.time = converter(t.time); t.value = t.value / 1000; return t; }); 79 | } else { 80 | converter = d3.timeParse('%s'); 81 | data = data.map(function(t) { t.time = converter(t.time); return t; }); 82 | } 83 | return data; 84 | } 85 | 86 | function ShowGraph(selector, data) { 87 | var formatter = d3.format(',.2s'); 88 | if (selector.endsWith("-time")) { 89 | formatter = secondsToHms 90 | } 91 | 92 | MG.data_graphic({ 93 | title: selector, 94 | description: "", 95 | data: data, 96 | width: 1200, 97 | height: 500, 98 | right: 40, 99 | area: false, 100 | target: document.getElementById(selector), 101 | mouseover: function(d, i) { 102 | var tf = d3.timeFormat('%b %e, %Y %H:%M:%S'); 103 | var text = ""; 104 | if (data[i].label) { 105 | text += data[i].label; 106 | } 107 | 108 | d3.select(`#${selector} svg .mg-active-datapoint`).html( 109 | `${tf(d.time)} ${formatter(d.value)}${text}`) 110 | }, 111 | x_accessor: 'time', 112 | y_accessor: 'value', 113 | brush: 'xy' 114 | }); 115 | } 116 | 117 | $(document).ready(function() { 118 | $.get("../metrics/api/list", function(metrics) { 119 | var node = $("#main"); 120 | for (const metric of metrics) { 121 | node.append(`
`); 122 | 123 | $.post(`../metrics/api/get/offset/${metric}`, "{}", function(data) { 124 | var polished = PrepareData(metric, data.point); 125 | ShowGraph(metric, polished); 126 | ShowLabels(metric, polished); 127 | }, "json"); 128 | } 129 | }); 130 | }); 131 | -------------------------------------------------------------------------------- /static/news.json: -------------------------------------------------------------------------------- 1 | {"news": [{"message": "Much better macro handling.", "time": 1551822763}, {"message": "Sbexr now uses llvm 8.0.", "time": 1549576256}]} -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | body { padding-top: 70px; background-color: white; } 2 | .type { color: green} 3 | .code { border-style: none; border-collapse:collapse; width:100%; } 4 | .code { font-family: 'Monospace', monospace; font-size:10pt } 5 | .code { line-height: 1.2em; background-color: transparent; z-index: 10; } 6 | 7 | #path li { 8 | display: inline 9 | } 10 | #path { 11 | display: inline; 12 | margin: 0; 13 | padding: 0; 14 | } 15 | #path li:after { 16 | content: "/" 17 | } 18 | 19 | #beta { 20 | position: fixed; 21 | bottom: 0px; 22 | right: 10px; 23 | opacity: 0.9; 24 | } 25 | 26 | #line-number { 27 | float:left; 28 | margin:0 1em 0 -1em; 29 | border-right:1px solid; 30 | border-right-color: #9E9E9E; 31 | text-align:right; 32 | } 33 | #line-number i { 34 | display:block; 35 | padding:0 .5em 0 1em; 36 | font-style: normal; 37 | font-size: smaller; 38 | color: #9E9E9E; 39 | } 40 | 41 | pre .cl { 42 | display:block; 43 | clear:both; 44 | } 45 | 46 | .js-highlight { 47 | float: left; 48 | background-color: yellow; 49 | z-index: -1; 50 | position: absolute; 51 | width: 100%; 52 | } 53 | 54 | .js-prompt { 55 | float: left; 56 | position: fixed; 57 | bottom: 0; 58 | background: white; 59 | width: 100%; 60 | } 61 | .correct-height { 62 | height: 34px !important; 63 | } 64 | 65 | .autocomplete-suggestions { border: 1px solid #999; background-color: rgba(255, 255, 255, 0.9); overflow: auto; } 66 | .autocomplete-suggestion { padding: 2px 5px; white-space: nowrap; overflow: hidden; } 67 | .autocomplete-selected { background: #F0F0F0; } 68 | .autocomplete-suggestions strong { font-weight: normal; color: #3399FF; } 69 | .autocomplete-group { padding: 2px 5px; } 70 | .autocomplete-group strong { display: block; border-bottom: 1px solid #000; } 71 | 72 | .compound { display: inline-block; } 73 | .compound:hover { border-left-style: solid; border-left-width: 2px; } 74 | .compound.level-0:hover { margin-left: -2px; border-left-color: yellow; } 75 | .compound.level-1:hover { margin-left: -4px; padding-left: 2px; border-left-color: green; } 76 | .compound.level-2:hover { margin-left: -6px; padding-left: 4px; border-left-color: orange; } 77 | .compound.level-3:hover { margin-left: -8px; padding-left: 6px; border-left-color: brown; } 78 | .compound.level-4:hover { margin-left: -12px; padding-left: 8px; border-left-color: brown; } 79 | .compound.level-5:hover { margin-left: -14px; padding-left: 10px; border-left-color: brown; } 80 | .compound.level-6:hover { margin-left: -16px; padding-left: 12px; border-left-color: brown; } 81 | .compound.level-7:hover { margin-left: -18px; padding-left: 14px; border-left-color: brown; } 82 | .compound.level-8:hover { margin-left: -20px; padding-left: 16px; border-left-color: brown; } 83 | .compound.level-9:hover { margin-left: -22px; padding-left: 18px; border-left-color: brown; } 84 | .comment { color: #00C4FF; font-style: oblique } 85 | .string { color: purple; } 86 | .numeric { color: purple; } 87 | .char { color: purple; } 88 | .directive { color: #0400FF; } 89 | .keyword { color: #4CAF50; } 90 | a.decl:hover { text-decoration: none !important; } 91 | /* Yellow highlighting of href targets */ 92 | *:target { animation: hilite 2.5s; } 93 | @keyframes hilite { 94 | 0% {background: transparent;} 95 | 10% {background: #f8f99a;} 96 | 100% {background: transparent;} 97 | } 98 | /* HREF within the same page refer to elements 99 | * with the id attribute. This trick makes those elements 100 | * not appear at the top of the page when a link is followed, 101 | * rather 75 pixel below, allowing for the navbar at the top 102 | * not to hide content, while being nicer to use. */ 103 | *[id]:before { 104 | display: block; 105 | content: " "; 106 | margin-top: -75px; 107 | height: 75px; 108 | visibility: hidden; 109 | float: left; 110 | z-index: 3; 111 | } 112 | .muted *, .muted span, .muted { 113 | /* color: grey !important; */ 114 | opacity: 0.5 !important; 115 | /* text-decoration: blink !important; */ 116 | } 117 | .macro-undefined *:hover, .macro-undefined span:hover, .macro-undefined:hover { 118 | text-decoration: underline wavy red !important; 119 | } 120 | 121 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | test-single-file 2 | test-multiple-file 3 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | LLVMVERSION := 8 2 | LLVMCONFIG := llvm-config-$(LLVMVERSION) 3 | LIBS := $(shell $(LLVMCONFIG) --libs) 4 | CXXFLAGS := $(shell $(LLVMCONFIG) --cxxflags) -ggdb3 -O0 -I../ 5 | LDFLAGS := $(shell $(LLVMCONFIG) --ldflags) 6 | #CFLAGS += -ccc-print-phases 7 | #CXXFLAGS += -ccc-print-phases 8 | EXTRALIBS := 9 | CC := clang-$(LLVMVERSION) 10 | CXX := clang-$(LLVMVERSION) 11 | 12 | all: test-single test-multi 13 | 14 | dump-single: 15 | clang-$(LLVMVERSION) -Xclang -ast-dump -fsyntax-only $(CXXFLAGS) $(LIBS) $(LIBDIR) ./test-single-file.c 16 | 17 | dump-multi: 18 | clang-$(LLVMVERSION) -Xclang -ast-dump -fsyntax-only $(CXXFLAGS) $(LIBS) $(LIBDIR) ./test-multiple-file-0.cc 19 | clang-$(LLVMVERSION) -Xclang -ast-dump -fsyntax-only $(CXXFLAGS) $(LIBS) $(LIBDIR) ./test-multiple-file-1.cc 20 | 21 | 22 | test-single: test-single-file 23 | 24 | test-single-file: test-single-file.o 25 | 26 | test-single-file.o: test-single-file.c test-single-file.h 27 | 28 | test-multi: test-multiple-file 29 | 30 | test-multiple-file: test-multiple-file-0.o test-multiple-file-1.o 31 | $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBS) $(LIBDIR) -o test-multiple-file $^ $(EXTRALIBS) 32 | 33 | test-multiple-file-0.o: test-multiple-file-0.cc test-multiple-file-0.h 34 | 35 | test-multiple-file-1.o: test-multiple-file-1.cc test-multiple-file-1.h 36 | 37 | format: 38 | clang-format-$(LLVMVERSION) --style=google -i *.cc *.h 39 | 40 | clean: 41 | rm -f test-multiple-file test-single-file 42 | rm -f *.o 43 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | THIS IS A TEST README FILE 2 | 3 | In this directory, test files used to compare input and output. 4 | -------------------------------------------------------------------------------- /test/include-all.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef INCLUDE_ALL_H 30 | # define INCLUDE_ALL_H 31 | 32 | # include "stdio.h" 33 | 34 | static inline void IncludedByAll(int value) { 35 | printf("%d\n", value); 36 | } 37 | 38 | # define MACRO_HIGHEST 65535 39 | # define MACRO_RECURSIVE MACRO_HIGHEST 40 | 41 | # define MACRO(A) IncludedByAll(A) 42 | # define MACROP(B) printf(B) 43 | # define FIELD(A) A 44 | 45 | #endif /* INCLUDE_ALL_H */ 46 | -------------------------------------------------------------------------------- /test/metrics/bear-build-rss-00000001.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/test/metrics/bear-build-rss-00000001.data -------------------------------------------------------------------------------- /test/metrics/bear-build-time-00000001.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/test/metrics/bear-build-time-00000001.data -------------------------------------------------------------------------------- /test/metrics/sbexr-run-rss-00000001.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/test/metrics/sbexr-run-rss-00000001.data -------------------------------------------------------------------------------- /test/metrics/sbexr-run-time-00000001.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/test/metrics/sbexr-run-time-00000001.data -------------------------------------------------------------------------------- /test/output/sources/00/eb21e8e066d2fe.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"FILE.h","path":"/usr/include/x86_64-linux-gnu/bits/types/FILE.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"},{"name":"types","href":"../50/6c0d28222dde39.html"}]} 2 | --- 3 | #ifndef __FILE_defined 4 | #define __FILE_defined 1 5 | 6 | struct _IO_FILE; 7 | 8 | /* The opaque type of streams. This is the definition used elsewhere. */ 9 | typedef struct _IO_FILE FILE; 10 | 11 | #endif -------------------------------------------------------------------------------- /test/output/sources/06/416cc91f3e3d90.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"","path":"/","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[],"dirs":[{"href":"../c6/5145c887253142.html","size":0,"name":"opt"},{"href":"../60/7abc7e1c17ae25.html","size":0,"name":"usr"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/0a/9de303fcf49f53.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"clang","path":"/usr/include/clang","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"}],"dirs":[{"href":"../19/901c5d9478e5ce.html","size":3,"name":".."},{"href":"../be/b21853bfd529ee.html","size":0,"name":"8.0.0"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/0c/a8a47b0c4f7800.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"stdio_lim.h","path":"/usr/include/x86_64-linux-gnu/bits/stdio_lim.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"}]} 2 | --- 3 | /* Copyright (C) 1994-2018 Free Software Foundation, Inc. 4 | This file is part of the GNU C Library. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | <http://www.gnu.org/licenses/>. */ 19 | 20 | #ifndef _BITS_STDIO_LIM_H 21 | #define _BITS_STDIO_LIM_H 1 22 | 23 | #ifndef _STDIO_H 24 | # error "Never include <bits/stdio_lim.h> directly; use <stdio.h> instead." 25 | #endif 26 | 27 | #define L_tmpnam 20 28 | #define TMP_MAX 238328 29 | #define FILENAME_MAX 4096 30 | 31 | #ifdef __USE_POSIX 32 | # define L_ctermid 9 33 | # if !defined __USE_XOPEN2K || defined __USE_GNU 34 | # define L_cuserid 9 35 | # endif 36 | #endif 37 | 38 | #undef FOPEN_MAX 39 | #define FOPEN_MAX 16 40 | 41 | #endif /* bits/stdio_lim.h */ -------------------------------------------------------------------------------- /test/output/sources/0d/97c98f8e7f311c.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"compile_commands.json","path":"compile_commands.json","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | [ 4 | { 5 | "arguments": [ 6 | "g++", 7 | "-c", 8 | "-I/usr/lib/llvm-3.9/include", 9 | "-std=c++0x", 10 | "-fPIC", 11 | "-fvisibility-inlines-hidden", 12 | "-Wall", 13 | "-W", 14 | "-Wno-unused-parameter", 15 | "-Wwrite-strings", 16 | "-Wcast-qual", 17 | "-Wno-missing-field-initializers", 18 | "-pedantic", 19 | "-Wno-long-long", 20 | "-Wno-maybe-uninitialized", 21 | "-Wdelete-non-virtual-dtor", 22 | "-Wno-comment", 23 | "-Werror=date-time", 24 | "-std=c++11", 25 | "-ffunction-sections", 26 | "-fdata-sections", 27 | "-O2", 28 | "-g", 29 | "-DNDEBUG", 30 | "-fno-exceptions", 31 | "-D_GNU_SOURCE", 32 | "-D__STDC_CONSTANT_MACROS", 33 | "-D__STDC_FORMAT_MACROS", 34 | "-D__STDC_LIMIT_MACROS", 35 | "-ggdb3", 36 | "-O0", 37 | "-I../", 38 | "-o", 39 | "test-multiple-file-1.o", 40 | "test-multiple-file-1.cc" 41 | ], 42 | "directory": "/opt/projects/sbexr/test", 43 | "file": "test-multiple-file-1.cc" 44 | }, 45 | { 46 | "arguments": [ 47 | "g++", 48 | "-c", 49 | "-I/usr/lib/llvm-3.9/include", 50 | "-std=c++0x", 51 | "-fPIC", 52 | "-fvisibility-inlines-hidden", 53 | "-Wall", 54 | "-W", 55 | "-Wno-unused-parameter", 56 | "-Wwrite-strings", 57 | "-Wcast-qual", 58 | "-Wno-missing-field-initializers", 59 | "-pedantic", 60 | "-Wno-long-long", 61 | "-Wno-maybe-uninitialized", 62 | "-Wdelete-non-virtual-dtor", 63 | "-Wno-comment", 64 | "-Werror=date-time", 65 | "-std=c++11", 66 | "-ffunction-sections", 67 | "-fdata-sections", 68 | "-O2", 69 | "-g", 70 | "-DNDEBUG", 71 | "-fno-exceptions", 72 | "-D_GNU_SOURCE", 73 | "-D__STDC_CONSTANT_MACROS", 74 | "-D__STDC_FORMAT_MACROS", 75 | "-D__STDC_LIMIT_MACROS", 76 | "-ggdb3", 77 | "-O0", 78 | "-I../", 79 | "-o", 80 | "test-multiple-file-0.o", 81 | "test-multiple-file-0.cc" 82 | ], 83 | "directory": "/opt/projects/sbexr/test", 84 | "file": "test-multiple-file-0.cc" 85 | } 86 | ] -------------------------------------------------------------------------------- /test/output/sources/19/901c5d9478e5ce.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"include","path":"/usr/include","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"}],"files":[{"name":"features.h","type":"parsed","href":"../08/80fafb6e566ce0.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":15565},{"name":"stdc-predef.h","type":"parsed","href":"../de/54dd5925795da2.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":2289},{"name":"stdio.h","type":"parsed","href":"../6f/078dbcc264af74.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":30168}],"dirs":[{"href":"../60/7abc7e1c17ae25.html","size":0,"name":".."},{"href":"../0a/9de303fcf49f53.html","size":0,"name":"clang"},{"href":"../f0/212845f8a256c3.html","size":0,"name":"x86_64-linux-gnu"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/23/32e20e89ff3dae.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"bits","path":"/usr/include/x86_64-linux-gnu/bits","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"}],"files":[{"name":"libc-header-start.h","type":"parsed","href":"../e1/6f60ab16e47e49.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":2607},{"name":"long-double.h","type":"parsed","href":"../2b/f7ba919473f734.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":923},{"name":"stdio_lim.h","type":"parsed","href":"../0c/a8a47b0c4f7800.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":1212},{"name":"sys_errlist.h","type":"parsed","href":"../b2/5867ddc3014e6a.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":1215},{"name":"types.h","type":"parsed","href":"../41/e28fc1cdef774c.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":8326},{"name":"typesizes.h","type":"parsed","href":"../44/abbd7f05c3bb64.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":3397},{"name":"wordsize.h","type":"parsed","href":"../fd/cacc45a9906e85.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":442}],"dirs":[{"href":"../f0/212845f8a256c3.html","size":0,"name":".."},{"href":"../50/6c0d28222dde39.html","size":7,"name":"types"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/24/f5ced826dbe9a5.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test-multiple-file-0.o","path":"test-multiple-file-0.o","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | <unparsable blob> -------------------------------------------------------------------------------- /test/output/sources/2b/f7ba919473f734.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"long-double.h","path":"/usr/include/x86_64-linux-gnu/bits/long-double.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"}]} 2 | --- 3 | /* Properties of long double type. ldbl-96 version. 4 | Copyright (C) 2016-2018 Free Software Foundation, Inc. 5 | This file is part of the GNU C Library. 6 | 7 | The GNU C Library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | The GNU C Library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with the GNU C Library; if not, see 19 | <http://www.gnu.org/licenses/>. */ 20 | 21 | /* long double is distinct from double, so there is nothing to 22 | define here. */ -------------------------------------------------------------------------------- /test/output/sources/44/7afd378fb9bef7.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"stdarg.h","path":"/usr/include/clang/8.0.0/include/stdarg.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"clang","href":"../0a/9de303fcf49f53.html"},{"name":"8.0.0","href":"../be/b21853bfd529ee.html"},{"name":"include","href":"../81/d9c49f99af3d0a.html"}]} 2 | --- 3 | /*===---- stdarg.h - Variable argument handling ----------------------------=== 4 | * 5 | * Copyright (c) 2008 Eli Friedman 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | *===-----------------------------------------------------------------------=== 26 | */ 27 | 28 | #ifndef __STDARG_H 29 | #define __STDARG_H 30 | 31 | #ifndef _VA_LIST 32 | typedef __builtin_va_list va_list; 33 | #define _VA_LIST 34 | #endif 35 | #define va_start(ap, param) __builtin_va_start(ap, param) 36 | #define va_end(ap) __builtin_va_end(ap) 37 | #define va_arg(ap, type) __builtin_va_arg(ap, type) 38 | 39 | /* GCC always defines __va_copy, but does not define va_copy unless in c99 mode 40 | * or -ansi is not specified, since it was not part of C90. 41 | */ 42 | #define __va_copy(d,s) __builtin_va_copy(d,s) 43 | 44 | #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__) 45 | #define va_copy(dest, src) __builtin_va_copy(dest, src) 46 | #endif 47 | 48 | #ifndef __GNUC_VA_LIST 49 | #define __GNUC_VA_LIST 1 50 | typedef __builtin_va_list __gnuc_va_list; 51 | #endif 52 | 53 | #endif /* __STDARG_H */ -------------------------------------------------------------------------------- /test/output/sources/50/6c0d28222dde39.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"types","path":"/usr/include/x86_64-linux-gnu/bits/types","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"}],"files":[{"name":"FILE.h","type":"parsed","href":"../00/eb21e8e066d2fe.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":180},{"name":"__FILE.h","type":"parsed","href":"../77/97ec9572248ea4.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":110},{"name":"__fpos64_t.h","type":"parsed","href":"../fa/0a0d3d8e7cc07c.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":410},{"name":"__fpos_t.h","type":"parsed","href":"../a3/5161b30e4c9c85.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":381},{"name":"__mbstate_t.h","type":"parsed","href":"../57/27d4eb0ac27416.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":564},{"name":"cookie_io_functions_t.h","type":"parsed","href":"../f9/72a0e406b846b3.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":2724},{"name":"struct_FILE.h","type":"parsed","href":"../91/8bbaed7fe58735.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":4103}],"dirs":[{"href":"../23/32e20e89ff3dae.html","size":7,"name":".."}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/57/27d4eb0ac27416.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"__mbstate_t.h","path":"/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"},{"name":"types","href":"../50/6c0d28222dde39.html"}]} 2 | --- 3 | #ifndef ____mbstate_t_defined 4 | #define ____mbstate_t_defined 1 5 | 6 | /* Integral type unchanged by default argument promotions that can 7 | hold any value corresponding to members of the extended character 8 | set, as well as at least one value that does not correspond to any 9 | member of the extended character set. */ 10 | #ifndef __WINT_TYPE__ 11 | # define __WINT_TYPE__ unsigned int 12 | #endif 13 | 14 | /* Conversion state information. */ 15 | typedef struct 16 | { 17 | int __count; 18 | union 19 | { 20 | __WINT_TYPE__ __wch; 21 | char __wchb[4]; 22 | } __value; /* Value so far. */ 23 | } __mbstate_t; 24 | 25 | #endif -------------------------------------------------------------------------------- /test/output/sources/60/7abc7e1c17ae25.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"usr","path":"/usr","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[],"dirs":[{"href":"../06/416cc91f3e3d90.html","size":0,"name":".."},{"href":"../19/901c5d9478e5ce.html","size":3,"name":"include"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/67/481f5ed307a09b.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test-single-file.c","path":"test-single-file.c","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | #include <stdio.h> 4 | #include "test-single-file.h" 5 | 6 | # define TEST(foo) if (foo) { printf("foo"); } 7 | int global = 0; 8 | 9 | /// Test comment. 10 | int test() { 11 | printf("this is a test"); 12 | 13 | { 14 | int a = 9; 15 | printf("this is another test: %d", a); 16 | 17 | } 18 | 19 | return 3; 20 | } 21 | 22 | // This is a pre-existing comment. 23 | /** Test comment */ 24 | int main(void) { 25 | int value = 12; 26 | if (1) { value = test(); 27 | if (value > 5) { 28 | printf("this is a second test"); 29 | } 30 | } 31 | 32 | toast foo = {0, 100}; 33 | while (foo.foo != foo.bar) { 34 | printf("this is another test %d", foo.foo); 35 | ++foo.foo; 36 | } 37 | global += 3; 38 | TEST(value); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /test/output/sources/6a/77ce5d776029cb.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"stubs.h","path":"/usr/include/x86_64-linux-gnu/gnu/stubs.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"gnu","href":"../92/0259119a2aa95d.html"}]} 2 | --- 3 | /* This file is automatically generated. 4 | This file selects the right generated file of `__stub_FUNCTION' macros 5 | based on the architecture being compiled for. */ 6 | 7 | 8 | #if !defined __x86_64__ 9 | # include <gnu/stubs-32.h> 10 | #endif 11 | #if defined __x86_64__ && defined __LP64__ 12 | # include <gnu/stubs-64.h> 13 | #endif 14 | #if defined __x86_64__ && defined __ILP32__ 15 | # include <gnu/stubs-x32.h> 16 | #endif -------------------------------------------------------------------------------- /test/output/sources/77/97ec9572248ea4.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"__FILE.h","path":"/usr/include/x86_64-linux-gnu/bits/types/__FILE.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"},{"name":"types","href":"../50/6c0d28222dde39.html"}]} 2 | --- 3 | #ifndef ____FILE_defined 4 | #define ____FILE_defined 1 5 | 6 | struct _IO_FILE; 7 | typedef struct _IO_FILE __FILE; 8 | 9 | #endif -------------------------------------------------------------------------------- /test/output/sources/81/3a8befd5338881.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/test/output/sources/81/3a8befd5338881.png -------------------------------------------------------------------------------- /test/output/sources/81/d9c49f99af3d0a.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"include","path":"/usr/include/clang/8.0.0/include","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"clang","href":"../0a/9de303fcf49f53.html"},{"name":"8.0.0","href":"../be/b21853bfd529ee.html"}],"files":[{"name":"stdarg.h","type":"parsed","href":"../44/7afd378fb9bef7.html","mtime":"Thu Feb 7 08:08:42 2019\n","size":2024},{"name":"stddef.h","type":"parsed","href":"../fd/abf26b4f65020a.html","mtime":"Thu Feb 7 08:08:42 2019\n","size":4498}],"dirs":[{"href":"../be/b21853bfd529ee.html","size":0,"name":".."}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/83/9c78609ba8228b.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"projects","path":"/opt/projects","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"opt","href":"../c6/5145c887253142.html"}],"dirs":[{"href":"../c6/5145c887253142.html","size":0,"name":".."},{"href":"../d2/c60e58c28f84da.html","size":0,"name":"sbexr"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/91/38a7b144866997.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test-multiple-file-1.o","path":"test-multiple-file-1.o","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | <unparsable blob> -------------------------------------------------------------------------------- /test/output/sources/92/0259119a2aa95d.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"gnu","path":"/usr/include/x86_64-linux-gnu/gnu","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"}],"files":[{"name":"stubs-64.h","type":"parsed","href":"../b4/1f7b6f8bf83afb.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":613},{"name":"stubs.h","type":"parsed","href":"../6a/77ce5d776029cb.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":384}],"dirs":[{"href":"../f0/212845f8a256c3.html","size":0,"name":".."}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/97/537cbc7aefc4ad.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"sys","path":"/usr/include/x86_64-linux-gnu/sys","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"}],"files":[{"name":"cdefs.h","type":"parsed","href":"../11/d2796f2851903a.html","mtime":"Sat Jan 12 09:50:25 2019\n","size":18008}],"dirs":[{"href":"../f0/212845f8a256c3.html","size":0,"name":".."}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/a2/d30e2ef9ad247b.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"Makefile","path":"Makefile","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | LLVMVERSION := 8 4 | LLVMCONFIG := llvm-config-$(LLVMVERSION) 5 | LIBS := $(shell $(LLVMCONFIG) --libs) 6 | CXXFLAGS := $(shell $(LLVMCONFIG) --cxxflags) -ggdb3 -O0 -I../ 7 | LDFLAGS := $(shell $(LLVMCONFIG) --ldflags) 8 | #CFLAGS += -ccc-print-phases 9 | #CXXFLAGS += -ccc-print-phases 10 | EXTRALIBS := 11 | CC := clang-$(LLVMVERSION) 12 | CXX := clang-$(LLVMVERSION) 13 | 14 | all: test-single test-multi 15 | 16 | dump-single: 17 | clang-$(LLVMVERSION) -Xclang -ast-dump -fsyntax-only $(CXXFLAGS) $(LIBS) $(LIBDIR) ./test-single-file.c 18 | 19 | dump-multi: 20 | clang-$(LLVMVERSION) -Xclang -ast-dump -fsyntax-only $(CXXFLAGS) $(LIBS) $(LIBDIR) ./test-multiple-file-0.cc 21 | clang-$(LLVMVERSION) -Xclang -ast-dump -fsyntax-only $(CXXFLAGS) $(LIBS) $(LIBDIR) ./test-multiple-file-1.cc 22 | 23 | 24 | test-single: test-single-file 25 | 26 | test-single-file: test-single-file.o 27 | 28 | test-single-file.o: test-single-file.c test-single-file.h 29 | 30 | test-multi: test-multiple-file 31 | 32 | test-multiple-file: test-multiple-file-0.o test-multiple-file-1.o 33 | $(CXX) $(CXXFLAGS) $(LDFLAGS) $(LIBS) $(LIBDIR) -o test-multiple-file $^ $(EXTRALIBS) 34 | 35 | test-multiple-file-0.o: test-multiple-file-0.cc test-multiple-file-0.h 36 | 37 | test-multiple-file-1.o: test-multiple-file-1.cc test-multiple-file-1.h 38 | 39 | format: 40 | clang-format-$(LLVMVERSION) --style=google -i *.cc *.h 41 | 42 | clean: 43 | rm -f test-multiple-file test-single-file 44 | rm -f *.o 45 | -------------------------------------------------------------------------------- /test/output/sources/a3/5161b30e4c9c85.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"__fpos_t.h","path":"/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"},{"name":"types","href":"../50/6c0d28222dde39.html"}]} 2 | --- 3 | #ifndef _____fpos_t_defined 4 | #define _____fpos_t_defined 1 5 | 6 | #include <bits/types.h> 7 | #include <bits/types/__mbstate_t.h> 8 | 9 | /* The tag name of this struct is _G_fpos_t to preserve historic 10 | C++ mangled names for functions taking fpos_t arguments. 11 | That name should not be used in new code. */ 12 | typedef struct _G_fpos_t 13 | { 14 | __off_t __pos; 15 | __mbstate_t __state; 16 | } __fpos_t; 17 | 18 | #endif -------------------------------------------------------------------------------- /test/output/sources/b2/5867ddc3014e6a.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"sys_errlist.h","path":"/usr/include/x86_64-linux-gnu/bits/sys_errlist.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"}]} 2 | --- 3 | /* Declare sys_errlist and sys_nerr, or don't. Compatibility (do) version. 4 | Copyright (C) 2002-2018 Free Software Foundation, Inc. 5 | This file is part of the GNU C Library. 6 | 7 | The GNU C Library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | The GNU C Library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with the GNU C Library; if not, see 19 | <http://www.gnu.org/licenses/>. */ 20 | 21 | #ifndef _STDIO_H 22 | # error "Never include <bits/sys_errlist.h> directly; use <stdio.h> instead." 23 | #endif 24 | 25 | /* sys_errlist and sys_nerr are deprecated. Use strerror instead. */ 26 | 27 | #ifdef __USE_MISC 28 | extern int sys_nerr; 29 | extern const char *const sys_errlist[]; 30 | #endif 31 | #ifdef __USE_GNU 32 | extern int _sys_nerr; 33 | extern const char *const _sys_errlist[]; 34 | #endif -------------------------------------------------------------------------------- /test/output/sources/b4/1f7b6f8bf83afb.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"stubs-64.h","path":"/usr/include/x86_64-linux-gnu/gnu/stubs-64.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"gnu","href":"../92/0259119a2aa95d.html"}]} 2 | --- 3 | /* This file is automatically generated. 4 | It defines a symbol `__stub_FUNCTION' for each function 5 | in the C library which is a stub, meaning it will fail 6 | every time called, usually setting errno to ENOSYS. */ 7 | 8 | #ifdef _LIBC 9 | # error Applications may not define the macro _LIBC 10 | #endif 11 | 12 | #define __stub___compat_bdflush 13 | #define __stub_chflags 14 | #define __stub_fattach 15 | #define __stub_fchflags 16 | #define __stub_fdetach 17 | #define __stub_getmsg 18 | #define __stub_gtty 19 | #define __stub_lchmod 20 | #define __stub_putmsg 21 | #define __stub_revoke 22 | #define __stub_setlogin 23 | #define __stub_sigreturn 24 | #define __stub_sstk 25 | #define __stub_stty -------------------------------------------------------------------------------- /test/output/sources/bc/764de7984141e0.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"include-all.h","path":"include-all.h","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | // The views and conclusions contained in the software and documentation are 28 | // those of the authors and should not be interpreted as representing official 29 | // policies, either expressed or implied, of Carlo Contavalli. 30 | 31 | #ifndef INCLUDE_ALL_H 32 | # define INCLUDE_ALL_H 33 | 34 | # include "stdio.h" 35 | 36 | static inline void IncludedByAll(int value) { 37 | printf("%d\n", value); 38 | } 39 | 40 | # define MACRO_HIGHEST 65535 41 | # define MACRO_RECURSIVE MACRO_HIGHEST 42 | 43 | # define MACRO(A) IncludedByAll(A) 44 | # define MACROP(B) printf(B) 45 | # define FIELD(A) A 46 | 47 | #endif /* INCLUDE_ALL_H */ -------------------------------------------------------------------------------- /test/output/sources/be/b21853bfd529ee.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"8.0.0","path":"/usr/include/clang/8.0.0","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"clang","href":"../0a/9de303fcf49f53.html"}],"dirs":[{"href":"../0a/9de303fcf49f53.html","size":0,"name":".."},{"href":"../81/d9c49f99af3d0a.html","size":2,"name":"include"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/be/e2916b98dcf1fc.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test","path":"/","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[],"files":[{"name":".gitignore","type":"text","href":"../d2/b0f1e1540e4279.html","mtime":"Thu Aug 18 00:36:13 2016\n","size":36},{"name":"Makefile","type":"text","href":"../a2/d30e2ef9ad247b.html","mtime":"Wed Mar 6 08:21:17 2019\n","size":1298},{"name":"README","type":"text","href":"../c9/859e7aa7cc3530.html","mtime":"Sun Sep 4 07:31:22 2016\n","size":92},{"name":"compile_commands.json","type":"text","href":"../0d/97c98f8e7f311c.html","mtime":"Tue Feb 12 17:33:18 2019\n","size":2342},{"name":"include-all.h","type":"parsed","href":"../bc/764de7984141e0.html","mtime":"Mon Feb 25 09:27:34 2019\n","size":1930},{"name":"tags","type":"text","href":"../29/15508da39cdcce.html","mtime":"Tue Mar 5 10:12:46 2019\n","size":1683697},{"name":"test-clang.html","type":"text","href":"../b9/1a03c8e3d833c6.html","mtime":"Thu May 19 10:11:48 2016\n","size":5117},{"name":"test-multiple-file","type":"blob","href":"../c8/b5fc81b5bf752b.html","mtime":"Fri Mar 8 20:54:30 2019\n","size":20960},{"name":"test-multiple-file-0.cc","type":"parsed","href":"../7c/1572fe148af43d.html","mtime":"Mon Sep 5 06:40:50 2016\n","size":2677},{"name":"test-multiple-file-0.h","type":"parsed","href":"../e0/389d8d16166a86.html","mtime":"Thu Aug 18 00:36:13 2016\n","size":1835},{"name":"test-multiple-file-0.o","type":"blob","href":"../24/f5ced826dbe9a5.html","mtime":"Fri Mar 8 20:54:30 2019\n","size":7464},{"name":"test-multiple-file-1.cc","type":"parsed","href":"../cf/341b97b05a5692.html","mtime":"Mon Feb 25 15:41:10 2019\n","size":1398},{"name":"test-multiple-file-1.h","type":"parsed","href":"../e5/66fd4ef5cee94a.html","mtime":"Thu Aug 18 00:36:13 2016\n","size":1771},{"name":"test-multiple-file-1.o","type":"blob","href":"../91/38a7b144866997.html","mtime":"Fri Mar 8 20:54:30 2019\n","size":6432},{"name":"test-single-file.c","type":"text","href":"../67/481f5ed307a09b.html","mtime":"Thu Aug 18 00:36:13 2016\n","size":611},{"name":"test-single-file.h","type":"text","href":"../fc/dade3d7f7bb00d.html","mtime":"Thu Aug 18 00:36:13 2016\n","size":1728},{"name":"test.html","type":"text","href":"../6b/0d1083ea424d53.html","mtime":"Sat May 21 16:26:44 2016\n","size":38944},{"name":"test2-clang.htm","type":"text","href":"../6a/d3db15bf642751.html","mtime":"Fri May 20 07:42:20 2016\n","size":78337},{"name":"tux.png","type":"media","href":"../81/3a8befd5338881.png","mtime":"Thu Aug 18 00:36:13 2016\n","size":583138}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/c6/5145c887253142.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"opt","path":"/opt","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[],"dirs":[{"href":"../06/416cc91f3e3d90.html","size":0,"name":".."},{"href":"../83/9c78609ba8228b.html","size":0,"name":"projects"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/c8/b5fc81b5bf752b.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test-multiple-file","path":"test-multiple-file","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | <unparsable blob> -------------------------------------------------------------------------------- /test/output/sources/c9/859e7aa7cc3530.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"README","path":"README","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | THIS IS A TEST README FILE 4 | 5 | In this directory, test files used to compare input and output. 6 | -------------------------------------------------------------------------------- /test/output/sources/d2/b0f1e1540e4279.jhtml: -------------------------------------------------------------------------------- 1 | {"name":".gitignore","path":".gitignore","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | test-single-file 4 | test-multiple-file 5 | -------------------------------------------------------------------------------- /test/output/sources/d2/c60e58c28f84da.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"sbexr","path":"/opt/projects/sbexr","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"opt","href":"../c6/5145c887253142.html"},{"name":"projects","href":"../83/9c78609ba8228b.html"}],"dirs":[{"href":"../83/9c78609ba8228b.html","size":0,"name":".."},{"href":"../be/e2916b98dcf1fc.html","size":19,"name":"test"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/de/54dd5925795da2.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"stdc-predef.h","path":"/usr/include/stdc-predef.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"}]} 2 | --- 3 | /* Copyright (C) 1991-2018 Free Software Foundation, Inc. 4 | This file is part of the GNU C Library. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | <http://www.gnu.org/licenses/>. */ 19 | 20 | #ifndef _STDC_PREDEF_H 21 | #define _STDC_PREDEF_H 1 22 | 23 | /* This header is separate from features.h so that the compiler can 24 | include it implicitly at the start of every compilation. It must 25 | not itself include <features.h> or any other header that includes 26 | <features.h> because the implicit include comes before any feature 27 | test macros that may be defined in a source file before it first 28 | explicitly includes a system header. GCC knows the name of this 29 | header in order to preinclude it. */ 30 | 31 | /* glibc's intent is to support the IEC 559 math functionality, real 32 | and complex. If the GCC (4.9 and later) predefined macros 33 | specifying compiler intent are available, use them to determine 34 | whether the overall intent is to support these features; otherwise, 35 | presume an older compiler has intent to support these features and 36 | define these macros by default. */ 37 | 38 | #ifdef __GCC_IEC_559 39 | # if __GCC_IEC_559 > 0 40 | # define __STDC_IEC_559__ 1 41 | # endif 42 | #else 43 | # define __STDC_IEC_559__ 1 44 | #endif 45 | 46 | #ifdef __GCC_IEC_559_COMPLEX 47 | # if __GCC_IEC_559_COMPLEX > 0 48 | # define __STDC_IEC_559_COMPLEX__ 1 49 | # endif 50 | #else 51 | # define __STDC_IEC_559_COMPLEX__ 1 52 | #endif 53 | 54 | /* wchar_t uses Unicode 10.0.0. Version 10.0 of the Unicode Standard is 55 | synchronized with ISO/IEC 10646:2017, fifth edition, plus 56 | the following additions from Amendment 1 to the fifth edition: 57 | - 56 emoji characters 58 | - 285 hentaigana 59 | - 3 additional Zanabazar Square characters */ 60 | #define __STDC_ISO_10646__ 201706L 61 | 62 | #endif -------------------------------------------------------------------------------- /test/output/sources/e0/389d8d16166a86.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test-multiple-file-0.h","path":"test-multiple-file-0.h","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | // The views and conclusions contained in the software and documentation are 28 | // those of the authors and should not be interpreted as representing official 29 | // policies, either expressed or implied, of Carlo Contavalli. 30 | 31 | #ifndef TEST2_H 32 | # define TEST2_H 33 | 34 | class Test { 35 | public: 36 | int Do00(void) { return 1; }; 37 | int Do02(void) { return Do01(); }; 38 | 39 | private: 40 | int Do01(void) { return 2; } 41 | }; 42 | 43 | extern void TestMore(Test* test); 44 | 45 | #endif /* TEST2_H */ -------------------------------------------------------------------------------- /test/output/sources/e5/66fd4ef5cee94a.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test-multiple-file-1.h","path":"test-multiple-file-1.h","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | // The views and conclusions contained in the software and documentation are 28 | // those of the authors and should not be interpreted as representing official 29 | // policies, either expressed or implied, of Carlo Contavalli. 30 | 31 | #ifndef TEST_MULTIPLE_FILE_1_H 32 | # define TEST_MULTIPLE_FILE_1_H 33 | 34 | class Test; 35 | 36 | extern int global_counter; 37 | 38 | void TestFunction(); 39 | 40 | #endif /* TEST_MULTIPLE_FILE_1_H */ -------------------------------------------------------------------------------- /test/output/sources/f0/212845f8a256c3.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"x86_64-linux-gnu","path":"/usr/include/x86_64-linux-gnu","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"}],"dirs":[{"href":"../19/901c5d9478e5ce.html","size":3,"name":".."},{"href":"../23/32e20e89ff3dae.html","size":7,"name":"bits"},{"href":"../92/0259119a2aa95d.html","size":2,"name":"gnu"},{"href":"../97/537cbc7aefc4ad.html","size":1,"name":"sys"}]} 2 | --- 3 | -------------------------------------------------------------------------------- /test/output/sources/fa/0a0d3d8e7cc07c.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"__fpos64_t.h","path":"/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"},{"name":"types","href":"../50/6c0d28222dde39.html"}]} 2 | --- 3 | #ifndef _____fpos64_t_defined 4 | #define _____fpos64_t_defined 1 5 | 6 | #include <bits/types.h> 7 | #include <bits/types/__mbstate_t.h> 8 | 9 | /* The tag name of this struct is _G_fpos64_t to preserve historic 10 | C++ mangled names for functions taking fpos_t and/or fpos64_t 11 | arguments. That name should not be used in new code. */ 12 | typedef struct _G_fpos64_t 13 | { 14 | __off64_t __pos; 15 | __mbstate_t __state; 16 | } __fpos64_t; 17 | 18 | #endif -------------------------------------------------------------------------------- /test/output/sources/fc/dade3d7f7bb00d.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"test-single-file.h","path":"test-single-file.h","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[]} 2 | --- 3 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | // The views and conclusions contained in the software and documentation are 28 | // those of the authors and should not be interpreted as representing official 29 | // policies, either expressed or implied, of Carlo Contavalli. 30 | 31 | #ifndef TEST_H 32 | # define TEST_H 33 | 34 | struct test { 35 | int foo; 36 | int bar; 37 | }; 38 | 39 | typedef struct test toast; 40 | 41 | #endif /* TEST_H */ 42 | -------------------------------------------------------------------------------- /test/output/sources/fd/cacc45a9906e85.jhtml: -------------------------------------------------------------------------------- 1 | {"name":"wordsize.h","path":"/usr/include/x86_64-linux-gnu/bits/wordsize.h","root":"../06/416cc91f3e3d90.html","project":"test","tag":"output","parents":[{"name":"usr","href":"../60/7abc7e1c17ae25.html"},{"name":"include","href":"../19/901c5d9478e5ce.html"},{"name":"x86_64-linux-gnu","href":"../f0/212845f8a256c3.html"},{"name":"bits","href":"../23/32e20e89ff3dae.html"}]} 2 | --- 3 | /* Determine the wordsize from the preprocessor defines. */ 4 | 5 | #if defined __x86_64__ && !defined __ILP32__ 6 | # define __WORDSIZE 64 7 | #else 8 | # define __WORDSIZE 32 9 | #define __WORDSIZE32_SIZE_ULONG 0 10 | #define __WORDSIZE32_PTRDIFF_LONG 0 11 | #endif 12 | 13 | #ifdef __x86_64__ 14 | # define __WORDSIZE_TIME64_COMPAT32 1 15 | /* Both x86-64 and x32 use the 64-bit system call interface. */ 16 | # define __SYSCALL_WORDSIZE 64 17 | #else 18 | # define __WORDSIZE_TIME64_COMPAT32 0 19 | #endif -------------------------------------------------------------------------------- /test/output/sources/meta/counters.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "metric": "cache/nullreturn/begin-end-different-files", 4 | "value": 0 5 | }, 6 | { 7 | "metric": "cache/nullreturn/empty-path", 8 | "value": 0 9 | }, 10 | { 11 | "metric": "cache/nullreturn/internal-buffer", 12 | "value": 196 13 | }, 14 | { 15 | "metric": "cache/nullreturn/invalid-fid", 16 | "value": 4 17 | }, 18 | { 19 | "metric": "cache/nullreturn/no-content-cache", 20 | "value": 0 21 | }, 22 | { 23 | "metric": "cache/nullreturn/no-sloc-entry", 24 | "value": 0 25 | }, 26 | { 27 | "metric": "indexer/object-id/invalid-file", 28 | "value": 0 29 | }, 30 | { 31 | "metric": "indexer/record/declare/invalid-file", 32 | "value": 0 33 | }, 34 | { 35 | "metric": "indexer/record/declare/invalid-range", 36 | "value": 0 37 | }, 38 | { 39 | "metric": "indexer/record/define/invalid-file", 40 | "value": 0 41 | }, 42 | { 43 | "metric": "indexer/record/define/invalid-range", 44 | "value": 0 45 | }, 46 | { 47 | "metric": "indexer/record/use/invalid-file", 48 | "value": 121 49 | }, 50 | { 51 | "metric": "indexer/record/use/invalid-range", 52 | "value": 6 53 | }, 54 | { 55 | "metric": "info/ast/ignored-uses-of-builtin-functions", 56 | "value": 0 57 | }, 58 | { 59 | "metric": "preprocessor/include/failed-inclusion", 60 | "value": 0 61 | }, 62 | { 63 | "metric": "preprocessor/include/not-found", 64 | "value": 0 65 | }, 66 | { 67 | "metric": "wrapping/discarded/file", 68 | "value": 0 69 | }, 70 | { 71 | "metric": "wrapping/discarded/macro", 72 | "value": 60 73 | } 74 | ] -------------------------------------------------------------------------------- /test/output/sources/meta/globals.json: -------------------------------------------------------------------------------- 1 | {"name":"","path":"","root":"../be/e2916b98dcf1fc.html","project":"test","tag":"output","parents":[] 2 | } -------------------------------------------------------------------------------- /test/output/sources/meta/index.jhtml: -------------------------------------------------------------------------------- 1 | ../be/e2916b98dcf1fc.jhtml -------------------------------------------------------------------------------- /test/output/validator.report: -------------------------------------------------------------------------------- 1 | ==== WARNINGS FOR ./output 2 | output/validator.report: WARNING - unexpected file 3 | output/sources/meta/counters.json: WARNING - unexpected file 4 | ==== STATISTICS FOR ./output 5 | Warnings: 2, Pedantic: 445 6 | 'Target is unused': 445 7 | 'unexpected file': 2 8 | 9 | File system statistcs: 10 | root: 'output/sources/06/416cc91f3e3d90.jhtml' absolute, 'output/sources/be/e2916b98dcf1fc.jhtml' relative 11 | paths: 60 scanned, of which 15 directories, 40 source, 1 copied, 2 meta, 2 unexpected 12 | 13 | Resource statistcs: 14 | requested: 56 file/dir resources, 148 targets, 290 users 15 | unused: 0 file/dir resources, 445 targets 16 | total: 56 file/dir resources, 593 targets 17 | 18 | JHTML Statistics: 19 | Text: 6342 blocks for 1921979 bytes 20 | Tags: 3670 opened, 3670 closed, in a 7 elements max stack 21 | Attributes: 576 href, 593 id, 3670 class (5113 classes specified) 22 | 23 | CLASS Attributes seen (59 different ones): 24 | 339:MACRO-uses 17:__attribute__ 6:__extension__ 2:bool 126:char 25 | 2:class 418:comment 89:const 125:decl 8:decl-CXXRecord 26 | 109:decl-Function 8:decl-Var 131:declaration-uses 1:decltype 468:def 27 | 3:def-CXXMethod 19:def-CXXRecord 66:def-Field 7:def-Function 260:def-MACRO 28 | 1:def-Namespace 8:def-ParmVar 84:def-Typedef 1:def-UsingDirective 19:def-Var 29 | 1078:directive 7:expression-uses 131:extern 1:float 1:if 30 | 34:include 1:inline 161:int 748:keyword 23:long 31 | 97:macro-undefined 102:muted 3:namespace 1:nullptr 50:numeric 32 | 102:preprocessor-if 1:private 1:public 8:return 20:return-uses 33 | 4:short 6:signed 3:sizeof 3:static 8:string 34 | 38:struct 62:typedef 20:typedef-uses 2:union 15:unsigned 35 | 2:using 25:variable-uses 37:void 1:wchar_t 36 | -------------------------------------------------------------------------------- /test/static: -------------------------------------------------------------------------------- 1 | ../static -------------------------------------------------------------------------------- /test/templates: -------------------------------------------------------------------------------- 1 | ../templates/ -------------------------------------------------------------------------------- /test/test-multiple-file-0.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #include "test-multiple-file-0.h" 30 | #include "include-all.h" 31 | 32 | int global_counter; 33 | 34 | struct Double { 35 | int mydouble; 36 | 37 | }; 38 | struct Single { 39 | float mysingle; 40 | }; 41 | 42 | // The anaonymous union will cause any expression 43 | // accessing one of the elements to have 2 MemberExpr: 44 | // 1 to access the field 45 | // 1 to access the anonymous union itself 46 | struct Nfs { 47 | union { 48 | struct Single fusingle; 49 | struct Double fudouble; 50 | }; 51 | }; 52 | 53 | bool MySingle(struct Single* single) { 54 | return (long long int)(single) % 2; 55 | } 56 | 57 | int Mytest(struct Nfs* nfs) { 58 | if (MySingle(&nfs->fusingle)) 59 | return 0; 60 | return 10; 61 | } 62 | 63 | 64 | int CheckArgs( 65 | int test, const char* value); 66 | int FuncWithNamedArgs(int foo, char* bar); 67 | int FuncNoNamedArgs( 68 | int, char*, bool CheckArgs); 69 | 70 | int CheckMyArgs( 71 | const struct Nfs& nfs); 72 | 73 | int FuncWithNamedArgs(int foo, const char* bar) { 74 | MACRO(foo); 75 | return foo * *bar + 2; 76 | } 77 | 78 | int main(int argc, const char** argv) { 79 | Test test; 80 | IncludedByAll(8); 81 | 82 | TestMore(&test); 83 | MACROP("this is a test\n"); 84 | MACRO(12); 85 | return test.Do00() + test.Do02() + FuncWithNamedArgs(3, "sbexr"); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /test/test-multiple-file-0.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef TEST2_H 30 | # define TEST2_H 31 | 32 | class Test { 33 | public: 34 | int Do00(void) { return 1; }; 35 | int Do02(void) { return Do01(); }; 36 | 37 | private: 38 | int Do01(void) { return 2; } 39 | }; 40 | 41 | extern void TestMore(Test* test); 42 | 43 | #endif /* TEST2_H */ 44 | -------------------------------------------------------------------------------- /test/test-multiple-file-1.cc: -------------------------------------------------------------------------------- 1 | #include "test-multiple-file-1.h" 2 | 3 | // #include 4 | #include 5 | #include "include-all.h" 6 | 7 | namespace test { 8 | struct Point { 9 | int x = 0, y = 0; 10 | }; 11 | 12 | 13 | struct PointerSquare { 14 | // Coordinates of the four vertexes. 15 | const Point *a, **b, ***c, *d; 16 | }; 17 | 18 | struct MixedSquare { 19 | // Coordinates of the four vertexes. 20 | const Point ***a, &b, *c[3], *&d; 21 | }; 22 | 23 | struct SimpleSquare { 24 | // Coordinates of the four vertexes. 25 | const Point a, b, c, d; 26 | }; 27 | 28 | struct RefSquare { 29 | const Point &f, &g, &h, &j; 30 | }; 31 | 32 | struct ArraySquare { 33 | const Point vx[4]; 34 | }; 35 | 36 | struct ArrayPointerSquare { 37 | const Point ***vx[4]; 38 | }; 39 | 40 | } 41 | 42 | void TestFunction() { 43 | MACRO(10); 44 | MACROP("TEST TEST"); 45 | printf("Test Function: %d\n", global_counter); 46 | } 47 | 48 | # define POINT volatile test::Point 49 | typedef POINT* punt; 50 | 51 | typedef int u65535_t; 52 | 53 | using namespace test; 54 | 55 | 56 | void TestMore(Test* test) { 57 | Point ab, ac, ad; 58 | Point p0, p1, p2, *p3, *p4; 59 | static POINT __attribute__((used))* fuffa; 60 | static __attribute__((used)) POINT* fuffa2; 61 | u65535_t value = 1000; 62 | 63 | // POINT* foffa 64 | // volatile Point* foffa 65 | punt foffa; 66 | // POINT** foffa 67 | // volatile Point** foffa 68 | punt* foffa2; 69 | 70 | // std::list* plist2, *plist3; 71 | test::Point test3; 72 | 73 | test::Point &z = ab, &w = ac, &x = ad; 74 | 75 | MACRO(MACRO_RECURSIVE); 76 | MACROP("TOST TOST"); 77 | printf("Test pointer %p %d\n", (void*)test, value); 78 | printf("Test point %d %d %d\n", p0.x, p1.x, p2.x); 79 | } 80 | -------------------------------------------------------------------------------- /test/test-multiple-file-1.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef TEST_MULTIPLE_FILE_1_H 30 | # define TEST_MULTIPLE_FILE_1_H 31 | 32 | class Test; 33 | 34 | extern int global_counter; 35 | 36 | void TestFunction(); 37 | 38 | #endif /* TEST_MULTIPLE_FILE_1_H */ 39 | -------------------------------------------------------------------------------- /test/test-single-file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test-single-file.h" 3 | 4 | # define TEST(foo) if (foo) { printf("foo"); } 5 | int global = 0; 6 | 7 | /// Test comment. 8 | int test() { 9 | printf("this is a test"); 10 | 11 | { 12 | int a = 9; 13 | printf("this is another test: %d", a); 14 | 15 | } 16 | 17 | return 3; 18 | } 19 | 20 | // This is a pre-existing comment. 21 | /** Test comment */ 22 | int main(void) { 23 | int value = 12; 24 | if (1) { value = test(); 25 | if (value > 5) { 26 | printf("this is a second test"); 27 | } 28 | } 29 | 30 | toast foo = {0, 100}; 31 | while (foo.foo != foo.bar) { 32 | printf("this is another test %d", foo.foo); 33 | ++foo.foo; 34 | } 35 | global += 3; 36 | TEST(value); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /test/test-single-file.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013,2014 Carlo Contavalli (ccontavalli@gmail.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY Carlo Contavalli ''AS IS'' AND ANY EXPRESS OR 15 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | // EVENT SHALL Carlo Contavalli OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | // The views and conclusions contained in the software and documentation are 26 | // those of the authors and should not be interpreted as representing official 27 | // policies, either expressed or implied, of Carlo Contavalli. 28 | 29 | #ifndef TEST_H 30 | # define TEST_H 31 | 32 | struct test { 33 | int foo; 34 | int bar; 35 | }; 36 | 37 | typedef struct test toast; 38 | 39 | #endif /* TEST_H */ 40 | -------------------------------------------------------------------------------- /test/tux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccontavalli/sbexr/77b445492bb7ef03bef5b0cd119d7331856dfa26/test/tux.png -------------------------------------------------------------------------------- /utils/.gitignore: -------------------------------------------------------------------------------- 1 | kernelc 2 | publishc 3 | tsdb-cli 4 | -------------------------------------------------------------------------------- /utils/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: check 3 | 4 | check: 5 | python -m py_compile kernel 6 | 7 | -------------------------------------------------------------------------------- /utils/publish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import collections 4 | import glob 5 | import grp 6 | import operator 7 | import os 8 | import re 9 | import subprocess 10 | import sys 11 | import tempfile 12 | import time 13 | import json 14 | import pprint 15 | 16 | BASE = "/opt/projects/sbexr" 17 | NEWS_FILE_PATH = os.path.join(BASE, "static/news.json") 18 | 19 | RunResult = collections.namedtuple("RunResult", ["status", "stdout", "stderr", "time"]) 20 | def Run(args, **kwargs): 21 | kwargs.setdefault("stderr", subprocess.PIPE) 22 | kwargs.setdefault("stdout", subprocess.PIPE) 23 | 24 | start = time.time() 25 | process = subprocess.Popen(args, stdin=subprocess.PIPE, 26 | shell=isinstance(args, str), **kwargs) 27 | sys.stderr.write("Running: %s %s" % (args, kwargs)) 28 | sys.stderr.flush() 29 | 30 | stdout, stderr = process.communicate() 31 | status = process.wait() 32 | end = time.time() 33 | sys.stderr.write(" %0.3fs\n" % (end - start)) 34 | sys.stderr.flush() 35 | 36 | if status: 37 | print >>sys.stderr, "FAILED:", kwargs, "\n" 38 | if stdout: 39 | print >>sys.stderr, " stdout:", stdout.strip() 40 | if stderr: 41 | print >>sys.stderr, " stderr:", stderr.strip() 42 | print >>sys.stderr, " status:", status 43 | return RunResult(status, stdout, stderr, end - start) 44 | 45 | def GetGitNews(): 46 | result = Run(["git", "log", "--format=format:Date: %ct%n%w(4096, 4, 4)%+B%n"]) 47 | if result.status != 0: 48 | raise RuntimeError("git log failed") 49 | 50 | # news_mtime = 0 51 | # if os.path.exists(NEWS_FILE_PATH): 52 | # news_mtime = int(os.path.getmtime(NEWS_FILE_PATH)) 53 | 54 | times = [] 55 | date_prefix = "Date: " 56 | news_prefix = "news: " 57 | git_mtime = None 58 | mesage = "" 59 | for line in result.stdout.split("\n"): 60 | if line.startswith(date_prefix): 61 | line = line[len(date_prefix):].strip() 62 | git_mtime = int(line) 63 | continue 64 | 65 | if line.startswith(" "): 66 | line = line.strip() 67 | if not line.startswith(news_prefix): 68 | continue 69 | line = line[len(news_prefix):].capitalize() 70 | if line[-1] != '.': 71 | line += '.' 72 | event = {"time": git_mtime, "message": line} 73 | times.append(event) 74 | print "NEWS", pprint.pformat(list(reversed(times)), indent=2) 75 | return times 76 | 77 | def UpdateNewsFile(): 78 | news = GetGitNews() 79 | 80 | with open(NEWS_FILE_PATH, "w") as newsfile: 81 | newsfile.write(json.dumps({"news": news})) 82 | 83 | def Transfer(): 84 | Run('rsync --exclude="indexes" --exclude="backup/" --exclude="run/" --exclude="examples" --exclude="testindex" ' 85 | '--exclude="tree.txt" --exclude="*.o" --include="news.json" --exclude="*.json" ' 86 | '--exclude="output/sources/" --progress -avz --delete -e ssh ' 87 | '%s/ root@pertini:/opt/sbexr/sbexr' % BASE, stdout=sys.stdout, stderr=sys.stderr) 88 | Run('ssh root@pertini -- killall server') 89 | 90 | def UpdateBinaries(): 91 | Run("cd /opt/projects/goutils/tsdb/tsdb-cli && go build") 92 | Run("cp /opt/projects/goutils/tsdb/tsdb-cli/tsdb-cli %s" % os.path.join(BASE, "utils")) 93 | 94 | Run("make clean", cwd=os.path.join(BASE, "src")) 95 | Run("make opt", cwd=os.path.join(BASE, "src")) 96 | Run("make", cwd=os.path.join(BASE, "sitemap")) 97 | Run("make", cwd=os.path.join(BASE, "server")) 98 | 99 | def main(): 100 | UpdateBinaries() 101 | UpdateNewsFile() 102 | Transfer() 103 | 104 | if __name__ == "__main__": 105 | # execute only if run as a script 106 | main() 107 | -------------------------------------------------------------------------------- /validator/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | validator 3 | -------------------------------------------------------------------------------- /validator/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | go build 4 | 5 | test: all 6 | go test 7 | 8 | run: all 9 | ./validator --root=../test/output 10 | 11 | clean: 12 | rm -f validator 13 | 14 | format: 15 | go fmt 16 | --------------------------------------------------------------------------------