summaryrefslogtreecommitdiff
path: root/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2017-01-25 07:27:05 +0000
committerDiana Picus <diana.picus@linaro.org>2017-01-25 07:27:05 +0000
commitb34a09453179341cf54d7bb70b4e5a8b37b2bb7b (patch)
treea326ac89350af2d6025c3e888aa408fed9f60f06 /lib/Frontend/FrontendAction.cpp
parentc0e6ebec8912daa0e63f4e229a79653b350e51cc (diff)
downloadclang-b34a09453179341cf54d7bb70b4e5a8b37b2bb7b.tar.gz
Revert "Use filename in linemarker when compiling preprocessed source"
This reverts commit r293004 because it broke the buildbots with "unknown CPU" errors. I tried to fix it in r293026, but that broke on Green Dragon with this kind of error: error: expected string not found in input // CHECK: l{{ +}}df{{ +}}*ABS*{{ +}}{{0+}}{{.+}}preprocessed-input.c{{$}} ^ <stdin>:2:1: note: scanning from here /Users/buildslave/jenkins/sharedspace/incremental@2/clang-build/tools/clang/test/Frontend/Output/preprocessed-input.c.tmp.o: file format Mach-O 64-bit x86-64 ^ <stdin>:2:67: note: possible intended match here /Users/buildslave/jenkins/sharedspace/incremental@2/clang-build/tools/clang/test/Frontend/Output/preprocessed-input.c.tmp.o: file format Mach-O 64-bit x86-64 I suppose this means that llvm-objdump doesn't support Mach-O, so the test should indeed check for linux (but not for x86). I'll leave it to someone that knows better. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
-rw-r--r--lib/Frontend/FrontendAction.cpp48
1 files changed, 2 insertions, 46 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 2eb91a7fb4..39fc1371a9 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/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<MultiplexConsumer>(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<Lexer> 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<ASTConsumer> 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<ExternalASTSource>
+ IntrusiveRefCntPtr<ExternalASTSource>
Override(new LayoutOverrideSource(
CI.getFrontendOpts().OverrideRecordLayoutsFile));
CI.getASTContext().setExternalSource(Override);