aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
diff options
context:
space:
mode:
authorJacques-Henri Jourdan <jacques-henri.jourdan@inria.fr>2015-11-07 16:06:33 +0100
committerJacques-Henri Jourdan <jacques-henri.jourdan@inria.fr>2015-11-07 16:06:33 +0100
commit99761d109a799f6ca62471058463b5713f37eddc (patch)
treef8038305ef9596629eb6084ff64044451fac1656 /cparser
parent15e6fc9861641d03ac32ae9ac03b9a6fa68036e9 (diff)
parentd0049e3b6bafb3aa88e173c10183b564918de115 (diff)
downloadcompcert-99761d109a799f6ca62471058463b5713f37eddc.tar.gz
compcert-99761d109a799f6ca62471058463b5713f37eddc.zip
Merge remote-tracking branch 'origin/master' into parser_fix
Diffstat (limited to 'cparser')
-rw-r--r--cparser/Cutil.ml16
-rw-r--r--cparser/Cutil.mli2
-rw-r--r--cparser/ErrorReports.ml10
3 files changed, 23 insertions, 5 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index a86c779f..1b0bf65d 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -880,6 +880,18 @@ let is_literal_0 e =
| EConst(CInt(0L, _, _)) -> true
| _ -> false
+(* Check that a C statement is a debug annotation *)
+
+let is_debug_stmt s =
+ let is_debug_call = function
+ | (ECall ({edesc = EVar id; _},_)) -> id.name = "__builtin_debug"
+ | _ -> false in
+ match s.sdesc with
+ | Sdo {edesc = e;_} ->
+ is_debug_call e
+ | _ -> false
+
+
(* Assignment compatibility check over attributes.
Standard attributes ("const", "volatile", "restrict") can safely
be added (to the rhs type to get the lhs type) but must not be dropped.
@@ -1099,7 +1111,3 @@ let rec subst_stmt phi s =
List.map subst_asm_operand inputs,
clob)
}
-
-
-
-
diff --git a/cparser/Cutil.mli b/cparser/Cutil.mli
index 8b6c609b..b353cba3 100644
--- a/cparser/Cutil.mli
+++ b/cparser/Cutil.mli
@@ -187,6 +187,8 @@ val type_of_member : Env.t -> field -> typ
(* Return the type of accessing the given field [fld].
Normally it's [fld.fld_type] but there is a special case for
small unsigned bitfields. *)
+val is_debug_stmt : stmt -> bool
+ (* Is the given statement a call to debug builtin? *)
val is_literal_0 : exp -> bool
(* Is the given expression the integer literal "0"? *)
val is_lvalue : exp -> bool
diff --git a/cparser/ErrorReports.ml b/cparser/ErrorReports.ml
index 4bbf3ded..a8976e42 100644
--- a/cparser/ErrorReports.ml
+++ b/cparser/ErrorReports.ml
@@ -92,6 +92,14 @@ let extract text (pos1, pos2) : string =
(* -------------------------------------------------------------------------- *)
+(* [compress text] replaces every run of at least one whitespace character
+ with exactly one space character. *)
+
+let compress text =
+ Str.global_replace (Str.regexp "[ \t\n\r]+") " " text
+
+(* -------------------------------------------------------------------------- *)
+
(* [sanitize text] eliminates any special characters from the text [text].
They are (arbitrarily) replaced with a single dot character. *)
@@ -182,7 +190,7 @@ let range text (e : element) : string =
(* Get the underlying source text fragment. *)
let fragment = extract text (pos1, pos2) in
(* Sanitize it and limit its length. Enclose it in single quotes. *)
- "'" ^ shorten width (sanitize fragment) ^ "'"
+ "'" ^ shorten width (sanitize (compress fragment)) ^ "'"
(* -------------------------------------------------------------------------- *)