@@ -122,6 +122,9 @@ struct TokenImpl {
122
122
};
123
123
CppcheckAttributes* mCppcheckAttributes {};
124
124
125
+ // alignas expressions
126
+ std::string mAttributeAlignas ;
127
+
125
128
// For memoization, to speed up parsing of huge arrays #8897
126
129
enum class Cpp11init { UNKNOWN, CPP11INIT, NOINIT } mCpp11init = Cpp11init::UNKNOWN;
127
130
@@ -545,6 +548,25 @@ class CPPCHECKLIB Token {
545
548
void isAttributeMaybeUnused (const bool value) {
546
549
setFlag (fIsAttributeMaybeUnused , value);
547
550
}
551
+ std::vector<std::string> getAttributeAlignas () const {
552
+ if (mImpl ->mAttributeAlignas .empty ())
553
+ return {};
554
+ const std::string::size_type pos = mImpl ->mAttributeAlignas .find (' \n ' );
555
+ if (pos == std::string::npos)
556
+ return {mImpl ->mAttributeAlignas };
557
+ return {mImpl ->mAttributeAlignas .substr (0 , pos),
558
+ mImpl ->mAttributeAlignas .substr (pos + 1 )};
559
+ }
560
+ bool hasAttributeAlignas () const {
561
+ return !mImpl ->mAttributeAlignas .empty ();
562
+ }
563
+ void addAttributeAlignas (const std::string& a) {
564
+ if (mImpl ->mAttributeAlignas .empty ())
565
+ mImpl ->mAttributeAlignas = a;
566
+ else if (a != mImpl ->mAttributeAlignas && mImpl ->mAttributeAlignas .find (' \n ' ) == std::string::npos)
567
+ // mismatching alignas expressions, add both
568
+ mImpl ->mAttributeAlignas += ' \n ' + a;
569
+ }
548
570
void setCppcheckAttribute (TokenImpl::CppcheckAttributes::Type type, MathLib::bigint value) {
549
571
mImpl ->setCppcheckAttribute (type, value);
550
572
}
0 commit comments