/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Having annotations in the AST unexpectedly impacts codegen. * Ideally, we'd avoid having annotations at all, by using an API such as * the one from https://reviews.llvm.org/D31338, and storing the attributes * data separately from the AST on our own. Unfortunately, there is no such * API currently in clang, so we must do without. * We can do something similar, though, where we go through the AST before * running the checks, create a mapping of AST nodes to attributes, and * remove the attributes/annotations from the AST nodes. * Not all declarations can be reached from the decl() AST matcher, though, * so we do our best effort (getting the other declarations we look at in * checks). We emit a warning when checks look at a note that still has * annotations attached (aka, hasn't been seen during our first pass), * so that those don't go unnoticed. (-Werror should then take care of * making that an error)
*/
static FrontendPluginRegistry::Add<CustomAttributesAction>
X("moz-custom-attributes", "prepare custom attributes for moz-check"); #endif
CustomAttributesSet GetAttributes(const Decl *D) {
CustomAttributesSet attrs = {}; if (D->hasAttr<AnnotateAttr>()) { // If we are not in clang-tidy env push warnings, most likely we are in the // build environment and this should have been done in AstMatcher - // CustomAttributesMatcher #ifndef CLANG_TIDY
Report(D, "Declaration has unhandled annotations."); #endif
attrs = CacheAttributes(D);
} else { auto attributes = AttributesCache.find(D); if (attributes != AttributesCache.end()) {
attrs = attributes->second;
}
} return attrs;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.