Skip to content

Commit 95674f4

Browse files
committed
[core] Remove never used code from the callbacks.
This will allow us to simplify our ASTConsumer model instead of creating many multiplexers that are not needed. That should simplify adoption of latest versions of clad.
1 parent e83e0e9 commit 95674f4

File tree

5 files changed

+3
-120
lines changed

5 files changed

+3
-120
lines changed

core/metacling/src/TClingCallbacks.cxx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,19 +1059,6 @@ void TClingCallbacks::DefinitionShadowed(const clang::NamedDecl *D) {
10591059
TCling__InvalidateGlobal(D);
10601060
}
10611061

1062-
void TClingCallbacks::DeclDeserialized(const clang::Decl* D) {
1063-
if (const RecordDecl* RD = dyn_cast<RecordDecl>(D)) {
1064-
// FIXME: Our AutoLoading doesn't work (load the library) when the looked
1065-
// up decl is found in the PCH/PCM. We have to do that extra step, which
1066-
// loads the corresponding library when a decl was deserialized.
1067-
//
1068-
// Unfortunately we cannot do that with the current implementation,
1069-
// because the library load will pull in the header files of the library
1070-
// as well, even though they are in the PCH/PCM and available.
1071-
(void)RD;//TCling__AutoLoadCallback(RD->getNameAsString().c_str());
1072-
}
1073-
}
1074-
10751062
void TClingCallbacks::LibraryLoaded(const void* dyLibHandle,
10761063
llvm::StringRef canonicalName) {
10771064
TCling__LibraryLoadedRTTI(dyLibHandle, canonicalName);

core/metacling/src/TClingCallbacks.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ class TClingCallbacks : public cling::InterpreterCallbacks {
112112
/// data about the old (global) decl.
113113
void DefinitionShadowed(const clang::NamedDecl *D) override;
114114

115-
// Used to inform client about a new decl read by the ASTReader.
116-
//
117-
void DeclDeserialized(const clang::Decl *D) override;
118-
119115
void LibraryLoaded(const void *dyLibHandle, llvm::StringRef canonicalName) override;
120116
void LibraryUnloaded(const void *dyLibHandle, llvm::StringRef canonicalName) override;
121117

interpreter/cling/include/cling/Interpreter/InterpreterCallbacks.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <memory>
2020

2121
namespace clang {
22-
class ASTDeserializationListener;
2322
class Decl;
2423
class DeclContext;
2524
class DeclarationName;
@@ -37,7 +36,6 @@ namespace clang {
3736
namespace cling {
3837
class Interpreter;
3938
class InterpreterCallbacks;
40-
class InterpreterDeserializationListener;
4139
class InterpreterExternalSemaSource;
4240
class InterpreterPPCallbacks;
4341
class Transaction;
@@ -57,12 +55,6 @@ namespace cling {
5755
///
5856
InterpreterExternalSemaSource* m_ExternalSemaSource;
5957

60-
///\brief Our custom ASTDeserializationListener, translating interesting
61-
/// events into callbacks.
62-
///
63-
std::unique_ptr
64-
<InterpreterDeserializationListener> m_DeserializationListener;
65-
6658
///\brief Our custom PPCallbacks, translating interesting
6759
/// events into interpreter callbacks.
6860
///
@@ -83,25 +75,18 @@ namespace cling {
8375
///\param[in] interp - an interpreter.
8476
///\param[in] enableExternalSemaSourceCallbacks - creates a default
8577
/// InterpreterExternalSemaSource and attaches it to Sema.
86-
///\param[in] enableDeserializationListenerCallbacks - creates a default
87-
/// InterpreterDeserializationListener and attaches it to the
88-
/// ModuleManager if it is set.
8978
///\param[in] enablePPCallbacks - creates a default InterpreterPPCallbacks
9079
/// and attaches it to the Preprocessor.
9180
///
9281
InterpreterCallbacks(Interpreter* interp,
9382
bool enableExternalSemaSourceCallbacks = false,
94-
bool enableDeserializationListenerCallbacks = false,
9583
bool enablePPCallbacks = false);
9684

9785
virtual ~InterpreterCallbacks();
9886

9987
cling::Interpreter* getInterpreter() const { return m_Interpreter; }
10088
clang::ExternalSemaSource* getInterpreterExternalSemaSource() const;
10189

102-
clang::ASTDeserializationListener*
103-
getInterpreterDeserializationListener() const;
104-
10590
virtual void InclusionDirective(clang::SourceLocation /*HashLoc*/,
10691
const clang::Token& /*IncludeTok*/,
10792
llvm::StringRef /*FileName*/,
@@ -174,16 +159,6 @@ namespace cling {
174159
///\param[in] - The declaration that has been shadowed.
175160
virtual void DefinitionShadowed(const clang::NamedDecl*) {}
176161

177-
/// \brief Used to inform client about a new decl read by the ASTReader.
178-
///
179-
///\param[in] - The Decl read by the ASTReader.
180-
virtual void DeclDeserialized(const clang::Decl*) {}
181-
182-
/// \brief Used to inform client about a new type read by the ASTReader.
183-
///
184-
///\param[in] - The Type read by the ASTReader.
185-
virtual void TypeDeserialized(const clang::Type*) {}
186-
187162
virtual void LibraryLoaded(const void*, llvm::StringRef) {}
188163
virtual void LibraryUnloaded(const void*, llvm::StringRef) {}
189164

interpreter/cling/lib/Interpreter/InterpreterCallbacks.cpp

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313

1414
#include "clang/AST/ASTContext.h"
1515
#include "clang/Frontend/CompilerInstance.h"
16-
#include "clang/Frontend/MultiplexConsumer.h"
1716
#include "clang/Lex/Preprocessor.h"
1817
#include "clang/Sema/CodeCompleteConsumer.h"
1918
#include "clang/Sema/MultiplexExternalSemaSource.h"
2019
#include "clang/Sema/Sema.h"
21-
#include "clang/Serialization/ASTDeserializationListener.h"
2220
#include "clang/Serialization/ASTReader.h"
2321

2422
#include <optional>
@@ -27,8 +25,8 @@ using namespace clang;
2725

2826
namespace cling {
2927

30-
///\brief Translates 'interesting' for the interpreter
31-
/// ASTDeserializationListener events into interpreter callback.
28+
///\brief Translates 'interesting' for the interpreter into interpreter
29+
/// callback.
3230
///
3331
class InterpreterPPCallbacks : public PPCallbacks {
3432
private:
@@ -69,40 +67,6 @@ namespace cling {
6967
}
7068
};
7169

72-
///\brief Translates 'interesting' for the interpreter
73-
/// ASTDeserializationListener events into interpreter callback.
74-
///
75-
class InterpreterDeserializationListener : public ASTDeserializationListener {
76-
private:
77-
cling::InterpreterCallbacks* m_Callbacks;
78-
public:
79-
InterpreterDeserializationListener(InterpreterCallbacks* C)
80-
: m_Callbacks(C) {}
81-
82-
void DeclRead(serialization::DeclID, const Decl *D) override {
83-
if (m_Callbacks)
84-
m_Callbacks->DeclDeserialized(D);
85-
}
86-
87-
void TypeRead(serialization::TypeIdx, QualType T) override {
88-
if (m_Callbacks)
89-
m_Callbacks->TypeDeserialized(T.getTypePtr());
90-
}
91-
};
92-
93-
/// \brief Wraps an ASTDeserializationListener in an ASTConsumer so that
94-
/// it can be used with a MultiplexConsumer.
95-
class DeserializationListenerWrapper : public ASTConsumer {
96-
ASTDeserializationListener* m_Listener;
97-
98-
public:
99-
DeserializationListenerWrapper(ASTDeserializationListener* Listener)
100-
: m_Listener(Listener) {}
101-
ASTDeserializationListener* GetASTDeserializationListener() override {
102-
return m_Listener;
103-
}
104-
};
105-
10670
/// \brief wraps an ExternalASTSource in an ExternalSemaSource. No functional
10771
/// difference between the original source and this wrapper intended.
10872
class ExternalASTSourceWrapper : public ExternalSemaSource {
@@ -297,7 +261,6 @@ namespace cling {
297261

298262
InterpreterCallbacks::InterpreterCallbacks(Interpreter* interp,
299263
bool enableExternalSemaSourceCallbacks/* = false*/,
300-
bool enableDeserializationListenerCallbacks/* = false*/,
301264
bool enablePPCallbacks/* = false*/)
302265
: m_Interpreter(interp), m_ExternalSemaSource(nullptr), m_PPCallbacks(nullptr),
303266
m_IsRuntime(false) {
@@ -340,27 +303,6 @@ namespace cling {
340303
}
341304
}
342305

343-
if (enableDeserializationListenerCallbacks && Reader) {
344-
// Create a new deserialization listener.
345-
m_DeserializationListener.
346-
reset(new InterpreterDeserializationListener(this));
347-
348-
// Wrap the deserialization listener in an MultiplexConsumer and then
349-
// combine it with the existing Consumer.
350-
// FIXME: Maybe it's better to make MultiplexASTDeserializationListener
351-
// public instead. See also: https://reviews.llvm.org/D37475
352-
std::unique_ptr<DeserializationListenerWrapper> wrapper(
353-
new DeserializationListenerWrapper(m_DeserializationListener.get()));
354-
355-
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
356-
Consumers.push_back(std::move(wrapper));
357-
Consumers.push_back(m_Interpreter->getCI()->takeASTConsumer());
358-
359-
std::unique_ptr<clang::MultiplexConsumer> multiConsumer(
360-
new clang::MultiplexConsumer(std::move(Consumers)));
361-
m_Interpreter->getCI()->setASTConsumer(std::move(multiConsumer));
362-
}
363-
364306
if (enablePPCallbacks) {
365307
Preprocessor& PP = m_Interpreter->getCI()->getPreprocessor();
366308
m_PPCallbacks = new InterpreterPPCallbacks(this);
@@ -384,11 +326,6 @@ namespace cling {
384326
return m_ExternalSemaSource;
385327
}
386328

387-
ASTDeserializationListener*
388-
InterpreterCallbacks::getInterpreterDeserializationListener() const {
389-
return m_DeserializationListener.get();
390-
}
391-
392329
bool InterpreterCallbacks::FileNotFound(llvm::StringRef) {
393330
// Default implementation is no op.
394331
return false;

interpreter/cling/lib/Interpreter/MultiplexInterpreterCallbacks.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace cling {
2121

2222
public:
2323
MultiplexInterpreterCallbacks(Interpreter* interp)
24-
: InterpreterCallbacks(interp, true, true, true) {}
24+
: InterpreterCallbacks(interp, true, true) {}
2525

2626
void addCallback(std::unique_ptr<InterpreterCallbacks> newCb) {
2727
m_Callbacks.push_back(std::move(newCb));
@@ -122,18 +122,6 @@ namespace cling {
122122
}
123123
}
124124

125-
void DeclDeserialized(const clang::Decl* D) override {
126-
for (auto&& cb : m_Callbacks) {
127-
cb->DeclDeserialized(D);
128-
}
129-
}
130-
131-
void TypeDeserialized(const clang::Type* Ty) override {
132-
for (auto&& cb : m_Callbacks) {
133-
cb->TypeDeserialized(Ty);
134-
}
135-
}
136-
137125
void LibraryLoaded(const void* Lib, llvm::StringRef Name) override {
138126
for (auto&& cb : m_Callbacks) {
139127
cb->LibraryLoaded(Lib,Name);

0 commit comments

Comments
 (0)