Skip to content

Backport the import-std-module patch and enable the fallback mode by default #2222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6e50fe6
[ASTImporter] Add basic support for comparing Stmts and compare funct…
Teemperor Sep 12, 2020
88fa1ba
[ASTImporter] Refactor IsStructurallyEquivalent's Decl overloads to b…
Teemperor Sep 21, 2020
33c5c98
[ASTImporter] Make the Import() return value consistent with the map …
Teemperor Nov 24, 2020
5d9787f
[ASTImporter] Import the default argument of NonTypeTemplateParmDecl
Teemperor Nov 26, 2020
5121854
[lldb] Don't infinite loop in SemaSourceWithPriorities::CompleteType …
Teemperor Sep 9, 2020
71fb2a9
[lldb] Enable std::pair in CxxModuleHandler
Teemperor Sep 9, 2020
73b530a
[lldb] Reference STL types in import-std-module tests
Teemperor Sep 28, 2020
8775386
[lldb][NFC] Fix flaky TestForwardDeclFromStdModule test
Teemperor Nov 13, 2020
6997f66
[lldb] Remove legacy casts from TestStackFromStdModule
Teemperor Sep 28, 2020
a0aa8f4
[ASTImporter] Import the default argument of TemplateTypeParmDecl
Teemperor Nov 26, 2020
c899b93
[lldb][import-std-module] Add a test for typedef'd std types
Teemperor Dec 8, 2020
1fc112f
[lldb] Fix that symbols.clang-modules-cache-path is never initialized
Teemperor Dec 10, 2020
a02e58b
[lldb] Remove assumption from Clang-based data formatters that their …
Teemperor Dec 10, 2020
1883ef7
Suppress printing template arguments that match default template
zygoloid Nov 11, 2020
17814aa
[lldb] Introduce a LLDB printing policy for Clang type names that sup…
Teemperor Nov 12, 2020
557437f
[lldb] Always include template arguments that have their default valu…
Teemperor Nov 30, 2020
7ea8fd4
[lldb] Ignore certain Clang type sugar when creating the type name
Teemperor Sep 22, 2020
7462f7b
[lldb] Add SubstTemplateTypeParm to RemoveWrappingTypes
Teemperor Aug 11, 2020
39cc2aa
[lldb] Remove nothreadallow from SWIG's __str__ wrappers to work arou…
Teemperor Sep 28, 2020
00f4df1
[lldb][NFC] Rename TypeSystemClangForExpressions to ScratchTypeSystem…
Teemperor Dec 4, 2020
f855014
[lldb] Desugar template specializations
Jul 15, 2020
664cdeb
[lldb][NFC] Document and encapsulate OriginMap in ASTContextMetadata
Teemperor Aug 4, 2020
2bfe352
[lldb] Fix a crash when the ASTImporter is giving us two Imported cal…
Teemperor Sep 9, 2020
59b8e78
[lldb] Allow LLDB to automatically retry a failed expression with an …
Teemperor Dec 10, 2020
b1dabed
[lldb][NFC] Rename TypeSystemClang::GetScratch to ScratchTypeSystemCl…
Teemperor Dec 4, 2020
5211a31
[lldb] Introduce separate scratch ASTs for debug info types and types…
Teemperor Dec 10, 2020
7f6e443
[lldb] Enable import-std-module's fallback mode by default
Teemperor Dec 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clang/include/clang/AST/ASTStructuralEquivalence.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ struct StructuralEquivalenceContext {
/// \c VisitedDecls members) and can cause faulty equivalent results.
bool IsEquivalent(QualType T1, QualType T2);

/// Determine whether the two statements are structurally equivalent.
/// Implementation functions (all static functions in
/// ASTStructuralEquivalence.cpp) must never call this function because that
/// will wreak havoc the internal state (\c DeclsToCheck and
/// \c VisitedDecls members) and can cause faulty equivalent results.
bool IsEquivalent(Stmt *S1, Stmt *S2);

/// Find the index of the given anonymous struct/union within its
/// context.
///
Expand Down
7 changes: 6 additions & 1 deletion clang/include/clang/AST/PrettyPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ struct PrintingPolicy {
SuppressInitializers(false), ConstantArraySizeAsWritten(false),
AnonymousTagLocations(true), SuppressStrongLifetime(false),
SuppressLifetimeQualifiers(false),
SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool),
SuppressTemplateArgsInCXXConstructors(false),
SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
UseVoidForZeroParams(!LO.CPlusPlus),
SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
Expand Down Expand Up @@ -173,6 +174,10 @@ struct PrintingPolicy {
/// constructors.
unsigned SuppressTemplateArgsInCXXConstructors : 1;

/// When true, attempt to suppress template arguments that match the default
/// argument for the parameter.
unsigned SuppressDefaultTemplateArgs : 1;

/// Whether we can use 'bool' rather than '_Bool' (even if the language
/// doesn't actually have 'bool', because, e.g., it is defined as a macro).
unsigned Bool : 1;
Expand Down
10 changes: 7 additions & 3 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ExtQuals;
class QualType;
class ConceptDecl;
class TagDecl;
class TemplateParameterList;
class Type;

enum {
Expand Down Expand Up @@ -5358,15 +5359,18 @@ class alignas(8) TemplateSpecializationType
/// enclosing the template arguments.
void printTemplateArgumentList(raw_ostream &OS,
ArrayRef<TemplateArgument> Args,
const PrintingPolicy &Policy);
const PrintingPolicy &Policy,
const TemplateParameterList *TPL = nullptr);

void printTemplateArgumentList(raw_ostream &OS,
ArrayRef<TemplateArgumentLoc> Args,
const PrintingPolicy &Policy);
const PrintingPolicy &Policy,
const TemplateParameterList *TPL = nullptr);

void printTemplateArgumentList(raw_ostream &OS,
const TemplateArgumentListInfo &Args,
const PrintingPolicy &Policy);
const PrintingPolicy &Policy,
const TemplateParameterList *TPL = nullptr);

/// The injected class name of a C++ class template or class
/// template partial specialization. Used to record that a type was
Expand Down
40 changes: 27 additions & 13 deletions clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5152,8 +5152,6 @@ ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
// context. This context will be fixed when the actual template declaration
// is created.

// FIXME: Import default argument and constraint expression.

ExpectedSLoc BeginLocOrErr = import(D->getBeginLoc());
if (!BeginLocOrErr)
return BeginLocOrErr.takeError();
Expand Down Expand Up @@ -5200,6 +5198,14 @@ ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
ToIDC);
}

if (D->hasDefaultArgument()) {
Expected<TypeSourceInfo *> ToDefaultArgOrErr =
import(D->getDefaultArgumentInfo());
if (!ToDefaultArgOrErr)
return ToDefaultArgOrErr.takeError();
ToD->setDefaultArgument(*ToDefaultArgOrErr);
}

return ToD;
}

Expand All @@ -5215,15 +5221,22 @@ ASTNodeImporter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
if (Err)
return std::move(Err);

// FIXME: Import default argument.

NonTypeTemplateParmDecl *ToD = nullptr;
(void)GetImportedOrCreateDecl(
ToD, D, Importer.getToContext(),
Importer.getToContext().getTranslationUnitDecl(),
ToInnerLocStart, ToLocation, D->getDepth(),
D->getPosition(), ToDeclName.getAsIdentifierInfo(), ToType,
D->isParameterPack(), ToTypeSourceInfo);
if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(),
Importer.getToContext().getTranslationUnitDecl(),
ToInnerLocStart, ToLocation, D->getDepth(),
D->getPosition(),
ToDeclName.getAsIdentifierInfo(), ToType,
D->isParameterPack(), ToTypeSourceInfo))
return ToD;

if (D->hasDefaultArgument()) {
ExpectedExpr ToDefaultArgOrErr = import(D->getDefaultArgument());
if (!ToDefaultArgOrErr)
return ToDefaultArgOrErr.takeError();
ToD->setDefaultArgument(*ToDefaultArgOrErr);
}

return ToD;
}

Expand Down Expand Up @@ -5417,8 +5430,9 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(

if (PrevDecl) {
if (IsStructuralMatch(D, PrevDecl)) {
if (D->isThisDeclarationADefinition() && PrevDecl->getDefinition()) {
Importer.MapImported(D, PrevDecl->getDefinition());
CXXRecordDecl *PrevDefinition = PrevDecl->getDefinition();
if (D->isThisDeclarationADefinition() && PrevDefinition) {
Importer.MapImported(D, PrevDefinition);
// Import those default field initializers which have been
// instantiated in the "From" context, but not in the "To" context.
for (auto *FromField : D->fields()) {
Expand All @@ -5440,7 +5454,7 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
//
// Generally, ASTCommon.h/DeclUpdateKind enum gives a very good hint
// what else could be fused during an AST merge.
return PrevDecl;
return PrevDefinition;
}
} else { // ODR violation.
// FIXME HandleNameConflict
Expand Down
Loading