Changeset View
Changeset View
Standalone View
Standalone View
src/ClazyContext.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 55 | { | |||
---|---|---|---|---|---|
57 | return InPlace ? filename | 57 | return InPlace ? filename | ||
58 | : filename + m_suffix; | 58 | : filename + m_suffix; | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | std::string m_suffix; | 61 | std::string m_suffix; | ||
62 | }; | 62 | }; | ||
63 | 63 | | |||
64 | ClazyContext::ClazyContext(const clang::CompilerInstance &compiler, | 64 | ClazyContext::ClazyContext(const clang::CompilerInstance &compiler, | ||
65 | const string &headerFilter, const string &ignoreDirs, ClazyOptions opts) | 65 | const string &headerFilter, const string &ignoreDirs, const string &exportFixes, ClazyOptions opts) | ||
66 | : ci(compiler) | 66 | : ci(compiler) | ||
67 | , astContext(ci.getASTContext()) | 67 | , astContext(ci.getASTContext()) | ||
68 | , sm(ci.getSourceManager()) | 68 | , sm(ci.getSourceManager()) | ||
69 | , m_noWerror(getenv("CLAZY_NO_WERROR") != nullptr) // Allows user to make clazy ignore -Werror | 69 | , m_noWerror(getenv("CLAZY_NO_WERROR") != nullptr) // Allows user to make clazy ignore -Werror | ||
70 | , options(opts) | 70 | , options(opts) | ||
71 | , extraOptions(clazy::splitString(getenv("CLAZY_EXTRA_OPTIONS"), ',')) | 71 | , extraOptions(clazy::splitString(getenv("CLAZY_EXTRA_OPTIONS"), ',')) | ||
72 | , exportFixes(exportFixes) | ||||
72 | { | 73 | { | ||
73 | if (!headerFilter.empty()) | 74 | if (!headerFilter.empty()) | ||
74 | headerFilterRegex = std::unique_ptr<llvm::Regex>(new llvm::Regex(headerFilter)); | 75 | headerFilterRegex = std::unique_ptr<llvm::Regex>(new llvm::Regex(headerFilter)); | ||
75 | 76 | | |||
76 | if (!ignoreDirs.empty()) | 77 | if (!ignoreDirs.empty()) | ||
77 | ignoreDirsRegex = std::unique_ptr<llvm::Regex>(new llvm::Regex(ignoreDirs)); | 78 | ignoreDirsRegex = std::unique_ptr<llvm::Regex>(new llvm::Regex(ignoreDirs)); | ||
78 | 79 | | |||
79 | const char *fixitsEnv = getenv("CLAZY_FIXIT"); | 80 | const char *fixitsEnv = getenv("CLAZY_FIXIT"); | ||
80 | allFixitsEnabled = (options & ClazyOption_AllFixitsEnabled); | 81 | allFixitsEnabled = (options & ClazyOption_AllFixitsEnabled); | ||
81 | if (!allFixitsEnabled && fixitsEnv) { | 82 | if (!allFixitsEnabled && fixitsEnv) { | ||
82 | const string fixitsEnvStr = clazy::unquoteString(fixitsEnv); | 83 | const string fixitsEnvStr = clazy::unquoteString(fixitsEnv); | ||
83 | if (fixitsEnvStr == "all_fixits") { | 84 | if (fixitsEnvStr == "all_fixits") { | ||
84 | allFixitsEnabled = true; | 85 | allFixitsEnabled = true; | ||
85 | } else { | 86 | } else { | ||
86 | requestedFixitName = fixitsEnvStr; | 87 | requestedFixitName = fixitsEnvStr; | ||
87 | } | 88 | } | ||
88 | } | 89 | } | ||
89 | 90 | | |||
90 | if (fixitsEnabled() && !(options & ClazyOption_NoFixitsAutoWrite)) | 91 | if (fixitsEnabled()) { | ||
92 | if (exportFixesEnabled()) | ||||
93 | exporter = new FixItExporter(ci.getDiagnostics(), sm, ci.getLangOpts(), | ||||
94 | exportFixes); | ||||
95 | else if (!(options & ClazyOption_NoFixitsAutoWrite)) | ||||
91 | rewriter = new FixItRewriter(ci.getDiagnostics(), sm, | 96 | rewriter = new FixItRewriter(ci.getDiagnostics(), sm, | ||
92 | ci.getLangOpts(), new ClazyFixItOptions(fixitsAreInplace())); | 97 | ci.getLangOpts(), new ClazyFixItOptions(fixitsAreInplace())); | ||
93 | 98 | } | |||
94 | exporter = new FixItExporter(ci.getDiagnostics(), sm, ci.getLangOpts(), | | |||
95 | new ClazyFixItOptions(fixitsAreInplace())); | | |||
96 | } | 99 | } | ||
97 | 100 | | |||
98 | ClazyContext::~ClazyContext() | 101 | ClazyContext::~ClazyContext() | ||
99 | { | 102 | { | ||
100 | //delete preprocessorVisitor; // we don't own it | 103 | //delete preprocessorVisitor; // we don't own it | ||
101 | delete accessSpecifierManager; | 104 | delete accessSpecifierManager; | ||
102 | delete parentMap; | 105 | delete parentMap; | ||
103 | 106 | | |||
Show All 39 Lines |