r368152 - [clang] Fix mismatched args constructing AddressSpaceAttr.
Anton Bikineev via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 04:12:44 PDT 2019
Author: antonbikineev
Date: Wed Aug 7 04:12:43 2019
New Revision: 368152
URL: http://llvm.org/viewvc/llvm-project?rev=368152&view=rev
Log:
[clang] Fix mismatched args constructing AddressSpaceAttr.
Differential Revision: https://reviews.llvm.org/D65589
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/unittests/AST/ASTTraverserTest.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=368152&r1=368151&r2=368152&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Aug 7 04:12:43 2019
@@ -5978,9 +5978,9 @@ static void HandleAddressSpaceTypeAttrib
}
ASTContext &Ctx = S.Context;
- auto *ASAttr = ::new (Ctx) AddressSpaceAttr(
- Attr.getRange(), Ctx, Attr.getAttributeSpellingListIndex(),
- static_cast<unsigned>(ASIdx));
+ auto *ASAttr = ::new (Ctx)
+ AddressSpaceAttr(Attr.getRange(), Ctx, static_cast<unsigned>(ASIdx),
+ Attr.getAttributeSpellingListIndex());
// If the expression is not value dependent (not templated), then we can
// apply the address space qualifiers just to the equivalent type.
Modified: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTTraverserTest.cpp?rev=368152&r1=368151&r2=368152&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/ASTTraverserTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp Wed Aug 7 04:12:43 2019
@@ -139,6 +139,8 @@ struct templ<int>
{
};
+void parmvardecl_attr(struct A __attribute__((address_space(19)))*);
+
)cpp");
const FunctionDecl *Func = getFunctionNode(AST.get(), "func");
@@ -220,5 +222,16 @@ FullComment
R"cpp(
TemplateArgument
)cpp");
+
+ Func = getFunctionNode(AST.get(), "parmvardecl_attr");
+
+ const auto *Parm = Func->getParamDecl(0);
+ const auto TL = Parm->getTypeSourceInfo()->getTypeLoc();
+ ASSERT_TRUE(TL.getType()->isPointerType());
+
+ const auto ATL = TL.getNextTypeLoc().getAs<AttributedTypeLoc>();
+ const auto *AS = cast<AddressSpaceAttr>(ATL.getAttr());
+ EXPECT_EQ(toTargetAddressSpace(static_cast<LangAS>(AS->getAddressSpace())),
+ 19u);
}
} // namespace clang
More information about the cfe-commits
mailing list