[PATCH] Update the coding standards to provide some guidance for a few constructs in C++11

Chandler Carruth chandlerc at gmail.com
Sun Mar 2 01:05:33 PST 2014



================
Comment at: docs/CodingStandards.rst:490-502
@@ +489,15 @@
+
+  dyn_switch(V->stripPointerCasts(),
+             [] (PHINode *PN) {
+               // process phis...
+             },
+             [] (SelectInst *SI) {
+               // process selects...
+             },
+             [] (LoadInst *LI) {
+               // process loads...
+             },
+             [] (AllocaInst *AI) {
+               // process allocas...
+             });
+
----------------
Sean Silva wrote:
> Sort of random, but it seems like clang-format doesn't get this quite right. Maybe we should add something to the coding standard describing how to work around/with clang-format to get desirable results?
> 
> E.g.
> 
> First attempt, no coercion:
> 
>     int foo() {
>       dyn_switch(V->stripPointerCasts(), [](PHINode *PN) {
>                                            // process phis...
>                                          },
>                  [](SelectInst *SI) {
>                    // process selects...
>                  },
>                  [](LoadInst *LI) {
>                    // process loads...
>                  },
>                  [](AllocaInst *AI) {
>         // process allocas...
>       });
>     }
> 
> Adding one comment:
> 
>     int foo() {
>       dyn_switch(V->stripPointerCasts(), //
>                  [](PHINode *PN) {
>                    // process phis...
>                  },
>                  [](SelectInst *SI) {
>                    // process selects...
>                  },
>                  [](LoadInst *LI) {
>                    // process loads...
>                  },
>                  [](AllocaInst *AI) {
>         // process allocas...
>       });
>     }
> 
> 
> And then, for the "hanging" last lambda:
> 
>     int foo() {
>       dyn_switch(V->stripPointerCasts(), //
>                  [](PHINode *PN) {
>                    // process phis...
>                  },
>                  [](SelectInst *SI) {
>                    // process selects...
>                  },
>                  [](LoadInst *LI) {
>                    // process loads...
>                  },
>                  [](AllocaInst *AI) {
>                    // process allocas...
>                  }//
>                  );
>     }
> 
> (The lack of space before that line comment is PR19017).
Bleh. Lame. I've filed PR19021 for this. I think we should just fix clang-format here.


http://llvm-reviews.chandlerc.com/D2905



More information about the llvm-commits mailing list