summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-03-07 02:22:41 +0000
committerNico Weber <nicolasweber@gmx.de>2018-03-07 02:22:41 +0000
commitbbf648253d096b4e25f588583df8ed8e764a28bb (patch)
tree0b02e45d28db415c8f5fa00795969510f93c1fd0 /clang/include
parent204ade4102c7959cc56e03f163ad7473c94a0b38 (diff)
downloadbcm5719-llvm-bbf648253d096b4e25f588583df8ed8e764a28bb.tar.gz
bcm5719-llvm-bbf648253d096b4e25f588583df8ed8e764a28bb.zip
Revert r326602, it caused PR36620.
llvm-svn: 326862
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/AST/Attr.h114
-rw-r--r--clang/include/clang/Basic/Attr.td44
2 files changed, 15 insertions, 143 deletions
diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 38dce44ddec..a7c766a65ce 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -195,120 +195,6 @@ public:
}
};
-/// A single parameter index whose accessors require each use to make explicit
-/// the parameter index encoding needed.
-class ParamIdx {
- // Idx is exposed only via accessors that specify specific encodings.
- unsigned Idx : 30;
- unsigned HasThis : 1;
- unsigned IsValid : 1;
-
- void assertComparable(const ParamIdx &I) const {
- assert(isValid() && I.isValid() &&
- "ParamIdx must be valid to be compared");
- // It's possible to compare indices from separate functions, but so far
- // it's not proven useful. Moreover, it might be confusing because a
- // comparison on the results of getASTIndex might be inconsistent with a
- // comparison on the ParamIdx objects themselves.
- assert(HasThis == I.HasThis &&
- "ParamIdx must be for the same function to be compared");
- }
-
-public:
- /// Construct an invalid parameter index (\c isValid returns false and
- /// accessors fail an assert).
- ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
-
- /// \param Idx is the parameter index as it is normally specified in
- /// attributes in the source: one-origin including any C++ implicit this
- /// parameter.
- ///
- /// \param D is the declaration containing the parameters. It is used to
- /// determine if there is a C++ implicit this parameter.
- ParamIdx(unsigned Idx, const Decl *D)
- : Idx(Idx), HasThis(false), IsValid(true) {
- if (const auto *FD = dyn_cast<FunctionDecl>(D))
- HasThis = FD->isCXXInstanceMember();
- }
-
- /// \param Idx is the parameter index as it is normally specified in
- /// attributes in the source: one-origin including any C++ implicit this
- /// parameter.
- ///
- /// \param HasThis specifies whether the function has a C++ implicit this
- /// parameter.
- ParamIdx(unsigned Idx, bool HasThis)
- : Idx(Idx), HasThis(HasThis), IsValid(true) {}
-
- /// Is this parameter index valid?
- bool isValid() const { return IsValid; }
-
- /// Is there a C++ implicit this parameter?
- bool hasThis() const {
- assert(isValid() && "ParamIdx must be valid");
- return HasThis;
- }
-
- /// Get the parameter index as it would normally be encoded for attributes at
- /// the source level of representation: one-origin including any C++ implicit
- /// this parameter.
- ///
- /// This encoding thus makes sense for diagnostics, pretty printing, and
- /// constructing new attributes from a source-like specification.
- unsigned getSourceIndex() const {
- assert(isValid() && "ParamIdx must be valid");
- return Idx;
- }
-
- /// Get the parameter index as it would normally be encoded at the AST level
- /// of representation: zero-origin not including any C++ implicit this
- /// parameter.
- ///
- /// This is the encoding primarily used in Sema. However, in diagnostics,
- /// Sema uses \c getSourceIndex instead.
- unsigned getASTIndex() const {
- assert(isValid() && "ParamIdx must be valid");
- assert(Idx >= 1 + HasThis &&
- "stored index must be base-1 and not specify C++ implicit this");
- return Idx - 1 - HasThis;
- }
-
- /// Get the parameter index as it would normally be encoded at the LLVM level
- /// of representation: zero-origin including any C++ implicit this parameter.
- ///
- /// This is the encoding primarily used in CodeGen.
- unsigned getLLVMIndex() const {
- assert(isValid() && "ParamIdx must be valid");
- assert(Idx >= 1 && "stored index must be base-1");
- return Idx - 1;
- }
-
- bool operator==(const ParamIdx &I) const {
- assertComparable(I);
- return Idx == I.Idx;
- }
- bool operator!=(const ParamIdx &I) const {
- assertComparable(I);
- return Idx != I.Idx;
- }
- bool operator<(const ParamIdx &I) const {
- assertComparable(I);
- return Idx < I.Idx;
- }
- bool operator>(const ParamIdx &I) const {
- assertComparable(I);
- return Idx > I.Idx;
- }
- bool operator<=(const ParamIdx &I) const {
- assertComparable(I);
- return Idx <= I.Idx;
- }
- bool operator>=(const ParamIdx &I) const {
- assertComparable(I);
- return Idx >= I.Idx;
- }
-};
-
#include "clang/AST/Attrs.inc"
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 92d1dd60151..afb516b5a6f 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -169,12 +169,6 @@ class VariadicUnsignedArgument<string name> : Argument<name, 1>;
class VariadicExprArgument<string name> : Argument<name, 1>;
class VariadicStringArgument<string name> : Argument<name, 1>;
-// Like VariadicUnsignedArgument except values are ParamIdx.
-class VariadicParamIdxArgument<string name> : Argument<name, 1>;
-
-// Like VariadicParamIdxArgument but for a single function parameter index.
-class ParamIdxArgument<string name, bit opt = 0> : Argument<name, opt>;
-
// A version of the form major.minor[.subminor].
class VersionArgument<string name, bit opt = 0> : Argument<name, opt>;
@@ -620,12 +614,6 @@ def XRayInstrument : InheritableAttr {
def XRayLogArgs : InheritableAttr {
let Spellings = [Clang<"xray_log_args">];
let Subjects = SubjectList<[Function, ObjCMethod]>;
- // This argument is a count not an index, so it has the same encoding (base
- // 1 including C++ implicit this parameter) at the source and LLVM levels of
- // representation, so ParamIdxArgument is inappropriate. It is never used
- // at the AST level of representation, so it never needs to be adjusted not
- // to include any C++ implicit this parameter. Thus, we just store it and
- // use it as an unsigned that never needs adjustment.
let Args = [UnsignedArgument<"ArgumentCount">];
let Documentation = [XRayDocs];
}
@@ -1033,8 +1021,7 @@ def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
def AllocSize : InheritableAttr {
let Spellings = [GCC<"alloc_size">];
let Subjects = SubjectList<[Function]>;
- let Args = [ParamIdxArgument<"ElemSizeParam">,
- ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
+ let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
let TemplateDependent = 1;
let Documentation = [AllocSizeDocs];
}
@@ -1121,7 +1108,7 @@ def Format : InheritableAttr {
def FormatArg : InheritableAttr {
let Spellings = [GCC<"format_arg">];
- let Args = [ParamIdxArgument<"FormatIdx">];
+ let Args = [IntArgument<"FormatIdx">];
let Subjects = SubjectList<[ObjCMethod, HasFunctionProto]>;
let Documentation = [Undocumented];
}
@@ -1401,16 +1388,16 @@ def NonNull : InheritableParamAttr {
let Spellings = [GCC<"nonnull">];
let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
"functions, methods, and parameters">;
- let Args = [VariadicParamIdxArgument<"Args">];
- let AdditionalMembers = [{
- bool isNonNull(unsigned IdxAST) const {
- if (!args_size())
+ let Args = [VariadicUnsignedArgument<"Args">];
+ let AdditionalMembers =
+[{bool isNonNull(unsigned idx) const {
+ if (!args_size())
+ return true;
+ for (const auto &V : args())
+ if (V == idx)
return true;
- return args_end() != std::find_if(
- args_begin(), args_end(),
- [=](const ParamIdx &Idx) { return Idx.getASTIndex() == IdxAST; });
- }
- }];
+ return false;
+ } }];
// FIXME: We should merge duplicates into a single nonnull attribute.
let InheritEvenIfAlreadyPresent = 1;
let Documentation = [NonNullDocs];
@@ -1468,7 +1455,7 @@ def AssumeAligned : InheritableAttr {
def AllocAlign : InheritableAttr {
let Spellings = [GCC<"alloc_align">];
let Subjects = SubjectList<[HasFunctionProto]>;
- let Args = [ParamIdxArgument<"ParamIndex">];
+ let Args = [IntArgument<"ParamIndex">];
let Documentation = [AllocAlignDocs];
}
@@ -1677,8 +1664,7 @@ def Ownership : InheritableAttr {
Returns;
}
}];
- let Args = [IdentifierArgument<"Module">,
- VariadicParamIdxArgument<"Args">];
+ let Args = [IdentifierArgument<"Module">, VariadicUnsignedArgument<"Args">];
let Subjects = SubjectList<[HasFunctionProto]>;
let Documentation = [Undocumented];
}
@@ -2504,8 +2490,8 @@ def ArgumentWithTypeTag : InheritableAttr {
Clang<"pointer_with_type_tag">];
let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
let Args = [IdentifierArgument<"ArgumentKind">,
- ParamIdxArgument<"ArgumentIdx">,
- ParamIdxArgument<"TypeTagIdx">,
+ UnsignedArgument<"ArgumentIdx">,
+ UnsignedArgument<"TypeTagIdx">,
BoolArgument<"IsPointer", /*opt*/0, /*fake*/1>];
let Documentation = [ArgumentWithTypeTagDocs, PointerWithTypeTagDocs];
}
OpenPOWER on IntegriCloud