Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
petrhosek opened this issue Oct 16, 2023 · 1 comment · Fixed by #69249
Closed

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

petrhosek opened this issue Oct 16, 2023 · 1 comment · Fixed by #69249
Assignees

Comments

@petrhosek
Copy link
Member

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(); }
@llvmbot
Copy link
Member

llvmbot commented Oct 16, 2023

@llvm/issue-subscribers-clang-format

Author: Petr Hosek (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(); }

@owenca owenca self-assigned this Oct 16, 2023
owenca added a commit to owenca/llvm-project that referenced this issue Oct 16, 2023
Skip TrailingAnnotation when looking for TrailingReturnArrow.

Fixes llvm#69234.
owenca added a commit that referenced this issue Oct 18, 2023
Skip TrailingAnnotation when looking for TrailingReturnArrow.

Fixes #69234.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants