[PATCH] Refactor tryCaptureVariable using ExtractMethod
Langmuir, Ben
ben.langmuir at intel.com
Fri May 10 06:20:33 PDT 2013
+static DeclContext *getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var,
...
+ return DC->getParent()->getParent();
+ else {
+ if (BuildAndDiagnose)
+ diagnoseUncapturableValueReference(S, Loc, Var, DC);
+ }
+ return 0;
+}
Can we move the contents of the else out? It is clearer to me what's going on if the 'if (BuildAndDiagnose)...' is in the same scope as return 0.
+static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI,
...
+ if (BuildAndDiagnose) {
+ // The current implementation assumes that all variables are captured
+ // by references. Since there is no capture by copy, no expression evaluation
...
+ }
+
+ // Actually capture the variable.
+ if (BuildAndDiagnose)
+ RSI->addCapture(Var, /*isBlock*/false, ByRef, RefersToEnclosingLocal, Loc,
The second if can just be part of the first one.
+ if (!IsPotentiallyEvaluatedContext(SemaRef)) {
+ return;
+ }
- if (!IsPotentiallyEvaluatedContext(SemaRef))
- return;
Nitpick: other code in this patch does not use braces in cases like this.
Ben
More information about the cfe-commits
mailing list