A CIL Tutorial - Department of Computer Science - ETH Zürich
A CIL Tutorial - Department of Computer Science - ETH Zürich A CIL Tutorial - Department of Computer Science - ETH Zürich
References [1] Mike Barnett and K. Rustan M. Leino. Weakest-precondition of unstructured programs. In Proceedings of the 6th ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering, PASTE '05, pages 8287, New York, NY, USA, 2005. ACM. [2] Yves Bertot and Pierre Castéran. Interactive Theorem Proving and Program Development. Coq'Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. Springer Verlag, 2004. [3] Jean-Christophe Filliâtre. Verifying two lines of C with Why3: an exercise in program verication. In Veried Software: Theories, Tools and Experiments (VSTTE), Philadelphia, USA, January 2012. [4] Thomas A. Henzinger, Ranjit Jhala, Rupak Majumdar, and Grégoire Sutre. Lazy abstraction. In Proceedings of the 29th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, POPL '02, pages 5870, New York, NY, USA, 2002. ACM. [5] Koushik Sen, Darko Marinov, and Gul Agha. Cute: a concolic unit testing engine for c. In Proceedings of the 10th European software engineering conference held jointly with 13th ACM SIG- SOFT international symposium on Foundations of software engineering, ESEC/FSE-13, pages 263272, New York, NY, USA, 2005. ACM. [6] Glynn Winskel. The formal semantics of programming languages - an introduction. Foundation of computing series. MIT Press, 1993. 104
Chapter 12 Comments CIL has a very basic mechanism for tracking comments. In this chapter we'll see how to use it. CIL only sees comments when they are maintained in the output of the preprocessor. The preprocessor may be instructed to maintain comments in its output by using the -C switch to ciltutcc. Then, the comments in the source are collected by CIL's parser and placed in the array Cabshelper.commentsGA. commentsGA is a GrowArray.t of triples of type (Cabs.cabsloc × string × bool). The cabsloc is the source location of the comment. The string is the comment itself, and the bool is set aside for application bookkeeping. 12.1 tut12.ml In this example, we'll visit the AST and print out comments nearby instructions and statements, taking care to only print each comment once. This will be accomplished by extracting the source location from instructions and statements and then doing a binary search on the array of comments. The array of comments lives in the Cabshelper module. The locations of the comments are dened in terms of the Cabs.cabsloc record type. module GA = GrowArray module A = Cabs module CH = Cabshelper First, we'll need a few utility functions, some of which are hidden away in Tututil (e.g. functions for ordering source locations and comments). prepareCommentArray lters out comments not from source le fname, and sorts the results according to source location. let prepareCommentArray (cca : comment array) (fname : string) : comment array = cca | > array filter (fun (cl, , ) → fname = cl.A.filename) |> array sort result comment compare The funcion commentsAdjacent returns the indexes of at most two comments that are immediately 105
- Page 55 and 56: CHAPTER 7. TYPE QUALIFIERS 53 let c
- Page 57 and 58: CHAPTER 7. TYPE QUALIFIERS 55 let w
- Page 59 and 60: CHAPTER 7. TYPE QUALIFIERS 57 $ cil
- Page 61 and 62: Chapter 8 Dependant Type Qualiers O
- Page 63 and 64: CHAPTER 8. DEPENDANT TYPE QUALIFIER
- Page 65 and 66: CHAPTER 8. DEPENDANT TYPE QUALIFIER
- Page 67 and 68: CHAPTER 8. DEPENDANT TYPE QUALIFIER
- Page 69 and 70: CHAPTER 8. DEPENDANT TYPE QUALIFIER
- Page 71 and 72: CHAPTER 8. DEPENDANT TYPE QUALIFIER
- Page 73 and 74: Chapter 9 Type Qualier Inference In
- Page 75 and 76: CHAPTER 9. TYPE QUALIFIER INFERENCE
- Page 77 and 78: CHAPTER 9. TYPE QUALIFIER INFERENCE
- Page 79 and 80: CHAPTER 9. TYPE QUALIFIER INFERENCE
- Page 81 and 82: CHAPTER 9. TYPE QUALIFIER INFERENCE
- Page 83 and 84: Chapter 10 Adding a New Kind of Sta
- Page 85 and 86: CHAPTER 10. ADDING A NEW KIND OF ST
- Page 87 and 88: CHAPTER 10. ADDING A NEW KIND OF ST
- Page 89 and 90: CHAPTER 10. ADDING A NEW KIND OF ST
- Page 91 and 92: CHAPTER 10. ADDING A NEW KIND OF ST
- Page 93 and 94: Chapter 11 Program Verication In th
- Page 95 and 96: CHAPTER 11. PROGRAM VERIFICATION 93
- Page 97 and 98: CHAPTER 11. PROGRAM VERIFICATION 95
- Page 99 and 100: CHAPTER 11. PROGRAM VERIFICATION 97
- Page 101 and 102: CHAPTER 11. PROGRAM VERIFICATION 99
- Page 103 and 104: CHAPTER 11. PROGRAM VERIFICATION 10
- Page 105: CHAPTER 11. PROGRAM VERIFICATION 10
- Page 109 and 110: CHAPTER 12. COMMENTS 107 let printC
- Page 111 and 112: References [1] Lin Tan, Ding Yuan,
- Page 113 and 114: CHAPTER 13. WHOLE-PROGRAM ANALYSIS
- Page 115 and 116: CHAPTER 13. WHOLE-PROGRAM ANALYSIS
- Page 117 and 118: CHAPTER 14. IMPLEMENTING A SIMPLE D
- Page 119 and 120: CHAPTER 14. IMPLEMENTING A SIMPLE D
- Page 121 and 122: CHAPTER 14. IMPLEMENTING A SIMPLE D
- Page 123 and 124: CHAPTER 14. IMPLEMENTING A SIMPLE D
- Page 125 and 126: CHAPTER 14. IMPLEMENTING A SIMPLE D
- Page 127 and 128: Chapter 15 Automated Test Generatio
- Page 129 and 130: CHAPTER 15. AUTOMATED TEST GENERATI
- Page 131 and 132: CHAPTER 15. AUTOMATED TEST GENERATI
- Page 133 and 134: CHAPTER 15. AUTOMATED TEST GENERATI
- Page 135 and 136: Index A (module), 10, 13, 15, 10, 1
- Page 137 and 138: INDEX 135 isCacheReportType, 11, 11
References<br />
[1] Mike Barnett and K. Rustan M. Leino. Weakest-precondition <strong>of</strong> unstructured programs. In<br />
Proceedings <strong>of</strong> the 6th ACM SIGPLAN-SIGSOFT workshop on Program analysis for s<strong>of</strong>tware<br />
tools and engineering, PASTE '05, pages 8287, New York, NY, USA, 2005. ACM.<br />
[2] Yves Bertot and Pierre Castéran. Interactive Theorem Proving and Program Development.<br />
Coq'Art: The Calculus <strong>of</strong> Inductive Constructions. Texts in Theoretical <strong>Computer</strong> <strong>Science</strong>.<br />
Springer Verlag, 2004.<br />
[3] Jean-Christophe Filliâtre. Verifying two lines <strong>of</strong> C with Why3: an exercise in program verication.<br />
In Veried S<strong>of</strong>tware: Theories, Tools and Experiments (VSTTE), Philadelphia, USA,<br />
January 2012.<br />
[4] Thomas A. Henzinger, Ranjit Jhala, Rupak Majumdar, and Grégoire Sutre. Lazy abstraction.<br />
In Proceedings <strong>of</strong> the 29th ACM SIGPLAN-SIGACT symposium on Principles <strong>of</strong> programming<br />
languages, POPL '02, pages 5870, New York, NY, USA, 2002. ACM.<br />
[5] Koushik Sen, Darko Marinov, and Gul Agha. Cute: a concolic unit testing engine for c. In Proceedings<br />
<strong>of</strong> the 10th European s<strong>of</strong>tware engineering conference held jointly with 13th ACM SIG-<br />
SOFT international symposium on Foundations <strong>of</strong> s<strong>of</strong>tware engineering, ESEC/FSE-13, pages<br />
263272, New York, NY, USA, 2005. ACM.<br />
[6] Glynn Winskel. The formal semantics <strong>of</strong> programming languages - an introduction. Foundation<br />
<strong>of</strong> computing series. MIT Press, 1993.<br />
104