]> granicus.if.org Git - clang/commitdiff
Revert "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
authorLeonard Chan <leonardchan@google.com>
Fri, 3 May 2019 03:28:06 +0000 (03:28 +0000)
committerLeonard Chan <leonardchan@google.com>
Fri, 3 May 2019 03:28:06 +0000 (03:28 +0000)
This reverts commit fc40cbd9d8c63e65eed3590ba925321afe782e1d.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359859 91177308-0d34-0410-b5e6-96231b3b80d8

33 files changed:
include/clang/AST/ASTContext.h
include/clang/AST/RecursiveASTVisitor.h
include/clang/AST/Type.h
include/clang/AST/TypeLoc.h
include/clang/AST/TypeNodes.def
include/clang/Parse/Parser.h
include/clang/Sema/ParsedAttr.h
include/clang/Sema/Sema.h
include/clang/Serialization/ASTBitCodes.h
lib/ARCMigrate/TransGCAttrs.cpp
lib/AST/ASTContext.cpp
lib/AST/ASTDiagnostic.cpp
lib/AST/ASTStructuralEquivalence.cpp
lib/AST/ItaniumMangle.cpp
lib/AST/Type.cpp
lib/AST/TypePrinter.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/Parse/ParseDecl.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaType.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/Frontend/macro_defined_type.cpp [deleted file]
test/Sema/address_space_print_macro.c [deleted file]
test/Sema/address_spaces.c
test/SemaObjC/externally-retained.m
test/SemaObjC/gc-attributes.m
test/SemaObjC/mrc-weak.m
test/SemaObjCXX/gc-attributes.mm
tools/libclang/CIndex.cpp

index a09157cad0accec949de52064e6b1ffdab5970a5..1cddb6fd290d59702f41d54290ba887122885523 100644 (file)
@@ -1441,9 +1441,6 @@ public:
 
   QualType getParenType(QualType NamedType) const;
 
-  QualType getMacroQualifiedType(QualType UnderlyingTy,
-                                 const IdentifierInfo *MacroII) const;
-
   QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
                              NestedNameSpecifier *NNS, QualType NamedType,
                              TagDecl *OwnedTagDecl = nullptr) const;
index 6096c9c0f40dedc38393028e4f715203ce1e3c77..22ef332dbb815ebf0458f1671718a010a1628c92 100644 (file)
@@ -1065,9 +1065,6 @@ DEF_TRAVERSE_TYPE(AttributedType,
 
 DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
 
-DEF_TRAVERSE_TYPE(MacroQualifiedType,
-                  { TRY_TO(TraverseType(T->getUnderlyingType())); })
-
 DEF_TRAVERSE_TYPE(ElaboratedType, {
   if (T->getQualifier()) {
     TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
@@ -1311,9 +1308,6 @@ DEF_TRAVERSE_TYPELOC(InjectedClassNameType, {})
 
 DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
 
-DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
-                     { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
-
 DEF_TRAVERSE_TYPELOC(AttributedType,
                      { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
 
index 0633924f108a5833206dfd835285a5b87df1a3bc..12a0213fddf8fb166af270491f34f0c29891a9a8 100644 (file)
@@ -4184,41 +4184,6 @@ public:
   static bool classof(const Type *T) { return T->getTypeClass() == Typedef; }
 };
 
-/// Sugar type that represents a type that was qualified by a qualifier written
-/// as a macro invocation.
-class MacroQualifiedType : public Type {
-  friend class ASTContext; // ASTContext creates these.
-
-  QualType UnderlyingTy;
-  const IdentifierInfo *MacroII;
-
-  MacroQualifiedType(QualType UnderlyingTy, QualType CanonTy,
-                     const IdentifierInfo *MacroII)
-      : Type(MacroQualified, CanonTy, UnderlyingTy->isDependentType(),
-             UnderlyingTy->isInstantiationDependentType(),
-             UnderlyingTy->isVariablyModifiedType(),
-             UnderlyingTy->containsUnexpandedParameterPack()),
-        UnderlyingTy(UnderlyingTy), MacroII(MacroII) {
-    assert(isa<AttributedType>(UnderlyingTy) &&
-           "Expected a macro qualified type to only wrap attributed types.");
-  }
-
-public:
-  const IdentifierInfo *getMacroIdentifier() const { return MacroII; }
-  QualType getUnderlyingType() const { return UnderlyingTy; }
-
-  /// Return this attributed type's modified type with no qualifiers attached to
-  /// it.
-  QualType getModifiedType() const;
-
-  bool isSugared() const { return true; }
-  QualType desugar() const;
-
-  static bool classof(const Type *T) {
-    return T->getTypeClass() == MacroQualified;
-  }
-};
-
 /// Represents a `typeof` (or __typeof__) expression (a GCC extension).
 class TypeOfExprType : public Type {
   Expr *TOExpr;
@@ -6840,8 +6805,6 @@ template <typename T> const T *Type::getAsAdjusted() const {
       Ty = P->desugar().getTypePtr();
     else if (const auto *A = dyn_cast<AdjustedType>(Ty))
       Ty = A->desugar().getTypePtr();
-    else if (const auto *M = dyn_cast<MacroQualifiedType>(Ty))
-      Ty = M->desugar().getTypePtr();
     else
       break;
   }
index 40d17f991f1fbfe7cafd347dba59b61752fadb64..3b3eb1b6c676a78a13381a2c27b6419f87ea5227 100644 (file)
@@ -173,9 +173,6 @@ public:
 
   TypeLoc IgnoreParens() const;
 
-  /// Strips MacroDefinitionTypeLocs from a type location.
-  TypeLoc IgnoreMacroDefinitions() const;
-
   /// Find a type with the location of an explicit type qualifier.
   ///
   /// The result, if non-null, will be one of:
@@ -1083,39 +1080,6 @@ public:
   }
 };
 
-struct MacroQualifiedLocInfo {
-  SourceLocation ExpansionLoc;
-};
-
-class MacroQualifiedTypeLoc
-    : public ConcreteTypeLoc<UnqualTypeLoc, MacroQualifiedTypeLoc,
-                             MacroQualifiedType, MacroQualifiedLocInfo> {
-public:
-  void initializeLocal(ASTContext &Context, SourceLocation Loc) {
-    setExpansionLoc(Loc);
-  }
-
-  TypeLoc getInnerLoc() const { return getInnerTypeLoc(); }
-
-  const IdentifierInfo *getMacroIdentifier() const {
-    return getTypePtr()->getMacroIdentifier();
-  }
-
-  SourceLocation getExpansionLoc() const {
-    return this->getLocalData()->ExpansionLoc;
-  }
-
-  void setExpansionLoc(SourceLocation Loc) {
-    this->getLocalData()->ExpansionLoc = Loc;
-  }
-
-  QualType getInnerType() const { return getTypePtr()->getUnderlyingType(); }
-
-  SourceRange getLocalSourceRange() const {
-    return getInnerLoc().getLocalSourceRange();
-  }
-};
-
 struct ParenLocInfo {
   SourceLocation LParenLoc;
   SourceLocation RParenLoc;
@@ -2325,8 +2289,6 @@ inline T TypeLoc::getAsAdjusted() const {
       Cur = ETL.getNamedTypeLoc();
     else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
       Cur = ATL.getOriginalLoc();
-    else if (auto MQL = Cur.getAs<MacroQualifiedTypeLoc>())
-      Cur = MQL.getInnerLoc();
     else
       break;
   }
index 58a5f880cbe61c41bb985adcdb2921c61775ac64..d1e4300fea6d5c24f44bc1606c9dbab5116830d3 100644 (file)
@@ -82,7 +82,6 @@ TYPE(FunctionNoProto, FunctionType)
 DEPENDENT_TYPE(UnresolvedUsing, Type)
 NON_CANONICAL_TYPE(Paren, Type)
 NON_CANONICAL_TYPE(Typedef, Type)
-NON_CANONICAL_TYPE(MacroQualified, Type)
 NON_CANONICAL_TYPE(Adjusted, Type)
 NON_CANONICAL_TYPE(Decayed, AdjustedType)
 NON_CANONICAL_UNLESS_DEPENDENT_TYPE(TypeOfExpr, Type)
index cb0080f14b0d6bee31f6e02c3b9550621cde175e..e831e226d4f34a30eae5bc97bae3c74888de11a3 100644 (file)
@@ -1152,7 +1152,6 @@ private:
     Parser *Self;
     CachedTokens Toks;
     IdentifierInfo &AttrName;
-    IdentifierInfo *MacroII = nullptr;
     SourceLocation AttrNameLoc;
     SmallVector<Decl*, 2> Decls;
 
index a42e4547a9679dcac3b6a83a9ba2a9a0980aeec2..2e0efe452a80647bb7af5a297d29c0fc67ceb92f 100644 (file)
@@ -167,8 +167,6 @@ public:
 private:
   IdentifierInfo *AttrName;
   IdentifierInfo *ScopeName;
-  IdentifierInfo *MacroII = nullptr;
-  SourceLocation MacroExpansionLoc;
   SourceRange AttrRange;
   SourceLocation ScopeLoc;
   SourceLocation EllipsisLoc;
@@ -549,27 +547,6 @@ public:
     return getPropertyDataBuffer().SetterId;
   }
 
-  /// Set the macro identifier info object that this parsed attribute was
-  /// declared in if it was declared in a macro. Also set the expansion location
-  /// of the macro.
-  void setMacroIdentifier(IdentifierInfo *MacroName, SourceLocation Loc) {
-    MacroII = MacroName;
-    MacroExpansionLoc = Loc;
-  }
-
-  /// Returns true if this attribute was declared in a macro.
-  bool hasMacroIdentifier() const { return MacroII != nullptr; }
-
-  /// Return the macro identifier if this attribute was declared in a macro.
-  /// nullptr is returned if it was not declared in a macro.
-  IdentifierInfo *getMacroIdentifier() const { return MacroII; }
-
-  SourceLocation getMacroExpansionLoc() const {
-    assert(hasMacroIdentifier() && "Can only get the macro expansion location "
-                                   "if this attribute has a macro identifier.");
-    return MacroExpansionLoc;
-  }
-
   /// Get an index into the attribute spelling list
   /// defined in Attr.td. This index is used by an attribute
   /// to pretty print itself.
index 0796e998584967502c00e32d7219599d9ae5b3ef..64b92d2e7a0de548516803c3a276ad29a7d3af31 100644 (file)
@@ -3516,7 +3516,7 @@ public:
   // Check if there is an explicit attribute, but only look through parens.
   // The intent is to look for an attribute on the current declarator, but not
   // one that came from a typedef.
-  bool hasExplicitCallingConv(QualType T);
+  bool hasExplicitCallingConv(QualType &T);
 
   /// Get the outermost AttributedType node that sets a calling convention.
   /// Valid types should not have multiple attributes with different CCs.
index 790cdf106f67ff8aa661a86d0f92490cf3541255..0365e3a696f6aee83fa404e5866402afc84d6e72 100644 (file)
@@ -1173,10 +1173,7 @@ namespace serialization {
       TYPE_DEPENDENT_ADDRESS_SPACE = 47,
 
       /// A dependentSizedVectorType record.
-      TYPE_DEPENDENT_SIZED_VECTOR = 48,
-
-      /// A type defined in a macro.
-      TYPE_MACRO_QUALIFIED = 49
+      TYPE_DEPENDENT_SIZED_VECTOR = 48
     };
 
     /// The type IDs for special types constructed by semantic
index fdbe1d119af816c2b7548cbca8a9bcc5dec62980..a73b526ca8e90211d06824816675b1f9c83974b5 100644 (file)
@@ -68,9 +68,6 @@ public:
         if (handleAttr(Attr, D))
           break;
         TL = Attr.getModifiedLoc();
-      } else if (MacroQualifiedTypeLoc MDTL =
-                     TL.getAs<MacroQualifiedTypeLoc>()) {
-        TL = MDTL.getInnerLoc();
       } else if (ArrayTypeLoc Arr = TL.getAs<ArrayTypeLoc>()) {
         TL = Arr.getElementLoc();
       } else if (PointerTypeLoc PT = TL.getAs<PointerTypeLoc>()) {
index 63488853759cd39b08fc28c26bab5bdfbeec5ab3..d0a790cad4db70577b0f5fe26f26e4b321b15cc1 100644 (file)
@@ -2047,10 +2047,6 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
   case Type::Paren:
     return getTypeInfo(cast<ParenType>(T)->getInnerType().getTypePtr());
 
-  case Type::MacroQualified:
-    return getTypeInfo(
-        cast<MacroQualifiedType>(T)->getUnderlyingType().getTypePtr());
-
   case Type::ObjCTypeParam:
     return getTypeInfo(cast<ObjCTypeParamType>(T)->desugar().getTypePtr());
 
@@ -3933,7 +3929,7 @@ QualType ASTContext::getAttributedType(attr::Kind attrKind,
 
   QualType canon = getCanonicalType(equivalentType);
   type = new (*this, TypeAlignment)
-      AttributedType(canon, attrKind, modifiedType, equivalentType);
+           AttributedType(canon, attrKind, modifiedType, equivalentType);
 
   Types.push_back(type);
   AttributedTypes.InsertNode(type, insertPos);
@@ -4214,19 +4210,6 @@ ASTContext::getParenType(QualType InnerType) const {
   return QualType(T, 0);
 }
 
-QualType
-ASTContext::getMacroQualifiedType(QualType UnderlyingTy,
-                                  const IdentifierInfo *MacroII) const {
-  QualType Canon = UnderlyingTy;
-  if (!Canon.isCanonical())
-    Canon = getCanonicalType(UnderlyingTy);
-
-  auto *newType = new (*this, TypeAlignment)
-      MacroQualifiedType(UnderlyingTy, Canon, MacroII);
-  Types.push_back(newType);
-  return QualType(newType, 0);
-}
-
 QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
                                           NestedNameSpecifier *NNS,
                                           const IdentifierInfo *Name,
index 15df865852941931f6fcaca3f9f2f0b168954e24..61900aa4ac907fba095879093ed53c5d4cc0f545 100644 (file)
@@ -41,11 +41,6 @@ static QualType Desugar(ASTContext &Context, QualType QT, bool &ShouldAKA) {
       QT = PT->desugar();
       continue;
     }
-    // ... or a macro defined type ...
-    if (const MacroQualifiedType *MDT = dyn_cast<MacroQualifiedType>(Ty)) {
-      QT = MDT->desugar();
-      continue;
-    }
     // ...or a substituted template type parameter ...
     if (const SubstTemplateTypeParmType *ST =
           dyn_cast<SubstTemplateTypeParmType>(Ty)) {
index 567945c16cdb97f54d4e750ebf51dfc17dcf5497..71bbd824812f470f803b5ac1f6e5e92e2a163283 100644 (file)
@@ -595,13 +595,6 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
       return false;
     break;
 
-  case Type::MacroQualified:
-    if (!IsStructurallyEquivalent(
-            Context, cast<MacroQualifiedType>(T1)->getUnderlyingType(),
-            cast<MacroQualifiedType>(T2)->getUnderlyingType()))
-      return false;
-    break;
-
   case Type::Typedef:
     if (!IsStructurallyEquivalent(Context, cast<TypedefType>(T1)->getDecl(),
                                   cast<TypedefType>(T2)->getDecl()))
index 930537a93434f2ed550f1d42b8b270b2e91c5049..3357756466fb2e2efc5536ad261895046ca9edf7 100644 (file)
@@ -1941,7 +1941,6 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty,
   case Type::ObjCTypeParam:
   case Type::Atomic:
   case Type::Pipe:
-  case Type::MacroQualified:
     llvm_unreachable("type is illegal as a nested name specifier");
 
   case Type::SubstTemplateTypeParmPack:
index 590e534fbdf44997e4b88d6f428aaadb7fe1c773..adffe92f95f90e23eef38c9b8ce86203545636b4 100644 (file)
@@ -973,7 +973,6 @@ public:
 
   SUGARED_TYPE_CLASS(Typedef)
   SUGARED_TYPE_CLASS(ObjCTypeParam)
-  SUGARED_TYPE_CLASS(MacroQualified)
 
   QualType VisitAdjustedType(const AdjustedType *T) {
     QualType originalType = recurse(T->getOriginalType());
@@ -1736,10 +1735,6 @@ namespace {
       return Visit(T->getModifiedType());
     }
 
-    Type *VisitMacroQualifiedType(const MacroQualifiedType *T) {
-      return Visit(T->getUnderlyingType());
-    }
-
     Type *VisitAdjustedType(const AdjustedType *T) {
       return Visit(T->getOriginalType());
     }
@@ -3165,20 +3160,6 @@ QualType TypedefType::desugar() const {
   return getDecl()->getUnderlyingType();
 }
 
-QualType MacroQualifiedType::desugar() const { return getUnderlyingType(); }
-
-QualType MacroQualifiedType::getModifiedType() const {
-  // Step over MacroQualifiedTypes from the same macro to find the type
-  // ultimately qualified by the macro qualifier.
-  QualType Inner = cast<AttributedType>(getUnderlyingType())->getModifiedType();
-  while (auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
-    if (InnerMQT->getMacroIdentifier() != getMacroIdentifier())
-      break;
-    Inner = InnerMQT->getModifiedType();
-  }
-  return Inner;
-}
-
 TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
     : Type(TypeOfExpr, can, E->isTypeDependent(),
            E->isInstantiationDependent(),
index fed39cadcb9aadd6ec8484102c4ee34f3d773ad7..82a2fa09c764f204ffe26d5a059c4029404d0110 100644 (file)
@@ -259,7 +259,6 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
     case Type::Paren:
     case Type::PackExpansion:
     case Type::SubstTemplateTypeParm:
-    case Type::MacroQualified:
       CanPrefixQualifiers = false;
       break;
 
@@ -964,21 +963,6 @@ void TypePrinter::printTypedefBefore(const TypedefType *T, raw_ostream &OS) {
   printTypeSpec(T->getDecl(), OS);
 }
 
-void TypePrinter::printMacroQualifiedBefore(const MacroQualifiedType *T,
-                                            raw_ostream &OS) {
-  StringRef MacroName = T->getMacroIdentifier()->getName();
-  OS << MacroName << " ";
-
-  // Since this type is meant to print the macro instead of the whole attribute,
-  // we trim any attributes and go directly to the original modified type.
-  printBefore(T->getModifiedType(), OS);
-}
-
-void TypePrinter::printMacroQualifiedAfter(const MacroQualifiedType *T,
-                                           raw_ostream &OS) {
-  printAfter(T->getModifiedType(), OS);
-}
-
 void TypePrinter::printTypedefAfter(const TypedefType *T, raw_ostream &OS) {}
 
 void TypePrinter::printTypeOfExprBefore(const TypeOfExprType *T,
index 4c43c00cd5ef29b526092b1ed6066b4d70be15c7..3656602c3d813548c6dbd317dd0fe2d4ebcaadb6 100644 (file)
@@ -2844,9 +2844,6 @@ static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) {
     case Type::Paren:
       T = cast<ParenType>(T)->getInnerType();
       break;
-    case Type::MacroQualified:
-      T = cast<MacroQualifiedType>(T)->getUnderlyingType();
-      break;
     case Type::SubstTemplateTypeParm:
       T = cast<SubstTemplateTypeParmType>(T)->getReplacementType();
       break;
@@ -3026,7 +3023,6 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit) {
   case Type::DeducedTemplateSpecialization:
   case Type::Elaborated:
   case Type::Paren:
-  case Type::MacroQualified:
   case Type::SubstTemplateTypeParm:
   case Type::TypeOfExpr:
   case Type::TypeOf:
index d7bb4a54c1b902afb7af36a129d014441bd8c8c2..7a8d79ba3b5b9d6c32f377a2522ebe70d3c3781a 100644 (file)
@@ -2149,7 +2149,6 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
     case Type::Attributed:
     case Type::SubstTemplateTypeParm:
     case Type::PackExpansion:
-    case Type::MacroQualified:
       // Keep walking after single level desugaring.
       type = type.getSingleStepDesugaredType(getContext());
       break;
index 4e5ca2ee8f34b3f78dfaf3a6da5d8a103796ac10..130cd9f20652b18ebe83e2a13bd768bfcb5ca0a2 100644 (file)
@@ -85,23 +85,6 @@ static bool isAttributeLateParsed(const IdentifierInfo &II) {
 #undef CLANG_ATTR_LATE_PARSED_LIST
 }
 
-/// Check if the a start and end source location expand to the same macro.
-bool FindLocsWithCommonFileID(Preprocessor &PP, SourceLocation StartLoc,
-                              SourceLocation EndLoc) {
-  if (!StartLoc.isMacroID() || !EndLoc.isMacroID())
-    return false;
-
-  SourceManager &SM = PP.getSourceManager();
-  if (SM.getFileID(StartLoc) != SM.getFileID(EndLoc))
-    return false;
-
-  bool AttrStartIsInMacro =
-      Lexer::isAtStartOfMacroExpansion(StartLoc, SM, PP.getLangOpts());
-  bool AttrEndIsInMacro =
-      Lexer::isAtEndOfMacroExpansion(EndLoc, SM, PP.getLangOpts());
-  return AttrStartIsInMacro && AttrEndIsInMacro;
-}
-
 /// ParseGNUAttributes - Parse a non-empty attributes list.
 ///
 /// [GNU] attributes:
@@ -150,10 +133,7 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs,
   assert(Tok.is(tok::kw___attribute) && "Not a GNU attribute list!");
 
   while (Tok.is(tok::kw___attribute)) {
-    SourceLocation AttrTokLoc = ConsumeToken();
-    unsigned OldNumAttrs = attrs.size();
-    unsigned OldNumLateAttrs = LateAttrs ? LateAttrs->size() : 0;
-
+    ConsumeToken();
     if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
                          "attribute")) {
       SkipUntil(tok::r_paren, StopAtSemi); // skip until ) or ;
@@ -221,24 +201,6 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs,
       SkipUntil(tok::r_paren, StopAtSemi);
     if (endLoc)
       *endLoc = Loc;
-
-    // If this was declared in a macro, attach the macro IdentifierInfo to the
-    // parsed attribute.
-    if (FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
-      auto &SM = PP.getSourceManager();
-      CharSourceRange ExpansionRange = SM.getExpansionRange(AttrTokLoc);
-      StringRef FoundName =
-          Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts());
-      IdentifierInfo *MacroII = PP.getIdentifierInfo(FoundName);
-
-      for (unsigned i = OldNumAttrs; i < attrs.size(); ++i)
-        attrs[i].setMacroIdentifier(MacroII, ExpansionRange.getBegin());
-
-      if (LateAttrs) {
-        for (unsigned i = OldNumLateAttrs; i < LateAttrs->size(); ++i)
-          (*LateAttrs)[i]->MacroII = MacroII;
-      }
-    }
   }
 }
 
index 35073614122d5ab25f6f20dd007c9903b60ca72a..9564c8f0cbd7513c12501d3d8c2625ddf2fc390a 100644 (file)
@@ -4096,7 +4096,6 @@ static void captureVariablyModifiedType(ASTContext &Context, QualType T,
     case Type::Attributed:
     case Type::SubstTemplateTypeParm:
     case Type::PackExpansion:
-    case Type::MacroQualified:
       // Keep walking after single level desugaring.
       T = T.getSingleStepDesugaredType(Context);
       break;
@@ -13696,8 +13695,8 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
   // Look for an explicit signature in that function type.
   FunctionProtoTypeLoc ExplicitSignature;
 
-  if ((ExplicitSignature = Sig->getTypeLoc()
-                               .getAsAdjusted<FunctionProtoTypeLoc>())) {
+  if ((ExplicitSignature =
+           Sig->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>())) {
 
     // Check whether that explicit signature was synthesized by
     // GetTypeForDeclarator.  If so, don't save that as part of the
index fe0cf744964102d3b6c113ebabd2665f251fb5d2..e9faba6e6b4f48e74d2e8b085efcd17d8e12d2ac 100644 (file)
@@ -3390,10 +3390,10 @@ bool LocalTypedefNameReferencer::VisitRecordType(const RecordType *RT) {
 }
 
 TypeLoc Sema::getReturnTypeLoc(FunctionDecl *FD) const {
-  return FD->getTypeSourceInfo()
-      ->getTypeLoc()
-      .getAsAdjusted<FunctionProtoTypeLoc>()
-      .getReturnLoc();
+  TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc().IgnoreParens();
+  while (auto ATL = TL.getAs<AttributedTypeLoc>())
+    TL = ATL.getModifiedLoc().IgnoreParens();
+  return TL.castAs<FunctionProtoTypeLoc>().getReturnLoc();
 }
 
 /// Deduce the return type for a function from a returned expression, per
index 65cf3f59b3d5a4f377e5f96860f3d691e747d9c9..3b25595a33a6f9274dd5825d83eb47c5bac4f807 100644 (file)
@@ -5643,9 +5643,6 @@ namespace {
       assert(Chunk.Kind == DeclaratorChunk::Pipe);
       TL.setKWLoc(Chunk.Loc);
     }
-    void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
-      TL.setExpansionLoc(Chunk.Loc);
-    }
 
     void VisitTypeLoc(TypeLoc TL) {
       llvm_unreachable("unsupported TypeLoc kind in declarator!");
@@ -5724,9 +5721,6 @@ GetTypeSourceInfoForDeclarator(TypeProcessingState &State,
       CurrTL = ATL.getValueLoc().getUnqualifiedLoc();
     }
 
-    while (MacroQualifiedTypeLoc TL = CurrTL.getAs<MacroQualifiedTypeLoc>())
-      CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc();
-
     while (AttributedTypeLoc TL = CurrTL.getAs<AttributedTypeLoc>()) {
       fillAttributedTypeLoc(TL, State);
       CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc();
@@ -6987,16 +6981,12 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr,
   return true;
 }
 
-bool Sema::hasExplicitCallingConv(QualType T) {
-  const AttributedType *AT;
-
-  // Stop if we'd be stripping off a typedef sugar node to reach the
-  // AttributedType.
-  while ((AT = T->getAs<AttributedType>()) &&
-         AT->getAs<TypedefType>() == T->getAs<TypedefType>()) {
+bool Sema::hasExplicitCallingConv(QualType &T) {
+  QualType R = T.IgnoreParens();
+  while (const AttributedType *AT = dyn_cast<AttributedType>(R)) {
     if (AT->isCallingConv())
       return true;
-    T = AT->getModifiedType();
+    R = AT->getModifiedType().IgnoreParens();
   }
   return false;
 }
@@ -7581,15 +7571,6 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type,
         distributeFunctionTypeAttr(state, attr, type);
       break;
     }
-
-    // Handle attributes that are defined in a macro. We do not want this to be
-    // applied to ObjC builtin attributes.
-    if (isa<AttributedType>(type) && attr.hasMacroIdentifier() &&
-        !type.getQualifiers().hasObjCLifetime() &&
-        !type.getQualifiers().hasObjCGCAttr()) {
-      const IdentifierInfo *MacroII = attr.getMacroIdentifier();
-      type = state.getSema().Context.getMacroQualifiedType(type, MacroII);
-    }
   }
 
   if (!state.getSema().getLangOpts().OpenCL ||
index dddb2476c7916000bd3937db0f9b5b635837996a..a8ea6b01d1c63b59acf5ee3bcb13f096fc0a2055 100644 (file)
@@ -883,12 +883,6 @@ public:
     return SemaRef.Context.getTypeDeclType(Typedef);
   }
 
-  /// Build a new MacroDefined type.
-  QualType RebuildMacroQualifiedType(QualType T,
-                                     const IdentifierInfo *MacroII) {
-    return SemaRef.Context.getMacroQualifiedType(T, MacroII);
-  }
-
   /// Build a new class/struct/union type.
   QualType RebuildRecordType(RecordDecl *Record) {
     return SemaRef.Context.getTypeDeclType(Record);
@@ -6199,27 +6193,6 @@ TreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB,
   return Result;
 }
 
-template <typename Derived>
-QualType
-TreeTransform<Derived>::TransformMacroQualifiedType(TypeLocBuilder &TLB,
-                                                    MacroQualifiedTypeLoc TL) {
-  QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
-  if (Inner.isNull())
-    return QualType();
-
-  QualType Result = TL.getType();
-  if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
-    Result =
-        getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
-    if (Result.isNull())
-      return QualType();
-  }
-
-  MacroQualifiedTypeLoc NewTL = TLB.push<MacroQualifiedTypeLoc>(Result);
-  NewTL.setExpansionLoc(TL.getExpansionLoc());
-  return Result;
-}
-
 template<typename Derived>
 QualType TreeTransform<Derived>::TransformDependentNameType(
     TypeLocBuilder &TLB, DependentNameTypeLoc TL) {
index 64af0fa8a1d1f8ccd6ddf223a5dffe2955c4fc1a..a6ff54568d21440e6b4388e6ee8c53b9a138cc04 100644 (file)
@@ -6200,16 +6200,6 @@ 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");
@@ -6531,10 +6521,6 @@ void TypeLocReader::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
   // nothing to do
 }
 
-void TypeLocReader::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
-  TL.setExpansionLoc(ReadSourceLocation());
-}
-
 void TypeLocReader::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
   TL.setCaretLoc(ReadSourceLocation());
 }
index accd8ccdfaf97c933388e41965e1f366620ac27b..756411a8c5bdc79d0b89122b7677e1904b55ed37 100644 (file)
@@ -516,12 +516,6 @@ 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());
@@ -808,10 +802,6 @@ 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());
@@ -1229,7 +1219,6 @@ 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);
diff --git a/test/Frontend/macro_defined_type.cpp b/test/Frontend/macro_defined_type.cpp
deleted file mode 100644 (file)
index 4e60c84..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-#define NODEREF __attribute__((noderef))
-
-void Func() {
-  int NODEREF i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
-  int NODEREF *i_ptr;
-
-  // There should be no difference whether a macro defined type is used or not.
-  auto __attribute__((noderef)) *auto_i_ptr = i_ptr;
-  auto __attribute__((noderef)) auto_i = i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
-
-  auto NODEREF *auto_i_ptr2 = i_ptr;
-  auto NODEREF auto_i2 = i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
-}
diff --git a/test/Sema/address_space_print_macro.c b/test/Sema/address_space_print_macro.c
deleted file mode 100644 (file)
index 9557149..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
-
-#define AS1 __attribute__((address_space(1)))
-#define AS2 __attribute__((address_space(2), annotate("foo")))
-#define AS_ND __attribute__((address_space(2), noderef))
-
-#define AS(i) address_space(i)
-#define AS3 __attribute__((AS(3)))
-#define AS5 __attribute__((address_space(5))) char
-
-void normal_case() {
-  int *p = 0;
-  __attribute__((address_space(1))) int *q = p; // expected-error{{initializing '__attribute__((address_space(1))) int *' with an expression of type 'int *' changes address space of pointer}}
-}
-
-char *cmp(AS1 char *x, AS2 char *y) {
-  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}}
-}
-
-__attribute__((address_space(1))) char test_array[10];
-void test3(void) {
-  extern void test3_helper(char *p); // expected-note{{passing argument to parameter 'p' here}}
-  test3_helper(test_array);          // expected-error{{passing '__attribute__((address_space(1))) char *' to parameter of type 'char *' changes address space of pointer}}
-}
-
-char AS2 *test4_array;
-void test4(void) {
-  extern void test3_helper(char *p); // expected-note{{passing argument to parameter 'p' here}}
-  test3_helper(test4_array);         // expected-error{{passing 'AS2 char *' to parameter of type 'char *' changes address space of pointer}}
-}
-
-void func() {
-  char AS1 *x;
-  char AS3 *x2;
-  AS5 *x3;
-  char *y;
-  y = x;  // expected-error{{assigning 'AS1 char *' to 'char *' changes address space of pointer}}
-  y = x2; // expected-error{{assigning 'AS3 char *' to 'char *' changes address space of pointer}}
-  y = x3; // expected-error{{assigning '__attribute__((address_space(5))) char *' to 'char *' changes address space of pointer}}
-}
-
-void multiple_attrs(AS_ND int *x) {
-  __attribute__((address_space(2))) int *y = x; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
-}
-
-void override_macro_name() {
-#define ATTRS __attribute__((noderef)) // expected-note{{previous definition is here}}
-  ATTRS
-#define ATTRS __attribute__((address_space(1))) // expected-warning{{'ATTRS' macro redefined}}
-  ATTRS
-  int *x;
-
-  int AS_ND *y = x; // expected-error{{initializing 'AS_ND int *' with an expression of type 'ATTRS int *' changes address space of pointer}}
-}
-
-void partial_macro_declaration() {
-#define ATTRS2 __attribute__((noderef))
-  ATTRS2 __attribute__((address_space(1))) int *x;
-
-  int AS_ND *y = x; // expected-error{{initializing 'AS_ND int *' with an expression of type 'ATTRS2 int __attribute__((address_space(1))) *' changes address space of pointer}}
-
-  // The attribute not wrapped with a macro should be printed regularly.
-#define ATTRS3 __attribute__((address_space(1)))
-  ATTRS3 __attribute__((noderef)) int *x2;
-
-  int AS_ND *y2 = x2; // expected-error{{initializing 'AS_ND int *' with an expression of type 'ATTRS3 int * __attribute__((noderef))' changes address space of pointer}}
-}
index 5425ef75b64e3a34f6bc5276266dabc2d5d23525..a9046d86f18cf118df43254086130665f0b3f99c 100644 (file)
@@ -71,7 +71,7 @@ __attribute__((address_space("12"))) int *i; // expected-error {{'address_space'
 
 // Clang extension doesn't forbid operations on pointers to different address spaces.
 char* cmp(_AS1 char *x,  _AS2 char *y) {
-  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}}
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *') which are pointers to non-overlapping address spaces}}
 }
 
 struct SomeStruct {
index 24c531ccf7396eb338a05d8bbdfc930e5866efd4..2708fc8eefe197bd6e2eacfb27c2ab8c9442887c 100644 (file)
@@ -68,12 +68,6 @@ void (^blk)(ObjCTy *, ObjCTy *) =
   second = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}
 };
 
-void (^blk2)(ObjCTy *, ObjCTy *) =
-    ^(__strong ObjCTy *first, ObjCTy *second) __attribute__((objc_externally_retained)) {
-  first = 0;
-  second = 0; // expected-error{{variable declared with 'objc_externally_retained' cannot be modified in ARC}}
-};
-
 void test8(EXT_RET ObjCTy *x) {} // expected-warning{{'objc_externally_retained' attribute only applies to variables}}
 
 #pragma clang attribute ext_ret.push(__attribute__((objc_externally_retained)), apply_to=any(function, block, objc_method))
index 8bc5c6af33b69a8f98ffb49fde0714bf209e13a0..1023ba6eec3739ee9456951eefbfbffa9c51f2e5 100644 (file)
@@ -9,7 +9,7 @@ void test_f0() {
   A *a;
   static __weak A *a2;
   f0(&a);
-  f0(&a2); // expected-warning{{passing 'A *__weak *' to parameter of type 'A *__strong *' discards qualifiers}}
+  f0(&a2); // expected-warning{{passing 'A *__weak *' to parameter of type 'A *__strong *' discards qualifiers}} 
 }
 
 void f1(__weak A**); // expected-note{{passing argument to parameter here}}
@@ -18,7 +18,7 @@ void test_f1() {
   A *a;
   __strong A *a2;
   f1(&a);
-  f1(&a2); // expected-warning{{passing 'A *__strong *' to parameter of type 'A *__weak *' discards qualifiers}}
+  f1(&a2); // expected-warning{{passing 'A *__strong *' to parameter of type 'A *__weak *' discards qualifiers}} 
 }
 
 // These qualifiers should silently expand to nothing in GC mode.
index af7081b53f82bd1315821e5532aa50af515d1ecc..e961e0ab75ed7674d6dd01f1d35bad91b6bb4db2 100644 (file)
@@ -62,6 +62,6 @@ void test_unsafe_unretained_cast(id *value) {
 
 void test_cast_qualifier_inference(__weak id *value) {
   __weak id *a = (id*) value;
-  __unsafe_unretained id *b = (id *)value; // expected-error {{initializing '__unsafe_unretained id *' with an expression of type '__weak id *' changes retain/release properties of pointer}}
+  __unsafe_unretained id *b = (id*) value; // expected-error {{initializing 'id *' with an expression of type '__weak id *' changes retain/release properties of pointer}}
 }
 
index ac5ee74c5fd44b5b42f804f84e88d98af1bdcdd1..4549683bb2e0adebf449181f9049f6788f9d8591 100644 (file)
@@ -3,7 +3,7 @@
 @interface A
 @end
 
-void f0(__strong A **); // expected-note{{candidate function not viable: 1st argument ('A *__weak *') has __weak ownership, but parameter has __strong ownership}}
+void f0(__strong A**); // expected-note{{candidate function not viable: 1st argument ('A *__weak *') has __weak ownership, but parameter has __strong ownership}}
 
 void test_f0() {
   A *a;
@@ -12,7 +12,7 @@ void test_f0() {
   f0(&a2); // expected-error{{no matching function}}
 }
 
-void f1(__weak A **); // expected-note{{candidate function not viable: 1st argument ('A *__strong *') has __strong ownership, but parameter has __weak ownership}}
+void f1(__weak A**); // expected-note{{candidate function not viable: 1st argument ('A *__strong *') has __strong ownership, but parameter has __weak ownership}}
 
 void test_f1() {
   A *a;
index 1144ec64f58c72d24e6de50a071b1cb1a25ed9bb..a5a8998f613f0e8c1fc1f2af6716dd26b791d6a1 100644 (file)
@@ -1614,10 +1614,6 @@ bool CursorVisitor::VisitParenTypeLoc(ParenTypeLoc TL) {
   return Visit(TL.getInnerLoc());
 }
 
-bool CursorVisitor::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
-  return Visit(TL.getInnerLoc());
-}
-
 bool CursorVisitor::VisitPointerTypeLoc(PointerTypeLoc TL) {
   return Visit(TL.getPointeeLoc());
 }