Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion clang-tools-extra/include-cleaner/lib/WalkAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
}

bool VisitCleanupAttr(CleanupAttr *attr) {
report(attr->getLocation(), attr->getFunctionDecl());
report(attr->getArgLoc(), attr->getFunctionDecl());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ TEST(WalkAST, OperatorNewDelete) {

TEST(WalkAST, CleanupAttr) {
testWalk("void* $explicit^freep(void *p);",
"void foo() { __attribute__((^__cleanup__(freep))) char* x = 0; }");
"void foo() { __attribute__((__cleanup__(^freep))) char* x = 0; }");
}

} // namespace
Expand Down
13 changes: 12 additions & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,17 @@ def Cleanup : InheritableAttr {
let Args = [DeclArgument<Function, "FunctionDecl">];
let Subjects = SubjectList<[LocalVar]>;
let Documentation = [CleanupDocs];
// FIXME: DeclArgument should be reworked to also store the
// Expr instead of adding attr specific hacks like the following.
// See the discussion in https://github.com/llvm/llvm-project/pull/14023.
let AdditionalMembers = [{
private:
SourceLocation ArgLoc;

public:
void setArgLoc(const SourceLocation &Loc) { ArgLoc = Loc; }
auto getArgLoc() const { return ArgLoc; }
}];
}

def CmseNSEntry : InheritableAttr, TargetSpecificAttr<TargetARM> {
Expand Down Expand Up @@ -4815,7 +4826,7 @@ def HLSLResourceBinding: InheritableAttr {
void setImplicitBindingOrderID(uint32_t Value) {
ImplicitBindingOrderID = Value;
}
bool hasImplicitBindingOrderID() const {
bool hasImplicitBindingOrderID() const {
return ImplicitBindingOrderID.has_value();
}
uint32_t getImplicitBindingOrderID() const {
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3620,7 +3620,9 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
}

D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD));
auto *attr = ::new (S.Context) CleanupAttr(S.Context, AL, FD);
attr->setArgLoc(E->getExprLoc());
D->addAttr(attr);
}

static void handleEnumExtensibilityAttr(Sema &S, Decl *D,
Expand Down
Loading