Skip to content

Commit f2306e3

Browse files
committed
Remove the __CPROVER_HIDE label when inlining
Leaving this label in place will mark the function being inlined into as hidden, which messes up, e.g., coverage instrumentation. Consider hidden.c: #include <string.h> int foo() { char *a, *b; return memcmp(a, b, 1); } int main() { foo(); return 0; } goto-cc hidden.c goto-instrument --add-library a.out b.out (add library function with hiding) goto-analyzer --simplify c.out b.out (goto-analyzer does inlining) cbmc --cover location c.out (will be missing any coverage targets in foo) cbmc --cover location b.out (has coverage targets in foo) With this patch, cbmc --cover location c.out also has coverage targets in foo.
1 parent f1489fd commit f2306e3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/goto-programs/goto_inline_class.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ void goto_inlinet::insert_function_body(
285285
for(auto &instruction : body.instructions)
286286
instruction.function=target->function;
287287

288+
// make sure the inlined function does not introduce hiding
289+
if(goto_function.is_hidden())
290+
{
291+
for(auto &instruction : body.instructions)
292+
instruction.labels.remove("__CPROVER_HIDE");
293+
}
294+
288295
replace_return(body, lhs);
289296

290297
goto_programt tmp1;

0 commit comments

Comments
 (0)