-
Notifications
You must be signed in to change notification settings - Fork 286
Fix name mangler to preserve definition when mangled name already exists #8930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| static void foo(int x) | ||
| { | ||
| __CPROVER_assert(0, "reachable"); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| void __CPROVER_file_local_a_c_foo(int); | ||
| int main() | ||
| { | ||
| __CPROVER_file_local_a_c_foo(0); | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| CORE | ||
| main.c | ||
| assertion-check compile-and-link | ||
| ^EXIT=10$ | ||
| ^SIGNAL=0$ | ||
| ^\[foo.assertion.1\] .* reachable: FAILURE$ | ||
| -- | ||
| ^warning: ignoring | ||
| ^\*\*\*\* WARNING: no body for function | ||
| -- | ||
| Check that when files are compiled together with --export-file-local-symbols | ||
| the local_bitvector_analysis does not crash with an invariant violation |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -84,7 +84,34 @@ class function_name_manglert | |||||
| } | ||||||
|
|
||||||
| for(const auto &sym : new_syms) | ||||||
| model.symbol_table.insert(sym); | ||||||
| { | ||||||
| auto result = model.symbol_table.insert(sym); | ||||||
| if(!result.second) | ||||||
| { | ||||||
| symbolt &existing = result.first; | ||||||
| if(existing.value.is_nil()) | ||||||
| { | ||||||
| // The existing symbol is a declaration (no body). This happens | ||||||
| // when user code forward-declares the mangled name. Replace it | ||||||
| // with the definition so that parameter identifiers and the | ||||||
|
Comment on lines
+91
to
+96
|
||||||
| // full type are preserved. | ||||||
| existing.type = sym.type; | ||||||
| existing.value = sym.value; | ||||||
| existing.is_file_local = sym.is_file_local; | ||||||
| existing.module = sym.module; | ||||||
|
||||||
| existing.module = sym.module; | |
| // Do not change existing.module: it participates in symbol_table indices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old_symsstores iterators intomodel.symbol_table.symbols(anunordered_map). Insertingnew_symsbefore erasingold_symscan trigger a rehash and invalidate those iterators, making the latererase(sym)undefined behaviour. Prefer storing the old symbol names (irep_idt) and erasing via a freshfind()after insertions, or erase old entries before inserting new ones (or reserve to prevent rehash).