Skip to content

Commit faff341

Browse files
authored
Merge pull request #89 from goblint/transform-location
Allow parsed location directive transformation
2 parents e559ead + 69c715c commit faff341

File tree

16 files changed

+56
-64
lines changed

16 files changed

+56
-64
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ jobs:
4646
- run: opam install . --deps-only --with-doc --with-test
4747
- run: opam exec -- dune build
4848
- run: opam exec -- dune runtest
49+
50+
- name: Upload test log
51+
uses: actions/upload-artifact@v3
52+
if: failure()
53+
with:
54+
name: ${{ matrix.os }}-${{ matrix.ocaml-version }}
55+
path: _build/default/test/cil.log

src/cil.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ type file =
156156
should always be false if there is no global initializer. When
157157
you create a global initialization CIL will try to insert code in
158158
main to call it. *)
159-
files: (string * bool) list;
160-
(** A list of those files that were encountered during parsing of this CIL file,
161-
and whether they are system header files *)
162159
}
163160

164161
and comment = location * string
@@ -5011,8 +5008,7 @@ let dummyFile =
50115008
{ globals = [];
50125009
fileName = "<dummy>";
50135010
globinit = None;
5014-
globinitcalled = false;
5015-
files = []; }
5011+
globinitcalled = false;}
50165012

50175013
(***** Load and store files as unmarshalled Ocaml binary data. ****)
50185014
type savedFile =

src/cil.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ type file =
9393
* create a global initialization CIL will try to insert code in main
9494
* to call it. This will not happen if your file does not contain a
9595
* function called "main" *)
96-
files: (string * bool) list;
97-
(** A list of those files that were encountered during parsing of this CIL file,
98-
* and whether they are system header files *)
9996
}
10097
(** Top-level representation of a C source file *)
10198

src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
(public_name goblint-cil)
55
(name cil)
66
(wrapped false) ; this should be changed, but then module paths in goblint need to be prefixed
7-
(libraries zarith findlib dynlink unix str stdlib-shims batteries.unthreaded)
7+
(libraries zarith findlib dynlink unix str stdlib-shims batteries.unthreaded) ; batteries shouldn't be needed, but tests fail on MacOS otherwise: https://github.com/goblint/cil/pull/89#issuecomment-1092610041
88
(modules (:standard \ main))
99
)
1010

src/formatcil.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ let doParse (prog: string)
8080
Formatparse.initialize Formatlex.initial lexbuf;
8181
let res = theParser Formatlex.initial lexbuf in
8282
H.add memoTable prog res;
83-
ignore @@ Formatlex.finish ();
83+
Formatlex.finish ();
8484
res
8585
with Parsing.Parse_error -> begin
86-
ignore @@ Formatlex.finish ();
86+
Formatlex.finish ();
8787
E.s (E.error "Parsing error: %s" prog)
8888
end
8989
| e -> begin
9090
ignore (E.log "Caught %s while parsing\n" (Printexc.to_string e));
91-
ignore @@ Formatlex.finish ();
91+
Formatlex.finish ();
9292
raise e
9393
end
9494
end

src/frontc/cabs.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ and definition =
189189
| STATIC_ASSERT of expression * string * cabsloc
190190

191191

192-
(* the string is a file name, then the list of toplevel forms, and finally a list of filenames
193-
encountered during parsing and whether they are system headers *)
194-
and file = string * definition list * (string * bool) list
192+
(* the string is a file name, and then the list of toplevel forms *)
193+
and file = string * definition list
195194

196195

197196
(*

src/frontc/cabs2cil.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6897,7 +6897,7 @@ let convFile (f : A.file) : Cil.file =
68976897
Cil.initCIL (); (* make sure we have initialized CIL *)
68986898

68996899
(* remove parentheses from the Cabs *)
6900-
let fname,dl,files = stripParenFile f in
6900+
let fname,dl = stripParenFile f in
69016901

69026902
(* Clean up the global types *)
69036903
initGlobals();
@@ -6986,5 +6986,4 @@ let convFile (f : A.file) : Cil.file =
69866986
globals = !globals;
69876987
globinit = None;
69886988
globinitcalled = false;
6989-
files = files;
69906989
}

src/frontc/cabsvisit.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ and childrenAttribute vis ((n, el) as input) =
582582
and visitCabsAttributes vis (al: attribute list) : attribute list =
583583
mapNoCopyList (visitCabsAttribute vis) al
584584

585-
let visitCabsFile (vis: cabsVisitor) ((fname, f, files): file) : file =
586-
(fname, mapNoCopyList (visitCabsDefinition vis) f, files)
585+
let visitCabsFile (vis: cabsVisitor) ((fname, f): file) : file =
586+
(fname, mapNoCopyList (visitCabsDefinition vis) f)
587587

588588
(* end of file *)

src/frontc/clexer.mli

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343

4444

4545
val init: filename:string -> Lexing.lexbuf
46-
val finish: unit -> (string * bool) list (* Return the list of filenames encountered during lexing
47-
and whether they are system headers *)
46+
val finish: unit -> unit
4847

4948
(* This is the main parser function *)
5049
val initial: Lexing.lexbuf -> Cparser.token

src/frontc/clexer.mll

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,8 @@ and hash = parse
659659
E.warn "Bad line number in preprocessed file: %s" s;
660660
(-1)
661661
in
662-
E.setCurrentLine (lineno - 1);
663662
(* A file name may follow *)
664-
file lexbuf }
663+
file (lineno - 1) lexbuf }
665664
| "line" { addWhite lexbuf; hash lexbuf } (* MSVC line number info *)
666665
(* For pragmas with irregular syntax, like #pragma warning,
667666
* we parse them as a whole line. *)
@@ -672,15 +671,15 @@ and hash = parse
672671
| "pragma" { pragmaLine := true; PRAGMA (currentLoc ()) }
673672
| _ { addWhite lexbuf; endline lexbuf}
674673

675-
and file = parse
676-
'\n' {addWhite lexbuf; E.newline (); initial lexbuf}
677-
| blank {addWhite lexbuf; file lexbuf}
674+
and file lineno = parse
675+
'\n' {addWhite lexbuf; E.setCurrent ~file:None ~line:lineno; E.newline (); initial lexbuf}
676+
| blank {addWhite lexbuf; file lineno lexbuf}
678677
| '"' ([^ '\012' '\t' '"']* as filename) '"' ((' ' ['1' -'4'])* as flags)
679678
{ addWhite lexbuf; (* '"' *)
680-
E.setCurrentFile filename (String.contains flags '3');
679+
E.setCurrent ~file:(Some (filename, String.contains flags '3')) ~line:lineno;
681680
endline lexbuf}
682681

683-
| _ {addWhite lexbuf; endline lexbuf}
682+
| _ {addWhite lexbuf; E.setCurrent ~file:None ~line:lineno; endline lexbuf}
684683

685684
and endline = parse
686685
'\n' { addWhite lexbuf; E.newline (); initial lexbuf}

0 commit comments

Comments
 (0)