Pulled in a new revision of LLVM/Clang and added

several patches.  These patches fix a problem
where templated types were not being completed the
first time they were used, and fix a variety of
minor issues I discovered while fixing that problem.

One of the previous local patches was resolved in
the most recent Clang, so I removed it.  The others
will be removed in due course.

llvm-svn: 144984
This commit is contained in:
Sean Callanan 2011-11-19 02:54:21 +00:00
parent 3b608422e8
commit 7f27d6044e
12 changed files with 155 additions and 76 deletions

View File

@ -77,7 +77,7 @@ public:
/// which need to be searched recursively. That job falls to
/// TransformTopLevelDecl.
//----------------------------------------------------------------------
void HandleTopLevelDecl(clang::DeclGroupRef D);
bool HandleTopLevelDecl(clang::DeclGroupRef D);
//----------------------------------------------------------------------
/// Passthrough stub

View File

@ -79,7 +79,7 @@ public:
/// which need to be searched recursively. That job falls to
/// TransformTopLevelDecl.
//----------------------------------------------------------------------
void HandleTopLevelDecl(clang::DeclGroupRef D);
bool HandleTopLevelDecl(clang::DeclGroupRef D);
//----------------------------------------------------------------------
/// Passthrough stub

View File

@ -21,8 +21,8 @@ our ($llvm_clang_basename, $llvm_clang_dirname) = fileparse ($llvm_clang_outfile
our $llvm_configuration = $ENV{LLVM_CONFIGURATION};
our $llvm_revision = "144573";
our $clang_revision = "144573";
our $llvm_revision = "144982";
our $clang_revision = "144982";
our $SRCROOT = "$ENV{SRCROOT}";
our $llvm_dstroot_zip = "$SRCROOT/llvm.zip";

View File

@ -0,0 +1,15 @@
Index: lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- lib/AST/RecordLayoutBuilder.cpp (revision 144982)
+++ lib/AST/RecordLayoutBuilder.cpp (working copy)
@@ -2044,6 +2044,10 @@
// as soon as we begin to parse the definition. That definition is
// not a complete definition (which is what isDefinition() tests)
// until we *finish* parsing the definition.
+
+ if (D->hasExternalLexicalStorage())
+ getExternalSource()->CompleteType(const_cast<RecordDecl*>(D));
+
D = D->getDefinition();
assert(D && "Cannot get layout of forward declarations!");
assert(D->isCompleteDefinition() && "Cannot layout type before complete!");

View File

@ -0,0 +1,15 @@
Index: lib/Sema/SemaTemplateInstantiate.cpp
===================================================================
--- lib/Sema/SemaTemplateInstantiate.cpp (revision 144982)
+++ lib/Sema/SemaTemplateInstantiate.cpp (working copy)
@@ -1683,6 +1683,10 @@
TemplateSpecializationKind TSK,
bool Complain) {
bool Invalid = false;
+
+ RequireCompleteType(Pattern->getLocation(),
+ QualType(Pattern->getTypeForDecl(), 0),
+ diag::err_incomplete_type);
CXXRecordDecl *PatternDef
= cast_or_null<CXXRecordDecl>(Pattern->getDefinition());

View File

@ -1,6 +1,41 @@
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp (revision 144982)
+++ lib/AST/ASTImporter.cpp (working copy)
@@ -2300,7 +2300,8 @@
if (RecordDecl *FoundRecord = dyn_cast<RecordDecl>(Found)) {
if (RecordDecl *FoundDef = FoundRecord->getDefinition()) {
- if (!D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) {
+ if (FoundDef->isBeingCompletedFromLexicalStorage() ||
+ !D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) {
// The record types structurally match, or the "from" translation
// unit only had a forward declaration anyway; call it the same
// function.
Index: lib/AST/Decl.cpp
===================================================================
--- lib/AST/Decl.cpp (revision 144982)
+++ lib/AST/Decl.cpp (working copy)
@@ -2405,8 +2405,14 @@
ExternalASTSource::Deserializing TheFields(Source);
SmallVector<Decl*, 64> Decls;
- LoadedFieldsFromExternalStorage = true;
- switch (Source->FindExternalLexicalDeclsBy<FieldDecl>(this, Decls)) {
+ LoadedFieldsFromExternalStorage = true;
+
+ setIsBeingCompletedFromLexicalStorage(true);
+ ExternalLoadResult LoadResult =
+ Source->FindExternalLexicalDeclsBy<FieldDecl>(this, Decls);
+ setIsBeingCompletedFromLexicalStorage(false);
+
+ switch (LoadResult) {
case ELR_Success:
break;
Index: include/clang/AST/DeclBase.h
===================================================================
--- include/clang/AST/DeclBase.h (revision 144573)
--- include/clang/AST/DeclBase.h (revision 144982)
+++ include/clang/AST/DeclBase.h (working copy)
@@ -807,6 +807,12 @@
/// storage that contains additional declarations that are visible
@ -41,38 +76,3 @@ Index: include/clang/AST/DeclBase.h
/// \brief Determine whether the given declaration is stored in the list of
/// declarations lexically within this context.
bool isDeclInLexicalTraversal(const Decl *D) const {
Index: lib/AST/Decl.cpp
===================================================================
--- lib/AST/Decl.cpp (revision 144573)
+++ lib/AST/Decl.cpp (working copy)
@@ -2405,8 +2405,14 @@
ExternalASTSource::Deserializing TheFields(Source);
SmallVector<Decl*, 64> Decls;
- LoadedFieldsFromExternalStorage = true;
- switch (Source->FindExternalLexicalDeclsBy<FieldDecl>(this, Decls)) {
+ LoadedFieldsFromExternalStorage = true;
+
+ setIsBeingCompletedFromLexicalStorage(true);
+ ExternalLoadResult LoadResult =
+ Source->FindExternalLexicalDeclsBy<FieldDecl>(this, Decls);
+ setIsBeingCompletedFromLexicalStorage(false);
+
+ switch (LoadResult) {
case ELR_Success:
break;
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp (revision 144573)
+++ lib/AST/ASTImporter.cpp (working copy)
@@ -2290,7 +2290,8 @@
if (RecordDecl *FoundRecord = dyn_cast<RecordDecl>(Found)) {
if (RecordDecl *FoundDef = FoundRecord->getDefinition()) {
- if (!D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) {
+ if (FoundDef->isBeingCompletedFromLexicalStorage() ||
+ !D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) {
// The record types structurally match, or the "from" translation
// unit only had a forward declaration anyway; call it the same
// function.

View File

@ -0,0 +1,75 @@
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp (revision 144982)
+++ lib/Sema/SemaType.cpp (working copy)
@@ -4065,6 +4065,34 @@
if (!T->isIncompleteType())
return false;
+ const TagType *Tag = T->getAs<TagType>();
+ const ObjCInterfaceType *IFace = 0;
+
+ if (Tag) {
+ // Avoid diagnosing invalid decls as incomplete.
+ if (Tag->getDecl()->isInvalidDecl())
+ return true;
+
+ // Give the external AST source a chance to complete the type.
+ if (Tag->getDecl()->hasExternalLexicalStorage()) {
+ Context.getExternalSource()->CompleteType(Tag->getDecl());
+ if (!Tag->isIncompleteType())
+ return false;
+ }
+ }
+ else if ((IFace = T->getAs<ObjCInterfaceType>())) {
+ // Avoid diagnosing invalid decls as incomplete.
+ if (IFace->getDecl()->isInvalidDecl())
+ return true;
+
+ // Give the external AST source a chance to complete the type.
+ if (IFace->getDecl()->hasExternalLexicalStorage()) {
+ Context.getExternalSource()->CompleteType(IFace->getDecl());
+ if (!IFace->isIncompleteType())
+ return false;
+ }
+ }
+
// If we have a class template specialization or a class member of a
// class template specialization, or an array with known size of such,
// try to instantiate it.
@@ -4096,35 +4124,7 @@
if (diag == 0)
return true;
-
- const TagType *Tag = T->getAs<TagType>();
- const ObjCInterfaceType *IFace = 0;
-
- if (Tag) {
- // Avoid diagnosing invalid decls as incomplete.
- if (Tag->getDecl()->isInvalidDecl())
- return true;
-
- // Give the external AST source a chance to complete the type.
- if (Tag->getDecl()->hasExternalLexicalStorage()) {
- Context.getExternalSource()->CompleteType(Tag->getDecl());
- if (!Tag->isIncompleteType())
- return false;
- }
- }
- else if ((IFace = T->getAs<ObjCInterfaceType>())) {
- // Avoid diagnosing invalid decls as incomplete.
- if (IFace->getDecl()->isInvalidDecl())
- return true;
- // Give the external AST source a chance to complete the type.
- if (IFace->getDecl()->hasExternalLexicalStorage()) {
- Context.getExternalSource()->CompleteType(IFace->getDecl());
- if (!IFace->isIncompleteType())
- return false;
- }
- }
-
// We have an incomplete type. Produce a diagnostic.
Diag(Loc, PD) << T;

View File

@ -1,28 +0,0 @@
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp (revision 144573)
+++ lib/AST/ASTImporter.cpp (working copy)
@@ -100,6 +100,7 @@
bool IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToRecord);
bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To);
Decl *VisitDecl(Decl *D);
+ Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D);
Decl *VisitNamespaceDecl(NamespaceDecl *D);
Decl *VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
Decl *VisitTypedefDecl(TypedefDecl *D);
@@ -2030,6 +2031,15 @@
return 0;
}
+Decl *ASTNodeImporter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
+ TranslationUnitDecl *ToD =
+ Importer.getToContext().getTranslationUnitDecl();
+
+ Importer.Imported(D, ToD);
+
+ return ToD;
+}
+
Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) {
// Import the major distinguishing characteristics of this namespace.
DeclContext *DC, *LexicalDC;

View File

@ -108,7 +108,7 @@ ASTResultSynthesizer::TransformTopLevelDecl(Decl* D)
}
}
void
bool
ASTResultSynthesizer::HandleTopLevelDecl(DeclGroupRef D)
{
DeclGroupRef::iterator decl_iterator;
@ -123,7 +123,8 @@ ASTResultSynthesizer::HandleTopLevelDecl(DeclGroupRef D)
}
if (m_passthrough)
m_passthrough->HandleTopLevelDecl(D);
return m_passthrough->HandleTopLevelDecl(D);
return true;
}
bool

View File

@ -116,7 +116,7 @@ ASTStructExtractor::ExtractFromTopLevelDecl(Decl* D)
}
}
void
bool
ASTStructExtractor::HandleTopLevelDecl(DeclGroupRef D)
{
DeclGroupRef::iterator decl_iterator;
@ -131,7 +131,8 @@ ASTStructExtractor::HandleTopLevelDecl(DeclGroupRef D)
}
if (m_passthrough)
m_passthrough->HandleTopLevelDecl(D);
return m_passthrough->HandleTopLevelDecl(D);
return true;
}
void

View File

@ -107,7 +107,7 @@ IRForTarget::FixFunctionLinkage(llvm::Function &llvm_function)
llvm_function.setLinkage(GlobalValue::ExternalLinkage);
std::string name = llvm_function.getNameStr();
std::string name = llvm_function.getName().str();
return true;
}
@ -141,7 +141,7 @@ IRForTarget::HasSideEffects (llvm::Function &llvm_function)
std::string ptr_name;
if (store_ptr->hasName())
ptr_name = store_ptr->getNameStr();
ptr_name = store_ptr->getName().str();
if (isa <AllocaInst> (store_ptr))
break;
@ -342,7 +342,7 @@ IRForTarget::ResolveFunctionPointers(llvm::Module &llvm_module,
bool is_decl = fun->isDeclaration();
if (log)
log->Printf("Examining %s function %s", (is_decl ? "declaration" : "non-declaration"), fun->getNameStr().c_str());
log->Printf("Examining %s function %s", (is_decl ? "declaration" : "non-declaration"), fun->getName().str().c_str());
if (!is_decl)
continue;

View File

@ -617,7 +617,7 @@ public:
{
// Special-case "this", "self", and "_cmd"
std::string name_str = value->getNameStr();
std::string name_str = value->getName().str();
if (name_str == "this" ||
name_str == "self" ||