]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add option to not discard comments in preprocessor
authorAnders Björklund <anders@itension.se>
Mon, 14 Mar 2016 06:46:58 +0000 (07:46 +0100)
committerAnders Björklund <anders@itension.se>
Mon, 14 Mar 2016 17:35:12 +0000 (18:35 +0100)
MANUAL.txt
ccache.c
conf.c
conf.h
confitems.gperf
confitems_lookup.c
envtoconfitems.gperf
envtoconfitems_lookup.c
test.sh
test/test_conf.c

index b2b3fbc6ad3cd133b1a073c63a96b0a91af1b3df..c1b3307760c2b1b19d795a812a63619d7b78928b 100644 (file)
@@ -385,6 +385,11 @@ WRAPPERS>>.
     change. The list separator is semicolon on Windows systems and colon on
     other systems.
 
+*keep_comments_cpp* (*CCACHE_COMMENTS*) [boolean]::
+
+    If true, ccache will not discard the comments before hashing preprocessor
+    output. This can be used to check documentation with *-Wdocumentation*.
+
 *log_file* (*CCACHE_LOGFILE*)::
 
     If set to a file path, ccache will write information on what it is doing to
index 941941d2b0eceb5bd7df0e4532ddfc63ed58c9ec..886b8521315d9927039e68b688d4577d6e9a2a02 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1312,6 +1312,8 @@ get_object_name_from_cpp(struct args *args, struct mdfour *hash)
                add_pending_tmp_file(path_stdout);
 
                args_add(args, "-E");
+               if (conf->keep_comments_cpp)
+                       args_add(args, "-C");
                args_add(args, input_file);
                add_prefix(args, conf->prefix_command_cpp);
                cc_log("Running preprocessor");
diff --git a/conf.c b/conf.c
index 8ab60c3915fb784657ea6714313f41db3aff7986..de81cd5f92a7c692fa293879277294e49c38b67e 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -316,6 +316,7 @@ conf_create(void)
        conf->hard_link = false;
        conf->hash_dir = false;
        conf->ignore_headers_in_manifest = x_strdup("");
+       conf->keep_comments_cpp = false;
        conf->log_file = x_strdup("");
        conf->max_files = 0;
        conf->max_size = (uint64_t)5 * 1000 * 1000 * 1000;
@@ -576,6 +577,9 @@ conf_print_items(struct conf *conf,
                conf->item_origins[find_conf("ignore_headers_in_manifest")->number],
                context);
 
+       reformat(&s, "keep_comments_cpp = %s", bool_to_string(conf->keep_comments_cpp));
+       printer(s, conf->item_origins[find_conf("keep_comments_cpp")->number], context);
+
        reformat(&s, "log_file = %s", conf->log_file);
        printer(s, conf->item_origins[find_conf("log_file")->number], context);
 
diff --git a/conf.h b/conf.h
index 238cb8d949f0483ef55c832e332a21ec2a1a5b1c..e1d0dbd3b1a8417146a44f7e6bf5f4006a9b9d4f 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -18,6 +18,7 @@ struct conf {
        bool hard_link;
        bool hash_dir;
        char *ignore_headers_in_manifest;
+       bool keep_comments_cpp;
        char *log_file;
        unsigned max_files;
        uint64_t max_size;
index d7041992bc2bbd26cfceb44fc628572853fc1994..6b24de25a0d911e9bc2478b51427dab943718810 100644 (file)
@@ -21,18 +21,19 @@ extra_files_to_hash, 10, ITEM(extra_files_to_hash, env_string)
 hard_link,           11, ITEM(hard_link, bool)
 hash_dir,            12, ITEM(hash_dir, bool)
 ignore_headers_in_manifest, 13, ITEM(ignore_headers_in_manifest, env_string)
-log_file,            14, ITEM(log_file, env_string)
-max_files,           15, ITEM(max_files, unsigned)
-max_size,            16, ITEM(max_size, size)
-path,                17, ITEM(path, env_string)
-prefix_command,      18, ITEM(prefix_command, env_string)
-prefix_command_cpp,  19, ITEM(prefix_command_cpp, env_string)
-read_only,           20, ITEM(read_only, bool)
-read_only_direct,    21, ITEM(read_only_direct, bool)
-recache,             22, ITEM(recache, bool)
-run_second_cpp,      23, ITEM(run_second_cpp, bool)
-sloppiness,          24, ITEM(sloppiness, sloppiness)
-stats,               25, ITEM(stats, bool)
-temporary_dir,       26, ITEM(temporary_dir, env_string)
-umask,               27, ITEM(umask, umask)
-unify,               28, ITEM(unify, bool)
+keep_comments_cpp,   14, ITEM(keep_comments_cpp, bool)
+log_file,            15, ITEM(log_file, env_string)
+max_files,           16, ITEM(max_files, unsigned)
+max_size,            17, ITEM(max_size, size)
+path,                18, ITEM(path, env_string)
+prefix_command,      19, ITEM(prefix_command, env_string)
+prefix_command_cpp,  20, ITEM(prefix_command_cpp, env_string)
+read_only,           21, ITEM(read_only, bool)
+read_only_direct,    22, ITEM(read_only_direct, bool)
+recache,             23, ITEM(recache, bool)
+run_second_cpp,      24, ITEM(run_second_cpp, bool)
+sloppiness,          25, ITEM(sloppiness, sloppiness)
+stats,               26, ITEM(stats, bool)
+temporary_dir,       27, ITEM(temporary_dir, env_string)
+umask,               28, ITEM(umask, umask)
+unify,               29, ITEM(unify, bool)
index dc4eb43d7aa744b84db81456f1404bafd3159ecc..845dfb1d185b776b18e2151b133662d581b55155 100644 (file)
@@ -55,7 +55,7 @@ confitems_hash (register const char *str, register unsigned int len)
       45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
       45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
       45, 45, 45, 45, 45, 45, 45,  0, 13,  0,
-      15, 10, 45,  5, 30, 10, 45, 45, 10, 20,
+      15, 10, 45,  5, 30, 10, 45,  0, 10, 20,
        5,  0,  0, 45,  5,  0, 10, 15, 45, 45,
       15, 45, 45, 45, 45, 45, 45, 45, 45, 45,
       45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
@@ -87,7 +87,7 @@ confitems_get (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 29,
+      TOTAL_KEYWORDS = 30,
       MIN_WORD_LENGTH = 4,
       MAX_WORD_LENGTH = 26,
       MIN_HASH_VALUE = 4,
@@ -98,8 +98,8 @@ confitems_get (register const char *str, register unsigned int len)
     {
       {"",0,NULL,0,NULL}, {"",0,NULL,0,NULL},
       {"",0,NULL,0,NULL}, {"",0,NULL,0,NULL},
-#line 27 "confitems.gperf"
-      {"path",                17, ITEM(path, env_string)},
+#line 28 "confitems.gperf"
+      {"path",                18, ITEM(path, env_string)},
       {"",0,NULL,0,NULL}, {"",0,NULL,0,NULL},
       {"",0,NULL,0,NULL},
 #line 13 "confitems.gperf"
@@ -114,42 +114,44 @@ confitems_get (register const char *str, register unsigned int len)
       {"cpp_extension",        7, ITEM(cpp_extension, string)},
 #line 14 "confitems.gperf"
       {"compiler_check",       4, ITEM(compiler_check, string)},
-#line 35 "confitems.gperf"
-      {"stats",               25, ITEM(stats, bool)},
+#line 36 "confitems.gperf"
+      {"stats",               26, ITEM(stats, bool)},
 #line 12 "confitems.gperf"
       {"cache_dir_levels",     2, ITEM_V(cache_dir_levels, unsigned, dir_levels)},
 #line 16 "confitems.gperf"
       {"compression_level",    6, ITEM(compression_level, unsigned)},
-#line 24 "confitems.gperf"
-      {"log_file",            14, ITEM(log_file, env_string)},
-#line 28 "confitems.gperf"
-      {"prefix_command",      18, ITEM(prefix_command, env_string)},
-#line 34 "confitems.gperf"
-      {"sloppiness",          24, ITEM(sloppiness, sloppiness)},
+#line 25 "confitems.gperf"
+      {"log_file",            15, ITEM(log_file, env_string)},
+#line 29 "confitems.gperf"
+      {"prefix_command",      19, ITEM(prefix_command, env_string)},
+#line 35 "confitems.gperf"
+      {"sloppiness",          25, ITEM(sloppiness, sloppiness)},
 #line 10 "confitems.gperf"
       {"base_dir",             0, ITEM_V(base_dir, env_string, absolute_path)},
-#line 32 "confitems.gperf"
-      {"recache",             22, ITEM(recache, bool)},
-#line 29 "confitems.gperf"
-      {"prefix_command_cpp",  19, ITEM(prefix_command_cpp, env_string)},
+#line 33 "confitems.gperf"
+      {"recache",             23, ITEM(recache, bool)},
 #line 30 "confitems.gperf"
-      {"read_only",           20, ITEM(read_only, bool)},
-#line 38 "confitems.gperf"
-      {"unify",               28, ITEM(unify, bool)},
-      {"",0,NULL,0,NULL}, {"",0,NULL,0,NULL},
+      {"prefix_command_cpp",  20, ITEM(prefix_command_cpp, env_string)},
+#line 31 "confitems.gperf"
+      {"read_only",           21, ITEM(read_only, bool)},
+#line 39 "confitems.gperf"
+      {"unify",               29, ITEM(unify, bool)},
+      {"",0,NULL,0,NULL},
+#line 24 "confitems.gperf"
+      {"keep_comments_cpp",   14, ITEM(keep_comments_cpp, bool)},
+#line 27 "confitems.gperf"
+      {"max_size",            17, ITEM(max_size, size)},
 #line 26 "confitems.gperf"
-      {"max_size",            16, ITEM(max_size, size)},
-#line 25 "confitems.gperf"
-      {"max_files",           15, ITEM(max_files, unsigned)},
+      {"max_files",           16, ITEM(max_files, unsigned)},
       {"",0,NULL,0,NULL},
-#line 31 "confitems.gperf"
-      {"read_only_direct",    21, ITEM(read_only_direct, bool)},
+#line 32 "confitems.gperf"
+      {"read_only_direct",    22, ITEM(read_only_direct, bool)},
 #line 19 "confitems.gperf"
       {"disable",              9, ITEM(disable, bool)},
-#line 36 "confitems.gperf"
-      {"temporary_dir",       26, ITEM(temporary_dir, env_string)},
-#line 33 "confitems.gperf"
-      {"run_second_cpp",      23, ITEM(run_second_cpp, bool)},
+#line 37 "confitems.gperf"
+      {"temporary_dir",       27, ITEM(temporary_dir, env_string)},
+#line 34 "confitems.gperf"
+      {"run_second_cpp",      24, ITEM(run_second_cpp, bool)},
       {"",0,NULL,0,NULL},
 #line 18 "confitems.gperf"
       {"direct_mode",          8, ITEM(direct_mode, bool)},
@@ -158,8 +160,8 @@ confitems_get (register const char *str, register unsigned int len)
       {"hash_dir",            12, ITEM(hash_dir, bool)},
 #line 21 "confitems.gperf"
       {"hard_link",           11, ITEM(hard_link, bool)},
-#line 37 "confitems.gperf"
-      {"umask",               27, ITEM(umask, umask)},
+#line 38 "confitems.gperf"
+      {"umask",               28, ITEM(umask, umask)},
 #line 23 "confitems.gperf"
       {"ignore_headers_in_manifest", 13, ITEM(ignore_headers_in_manifest, env_string)},
       {"",0,NULL,0,NULL}, {"",0,NULL,0,NULL},
@@ -181,4 +183,4 @@ confitems_get (register const char *str, register unsigned int len)
     }
   return 0;
 }
-static const size_t CONFITEMS_TOTAL_KEYWORDS = 29;
+static const size_t CONFITEMS_TOTAL_KEYWORDS = 30;
index a3808aa7ba25ecfcf410ca0d8207ac9015ca752d..746cdc206859bb9c59bb9c7f503319c1f375f0c0 100644 (file)
@@ -14,6 +14,7 @@ COMPILERCHECK, "compiler_check"
 COMPRESS, "compression"
 COMPRESSLEVEL, "compression_level"
 CPP2, "run_second_cpp"
+COMMENTS, "keep_comments_cpp"
 DIR, "cache_dir"
 DIRECT, "direct_mode"
 DISABLE, "disable"
index 0b6357fe3c1af75d86bdf0bbce0e4731bdcf1365..04aedd72d46986f30deddd5222f8fbbb0ded9a58 100644 (file)
@@ -52,7 +52,7 @@ envtoconfitems_hash (register const char *str, register unsigned int len)
       44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
       44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
       44, 44, 44, 44, 44, 44, 10,  0,  0, 10,
-      20, 44,  5, 15,  0, 44, 30, 25, 15,  0,
+       0, 44,  5, 15,  0, 44, 30, 25,  3,  0,
        5, 15,  5, 15,  0,  0, 44, 44, 44, 44,
        0, 44, 44, 44, 44, 44, 44, 44, 44, 44,
       44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
@@ -101,7 +101,7 @@ envtoconfitems_get (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 29,
+      TOTAL_KEYWORDS = 30,
       MIN_WORD_LENGTH = 2,
       MAX_WORD_LENGTH = 15,
       MIN_HASH_VALUE = 2,
@@ -113,45 +113,47 @@ envtoconfitems_get (register const char *str, register unsigned int len)
       {"",""}, {"",""},
 #line 12 "envtoconfitems.gperf"
       {"CC", "compiler"},
-#line 17 "envtoconfitems.gperf"
+#line 18 "envtoconfitems.gperf"
       {"DIR", "cache_dir"},
 #line 16 "envtoconfitems.gperf"
       {"CPP2", "run_second_cpp"},
-#line 39 "envtoconfitems.gperf"
+#line 40 "envtoconfitems.gperf"
       {"UNIFY", "unify"},
-#line 18 "envtoconfitems.gperf"
-      {"DIRECT", "direct_mode"},
 #line 19 "envtoconfitems.gperf"
+      {"DIRECT", "direct_mode"},
+#line 20 "envtoconfitems.gperf"
       {"DISABLE", "disable"},
-      {"",""},
-#line 29 "envtoconfitems.gperf"
-      {"PATH", "path"},
-      {"",""},
+#line 17 "envtoconfitems.gperf"
+      {"COMMENTS", "keep_comments_cpp"},
 #line 30 "envtoconfitems.gperf"
+      {"PATH", "path"},
+#line 29 "envtoconfitems.gperf"
+      {"NLEVELS", "cache_dir_levels"},
+#line 31 "envtoconfitems.gperf"
       {"PREFIX", "prefix_command"},
-#line 34 "envtoconfitems.gperf"
+#line 35 "envtoconfitems.gperf"
       {"RECACHE", "recache"},
 #line 13 "envtoconfitems.gperf"
       {"COMPILERCHECK", "compiler_check"},
       {"",""},
-#line 31 "envtoconfitems.gperf"
+#line 32 "envtoconfitems.gperf"
       {"PREFIX_CPP", "prefix_command_cpp"},
       {"",""},
-#line 37 "envtoconfitems.gperf"
+#line 38 "envtoconfitems.gperf"
       {"TEMPDIR", "temporary_dir"},
-#line 32 "envtoconfitems.gperf"
+#line 33 "envtoconfitems.gperf"
       {"READONLY", "read_only"},
-#line 20 "envtoconfitems.gperf"
+#line 21 "envtoconfitems.gperf"
       {"EXTENSION", "cpp_extension"},
-#line 36 "envtoconfitems.gperf"
+#line 37 "envtoconfitems.gperf"
       {"STATS", "stats"},
       {"",""},
-#line 23 "envtoconfitems.gperf"
+#line 24 "envtoconfitems.gperf"
       {"HASHDIR", "hash_dir"},
 #line 14 "envtoconfitems.gperf"
       {"COMPRESS", "compression"},
       {"",""},
-#line 33 "envtoconfitems.gperf"
+#line 34 "envtoconfitems.gperf"
       {"READONLY_DIRECT", "read_only_direct"},
       {"",""},
 #line 11 "envtoconfitems.gperf"
@@ -159,28 +161,26 @@ envtoconfitems_get (register const char *str, register unsigned int len)
 #line 15 "envtoconfitems.gperf"
       {"COMPRESSLEVEL", "compression_level"},
       {"",""},
-#line 21 "envtoconfitems.gperf"
+#line 22 "envtoconfitems.gperf"
       {"EXTRAFILES", "extra_files_to_hash"},
       {"",""},
-#line 27 "envtoconfitems.gperf"
+#line 28 "envtoconfitems.gperf"
       {"MAXSIZE", "max_size"},
-#line 26 "envtoconfitems.gperf"
+#line 27 "envtoconfitems.gperf"
       {"MAXFILES", "max_files"},
       {"",""},
-#line 38 "envtoconfitems.gperf"
+#line 39 "envtoconfitems.gperf"
       {"UMASK", "umask"},
       {"",""},
-#line 25 "envtoconfitems.gperf"
+#line 26 "envtoconfitems.gperf"
       {"LOGFILE", "log_file"},
-#line 22 "envtoconfitems.gperf"
+#line 23 "envtoconfitems.gperf"
       {"HARDLINK", "hard_link"},
       {"",""},
-#line 35 "envtoconfitems.gperf"
+#line 36 "envtoconfitems.gperf"
       {"SLOPPINESS", "sloppiness"},
-      {"",""},
-#line 28 "envtoconfitems.gperf"
-      {"NLEVELS", "cache_dir_levels"},
-#line 24 "envtoconfitems.gperf"
+      {"",""}, {"",""},
+#line 25 "envtoconfitems.gperf"
       {"IGNOREHEADERS", "ignore_headers_in_manifest"}
     };
 
@@ -198,4 +198,4 @@ envtoconfitems_get (register const char *str, register unsigned int len)
     }
   return 0;
 }
-static const size_t ENVTOCONFITEMS_TOTAL_KEYWORDS = 29;
+static const size_t ENVTOCONFITEMS_TOTAL_KEYWORDS = 30;
diff --git a/test.sh b/test.sh
index 076445f87b609a42a6b296eb192fe465827fada0..a273fe67171763bc6c60a37d37f3600b0c60e568 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -23,6 +23,7 @@ unset CCACHE_BASEDIR
 unset CCACHE_CC
 unset CCACHE_COMPILERCHECK
 unset CCACHE_COMPRESS
+unset CCACHE_COMMENTS
 unset CCACHE_CPP2
 unset CCACHE_DIR
 unset CCACHE_DISABLE
index 6a1524185d02fda08a6a9a12fcf1a9cd7eb4234b..2bc9e40d97bfe88d2139ea2895dcc0289f4bbd18 100644 (file)
@@ -20,7 +20,7 @@
 #include "test/framework.h"
 #include "test/util.h"
 
-#define N_CONFIG_ITEMS 29
+#define N_CONFIG_ITEMS 30
 static struct {
        char *descr;
        const char *origin;
@@ -65,6 +65,7 @@ TEST(conf_create)
        CHECK(!conf->hard_link);
        CHECK(!conf->hash_dir);
        CHECK_STR_EQ("", conf->ignore_headers_in_manifest);
+       CHECK(!conf->keep_comments_cpp);
        CHECK_STR_EQ("", conf->log_file);
        CHECK_INT_EQ(0, conf->max_files);
        CHECK_INT_EQ((uint64_t)5 * 1000 * 1000 * 1000, conf->max_size);
@@ -114,6 +115,7 @@ TEST(conf_read_valid_config)
          "hard_link = true\n"
          "hash_dir = true\n"
          "ignore_headers_in_manifest = a:b/c\n"
+         "keep_comments_cpp = true\n"
          "log_file = $USER${USER} \n"
          "max_files = 17\n"
          "max_size = 123M\n"
@@ -150,6 +152,7 @@ TEST(conf_read_valid_config)
        CHECK(conf->hard_link);
        CHECK(conf->hash_dir);
        CHECK_STR_EQ("a:b/c", conf->ignore_headers_in_manifest);
+       CHECK(conf->keep_comments_cpp);
        CHECK_STR_EQ_FREE1(format("%s%s", user, user), conf->log_file);
        CHECK_INT_EQ(17, conf->max_files);
        CHECK_INT_EQ(123 * 1000 * 1000, conf->max_size);
@@ -374,6 +377,7 @@ TEST(conf_print_items)
                true,
                true,
                "ihim",
+               true,
                "lf",
                4711,
                98.7 * 1000 * 1000,
@@ -421,6 +425,7 @@ TEST(conf_print_items)
        CHECK_STR_EQ("hash_dir = true", received_conf_items[n++].descr);
        CHECK_STR_EQ("ignore_headers_in_manifest = ihim",
                     received_conf_items[n++].descr);
+       CHECK_STR_EQ("keep_comments_cpp = true", received_conf_items[n++].descr);
        CHECK_STR_EQ("log_file = lf", received_conf_items[n++].descr);
        CHECK_STR_EQ("max_files = 4711", received_conf_items[n++].descr);
        CHECK_STR_EQ("max_size = 98.7M", received_conf_items[n++].descr);