From: Alexey Sheplyakov Date: Wed, 29 Dec 2021 14:20:11 +0000 (+0400) Subject: fix: Avoid .incbin false positive (#983) X-Git-Tag: v4.6~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d2de82bb9231b981b40486b093a2c0002200c40;p=thirdparty%2Fccache.git fix: Avoid .incbin false positive (#983) --- diff --git a/src/ccache.cpp b/src/ccache.cpp index bd3641ed6..9e58317de 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -567,8 +567,8 @@ process_preprocessed_file(Context& ctx, Hash& hash, const std::string& path) Statistic::could_not_use_precompiled_header); } p = q; // Everything of interest between p and q has been hashed now. - } else if (q[0] == '.' && q[1] == 'i' && q[2] == 'n' && q[3] == 'c' - && q[4] == 'b' && q[5] == 'i' && q[6] == 'n') { + } else if (strncmp(q, ".incbin \\\"", 10) == 0 + || strncmp(q, ".incbin \"", 9) == 0) { // An assembler .inc bin (without the space) statement, which could be // part of inline assembly, refers to an external file. If the file // changes, the hash should change as well, but finding out what file to diff --git a/test/suites/base.bash b/test/suites/base.bash index d082bd062..dd52292d2 100644 --- a/test/suites/base.bash +++ b/test/suites/base.bash @@ -1440,6 +1440,20 @@ EOF expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 0 expect_stat unsupported_code_directive 2 + + cat <incbin.cpp + struct A { + void incbin() const { } + }; + void f() { + A a; + a.incbin(); + } +EOF + $CCACHE_COMPILE -x c++ -c incbin.cpp + expect_stat preprocessed_cache_hit 0 + expect_stat unsupported_code_directive 2 + expect_stat cache_miss 1 fi # -------------------------------------------------------------------------