diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index aa9ddffb7938..9c960bb0c305 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -81,7 +81,7 @@ enum InputKind { IK_LLVM_IR }; - + /// \brief An input file for the front end. class FrontendInputFile { /// \brief The file name, or "-" to read from standard input. @@ -109,13 +109,6 @@ public: bool isEmpty() const { return File.empty() && Buffer == nullptr; } bool isFile() const { return !isBuffer(); } bool isBuffer() const { return Buffer != nullptr; } - bool isPreprocessed() const { - return Kind == IK_PreprocessedC || - Kind == IK_PreprocessedCXX || - Kind == IK_PreprocessedObjC || - Kind == IK_PreprocessedObjCXX || - Kind == IK_PreprocessedCuda; - } StringRef getFile() const { assert(isFile()); diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 2eb91a7fb4fe..39fc1371a9ef 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -19,7 +19,6 @@ #include "clang/Frontend/MultiplexConsumer.h" #include "clang/Frontend/Utils.h" #include "clang/Lex/HeaderSearch.h" -#include "clang/Lex/LiteralSupport.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" #include "clang/Parse/ParseAST.h" @@ -188,42 +187,6 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, return llvm::make_unique(std::move(Consumers)); } -// For preprocessed files, if the first line is the linemarker and specifies -// the original source file name, use that name as the input file name. -static bool ReadOriginalFileName(CompilerInstance &CI, std::string &InputFile) -{ - bool Invalid = false; - auto &SourceMgr = CI.getSourceManager(); - auto MainFileID = SourceMgr.getMainFileID(); - const auto *MainFileBuf = SourceMgr.getBuffer(MainFileID, &Invalid); - if (Invalid) - return false; - - std::unique_ptr RawLexer( - new Lexer(MainFileID, MainFileBuf, SourceMgr, CI.getLangOpts())); - - // If the first line has the syntax of - // - // # NUM "FILENAME" - // - // we use FILENAME as the input file name. - Token T; - if (RawLexer->LexFromRawLexer(T) || T.getKind() != tok::hash) - return false; - if (RawLexer->LexFromRawLexer(T) || T.isAtStartOfLine() || - T.getKind() != tok::numeric_constant) - return false; - RawLexer->LexFromRawLexer(T); - if (T.isAtStartOfLine() || T.getKind() != tok::string_literal) - return false; - - StringLiteralParser Literal(T, CI.getPreprocessor()); - if (Literal.hadError) - return false; - InputFile = Literal.GetString().str(); - return true; -} - bool FrontendAction::BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input) { assert(!Instance && "Already processing a source file!"); @@ -372,13 +335,6 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!isModelParsingAction()) CI.createASTContext(); - // For preprocessed files, check if the first line specifies the original - // source file name with a linemarker. - std::string OrigFile; - if (Input.isPreprocessed()) - if (ReadOriginalFileName(CI, OrigFile)) - InputFile = OrigFile; - std::unique_ptr Consumer = CreateWrappedASTConsumer(CI, InputFile); if (!Consumer) @@ -465,9 +421,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, // If there is a layout overrides file, attach an external AST source that // provides the layouts from that file. - if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() && + if (!CI.getFrontendOpts().OverrideRecordLayoutsFile.empty() && CI.hasASTContext() && !CI.getASTContext().getExternalSource()) { - IntrusiveRefCntPtr + IntrusiveRefCntPtr Override(new LayoutOverrideSource( CI.getFrontendOpts().OverrideRecordLayoutsFile)); CI.getASTContext().setExternalSource(Override); diff --git a/clang/test/Frontend/preprocessed-input.c b/clang/test/Frontend/preprocessed-input.c deleted file mode 100644 index 65e52db4fca9..000000000000 --- a/clang/test/Frontend/preprocessed-input.c +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang -E -o %t.i %s -// RUN: %clang -c -o %t.o %t.i -// RUN: llvm-objdump -t %t.o | FileCheck %s -// CHECK: l{{ +}}df{{ +}}*ABS*{{ +}}{{0+}}{{.+}}preprocessed-input.c{{$}}