含义:将属性放入源中以防止需要迭代?

meaning of: putting attributes into source to prevent the need for iteration?

按源顺序放置属性以防止重复的需要是什么意思?例如,在此块中,它们不是按源顺序排列的,所以需要做什么?

  for (auto *Attr : D->getAttrs()) {
    SourceLoc AttrLoc = Attr->getRangeWithAt().Start;
    if (AttrLoc.isValid() && SM.isBeforeInBuffer(AttrLoc, SL))
        SL = AttrLoc;
  }

从代码片段中我看到您在谈论 Clang API。源顺序很可能是指属性在源文件中出现的顺序。您可以通过按源位置(由 SourceLoc 表示)排序来按此顺序排列它们。不确定 "preventing the need for repetition" 是什么意思。我希望每个属性都有一个唯一的源位置,即使有重复,它们也会有不同的位置。