Skip to content

Conversation

awruef
Copy link
Collaborator

@awruef awruef commented Sep 7, 2016

Many changes to deal with running on "real" code:

  • In certain situations (macros) two AST nodes can occupy precisely the same source location. This is a problem for the re-writer that maintains a strong mapping between source locations and constraint variables, especially for whole-program analysis. The rewriter now does something conservative where two constraint variables that occupy the same source location implicitly alias.
  • In other situations, it's difficult to know what to do when re-writing structure typedefs or other kinds of typedefs. We now do something conservative where structure typedefs are left alone.
  • There is now a bunch of defensive programming to keep the rewriting logic from trying to do rash things like rewrite a declaration that starts in one file and ends in another file.

Andrew Ruef and others added 29 commits August 31, 2016 10:01
* Initial version of the checked-c conversion tool. Current features:

 - Processes single C files or multiple C files (up to whole programs)
 - Infers "ptr-ness" for local variables used in those programs.
 - Re-write many source files
 - Supports many aspects of the C grammar
 - Contains unit tests

Current weaknesses:

 - Macro support is limited
 - Casting support is limited, needs structural type equality checks
 - No inherent support for standard library functions.
 - Doesn't honor existing checked C types
ptr<int> then that would mean 'a' would too, since the assignment copies
the constraints. However, 'a' is used with arithmetic, so there doesn't
seem to be a logical way that 'd' could be used as a ptr without a cast.
 - typedefs complicate re-writing. Adopting a conservative strategy for
   now.
 - macros that define functions complicate identification of constraint
   variables. Adopting a conservative strategy for now.
Conflicts:
	tools/checked-c-convert/CheckedCConvert.cpp
	tools/checked-c-convert/ConstraintBuilder.cpp
	tools/checked-c-convert/ProgramInfo.cpp
	tools/checked-c-convert/ProgramInfo.h
@awruef awruef self-assigned this Sep 7, 2016
// so don't.
SourceRange SR = UD->getReturnTypeSourceRange();
if(SR.isValid())
if(SR.isValid() && (R.getRangeSize(SR) != -1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: need a space after the 'if'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing space after 'if'

@dtarditi
Copy link
Member

dtarditi commented Sep 7, 2016

Generally looks good - I've pointed out some minor nits in the code.

The PersistentSourceLoc file needs more comments describing what it is doing. Please clarify that the source location used for comparisons is the original textual location, not the expanded source location.

You might want a helper function for validating that a range can be rewritten. Currently, you are checking that a range is valid and that getRangeSize(...) != -1. The test that getRangeSize(...) != -1 is idiomatic, so using a helper function would make the code clearer to read.

@awruef
Copy link
Collaborator Author

awruef commented Sep 8, 2016

I think I've addressed the code review feedback.

@dtarditi
Copy link
Member

dtarditi commented Sep 8, 2016

LGTM.

@dtarditi dtarditi removed their assignment Sep 8, 2016
@awruef awruef merged commit ce76d0d into master Sep 8, 2016
@awruef awruef deleted the awr_11 branch September 8, 2016 02:35
dopelsunce pushed a commit to dopelsunce/checkedc-clang that referenced this pull request Sep 28, 2020
- Clarify that the checked property of an array declarator is only propagated
  to nested array declarators.  It is not propagated to typedef bodies.
- It is an error if there is a mismatch in checked properties between an array
  type and an element type that is an array type.
- Improve the organization and wording of the text for checked
  multi-dimensional arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants