Skip to content

Clang-Format misformats Thread Safety Analysis annotations that include an arrow  #69234

@petrhosek

Description

@petrhosek

For the following snippet:

#if __has_attribute(capability)
#define LOCKABLE(name) __attribute__((capability(name)))
#endif

#if __has_attribute(unlock_function)
#define UNLOCK_FUNCTION(...) __attribute__((unlock_function(__VA_ARGS__)))
#endif

struct LOCKABLE("M") M {
  void unlock() UNLOCK_FUNCTION();
};

class L {
public:
  void f() UNLOCK_FUNCTION(this->mutex_) { this->mutex_.unlock(); }

private:
  M mutex_;
};

#67780 changed the behavior where it would insert extra spaces around the arrow in the annotation, so the following:

  void f() UNLOCK_FUNCTION(this->mutex_) { this->mutex_.unlock(); }

becomes:

  void f() UNLOCK_FUNCTION(this -> mutex_) { this->mutex_.unlock(); }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions