[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-15 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa4558497ff6: [clang] Improve LLVM-style RTTI support in 
ExternalASTSource/ExternalSemaSource (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397

Files:
  clang/include/clang/AST/ExternalASTSource.h
  clang/include/clang/Sema/ExternalSemaSource.h
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp

Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1917,6 +1917,7 @@
 
 // Pin this vtable to this file.
 ExternalSemaSource::~ExternalSemaSource() {}
+char ExternalSemaSource::ID;
 
 void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
 void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) { }
Index: clang/lib/Sema/MultiplexExternalSemaSource.cpp
===
--- clang/lib/Sema/MultiplexExternalSemaSource.cpp
+++ clang/lib/Sema/MultiplexExternalSemaSource.cpp
@@ -15,6 +15,8 @@
 
 using namespace clang;
 
+char MultiplexExternalSemaSource::ID;
+
 ///Constructs a new multiplexing external sema source and appends the
 /// given element to it.
 ///
Index: clang/lib/AST/ExternalASTSource.cpp
===
--- clang/lib/AST/ExternalASTSource.cpp
+++ clang/lib/AST/ExternalASTSource.cpp
@@ -24,6 +24,8 @@
 
 using namespace clang;
 
+char ExternalASTSource::ID;
+
 ExternalASTSource::~ExternalASTSource() = default;
 
 llvm::Optional
Index: clang/include/clang/Sema/MultiplexExternalSemaSource.h
===
--- clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -36,6 +36,8 @@
 /// external AST sources that also provide information for semantic
 /// analysis.
 class MultiplexExternalSemaSource : public ExternalSemaSource {
+  /// LLVM-style RTTI.
+  static char ID;
 
 private:
   SmallVector Sources; // doesn't own them.
@@ -352,9 +354,13 @@
   bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc,
 QualType T) override;
 
-  // isa/cast/dyn_cast support
-  static bool classof(const MultiplexExternalSemaSource*) { return true; }
-  //static bool classof(const ExternalSemaSource*) { return true; }
+  /// LLVM-style RTTI.
+  /// \{
+  bool isA(const void *ClassID) const override {
+return ClassID ==  || ExternalSemaSource::isA(ClassID);
+  }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
+  /// \}
 };
 
 } // end namespace clang
Index: clang/include/clang/Sema/ExternalSemaSource.h
===
--- clang/include/clang/Sema/ExternalSemaSource.h
+++ clang/include/clang/Sema/ExternalSemaSource.h
@@ -50,10 +50,11 @@
 /// external AST sources that also provide information for semantic
 /// analysis.
 class ExternalSemaSource : public ExternalASTSource {
+  /// LLVM-style RTTI.
+  static char ID;
+
 public:
-  ExternalSemaSource() {
-ExternalASTSource::SemaSource = true;
-  }
+  ExternalSemaSource() = default;
 
   ~ExternalSemaSource() override;
 
@@ -222,10 +223,13 @@
 return false;
   }
 
-  // isa/cast/dyn_cast support
-  static bool classof(const ExternalASTSource *Source) {
-return Source->SemaSource;
+  /// LLVM-style RTTI.
+  /// \{
+  bool isA(const void *ClassID) const override {
+return ClassID ==  || ExternalASTSource::isA(ClassID);
   }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
+  /// \}
 };
 
 } // end namespace clang
Index: clang/include/clang/AST/ExternalASTSource.h
===
--- clang/include/clang/AST/ExternalASTSource.h
+++ clang/include/clang/AST/ExternalASTSource.h
@@ -66,9 +66,8 @@
   /// whenever we might have added new redeclarations for existing decls.
   uint32_t CurrentGeneration = 0;
 
-  /// Whether this AST source also provides information for
-  /// semantic analysis.
-  bool SemaSource = false;
+  /// LLVM-style RTTI.
+  static char ID;
 
 public:
   ExternalASTSource() = default;
@@ -325,6 +324,12 @@
 
   virtual void getMemoryBufferSizes(MemoryBufferSizes ) const;
 
+  /// LLVM-style RTTI.
+  /// \{
+  virtual bool isA(const void *ClassID) const { return ClassID ==  }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
+  /// \}
+
 protected:
   static DeclContextLookupResult
   SetExternalVisibleDeclsForName(const DeclContext *DC,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 233968.
teemperor added a comment.

- Addressed Adrian's comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397

Files:
  clang/include/clang/AST/ExternalASTSource.h
  clang/include/clang/Sema/ExternalSemaSource.h
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp

Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1917,6 +1917,7 @@
 
 // Pin this vtable to this file.
 ExternalSemaSource::~ExternalSemaSource() {}
+char ExternalSemaSource::ID;
 
 void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
 void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) { }
Index: clang/lib/Sema/MultiplexExternalSemaSource.cpp
===
--- clang/lib/Sema/MultiplexExternalSemaSource.cpp
+++ clang/lib/Sema/MultiplexExternalSemaSource.cpp
@@ -15,6 +15,8 @@
 
 using namespace clang;
 
+char MultiplexExternalSemaSource::ID;
+
 ///Constructs a new multiplexing external sema source and appends the
 /// given element to it.
 ///
Index: clang/lib/AST/ExternalASTSource.cpp
===
--- clang/lib/AST/ExternalASTSource.cpp
+++ clang/lib/AST/ExternalASTSource.cpp
@@ -24,6 +24,8 @@
 
 using namespace clang;
 
+char ExternalASTSource::ID;
+
 ExternalASTSource::~ExternalASTSource() = default;
 
 llvm::Optional
Index: clang/include/clang/Sema/MultiplexExternalSemaSource.h
===
--- clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -36,6 +36,8 @@
 /// external AST sources that also provide information for semantic
 /// analysis.
 class MultiplexExternalSemaSource : public ExternalSemaSource {
+  /// LLVM-style RTTI.
+  static char ID;
 
 private:
   SmallVector Sources; // doesn't own them.
@@ -352,9 +354,13 @@
   bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc,
 QualType T) override;
 
-  // isa/cast/dyn_cast support
-  static bool classof(const MultiplexExternalSemaSource*) { return true; }
-  //static bool classof(const ExternalSemaSource*) { return true; }
+  /// LLVM-style RTTI.
+  /// \{
+  bool isA(const void *ClassID) const override {
+return ClassID ==  || ExternalSemaSource::isA(ClassID);
+  }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
+  /// \}
 };
 
 } // end namespace clang
Index: clang/include/clang/Sema/ExternalSemaSource.h
===
--- clang/include/clang/Sema/ExternalSemaSource.h
+++ clang/include/clang/Sema/ExternalSemaSource.h
@@ -50,10 +50,11 @@
 /// external AST sources that also provide information for semantic
 /// analysis.
 class ExternalSemaSource : public ExternalASTSource {
+  /// LLVM-style RTTI.
+  static char ID;
+
 public:
-  ExternalSemaSource() {
-ExternalASTSource::SemaSource = true;
-  }
+  ExternalSemaSource() = default;
 
   ~ExternalSemaSource() override;
 
@@ -222,10 +223,13 @@
 return false;
   }
 
-  // isa/cast/dyn_cast support
-  static bool classof(const ExternalASTSource *Source) {
-return Source->SemaSource;
+  /// LLVM-style RTTI.
+  /// \{
+  bool isA(const void *ClassID) const override {
+return ClassID ==  || ExternalASTSource::isA(ClassID);
   }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
+  /// \}
 };
 
 } // end namespace clang
Index: clang/include/clang/AST/ExternalASTSource.h
===
--- clang/include/clang/AST/ExternalASTSource.h
+++ clang/include/clang/AST/ExternalASTSource.h
@@ -66,9 +66,8 @@
   /// whenever we might have added new redeclarations for existing decls.
   uint32_t CurrentGeneration = 0;
 
-  /// Whether this AST source also provides information for
-  /// semantic analysis.
-  bool SemaSource = false;
+  /// LLVM-style RTTI.
+  static char ID;
 
 public:
   ExternalASTSource() = default;
@@ -325,6 +324,12 @@
 
   virtual void getMemoryBufferSizes(MemoryBufferSizes ) const;
 
+  /// LLVM-style RTTI.
+  /// \{
+  virtual bool isA(const void *ClassID) const { return ClassID ==  }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
+  /// \}
+
 protected:
   static DeclContextLookupResult
   SetExternalVisibleDeclsForName(const DeclContext *DC,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-15 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

In D71397#1784325 , @teemperor wrote:

> I would prefer landing this as-is because it is just doing the same we do in 
> other places in LLVM. Afterwards migrating the whole RTTI system in LLVM to a 
> new system (whether that will be D39111  or 
> just a ClassID type) sounds good to me.


Yep -- To be clear I didn't raise D39111  as 
an objection to this approach, just as a matter of interest. As you noted it 
should be easy to switch later.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

If we decide as a community that D39111  is 
better, we can go back and adopt it at any point; I don't see that as a reason 
to reject modest refinements, especially given that there is no sign whatsoever 
of movement on D39111 .


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-13 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor marked an inline comment as done.
teemperor added a comment.

In D71397#1782537 , @lhames wrote:

> Side note: This https://reviews.llvm.org/D39111 seems related. The patch has 
> languished as I have been busy with other work, but if it would be useful for 
> you guys I'd be happy to try to land it.


Moving ExternalASTSource to that system would also work, but that would add yet 
another dependency to D71398  (which is 
removing really gnarly code). But otherwise this seems like something we could 
use here (and also in LLDB).

I would prefer landing this as-is because it is just doing the same we do in 
other places in LLVM. Afterwards migrating the whole RTTI system in LLVM to a 
new system (whether that will be D39111  or 
just a ClassID type) sounds good to me.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

If this is commonly used, it would make sense to introduce those types into 
some common header in LLVM.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-13 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/include/clang/AST/ExternalASTSource.h:69
 
-  /// Whether this AST source also provides information for
-  /// semantic analysis.
-  bool SemaSource = false;
+  // LLVM-style RTTI.
+  static char ID;

rjmccall wrote:
> aprantl wrote:
> > /// LLVM-style RTTI.
> It would be better if this had a dedicated type instead of using `char` and 
> then `void*` as the parameter, just to prevent simple bugs where somebody 
> passes in the wrong pointer.  Maybe you could have a non-copyable `ClassID` 
> type and a `ClassRef` type with the sole constructor `ClassRef(const ClassID 
> &)`?
> 
> The virtual method name is trying too hard to be succinct, and it doesn't 
> matter because it's rarely used; I would recommend borrowing the name 
> `isKindOf` from Objective-C.
This is a pattern that is used all over in LLDB. However, these are good 
suggestions, and we might want to make those improvements there as well.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/ExternalASTSource.h:69
 
-  /// Whether this AST source also provides information for
-  /// semantic analysis.
-  bool SemaSource = false;
+  // LLVM-style RTTI.
+  static char ID;

aprantl wrote:
> /// LLVM-style RTTI.
It would be better if this had a dedicated type instead of using `char` and 
then `void*` as the parameter, just to prevent simple bugs where somebody 
passes in the wrong pointer.  Maybe you could have a non-copyable `ClassID` 
type and a `ClassRef` type with the sole constructor `ClassRef(const ClassID 
&)`?

The virtual method name is trying too hard to be succinct, and it doesn't 
matter because it's rarely used; I would recommend borrowing the name 
`isKindOf` from Objective-C.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-12 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

Side note: This https://reviews.llvm.org/D39111 seems related. The patch has 
languished as I have been busy with other work, but if it would be useful for 
you guys I'd be happy to try to land it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-12 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/AST/ExternalASTSource.h:69
 
-  /// Whether this AST source also provides information for
-  /// semantic analysis.
-  bool SemaSource = false;
+  // LLVM-style RTTI.
+  static char ID;

/// LLVM-style RTTI.



Comment at: clang/include/clang/AST/ExternalASTSource.h:327
 
+  // LLVM-style RTTI.
+  virtual bool isA(const void *ClassID) const { return ClassID ==  }

```
/// LLVM-style RTTI.
/// \{
...
/// \}
```



Comment at: clang/include/clang/Sema/ExternalSemaSource.h:53
 class ExternalSemaSource : public ExternalASTSource {
+  // LLVM-style RTTI.
+  static char ID;

etc


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-12 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

See D71398  for the LLDB removal of our own 
RTTI workaround.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-12 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

I didn't add specific ID's to all of the subclasses in clang/clang-tools-extra 
because we never actually check for these specific classes anywhere from what I 
can see. But if anyone thinks that would be useful to have then I can update 
the patch.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71397/new/

https://reviews.llvm.org/D71397



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

2019-12-12 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
teemperor added reviewers: aprantl, dblaikie, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We currently have some very basic LLVM-style RTTI support in the 
ExternalASTSource class hierarchy
based on the `SemaSource` bool( to discriminate it form the 
ExternalSemaSource). As ExternalASTSource 
is supposed to be subclassed we should have extendable LLVM-style RTTI in this 
class hierarchy to make life easier
for projects building on top of Clang.

Most notably the current RTTI implementation forces LLDB to implement RTTI for 
its
own ExternalASTSource class (ClangExternalASTSourceCommon) by keeping a global 
set of
ExternalASTSources that are known to be ClangExternalASTSourceCommon. Projects
using Clang currently have to dosimilar workarounds to get RTTI support for 
their subclasses.

This patch turns this into full-fledged LLVM-style RTTI based on a static `ID` 
variable similar to
other LLVM class hierarchies. Also removes the friend declaration from 
ExternalASTSource to
its child class that was only used to grant access to the `SemaSource` member.


Repository:
  rC Clang

https://reviews.llvm.org/D71397

Files:
  clang/include/clang/AST/ExternalASTSource.h
  clang/include/clang/Sema/ExternalSemaSource.h
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp

Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1917,6 +1917,7 @@
 
 // Pin this vtable to this file.
 ExternalSemaSource::~ExternalSemaSource() {}
+char ExternalSemaSource::ID;
 
 void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
 void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) { }
Index: clang/lib/Sema/MultiplexExternalSemaSource.cpp
===
--- clang/lib/Sema/MultiplexExternalSemaSource.cpp
+++ clang/lib/Sema/MultiplexExternalSemaSource.cpp
@@ -15,6 +15,8 @@
 
 using namespace clang;
 
+char MultiplexExternalSemaSource::ID;
+
 ///Constructs a new multiplexing external sema source and appends the
 /// given element to it.
 ///
Index: clang/lib/AST/ExternalASTSource.cpp
===
--- clang/lib/AST/ExternalASTSource.cpp
+++ clang/lib/AST/ExternalASTSource.cpp
@@ -24,6 +24,8 @@
 
 using namespace clang;
 
+char ExternalASTSource::ID;
+
 ExternalASTSource::~ExternalASTSource() = default;
 
 llvm::Optional
Index: clang/include/clang/Sema/MultiplexExternalSemaSource.h
===
--- clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -36,6 +36,8 @@
 /// external AST sources that also provide information for semantic
 /// analysis.
 class MultiplexExternalSemaSource : public ExternalSemaSource {
+  // LLVM-style RTTI.
+  static char ID;
 
 private:
   SmallVector Sources; // doesn't own them.
@@ -352,9 +354,11 @@
   bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc,
 QualType T) override;
 
-  // isa/cast/dyn_cast support
-  static bool classof(const MultiplexExternalSemaSource*) { return true; }
-  //static bool classof(const ExternalSemaSource*) { return true; }
+  // LLVM-style RTTI.
+  bool isA(const void *ClassID) const override {
+return ClassID ==  || ExternalSemaSource::isA(ClassID);
+  }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
 };
 
 } // end namespace clang
Index: clang/include/clang/Sema/ExternalSemaSource.h
===
--- clang/include/clang/Sema/ExternalSemaSource.h
+++ clang/include/clang/Sema/ExternalSemaSource.h
@@ -50,10 +50,11 @@
 /// external AST sources that also provide information for semantic
 /// analysis.
 class ExternalSemaSource : public ExternalASTSource {
+  // LLVM-style RTTI.
+  static char ID;
+
 public:
-  ExternalSemaSource() {
-ExternalASTSource::SemaSource = true;
-  }
+  ExternalSemaSource() = default;
 
   ~ExternalSemaSource() override;
 
@@ -222,10 +223,11 @@
 return false;
   }
 
-  // isa/cast/dyn_cast support
-  static bool classof(const ExternalASTSource *Source) {
-return Source->SemaSource;
+  // LLVM-style RTTI.
+  bool isA(const void *ClassID) const override {
+return ClassID ==  || ExternalASTSource::isA(ClassID);
   }
+  static bool classof(const ExternalASTSource *S) { return S->isA(); }
 };
 
 } // end namespace clang
Index: clang/include/clang/AST/ExternalASTSource.h
===
--- clang/include/clang/AST/ExternalASTSource.h
+++ clang/include/clang/AST/ExternalASTSource.h
@@ -66,9 +66,8 @@
   /// whenever we might have added new