Annotation of src/usr.bin/xlint/README, Revision 1.1
1.1 ! cloder 1: lint is divided into 3 separate programs: lint, lint1, and
! 2: lint2 (the latter two programs reside in /usr/libexec).
! 3:
! 4: lint calls /usr/libexec/cpp to preprocess the program, then passes
! 5: the output to lint1, which does most of the work. lint1 then outputs
! 6: a .ln file, which is parsed by lint2 to do more holistic checks. all
! 7: of this is driven by /usr/bin/lint, which is like a wrapper program.
! 8:
! 9: lint1 implements its own C parser. it is incapable of parsing some
! 10: weird gcc things, such as __attribute__ and so on. OpenBSD's source
! 11: tree already does a good job of removing gcc'isms when parsers other
! 12: than gcc are detected.
! 13:
! 14: lint1 keeps a symbol table for the current context, which always
! 15: includes global symbols for the current translation unit, as well as
! 16: locals (inside a function definition). When it parses a function
! 17: definition, it pushes a symbol table context onto the stack, and
! 18: then pops it off when it when the function definition ends.
! 19:
! 20: lint1 does the vast majority of its checks one expression at a time.
! 21: It uses the symbol table (which contains types of symbols) and almost
! 22: nothing else when doing type conversions. All of the checks happen at
! 23: parse time. lint1 does not really build an abstract syntax tree (AST)
! 24: to represent the entire program; it only keeps track of the symbols
! 25: in the current context, and some minimal information about the types
! 26: of enclosing control blocks (loops, switch statements, etc). When lint1
! 27: is finished parsing an expression, you will not see any more warnings
! 28: regarding that expression.
! 29:
! 30: $OpenBSD$