diff options
author | Leonard Chan <leonardchan@google.com> | 2019-05-02 20:38:14 +0000 |
---|---|---|
committer | Leonard Chan <leonardchan@google.com> | 2019-05-02 20:38:14 +0000 |
commit | fc40cbd9d8c63e65eed3590ba925321afe782e1d (patch) | |
tree | a98067aca61c26511d17adffdc19f7acaeece7ae /clang/lib/Serialization | |
parent | 206bc17ea0f522fa0a5939991796fc3ce814d01d (diff) | |
download | bcm5719-llvm-fc40cbd9d8c63e65eed3590ba925321afe782e1d.tar.gz bcm5719-llvm-fc40cbd9d8c63e65eed3590ba925321afe782e1d.zip |
[Attribute/Diagnostics] Print macro if definition is an attribute declaration
If an address_space attribute is defined in a macro, print the macro instead
when diagnosing a warning or error for incompatible pointers with different
address_spaces.
We allow this for all attributes (not just address_space), and for multiple
attributes declared in the same macro.
Differential Revision: https://reviews.llvm.org/D51329
llvm-svn: 359826
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 11 |
2 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index a6ff54568d2..64af0fa8a1d 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -6200,6 +6200,16 @@ QualType ASTReader::readTypeRecord(unsigned Index) { return Context.getParenType(InnerType); } + case TYPE_MACRO_QUALIFIED: { + if (Record.size() != 2) { + Error("incorrect encoding of macro defined type"); + return QualType(); + } + QualType UnderlyingTy = readType(*Loc.F, Record, Idx); + IdentifierInfo *MacroII = GetIdentifierInfo(*Loc.F, Record, Idx); + return Context.getMacroQualifiedType(UnderlyingTy, MacroII); + } + case TYPE_PACK_EXPANSION: { if (Record.size() != 2) { Error("incorrect encoding of pack expansion type"); @@ -6521,6 +6531,10 @@ void TypeLocReader::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) { // nothing to do } +void TypeLocReader::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) { + TL.setExpansionLoc(ReadSourceLocation()); +} + void TypeLocReader::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) { TL.setCaretLoc(ReadSourceLocation()); } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 756411a8c5b..accd8ccdfaf 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -516,6 +516,12 @@ void ASTTypeWriter::VisitParenType(const ParenType *T) { Code = TYPE_PAREN; } +void ASTTypeWriter::VisitMacroQualifiedType(const MacroQualifiedType *T) { + Record.AddTypeRef(T->getUnderlyingType()); + Record.AddIdentifierRef(T->getMacroIdentifier()); + Code = TYPE_MACRO_QUALIFIED; +} + void ASTTypeWriter::VisitElaboratedType(const ElaboratedType *T) { Record.push_back(T->getKeyword()); Record.AddNestedNameSpecifier(T->getQualifier()); @@ -802,6 +808,10 @@ void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) { Record.AddSourceLocation(TL.getRParenLoc()); } +void TypeLocWriter::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) { + Record.AddSourceLocation(TL.getExpansionLoc()); +} + void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { Record.AddSourceLocation(TL.getElaboratedKeywordLoc()); Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc()); @@ -1219,6 +1229,7 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION); RECORD(TYPE_DEPENDENT_SIZED_ARRAY); RECORD(TYPE_PAREN); + RECORD(TYPE_MACRO_QUALIFIED); RECORD(TYPE_PACK_EXPANSION); RECORD(TYPE_ATTRIBUTED); RECORD(TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK); |