aboutsummaryrefslogtreecommitdiff
path: root/lib/ARCMigrate/ObjCMT.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-12-04 07:27:05 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-12-04 07:27:05 +0000
commit37ed12720a35b7bfa1c4de73ad6f1c6c1c88ee17 (patch)
treebba1cb7716cd13f295e22172dd4ca239d62fae54 /lib/ARCMigrate/ObjCMT.cpp
parentdf1059cac42d613547d86b4e44c5e364bfc03073 (diff)
Refactor recording the preprocessor conditional directive regions out of
PreprocessingRecord and into its own class, PPConditionalDirectiveRecord. Decoupling allows a client to use the functionality of PPConditionalDirectiveRecord without needing a PreprocessingRecord. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate/ObjCMT.cpp')
-rw-r--r--lib/ARCMigrate/ObjCMT.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp
index dfe14e2b5d..58499572a8 100644
--- a/lib/ARCMigrate/ObjCMT.cpp
+++ b/lib/ARCMigrate/ObjCMT.cpp
@@ -20,6 +20,7 @@
#include "clang/Edit/EditsReceiver.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PPConditionalDirectiveRecord.h"
#include "clang/Basic/FileManager.h"
#include "llvm/ADT/SmallString.h"
@@ -39,7 +40,7 @@ public:
llvm::OwningPtr<edit::EditedSource> Editor;
FileRemapper &Remapper;
FileManager &FileMgr;
- const PreprocessingRecord *PPRec;
+ const PPConditionalDirectiveRecord *PPRec;
bool IsOutputFile;
ObjCMigrateASTConsumer(StringRef migrateDir,
@@ -47,7 +48,7 @@ public:
bool migrateSubscripting,
FileRemapper &remapper,
FileManager &fileMgr,
- const PreprocessingRecord *PPRec,
+ const PPConditionalDirectiveRecord *PPRec,
bool isOutputFile = false)
: MigrateDir(migrateDir),
MigrateLiterals(migrateLiterals),
@@ -93,6 +94,9 @@ ObjCMigrateAction::ObjCMigrateAction(FrontendAction *WrappedAction,
ASTConsumer *ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
+ PPConditionalDirectiveRecord *
+ PPRec = new PPConditionalDirectiveRecord(CompInst->getSourceManager());
+ CompInst->getPreprocessor().addPPCallbacks(PPRec);
ASTConsumer *
WrappedConsumer = WrapperFrontendAction::CreateASTConsumer(CI, InFile);
ASTConsumer *MTConsumer = new ObjCMigrateASTConsumer(MigrateDir,
@@ -100,7 +104,7 @@ ASTConsumer *ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI,
MigrateSubscripting,
Remapper,
CompInst->getFileManager(),
- CompInst->getPreprocessor().getPreprocessingRecord());
+ PPRec);
ASTConsumer *Consumers[] = { MTConsumer, WrappedConsumer };
return new MultiplexConsumer(Consumers);
}
@@ -110,8 +114,6 @@ bool ObjCMigrateAction::BeginInvocation(CompilerInstance &CI) {
/*ignoreIfFilesChanges=*/true);
CompInst = &CI;
CI.getDiagnostics().setIgnoreAllWarnings(true);
- CI.getPreprocessorOpts().DetailedRecord = true;
- CI.getPreprocessorOpts().DetailedRecordConditionalDirectives = true;
return true;
}
@@ -211,18 +213,19 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
bool MigrateSourceAction::BeginInvocation(CompilerInstance &CI) {
CI.getDiagnostics().setIgnoreAllWarnings(true);
- CI.getPreprocessorOpts().DetailedRecord = true;
- CI.getPreprocessorOpts().DetailedRecordConditionalDirectives = true;
return true;
}
ASTConsumer *MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
+ PPConditionalDirectiveRecord *
+ PPRec = new PPConditionalDirectiveRecord(CI.getSourceManager());
+ CI.getPreprocessor().addPPCallbacks(PPRec);
return new ObjCMigrateASTConsumer(CI.getFrontendOpts().OutputFile,
/*MigrateLiterals=*/true,
/*MigrateSubscripting=*/true,
Remapper,
CI.getFileManager(),
- CI.getPreprocessor().getPreprocessingRecord(),
+ PPRec,
/*isOutputFile=*/true);
}