Skip to content

Commit 37e45d5

Browse files
authored
Merge pull request #6593 from tautschnig/cleanup/is_type_internal
Remove useless system_library_symbolst::is_type_internal
2 parents 1214c7f + f32b18b commit 37e45d5

File tree

5 files changed

+66
-30
lines changed

5 files changed

+66
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdint.h>
2+
3+
// NOLINTNEXTLINE(whitespace/line_length)
4+
#line 1 "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdint.h"
5+
typedef short int16_t;
6+
7+
// NOLINTNEXTLINE(whitespace/line_length)
8+
#line 1 "/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h"
9+
typedef unsigned short uint16_t;
10+
11+
// NOLINTNEXTLINE(whitespace/line_length)
12+
#line 1 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.10.25017\\include\\stdint.h"
13+
typedef int int32_t;
14+
15+
// NOLINTNEXTLINE(whitespace/line_length)
16+
#line 1 "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.30.30705\\include\\stdint.h"
17+
typedef unsigned int uint32_t;
18+
19+
#line 20 "main.c"
20+
int main(int argc, char *argv[])
21+
{
22+
intmax_t x;
23+
int16_t y;
24+
uint16_t uy;
25+
int32_t z;
26+
uint32_t uz;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
main.c
3+
--dump-c --use-all-headers
4+
#include <(stdint.h|_types/_intmax_t.h)>
5+
intmax_t
6+
^EXIT=0$
7+
^SIGNAL=0$
8+
--
9+
typedef
10+
^warning: ignoring
11+
--
12+
Dump-c with --use-all-headers should re-generate the #include and not print a
13+
local typedef statement for intmax_t instead.

src/goto-instrument/dump_c.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,6 @@ void dump_ct::collect_typedefs_rec(
733733
bool early,
734734
std::unordered_set<irep_idt> &dependencies)
735735
{
736-
if(system_symbols.is_type_internal(type, system_headers))
737-
return;
738-
739736
std::unordered_set<irep_idt> local_deps;
740737

741738
if(type.id()==ID_code)

src/goto-programs/system_library_symbols.cpp

+26-23
Original file line numberDiff line numberDiff line change
@@ -253,22 +253,6 @@ void system_library_symbolst::add_to_system_library(
253253
}
254254
}
255255

256-
/// Helper function to call `is_symbol_internal_symbol` on a nameless
257-
/// fake symbol with the given type, to determine whether the type alone
258-
/// is sufficient to classify a symbol of that type as internal.
259-
/// \param type: the type to check
260-
/// \param [out] out_system_headers: specific system headers that need to be
261-
/// included
262-
/// \return True if the type is an internal type
263-
bool system_library_symbolst::is_type_internal(
264-
const typet &type,
265-
std::set<std::string> &out_system_headers) const
266-
{
267-
symbolt symbol;
268-
symbol.type=type;
269-
return is_symbol_internal_symbol(symbol, out_system_headers);
270-
}
271-
272256
/// To find out if a symbol is an internal symbol.
273257
/// \param symbol: the symbol to check
274258
/// \param [out] out_system_headers: specific system headers that need to be
@@ -336,17 +320,36 @@ bool system_library_symbolst::is_symbol_internal_symbol(
336320
return true;
337321
}
338322

339-
if(use_all_headers &&
340-
has_prefix(file_str, "/usr/include/"))
323+
if(use_all_headers)
341324
{
342-
if(file_str.find("/bits/")==std::string::npos)
325+
if(
326+
has_prefix(file_str, "/usr/include/") ||
327+
((has_prefix(file_str, "/Library/Developer/") ||
328+
has_prefix(file_str, "/Applications/Xcode")) &&
329+
file_str.find("/usr/include/") != std::string::npos))
343330
{
344-
// Do not include transitive includes of system headers!
345-
std::string::size_type prefix_len=std::string("/usr/include/").size();
346-
out_system_headers.insert(file_str.substr(prefix_len));
331+
if(file_str.find("/bits/") == std::string::npos)
332+
{
333+
// Do not include transitive includes of system headers!
334+
const std::string::size_type prefix_len =
335+
file_str.find("/usr/include/") + std::string("/usr/include/").size();
336+
out_system_headers.insert(file_str.substr(prefix_len));
337+
}
338+
339+
return true;
347340
}
341+
else if(
342+
(has_prefix(
343+
file_str, "C:\\Program Files (x86)\\Microsoft Visual Studio\\") ||
344+
has_prefix(file_str, "C:\\Program Files\\Microsoft Visual Studio\\")) &&
345+
file_str.find("\\include\\") != std::string::npos)
346+
{
347+
const std::string::size_type prefix_len =
348+
file_str.find("\\include\\") + std::string("\\include\\").size();
349+
out_system_headers.insert(file_str.substr(prefix_len));
348350

349-
return true;
351+
return true;
352+
}
350353
}
351354

352355
return false;

src/goto-programs/system_library_symbols.h

-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ class system_library_symbolst
3535
const symbolt &symbol,
3636
std::set<std::string> &out_system_headers) const;
3737

38-
bool is_type_internal(
39-
const typet &type,
40-
std::set<std::string> &out_system_headers) const;
41-
4238
void set_use_all_headers(bool use)
4339
{
4440
use_all_headers=use;

0 commit comments

Comments
 (0)