Linux Sparse chrisl branch
C Other
Switch branches/tags
Nothing to show
Clone or download
sparsecli teach next_designators() use array_element_offset()
I miss a spot when converting array size caculation using
array_element_offet(). "next_designators()" is still using
"n*bit_size" to caculate the element offset. It is wrong
for the case of bool array.

Signed-off-by: Christopher Li <sparse@chrisli.org>
Latest commit c1c3f96 Oct 25, 2014
Permalink
Failed to load latest commit information.
Documentation I have updated the sparse.1 man page including the __bitwise May 20, 2012
compat Add DEBUG mode, which enables various expensive debug options Aug 3, 2005
gvpr Add shebang to gvpr scripts, make them executable, and change usage a… May 22, 2007
validation don't run sparse{c,i} tests when sparse-llvm is disabled Oct 10, 2014
.gitignore gitignore: add 'version.h' Dec 21, 2013
FAQ FAQ: Remove outdated sections about the license Nov 29, 2013
LICENSE sparse: Relicense under the MIT license Nov 29, 2013
Makefile Add support for multiarch system header files Oct 10, 2014
README Update the information in README about using the library. Dec 9, 2013
allocate.c sparse: Relicense under the MIT license Nov 29, 2013
allocate.h allocate.h: Stop needlessly returning a void value in __DO_ALLOCATOR Jul 23, 2007
ast-inspect.c inspect: Add switch statement and more Aug 12, 2011
ast-inspect.h inspect: add some expression inspection Jul 13, 2010
ast-model.c fix common misspellings with codespell Aug 20, 2011
ast-model.h inspect: Add switch statement and more Aug 12, 2011
ast-view.c inspect: Add switch statement and more Aug 12, 2011
ast-view.h inspect: add custom ast treeview model Jul 13, 2010
bitmap.h Add "bitmap.h" for some simple bitmap ops Apr 8, 2005
c2xml.c sparse: Relicense under the MIT license Nov 29, 2013
cgcc cgcc: use $ccom to set $multiarch_dir if not specified Oct 10, 2014
cgcc.1 Add a manpage for cgcc Sep 15, 2007
char.c char.c: Fix parsing of escapes May 17, 2013
char.h switch to delayed handling of escape sequences Feb 12, 2013
compat-bsd.c sparse: Relicense under the MIT license Nov 29, 2013
compat-cygwin.c sparse: Relicense under the MIT license Nov 29, 2013
compat-linux.c Remove stat-based file identity tests. Apr 8, 2005
compat-mingw.c sparse: Relicense under the MIT license Nov 29, 2013
compat-solaris.c Remove stat-based file identity tests. Apr 8, 2005
compat.h Fix typos in comments Mar 9, 2007
compile-i386.c sparse: Relicense under the MIT license Nov 29, 2013
compile.c sparse: Relicense under the MIT license Nov 29, 2013
compile.h make sparse headers self-compilable... Aug 11, 2009
cse.c cse: update PHI users when throwing away an instruction Aug 28, 2011
ctags.c sparse: Relicense under the MIT license Nov 29, 2013
dissect.c sparse: Relicense under the MIT license Nov 29, 2013
dissect.h Coding style fix: in a pointer type, * goes with the name, not the type. Jan 27, 2007
evaluate.c teach next_designators() use array_element_offset() Oct 25, 2014
example.c Unhardcode byte size being 8 bits. Dec 17, 2008
expand.c sparse: Relicense under the MIT license Nov 29, 2013
expression.c don't call isdigit/tolower with a char argument Oct 10, 2014
expression.h Fix initializers in anonymous structs and unions Sep 18, 2014
flow.c flow.c: make comment for `dominates' reflect code Apr 13, 2011
flow.h make sparse headers self-compilable... Aug 11, 2009
gdbhelpers Add support for TImode type (__int128_t) Aug 2, 2009
graph.c sparse: Relicense under the MIT license Nov 29, 2013
ident-list.h Add the __restrict__ keyword Oct 10, 2014
inline.c sparse: Relicense under the MIT license Nov 29, 2013
lib.c Add support for multiarch system header files Oct 10, 2014
lib.h rename -Werror to -Wsparse-error Oct 10, 2014
linearize.c Fix result type of relational and logical operators May 27, 2013
linearize.h sparse, llvm: Make function declaration accessible to backend Feb 4, 2012
liveness.c unssa: track uses when replacing a phi node Aug 2, 2009
memops.c memops.c: always true expression Jan 3, 2011
obfuscate.c sparse: Relicense under the MIT license Nov 29, 2013
parse.c sparse: add 'gnu_inline' to the ignored attributes Oct 10, 2014
parse.dtd add c2xml program Jul 14, 2007
parse.h sparse: Relicense under the MIT license Nov 29, 2013
pre-process.c sparse: Relicense under the MIT license Nov 29, 2013
ptrlist.c ptrlist.c: fix a typo in a comment Jun 26, 2012
ptrlist.h remove unused "container" macro Apr 13, 2011
scope.c Make same_symbol list share the same scope Aug 2, 2014
scope.h Make same_symbol list share the same scope Aug 2, 2014
show-parse.c sparse: Relicense under the MIT license Nov 29, 2013
simplify.c fix SIGFPE caused by signed division overflow May 11, 2013
sort.c Fix typos in comments Mar 9, 2007
sparse-llvm.c Fix result type of relational and logical operators May 27, 2013
sparse.1 Add support for multiarch system header files Oct 10, 2014
sparse.c rename -Werror to -Wsparse-error Oct 10, 2014
sparse.pc.in Generate and install a pkg-config file. Add DESTDIR support to Makefile. Dec 5, 2006
sparsec sparse{i,c}: use LLVM_CONFIG to find llc and lli Apr 15, 2014
sparsei sparse{i,c}: use LLVM_CONFIG to find llc and lli Apr 15, 2014
storage.c [PATCH] makes some needlessly global code static Jun 27, 2005
storage.h make sparse headers self-compilable... Aug 11, 2009
symbol.c Fix scoping of extern symbols in block scope Aug 2, 2014
symbol.h Support GCC's transparent unions Apr 1, 2014
target.c Revert "sparse: Bump up sizeof(_Bool) to 8 bits" Dec 21, 2011
target.h round up the array element size to byte align Jul 17, 2014
test-dissect.c cleanup write to argument array hack Dec 5, 2006
test-inspect.c inspect: Add test-inspect program Jul 13, 2010
test-lexing.c sparse: Relicense under the MIT license Nov 29, 2013
test-linearize.c sparse: Relicense under the MIT license Nov 29, 2013
test-parsing.c sparse: Relicense under the MIT license Nov 29, 2013
test-sort.c Coding style fix: in a pointer type, * goes with the name, not the type. Jan 27, 2007
test-unssa.c cleanup write to argument array hack Dec 5, 2006
token.h sparse: Relicense under the MIT license Nov 29, 2013
tokenize.c sparse: Relicense under the MIT license Nov 29, 2013
unssa.c unssa: track use of newly added pseudo May 4, 2012

README

  sparse (spärs), adj,., spars-er, spars-est.
	1. thinly scattered or distributed; "a sparse population"
	2. thin; not thick or dense: "sparse hair"
	3. scanty; meager.
	4. semantic parse
  	[ from Latin: spars(us) scattered, past participle of
	  spargere 'to sparge' ]

	Antonym: abundant

Sparse is a semantic parser of source files: it's neither a compiler
(although it could be used as a front-end for one) nor is it a
preprocessor (although it contains as a part of it a preprocessing
phase). 

It is meant to be a small - and simple - library.  Scanty and meager,
and partly because of that easy to use.  It has one mission in life:
create a semantic parse tree for some arbitrary user for further
analysis.  It's not a tokenizer, nor is it some generic context-free
parser.  In fact, context (semantics) is what it's all about - figuring
out not just what the grouping of tokens are, but what the _types_ are
that the grouping implies.

And no, it doesn't use lex and yacc (or flex and bison).  In my personal
opinion, the result of using lex/yacc tends to end up just having to
fight the assumptions the tools make. 

The parsing is done in five phases:

 - full-file tokenization
 - pre-processing (which can cause another tokenization phase of another
   file)
 - semantic parsing.
 - lazy type evaluation
 - inline function expansion and tree simplification

Note the "full file" part. Partly for efficiency, but mostly for ease of
use, there are no "partial results". The library completely parses one
whole source file, and builds up the _complete_ parse tree in memory.

Also note the "lazy" in the type evaluation.  The semantic parsing
itself will know which symbols are typedefines (required for parsing C
correctly), but it will not have calculated what the details of the
different types are.  That will be done only on demand, as the back-end
requires the information. 

This means that a user of the library will literally just need to do

  struct string_list *filelist = NULL;
  char *file;

  action(sparse_initialize(argc, argv, filelist));

  FOR_EACH_PTR_NOTAG(filelist, file) {
    action(sparse(file));
  } END_FOR_EACH_PTR_NOTAG(file);

and he is now done - having a full C parse of the file he opened.  The
library doesn't need any more setup, and once done does not impose any
more requirements.  The user is free to do whatever he wants with the
parse tree that got built up, and needs not worry about the library ever
again.  There is no extra state, there are no parser callbacks, there is
only the parse tree that is described by the header files. The action
funtion takes a pointer to a symbol_list and does whatever it likes with it.

The library also contains (as an example user) a few clients that do the
preprocessing, parsing and type evaluation and just print out the
results.  These clients were done to verify and debug the library, and
also as trivial examples of what you can do with the parse tree once it
is formed, so that users can see how the tree is organized.