Skip to content

Commit f405c6e

Browse files
authored
Merge pull request #5301 from tautschnig/overload-fix
Fix overload resolution in options processing
2 parents 48b8c90 + 5f1e354 commit f405c6e

File tree

9 files changed

+69
-0
lines changed

9 files changed

+69
-0
lines changed

regression/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ if(WITH_MEMORY_ANALYZER)
6262
endif()
6363

6464
add_subdirectory(solver-hardness)
65+
if(NOT WIN32)
66+
add_subdirectory(goto-ld)
67+
endif()

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ DIRS = cbmc \
3131
linking-goto-binaries \
3232
symtab2gb \
3333
solver-hardness \
34+
goto-ld \
3435
# Empty last line
3536

3637
ifeq ($(OS),Windows_NT)

regression/goto-gcc/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ tests.log: ../test.pl ../../src/goto-cc/goto-gcc
1818
../../src/goto-cc/goto-gcc: ../../src/goto-cc/goto-cc
1919
@ln -sf goto-cc ../../src/goto-cc/goto-gcc
2020

21+
../../src/goto-cc/goto-ld: ../../src/goto-cc/goto-cc
22+
@ln -sf goto-cc ../../src/goto-cc/goto-ld
23+
2124
test tests.log: archives/libour_archive.a
2225
archives/libour_archive.a: archives/foo.c ../../src/goto-cc/goto-gcc
2326
@cd archives && \

regression/goto-ld/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# TARGET_FILE (as used in other directories) can't be used with goto-gcc as it
2+
# isn't marked as an executable (target), which CMake requires. Thus construct a
3+
# path in the same way the symbolic link is created in the goto-cc directory.
4+
add_test_pl_tests("$<TARGET_FILE_DIR:goto-cc>/goto-ld")

regression/goto-ld/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
default: tests.log
2+
3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
ifeq ($(BUILD_ENV_),MSVC)
7+
test:
8+
9+
tests.log: ../test.pl
10+
11+
else
12+
test: ../../src/goto-cc/goto-ld
13+
@../test.pl -e -p -c ../../../src/goto-cc/goto-ld
14+
15+
tests.log: ../test.pl ../../src/goto-cc/goto-ld
16+
@../test.pl -e -p -c ../../../src/goto-cc/goto-ld
17+
18+
../../src/goto-cc/goto-ld: ../../src/goto-cc/goto-cc
19+
@ln -sf goto-cc ../../src/goto-cc/goto-ld
20+
endif
21+
22+
show:
23+
@for dir in *; do \
24+
if [ -d "$$dir" ]; then \
25+
vim -o "$$dir/*.c" "$$dir/*.out"; \
26+
fi; \
27+
done;
28+
29+
clean:
30+
find -name '*.out' -execdir $(RM) '{}' \;
31+
find -name '*.gb' -execdir $(RM) '{}' \;
32+
find -name '*.goto-cc-saved' -execdir $(RM) '{}' \;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
3+
--native-linker=true -o dummy.gb
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
--
8+
This is just to test that goto-ld exits without an error or a segmentation fault
9+
when processong command-line options, running the dummy-linker (/bin/)true.

src/goto-cc/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ else()
3434
COMMAND "${CMAKE_COMMAND}" -E create_symlink
3535
goto-cc $<TARGET_FILE_DIR:goto-cc>/goto-gcc
3636
BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/goto-gcc)
37+
add_custom_command(TARGET goto-cc
38+
POST_BUILD
39+
COMMAND "${CMAKE_COMMAND}" -E create_symlink
40+
goto-cc $<TARGET_FILE_DIR:goto-cc>/goto-ld
41+
BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/goto-ld)
3742
endif()

src/goto-cc/goto_cc_cmdline.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ class goto_cc_cmdlinet:public cmdlinet
3434
// never fails, will add if not found
3535
std::size_t get_optnr(const std::string &option);
3636

37+
/// Set option \p option to \p value.
38+
void set(const std::string &opt, const char *value) override
39+
{
40+
set(opt, std::string{value});
41+
}
42+
3743
void set(const std::string &opt, const std::string &value) override
3844
{
3945
std::size_t nr=get_optnr(opt);

src/util/cmdline.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ class cmdlinet
3232

3333
virtual bool isset(char option) const;
3434
virtual bool isset(const char *option) const;
35+
/// Set option \p option to \p value, or \c true if the value is omitted.
3536
virtual void set(const std::string &option, bool value = true);
3637
virtual void set(const std::string &option, const std::string &value);
38+
virtual void set(const std::string &option, const char *value)
39+
{
40+
set(option, std::string{value});
41+
}
42+
3743
virtual void clear();
3844

3945
bool has_option(const std::string &option) const

0 commit comments

Comments
 (0)