Mass rename of C++ .c files to .cc suffix?

Martin Liška mliska@suse.cz
Mon Jan 10 09:11:23 GMT 2022


On 1/7/22 16:59, David Malcolm via Gcc wrote:
> On Fri, 2022-01-07 at 11:25 +0100, Martin Jambor wrote:
>> Hi,
>>
>> Would anyone be terribly against mass renaming all *.c files (that are
>> actually C++ files) within the gcc subdirectory to ones with .cc
>> suffix?
>>
>> We already have 47 files with suffix .cc directly in the gcc
>> subdirectory and 160 if we also count those in (non-testsuite)
>> subdirectories, while the majority of our non-header C++ files still
>> has
>> the .c suffix.
>>
>> I have already missed stuff when grepping because I did not include
>> *.cc
>> files and the inconsistency is also just ugly and must be very
>> confusing
>> to anyone who encounters it for the first time.
>>
>> Since we have switched to git, this should have quite small effect on
>> anyone who does their development on branches.  With Martin Liška we
>> did
>> a few experiments and git blame, git rebase and even git gcc-backport
>> worked seamlessly across a rename.
>>
>> I would be fine waiting with it until GCC 12 gets released but see
>> little value in doing so.
>>
>> What do others think?  (Any important caveats I might have missed?)
> 
> +1 from me.
> 
> Various details:
> 
> Presumably the generated files should also change from .c to .cc (e.g.
> gengtype generates a gtype-desc.c which is actually C++).

Exactly. I'm willing to work on the transition.

I started with a replacement script that takes all *.c files in gcc/ subfolder
(excluding testsuite) and I made re.sub('\b${filename}\b', '${filename}c')
for all these files. It's quite surprising how many occurrences do we have
in comments (please see preliminary patch).

Martin

> 
> grep for "files_rules" in gengtype: it seems to have some hardcoded
> regex patterns that end in "\\.c" (not sure what these do, but should
> be investigated w.r.t. a renaming to .cc)
> 
> A minor detail that would be nice to get right: the selftests manually
> code the names of source files in function names; see
> selftest::run_tests in selftest-run-tests.c, which has lots of calls to
> functions of the form "foo_c_tests ();"  These function names should
> probably be renamed to "foo_cc_tests" if "foo.c" is renamed to
> "foo.cc".  Though perhaps that can wait to a followup, or be a separate
> commit, if that helps with backporting.
> 
> Hope this is constructive
> Dave
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Renaming.patch.zst
Type: application/zstd
Size: 199546 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20220110/d66b8589/attachment-0001.bin>


More information about the Gcc mailing list