[cfe-commits] r119316 - in /cfe/trunk: include/clang/AST/ExternalASTSource.h lib/Sema/SemaType.cpp
John McCall
rjmccall at apple.com
Mon Nov 15 17:44:35 PST 2010
Author: rjmccall
Date: Mon Nov 15 19:44:35 2010
New Revision: 119316
URL: http://llvm.org/viewvc/llvm-project?rev=119316&view=rev
Log:
Add an ExternalASTSource hook to complete a type on demand.
Modified:
cfe/trunk/include/clang/AST/ExternalASTSource.h
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=119316&r1=119315&r2=119316&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Mon Nov 15 19:44:35 2010
@@ -34,6 +34,7 @@
class NamedDecl;
class Selector;
class Stmt;
+class TagDecl;
/// \brief Abstract interface for external sources of AST nodes.
///
@@ -142,6 +143,10 @@
return FindExternalLexicalDecls(DC, DeclTy::classofKind, Result);
}
+ /// \brief Gives the external AST source an opportunity to complete
+ /// an incomplete type.
+ virtual void CompleteType(TagDecl *Tag) {}
+
/// \brief Notify ExternalASTSource that we started deserialization of
/// a decl or type so until FinishedDeserializing is called there may be
/// decls that are initializing. Must be paired with FinishedDeserializing.
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=119316&r1=119315&r2=119316&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Nov 15 19:44:35 2010
@@ -2227,16 +2227,19 @@
if (diag == 0)
return true;
- const TagType *Tag = 0;
- if (const RecordType *Record = T->getAs<RecordType>())
- Tag = Record;
- else if (const EnumType *Enum = T->getAs<EnumType>())
- Tag = Enum;
+ const TagType *Tag = T->getAs<TagType>();
// Avoid diagnosing invalid decls as incomplete.
if (Tag && Tag->getDecl()->isInvalidDecl())
return true;
+ // Give the external AST source a chance to complete the type.
+ if (Tag && Tag->getDecl()->hasExternalLexicalStorage()) {
+ Context.getExternalSource()->CompleteType(Tag->getDecl());
+ if (!Tag->isIncompleteType())
+ return false;
+ }
+
// We have an incomplete type. Produce a diagnostic.
Diag(Loc, PD) << T;
More information about the cfe-commits
mailing list