[clang] b336826 - Non-implicit attribute creation requires a source range; NFC
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 12 10:10:59 PST 2020
Author: Aaron Ballman
Date: 2020-11-12T10:06:30-08:00
New Revision: b336826c1dd92adabef682f9b013b2e36bce066c
URL: https://github.com/llvm/llvm-project/commit/b336826c1dd92adabef682f9b013b2e36bce066c
DIFF: https://github.com/llvm/llvm-project/commit/b336826c1dd92adabef682f9b013b2e36bce066c.diff
LOG: Non-implicit attribute creation requires a source range; NFC
There are two factory functions used to create a semantic attribute,
Create() and CreateImplicit(). CreateImplicit() does not need to
specify the source range of the attribute since it's an implicitly-
generated attribute. The same logic does not apply to Create(), so
this removes the default argument from those declarations to avoid
accidentally creating a semantic attribute without source location
information.
Added:
Modified:
clang/include/clang/Basic/Attr.td
clang/utils/TableGen/ClangAttrEmitter.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 7ae5803f1c30..62c97cb0440c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -742,7 +742,7 @@ def Annotate : InheritableParamAttr {
// '#pragma clang attribute' even though it has no subject list.
let AdditionalMembers = [{
static AnnotateAttr *Create(ASTContext &Ctx, llvm::StringRef Annotation, \
- const AttributeCommonInfo &CommonInfo = {SourceRange{}}) {
+ const AttributeCommonInfo &CommonInfo) {
return AnnotateAttr::Create(Ctx, Annotation, nullptr, 0, CommonInfo);
}
static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, \
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 1ed81eefe981..ec109e134e20 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2367,7 +2367,7 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS,
ai->writeCtorParameters(OS);
}
OS << ", const AttributeCommonInfo &CommonInfo";
- if (Header)
+ if (Header && Implicit)
OS << " = {SourceRange{}}";
OS << ")";
if (Header) {
More information about the cfe-commits
mailing list