[polly] r202648 - PollyDectect: Use spaces before foreach colons

David Blaikie dblaikie at gmail.com
Mon Mar 3 09:16:07 PST 2014


On Sun, Mar 2, 2014 at 8:28 AM, Tobias Grosser <tobias at grosser.es> wrote:

> Author: grosser
> Date: Sun Mar  2 10:28:24 2014
> New Revision: 202648
>
> URL: http://llvm.org/viewvc/llvm-project?rev=202648&view=rev
> Log:
> PollyDectect: Use spaces before foreach colons
>
> clang-format requires a space before the ":" in the foreach loop. Even
> though
> this is surprising to me, we follow this style to make our formatting
> consistent with clang-format. I found that this clang-format style is used
> in a
> couple of C++11 examples, hence I believe the fact that clang-format adds a
> colon is not a bug but just something I was not used to yet.
>

For what it's worth, I assume the nearest analogy (and only other context I
recall ':' in like this) is for conditional operators ("x ? y : z") and
inheritance ("struct foo : bar") - both of which also uses spaces on both
sides of the ':'.

Just in case that helps provide developers with a good mental model of
"space on both sides of a colon, even in a range based for".


>
> Modified:
>     polly/trunk/lib/Analysis/ScopDetection.cpp
>
> Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=202648&r1=202647&r2=202648&view=diff
>
> ==============================================================================
> --- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
> +++ polly/trunk/lib/Analysis/ScopDetection.cpp Sun Mar  2 10:28:24 2014
> @@ -332,7 +332,7 @@ std::string ScopDetection::formatInvalid
>
>    std::vector<Value *> Pointers;
>
> -  for (auto I: AS)
> +  for (auto I : AS)
>      Pointers.push_back(I.getValue());
>
>    std::sort(Pointers.begin(), Pointers.end());
> @@ -607,7 +607,7 @@ static bool regionWithoutLoops(Region &R
>  static unsigned eraseAllChildren(std::set<const Region *> &Regs,
>                                   const Region *R) {
>    unsigned Count = 0;
> -  for (auto SubRegion: *R) {
> +  for (auto SubRegion : *R) {
>      if (Regs.find(SubRegion) != Regs.end()) {
>        ++Count;
>        Regs.erase(SubRegion);
> @@ -633,7 +633,7 @@ void ScopDetection::findScops(Region &R)
>
>    InvalidRegions[&R] = LastFailure;
>
> -  for (auto SubRegion: R)
> +  for (auto SubRegion : R)
>      findScops(*SubRegion);
>
>    // Try to expand regions.
> @@ -644,10 +644,10 @@ void ScopDetection::findScops(Region &R)
>
>    std::vector<Region *> ToExpand;
>
> -  for (auto SubRegion: R)
> +  for (auto SubRegion : R)
>      ToExpand.push_back(SubRegion);
>
> -  for (auto CurrentRegion: ToExpand) {
> +  for (auto CurrentRegion : ToExpand) {
>      // Skip invalid regions. Regions may become invalid, if they are
> element of
>      // an already expanded region.
>      if (ValidRegions.find(CurrentRegion) == ValidRegions.end())
> @@ -800,7 +800,7 @@ void ScopDetection::getDebugLocation(con
>  }
>
>  void ScopDetection::printLocations(llvm::Function &F) {
> -  for (auto R: *this) {
> +  for (auto R : *this) {
>      unsigned LineEntry, LineExit;
>      std::string FileName;
>
> @@ -846,7 +846,7 @@ void polly::ScopDetection::verifyAnalysi
>    if (!VerifyScops)
>      return;
>
> -  for (auto R: ValidRegions)
> +  for (auto R : ValidRegions)
>      verifyRegion(*R);
>  }
>
> @@ -862,7 +862,7 @@ void ScopDetection::getAnalysisUsage(Ana
>  }
>
>  void ScopDetection::print(raw_ostream &OS, const Module *) const {
> -  for (auto R: ValidRegions)
> +  for (auto R : ValidRegions)
>      OS << "Valid Region for Scop: " << R->getNameStr() << '\n';
>
>    OS << "\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/20140303/e27a91e4/attachment.html>


More information about the llvm-commits mailing list