]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Avoid .incbin false positive (#983)
authorAlexey Sheplyakov <asheplyakov@yandex.ru>
Wed, 29 Dec 2021 14:20:11 +0000 (18:20 +0400)
committerGitHub <noreply@github.com>
Wed, 29 Dec 2021 14:20:11 +0000 (15:20 +0100)
src/ccache.cpp
test/suites/base.bash

index bd3641ed673d3c929e48bfde523118e9e3be1346..9e58317de2759536d6ede513167e5f7f4b38b09c 100644 (file)
@@ -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
index d082bd06270dab0ffd597520a3f23a35b91b338f..dd52292d29623e847732341d7d6993a9436a66db 100644 (file)
@@ -1440,6 +1440,20 @@ EOF
     expect_stat preprocessed_cache_hit 0
     expect_stat cache_miss 0
     expect_stat unsupported_code_directive 2
+
+    cat <<EOF >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
 
     # -------------------------------------------------------------------------