Skip to content

Commit fd4d8af

Browse files
Command line options clean up (#692)
We previously used the _3COptions structure to store command line options immediately after they were parsed, but later copied the option values out of this structure and into global variables for use in the rest of the program. This change deletes the global variables and replaces them with a single global instance of the _3COptions structure.
1 parent df738a4 commit fd4d8af

13 files changed

+170
-228
lines changed

clang/include/clang/3C/3C.h

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,60 +22,6 @@
2222
#include "clang/Tooling/CommonOptionsParser.h"
2323
#include <mutex>
2424

25-
// Options used to initialize 3C tool.
26-
//
27-
// See clang/docs/checkedc/3C/clang-tidy.md#_3c-name-prefix
28-
// NOLINTNEXTLINE(readability-identifier-naming)
29-
struct _3COptions {
30-
bool DumpIntermediate;
31-
32-
bool Verbose;
33-
34-
std::string OutputPostfix;
35-
std::string OutputDir;
36-
37-
std::string ConstraintOutputJson;
38-
39-
bool DumpStats;
40-
41-
std::string StatsOutputJson;
42-
43-
std::string WildPtrInfoJson;
44-
45-
std::string PerPtrInfoJson;
46-
47-
std::vector<std::string> AllocatorFunctions;
48-
49-
bool HandleVARARGS;
50-
51-
bool EnablePropThruIType;
52-
53-
std::string BaseDir;
54-
bool AllowSourcesOutsideBaseDir;
55-
56-
bool EnableAllTypes;
57-
58-
bool AddCheckedRegions;
59-
60-
bool EnableCCTypeChecker;
61-
62-
bool WarnRootCause;
63-
64-
bool WarnAllRootCause;
65-
66-
#ifdef FIVE_C
67-
bool RemoveItypes;
68-
bool ForceItypes;
69-
#endif
70-
71-
bool DumpUnwritableChanges;
72-
bool AllowUnwritableChanges;
73-
74-
bool AllowRewriteFailures;
75-
76-
bool ItypesForExtern;
77-
};
78-
7925
// The main interface exposed by the 3C to interact with the tool.
8026
//
8127
// See clang/docs/checkedc/3C/clang-tidy.md#_3c-name-prefix

clang/include/clang/3C/3CGlobalOptions.h

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,61 @@
1515

1616
#include "llvm/Support/CommandLine.h"
1717

18-
extern bool Verbose;
19-
extern bool DumpIntermediate;
20-
extern std::string OutputPostfix;
21-
extern std::string OutputDir;
22-
extern bool HandleVARARGS;
23-
extern bool SeperateMultipleFuncDecls;
24-
extern bool EnablePropThruIType;
25-
extern bool ConsiderAllocUnsafe;
26-
extern bool AllTypes;
27-
extern bool NewSolver;
28-
extern std::string BaseDir;
29-
extern std::vector<std::string> AllocatorFunctions;
30-
extern bool AddCheckedRegions;
31-
extern bool WarnRootCause;
32-
extern bool WarnAllRootCause;
33-
extern bool DumpUnwritableChanges;
34-
extern bool AllowUnwritableChanges;
35-
extern bool AllowRewriteFailures;
36-
extern bool ItypesForExtern;
18+
// Options used to initialize 3C tool.
19+
//
20+
// See clang/docs/checkedc/3C/clang-tidy.md#_3c-name-prefix
21+
// NOLINTNEXTLINE(readability-identifier-naming)
22+
struct _3COptions {
23+
bool DumpIntermediate;
24+
25+
bool Verbose;
26+
27+
std::string OutputPostfix;
28+
std::string OutputDir;
29+
30+
std::string ConstraintOutputJson;
31+
32+
bool DumpStats;
33+
34+
std::string StatsOutputJson;
35+
36+
std::string WildPtrInfoJson;
37+
38+
std::string PerWildPtrInfoJson;
39+
40+
std::vector<std::string> AllocatorFunctions;
41+
42+
bool HandleVARARGS;
43+
44+
bool EnablePropThruIType;
45+
46+
std::string BaseDir;
47+
bool AllowSourcesOutsideBaseDir;
48+
49+
bool AllTypes;
50+
51+
bool AddCheckedRegions;
52+
53+
bool EnableCCTypeChecker;
54+
55+
bool WarnRootCause;
56+
57+
bool WarnAllRootCause;
3758

3859
#ifdef FIVE_C
39-
extern bool RemoveItypes;
40-
extern bool ForceItypes;
60+
bool RemoveItypes;
61+
bool ForceItypes;
4162
#endif
4263

64+
bool DumpUnwritableChanges;
65+
bool AllowUnwritableChanges;
66+
67+
bool AllowRewriteFailures;
68+
69+
bool ItypesForExtern;
70+
};
71+
72+
// NOLINTNEXTLINE(readability-identifier-naming)
73+
extern struct _3COptions _3COpts;
74+
4375
#endif // LLVM_CLANG_3C_3CGLOBALOPTIONS_H

0 commit comments

Comments
 (0)