[llvm-commits] [llvm] r128474 - /llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp

Tilmann Scheller tilmann.scheller at googlemail.com
Tue Mar 29 13:28:52 PDT 2011


Hi Argyrios,

please don't use a data structure whose order is non-determinstic (walking
over a DenseSet gives different results depending on the memory layout),
this leads to Checkers.inc being different on every run :)

Regards,

Tilmann

On Tue, Mar 29, 2011 at 8:53 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com>wrote:

> Author: akirtzidis
> Date: Tue Mar 29 13:53:00 2011
> New Revision: 128474
>
> URL: http://llvm.org/viewvc/llvm-project?rev=128474&view=rev
> Log:
> For ClangSACheckersEmitter, allow a package to belong to checker group, in
> which all its checkers will go into the group.
>
> Modified:
>    llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp
>
> Modified: llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp?rev=128474&r1=128473&r2=128474&view=diff
>
> ==============================================================================
> --- llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp (original)
> +++ llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp Tue Mar 29
> 13:53:00 2011
> @@ -71,7 +71,7 @@
>
>  namespace {
>  struct GroupInfo {
> -  std::vector<const Record*> Checkers;
> +  llvm::DenseSet<const Record*> Checkers;
>   llvm::DenseSet<const Record *> SubGroups;
>   bool Hidden;
>   unsigned Index;
> @@ -80,6 +80,19 @@
>  };
>  }
>
> +static void addPackageToCheckerGroup(const Record *package, const Record
> *group,
> +                  llvm::DenseMap<const Record *, GroupInfo *>
> &recordGroupMap) {
> +  llvm::DenseSet<const Record *> &checkers =
> recordGroupMap[package]->Checkers;
> +  for (llvm::DenseSet<const Record *>::iterator
> +         I = checkers.begin(), E = checkers.end(); I != E; ++I)
> +    recordGroupMap[group]->Checkers.insert(*I);
> +
> +  llvm::DenseSet<const Record *> &subGroups =
> recordGroupMap[package]->SubGroups;
> +  for (llvm::DenseSet<const Record *>::iterator
> +         I = subGroups.begin(), E = subGroups.end(); I != E; ++I)
> +    addPackageToCheckerGroup(*I, group, recordGroupMap);
> +}
> +
>  void ClangSACheckersEmitter::run(raw_ostream &OS) {
>   std::vector<Record*> checkers =
> Records.getAllDerivedDefinitions("Checker");
>   llvm::DenseMap<const Record *, unsigned> checkerRecIndexMap;
> @@ -150,9 +163,9 @@
>       GroupInfo &info = groupInfoByName[fullName];
>       info.Hidden = R->getValueAsBit("Hidden");
>       recordGroupMap[R] = &info;
> -      info.Checkers.push_back(R);
> +      info.Checkers.insert(R);
>     } else {
> -      recordGroupMap[package]->Checkers.push_back(R);
> +      recordGroupMap[package]->Checkers.insert(R);
>     }
>
>     Record *currR = isCheckerNamed(R) ? R : package;
> @@ -166,9 +179,15 @@
>     }
>     // Insert the checker into the set of its group.
>     if (DefInit *DI = dynamic_cast<DefInit*>(R->getValueInit("Group")))
> -      recordGroupMap[DI->getDef()]->Checkers.push_back(R);
> +      recordGroupMap[DI->getDef()]->Checkers.insert(R);
>   }
>
> +  // If a package is in group, add all its checkers and its sub-packages
> +  // checkers into the group.
> +  for (unsigned i = 0, e = packages.size(); i != e; ++i)
> +    if (DefInit *DI =
> dynamic_cast<DefInit*>(packages[i]->getValueInit("Group")))
> +      addPackageToCheckerGroup(packages[i], DI->getDef(), recordGroupMap);
> +
>   unsigned index = 0;
>   for (std::map<std::string, GroupInfo>::iterator
>          I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E;
> ++I)
> @@ -183,11 +202,12 @@
>          I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E;
> ++I) {
>     maxLen = std::max(maxLen, (unsigned)I->first.size());
>
> -    std::vector<const Record*> &V = I->second.Checkers;
> -    if (!V.empty()) {
> +    llvm::DenseSet<const Record *> &checkers = I->second.Checkers;
> +    if (!checkers.empty()) {
>       OS << "static const short CheckerArray" << I->second.Index << "[] = {
> ";
> -      for (unsigned i = 0, e = V.size(); i != e; ++i)
> -        OS << checkerRecIndexMap[V[i]] << ", ";
> +      for (llvm::DenseSet<const Record *>::iterator
> +          I = checkers.begin(), E = checkers.end(); I != E; ++I)
> +        OS << checkerRecIndexMap[*I] << ", ";
>       OS << "-1 };\n";
>     }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110329/b82ddd84/attachment.html>


More information about the llvm-commits mailing list