diff options
Diffstat (limited to 'clang/lib/Edit/Commit.cpp')
-rw-r--r-- | clang/lib/Edit/Commit.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Edit/Commit.cpp b/clang/lib/Edit/Commit.cpp index 9c08cc28ac9..706c732dba4 100644 --- a/clang/lib/Edit/Commit.cpp +++ b/clang/lib/Edit/Commit.cpp @@ -38,7 +38,9 @@ CharSourceRange Commit::Edit::getInsertFromRange(SourceManager &SM) const { Commit::Commit(EditedSource &Editor) : SourceMgr(Editor.getSourceManager()), LangOpts(Editor.getLangOpts()), PPRec(Editor.getPPCondDirectiveRecord()), - Editor(&Editor), IsCommitable(true) { } + Editor(&Editor), + ForceCommitInSystemHeader(Editor.getForceCommitInSystemHeader()), + IsCommitable(true) { } bool Commit::insert(SourceLocation loc, StringRef text, bool afterToken, bool beforePreviousInsertions) { @@ -232,7 +234,7 @@ bool Commit::canInsert(SourceLocation loc, FileOffset &offs) { if (!isAtStartOfMacroExpansion(loc, &loc)) return false; - if (SM.isInSystemHeader(loc)) + if (SM.isInSystemHeader(loc) && ForceCommitInSystemHeader) return false; std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(loc); @@ -263,7 +265,7 @@ bool Commit::canInsertAfterToken(SourceLocation loc, FileOffset &offs, if (!isAtEndOfMacroExpansion(loc, &loc)) return false; - if (SM.isInSystemHeader(loc)) + if (SM.isInSystemHeader(loc) && ForceCommitInSystemHeader) return false; loc = Lexer::getLocForEndOfToken(loc, 0, SourceMgr, LangOpts); @@ -301,8 +303,8 @@ bool Commit::canRemoveRange(CharSourceRange range, if (range.getBegin().isMacroID() || range.getEnd().isMacroID()) return false; - if (SM.isInSystemHeader(range.getBegin()) || - SM.isInSystemHeader(range.getEnd())) + if ((SM.isInSystemHeader(range.getBegin()) || + SM.isInSystemHeader(range.getEnd())) && ForceCommitInSystemHeader) return false; if (PPRec && PPRec->rangeIntersectsConditionalDirective(range.getAsRange())) |