Skip to content

Commit edf0ed7

Browse files
Minimal change to convert_project to turn off #include updating by
default now that we've merged Microsoft's change for implicit checked header inclusion (checkedc#998). I filed #520 for follow-ups. We don't have to change the benchmark workflow right now: it still passes --includeDir, but that option is ignored when #include updating is off.
1 parent 38bdf5e commit edf0ed7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

clang/tools/3c/utils/port_tools/convert_project.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ def parseTheArg():
4747

4848
parser = argparse.ArgumentParser(description='Convert the provided project into Checked C.')
4949

50+
parser.add_argument('--updateIncludes',
51+
dest='update_includes', action='store_true',
52+
default=False,
53+
help=('Update `#include <foo.h>` to `#include <foo_checked.h>` in '
54+
'source files before running 3c. Should normally no longer '
55+
'be needed with implicit checked header inclusion.'))
5056
parser.add_argument('--includeDir',
5157
default=checkedcHeaderDir if os.path.exists(checkedcHeaderDir) else pathBasedDir,
5258
required=False,
5359
dest='includeDir',
54-
help='Path to the checkedC headers, run from a checkedCclang repo')
60+
help=('Path to the checkedC headers, run from a checkedCclang repo '
61+
'(used only if --updateIncludes is on)'))
5562
parser.add_argument("-p", "--prog_name", dest='prog_name', type=str, default=_3c_bin,
5663
help='Program name to run. i.e., path to 3c')
5764

@@ -100,7 +107,7 @@ def parseTheArg():
100107
logging.error("Provided argument: {} is not a file.".format(args.prog_name))
101108
sys.exit()
102109

103-
if not args.includeDir or not os.path.isdir(args.includeDir):
110+
if args.update_includes and (not args.includeDir or not os.path.isdir(args.includeDir)):
104111
logging.error("Error: --includeDir argument must be the name of a directory.")
105112
logging.error("Provided argument: {} is not a directory.".format(args.includeDir))
106113
sys.exit()
@@ -129,10 +136,11 @@ def parseTheArg():
129136
logging.error("Error: Build directory does not contain compile_commands.json.")
130137
logging.error("compile_commands.json file: {} does not exist.".format(compileCmdsJson))
131138
sys.exit()
132-
# replace include files
133-
logging.info("Updating include lines of all the source files.")
134-
updateProjectIncludes(progArgs.project_path, progArgs.includeDir)
135-
logging.info("Finished updating project files.")
139+
if progArgs.update_includes:
140+
# replace include files
141+
logging.info("Updating include lines of all the source files.")
142+
updateProjectIncludes(progArgs.project_path, progArgs.includeDir)
143+
logging.info("Finished updating project files.")
136144

137145
logging.info("Trying to convert all the source files to header files")
138146
run3C(progArgs.prog_name, progArgs.extra_3c_args,

0 commit comments

Comments
 (0)