================ @@ -26,6 +29,17 @@ bool isOverrideMethod(const FunctionDecl *Function) { return MD->size_overridden_methods() > 0 || MD->hasAttr<OverrideAttr>(); return false; } + +bool hasAttrAfterParam(const SourceManager *SourceManager, + const ParmVarDecl *Param) { + for (const auto *Attr : Param->attrs()) { + if (SourceManager->isBeforeInTranslationUnit(Param->getLocation(), + Attr->getLocation())) { + return true; + } + } + return false; +} ---------------- usx95 wrote:
It is unfortunate that for declaration attributes we do not have the information that attr appeared before or after the decl. I would argue, for simplicity, we filter out all annotated params irrespective of the position of attribute. Dealing with raw source locations can quickly become problematic. For example with expanded locations: ```cpp #define ANNOTATE_BEFORE(x) [[clang::lifetimebound]] x #define ANNOTATE_AFTER(x) x [[clang::lifetimebound]] int* foo(ANNOTATE_BEFORE(int* x)) {} int* bar(ANNOTATE_AFTER(int* x)) {} ``` https://godbolt.org/z/brYMKfcxf It is possible to make it work but I don't see the point of this complexity when we can have a simpler filter without much fallout https://github.com/llvm/llvm-project/pull/122286 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits