================
@@ -5992,6 +5992,64 @@ Expr *unwrapParenList(Expr *Base) {
} // namespace
+static void AddHLSLVectorSwizzleCompletions(Sema &SemaRef,
+ ResultBuilder &Results,
+ const ExtVectorType *VT) {
+
+ unsigned NumElts = VT->getNumElements();
+ if (NumElts > 4)
+ NumElts = 4;
+
+ StringRef Filter = SemaRef.PP.getCodeCompletionFilter();
+
+ bool UseXYZW = true;
+ bool UseRGBA = true;
+ if (!Filter.empty()) {
+ bool HasXYZW = Filter.find_first_of("xyzw") != StringRef::npos;
+ bool HasRGBA = Filter.find_first_of("rgba") != StringRef::npos;
+ if (HasXYZW && !HasRGBA)
+ UseRGBA = false;
+ if (HasRGBA && !HasXYZW)
+ UseXYZW = false;
+ if (HasXYZW && HasRGBA)
+ return;
+ if (Filter.size() >= 4)
+ return;
+ }
----------------
V-FEXrt wrote:
It seems like the logic here is more complex than needed? Also it could
probably use a couple small comments
```suggestion
// If we don't have a filter string yet then either xyzw or rgba is allowed
bool UseXYZW = true;
bool UseRGBA = true;
// otherwise, we need to restrict the results
if (!Filter.empty()) {
// stop suggestions after 4 components
if (Filter.size() >= 4)
return;
// determine which type of swizzle is being used
UseXYZW = Filter.find_first_of("xyzw") != StringRef::npos;
UseRGBA = Filter.find_first_of("rgba") != StringRef::npos;
// Both types are already in the filter, we can't help
if (UseXYZW && UseRGBA)
return;
// the filter has text but neither are valid swizzles, we can't help
if (!UseXYZW && !UseRGBA)
return;
}
```
https://github.com/llvm/llvm-project/pull/217381
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits