Skip to content

Commit ab9c00c

Browse files
authored
Merge pull request #7148 from bnbarham/revert-repl-token
[stable/20230725] Revert "[clang] Add a new annotation token: annot_repl_input_end"
2 parents 728427b + 29c1ba8 commit ab9c00c

37 files changed

+75
-1948
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4340,7 +4340,6 @@ class TopLevelStmtDecl : public Decl {
43404340
friend class ASTDeclWriter;
43414341

43424342
Stmt *Statement = nullptr;
4343-
bool IsSemiMissing = false;
43444343

43454344
TopLevelStmtDecl(DeclContext *DC, SourceLocation L, Stmt *S)
43464345
: Decl(TopLevelStmt, DC, L), Statement(S) {}
@@ -4354,12 +4353,6 @@ class TopLevelStmtDecl : public Decl {
43544353
SourceRange getSourceRange() const override LLVM_READONLY;
43554354
Stmt *getStmt() { return Statement; }
43564355
const Stmt *getStmt() const { return Statement; }
4357-
void setStmt(Stmt *S) {
4358-
assert(IsSemiMissing && "Operation supported for printing values only!");
4359-
Statement = S;
4360-
}
4361-
bool isSemiMissing() const { return IsSemiMissing; }
4362-
void setSemiMissing(bool Missing = true) { IsSemiMissing = Missing; }
43634356

43644357
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
43654358
static bool classofKind(Kind K) { return K == TopLevelStmt; }

clang/include/clang/Basic/TokenKinds.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,6 @@ ANNOTATION(module_end)
965965
// into the name of a header unit.
966966
ANNOTATION(header_unit)
967967

968-
// Annotation for end of input in clang-repl.
969-
ANNOTATION(repl_input_end)
970-
971968
#undef PRAGMA_ANNOTATION
972969
#undef ANNOTATION
973970
#undef TESTING_KEYWORD

clang/include/clang/Interpreter/Interpreter.h

Lines changed: 11 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
1515
#define LLVM_CLANG_INTERPRETER_INTERPRETER_H
1616

17-
#include "clang/AST/Decl.h"
18-
#include "clang/AST/GlobalDecl.h"
1917
#include "clang/Interpreter/PartialTranslationUnit.h"
20-
#include "clang/Interpreter/Value.h"
2118

22-
#include "llvm/ADT/DenseMap.h"
19+
#include "clang/AST/GlobalDecl.h"
20+
2321
#include "llvm/ExecutionEngine/JITSymbol.h"
2422
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
2523
#include "llvm/Support/Error.h"
24+
2625
#include <memory>
2726
#include <vector>
2827

@@ -42,34 +41,8 @@ class IncrementalParser;
4241
/// Create a pre-configured \c CompilerInstance for incremental processing.
4342
class IncrementalCompilerBuilder {
4443
public:
45-
IncrementalCompilerBuilder() {}
46-
47-
void SetCompilerArgs(const std::vector<const char *> &Args) {
48-
UserArgs = Args;
49-
}
50-
51-
// General C++
52-
llvm::Expected<std::unique_ptr<CompilerInstance>> CreateCpp();
53-
54-
// Offload options
55-
void SetOffloadArch(llvm::StringRef Arch) { OffloadArch = Arch; };
56-
57-
// CUDA specific
58-
void SetCudaSDK(llvm::StringRef path) { CudaSDKPath = path; };
59-
60-
llvm::Expected<std::unique_ptr<CompilerInstance>> CreateCudaHost();
61-
llvm::Expected<std::unique_ptr<CompilerInstance>> CreateCudaDevice();
62-
63-
private:
6444
static llvm::Expected<std::unique_ptr<CompilerInstance>>
6545
create(std::vector<const char *> &ClangArgv);
66-
67-
llvm::Expected<std::unique_ptr<CompilerInstance>> createCuda(bool device);
68-
69-
std::vector<const char *> UserArgs;
70-
71-
llvm::StringRef OffloadArch;
72-
llvm::StringRef CudaSDKPath;
7346
};
7447

7548
/// Provides top-level interfaces for incremental compilation and execution.
@@ -78,35 +51,27 @@ class Interpreter {
7851
std::unique_ptr<IncrementalParser> IncrParser;
7952
std::unique_ptr<IncrementalExecutor> IncrExecutor;
8053

81-
// An optional parser for CUDA offloading
82-
std::unique_ptr<IncrementalParser> DeviceParser;
83-
8454
Interpreter(std::unique_ptr<CompilerInstance> CI, llvm::Error &Err);
8555

8656
llvm::Error CreateExecutor();
87-
unsigned InitPTUSize = 0;
88-
89-
// This member holds the last result of the value printing. It's a class
90-
// member because we might want to access it after more inputs. If no value
91-
// printing happens, it's in an invalid state.
92-
Value LastValue;
9357

9458
public:
9559
~Interpreter();
9660
static llvm::Expected<std::unique_ptr<Interpreter>>
9761
create(std::unique_ptr<CompilerInstance> CI);
98-
static llvm::Expected<std::unique_ptr<Interpreter>>
99-
createWithCUDA(std::unique_ptr<CompilerInstance> CI,
100-
std::unique_ptr<CompilerInstance> DCI);
101-
const ASTContext &getASTContext() const;
102-
ASTContext &getASTContext();
10362
const CompilerInstance *getCompilerInstance() const;
10463
llvm::Expected<llvm::orc::LLJIT &> getExecutionEngine();
10564

10665
llvm::Expected<PartialTranslationUnit &> Parse(llvm::StringRef Code);
10766
llvm::Error Execute(PartialTranslationUnit &T);
108-
llvm::Error ParseAndExecute(llvm::StringRef Code, Value *V = nullptr);
109-
llvm::Expected<llvm::orc::ExecutorAddr> CompileDtorCall(CXXRecordDecl *CXXRD);
67+
llvm::Error ParseAndExecute(llvm::StringRef Code) {
68+
auto PTU = Parse(Code);
69+
if (!PTU)
70+
return PTU.takeError();
71+
if (PTU->TheModule)
72+
return Execute(*PTU);
73+
return llvm::Error::success();
74+
}
11075

11176
/// Undo N previous incremental inputs.
11277
llvm::Error Undo(unsigned N = 1);
@@ -127,23 +92,6 @@ class Interpreter {
12792
/// file.
12893
llvm::Expected<llvm::orc::ExecutorAddr>
12994
getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const;
130-
131-
enum InterfaceKind { NoAlloc, WithAlloc, CopyArray };
132-
133-
const llvm::SmallVectorImpl<Expr *> &getValuePrintingInfo() const {
134-
return ValuePrintingInfo;
135-
}
136-
137-
Expr *SynthesizeExpr(Expr *E);
138-
139-
private:
140-
size_t getEffectivePTUSize() const;
141-
142-
bool FindRuntimeInterface();
143-
144-
llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
145-
146-
llvm::SmallVector<Expr *, 3> ValuePrintingInfo;
14795
};
14896
} // namespace clang
14997

clang/include/clang/Interpreter/Value.h

Lines changed: 0 additions & 208 deletions
This file was deleted.

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "clang/Basic/OpenMPKinds.h"
1919
#include "clang/Basic/OperatorPrecedence.h"
2020
#include "clang/Basic/Specifiers.h"
21-
#include "clang/Basic/TokenKinds.h"
2221
#include "clang/Lex/CodeCompletionHandler.h"
2322
#include "clang/Lex/Preprocessor.h"
2423
#include "clang/Sema/DeclSpec.h"
@@ -693,8 +692,7 @@ class Parser : public CodeCompletionHandler {
693692
bool isEofOrEom() {
694693
tok::TokenKind Kind = Tok.getKind();
695694
return Kind == tok::eof || Kind == tok::annot_module_begin ||
696-
Kind == tok::annot_module_end || Kind == tok::annot_module_include ||
697-
Kind == tok::annot_repl_input_end;
695+
Kind == tok::annot_module_end || Kind == tok::annot_module_include;
698696
}
699697

700698
/// Checks if the \p Level is valid for use in a fold expression.

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "llvm/IR/DerivedTypes.h"
2525
#include "llvm/IR/ReplaceConstant.h"
2626
#include "llvm/Support/Format.h"
27-
#include "llvm/Support/VirtualFileSystem.h"
2827

2928
using namespace clang;
3029
using namespace CodeGen;
@@ -727,9 +726,8 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
727726
// handle so CUDA runtime can figure out what to call on the GPU side.
728727
std::unique_ptr<llvm::MemoryBuffer> CudaGpuBinary = nullptr;
729728
if (!CudaGpuBinaryFileName.empty()) {
730-
auto VFS = CGM.getFileSystem();
731-
auto CudaGpuBinaryOrErr =
732-
VFS->getBufferForFile(CudaGpuBinaryFileName, -1, false);
729+
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> CudaGpuBinaryOrErr =
730+
llvm::MemoryBuffer::getFileOrSTDIN(CudaGpuBinaryFileName);
733731
if (std::error_code EC = CudaGpuBinaryOrErr.getError()) {
734732
CGM.getDiags().Report(diag::err_cannot_open_file)
735733
<< CudaGpuBinaryFileName << EC.message();

0 commit comments

Comments
 (0)