From efdd867fb3a6a5524438f958bafa55b69bbd5f52 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 28 Apr 2014 02:38:51 +0000 Subject: [PATCH] [objcmt] Revert r191796, it's not needed anymore. rdar://16223810 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207391 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Edit/Commit.h | 5 ++--- include/clang/Edit/EditedSource.h | 9 +-------- lib/ARCMigrate/ObjCMT.cpp | 32 +------------------------------ lib/Edit/Commit.cpp | 12 +++++------- 4 files changed, 9 insertions(+), 49 deletions(-) diff --git a/include/clang/Edit/Commit.h b/include/clang/Edit/Commit.h index 626b1dd630..0ff7034ba0 100644 --- a/include/clang/Edit/Commit.h +++ b/include/clang/Edit/Commit.h @@ -49,8 +49,7 @@ private: const LangOptions &LangOpts; const PPConditionalDirectiveRecord *PPRec; EditedSource *Editor; - - const bool ForceCommitInSystemHeader; + bool IsCommitable; SmallVector CachedEdits; @@ -61,7 +60,7 @@ public: Commit(const SourceManager &SM, const LangOptions &LangOpts, const PPConditionalDirectiveRecord *PPRec = 0) : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec), Editor(0), - ForceCommitInSystemHeader(true), IsCommitable(true) { } + IsCommitable(true) { } bool isCommitable() const { return IsCommitable; } diff --git a/include/clang/Edit/EditedSource.h b/include/clang/Edit/EditedSource.h index f95b79785f..f9887cc9e8 100644 --- a/include/clang/Edit/EditedSource.h +++ b/include/clang/Edit/EditedSource.h @@ -28,7 +28,6 @@ class EditedSource { const SourceManager &SourceMgr; const LangOptions &LangOpts; const PPConditionalDirectiveRecord *PPRec; - const bool ForceCommitInSystemHeader; struct FileEdit { StringRef Text; @@ -46,10 +45,8 @@ class EditedSource { public: EditedSource(const SourceManager &SM, const LangOptions &LangOpts, - const PPConditionalDirectiveRecord *PPRec = 0, - const bool FCommitInSystemHeader = true) + const PPConditionalDirectiveRecord *PPRec = 0) : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec), - ForceCommitInSystemHeader(FCommitInSystemHeader), StrAlloc() { } const SourceManager &getSourceManager() const { return SourceMgr; } @@ -57,10 +54,6 @@ public: const PPConditionalDirectiveRecord *getPPCondDirectiveRecord() const { return PPRec; } - - bool getForceCommitInSystemHeader() const { - return ForceCommitInSystemHeader; - } bool canInsertInOffset(SourceLocation OrigLoc, FileOffset Offs); diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index 3ae6724edc..11837f79d6 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -124,7 +124,7 @@ protected: NSAPIObj.reset(new NSAPI(Context)); Editor.reset(new edit::EditedSource(Context.getSourceManager(), Context.getLangOpts(), - PPRec, false)); + PPRec)); } bool HandleTopLevelDecl(DeclGroupRef DG) override { @@ -1698,34 +1698,6 @@ private: } -static bool -IsReallyASystemHeader(ASTContext &Ctx, const FileEntry *file, FileID FID) { - bool Invalid = false; - const SrcMgr::SLocEntry &SEntry = - Ctx.getSourceManager().getSLocEntry(FID, &Invalid); - if (!Invalid && SEntry.isFile()) { - const SrcMgr::FileInfo &FI = SEntry.getFile(); - if (!FI.hasLineDirectives()) { - if (FI.getFileCharacteristic() == SrcMgr::C_ExternCSystem) - return true; - if (FI.getFileCharacteristic() == SrcMgr::C_System) { - // This file is in a system header directory. Continue committing - // change only if it's a user-specified system directory because user - // put a .system_framework file in the framework directory. - StringRef Directory(file->getDir()->getName()); - size_t Ix = Directory.rfind(".framework"); - if (Ix == StringRef::npos) - return true; - std::string PatchToSystemFramework = Directory.slice(0, Ix+sizeof(".framework")); - PatchToSystemFramework += ".system_framework"; - if (!llvm::sys::fs::exists(PatchToSystemFramework.data())) - return true; - } - } - } - return false; -} - void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl(); @@ -1847,8 +1819,6 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { RewriteBuffer &buf = I->second; const FileEntry *file = Ctx.getSourceManager().getFileEntryForID(FID); assert(file); - if (IsReallyASystemHeader(Ctx, file, FID)) - continue; SmallString<512> newText; llvm::raw_svector_ostream vecOS(newText); buf.write(vecOS); diff --git a/lib/Edit/Commit.cpp b/lib/Edit/Commit.cpp index 706c732dba..9c08cc28ac 100644 --- a/lib/Edit/Commit.cpp +++ b/lib/Edit/Commit.cpp @@ -38,9 +38,7 @@ CharSourceRange Commit::Edit::getInsertFromRange(SourceManager &SM) const { Commit::Commit(EditedSource &Editor) : SourceMgr(Editor.getSourceManager()), LangOpts(Editor.getLangOpts()), PPRec(Editor.getPPCondDirectiveRecord()), - Editor(&Editor), - ForceCommitInSystemHeader(Editor.getForceCommitInSystemHeader()), - IsCommitable(true) { } + Editor(&Editor), IsCommitable(true) { } bool Commit::insert(SourceLocation loc, StringRef text, bool afterToken, bool beforePreviousInsertions) { @@ -234,7 +232,7 @@ bool Commit::canInsert(SourceLocation loc, FileOffset &offs) { if (!isAtStartOfMacroExpansion(loc, &loc)) return false; - if (SM.isInSystemHeader(loc) && ForceCommitInSystemHeader) + if (SM.isInSystemHeader(loc)) return false; std::pair locInfo = SM.getDecomposedLoc(loc); @@ -265,7 +263,7 @@ bool Commit::canInsertAfterToken(SourceLocation loc, FileOffset &offs, if (!isAtEndOfMacroExpansion(loc, &loc)) return false; - if (SM.isInSystemHeader(loc) && ForceCommitInSystemHeader) + if (SM.isInSystemHeader(loc)) return false; loc = Lexer::getLocForEndOfToken(loc, 0, SourceMgr, LangOpts); @@ -303,8 +301,8 @@ bool Commit::canRemoveRange(CharSourceRange range, if (range.getBegin().isMacroID() || range.getEnd().isMacroID()) return false; - if ((SM.isInSystemHeader(range.getBegin()) || - SM.isInSystemHeader(range.getEnd())) && ForceCommitInSystemHeader) + if (SM.isInSystemHeader(range.getBegin()) || + SM.isInSystemHeader(range.getEnd())) return false; if (PPRec && PPRec->rangeIntersectsConditionalDirective(range.getAsRange())) -- 2.40.0