[PATCH] D60387: FileCheck [7/12]: Arbitrary long numeric expressions
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 08:25:32 PDT 2019
jhenderson added inline comments.
================
Comment at: llvm/lib/Support/FileCheck.cpp:108
+ VariableProperties VarProperties = {Name, IsPseudo};
+ return VarProperties;
}
----------------
arichardson wrote:
> thopre wrote:
> > thopre wrote:
> > > jhenderson wrote:
> > > > You might be able to just do `return {Name, IsPseudo}` to avoid the temporary.
> > > I tried but it didn't work. I think it would if I was returning the structure, but here I'm returning an Expected.
> > >
> > > As per 6.6.3 C++11 draft:
> > > "A return statement with a braced-init-list initializes the object or reference to be returned from the function by copy-list-initialization (8.5.4) from the specified initializer list."
> > >
> > > So it tries to build an Expected with that initialization list which fails because I think an Expected<foo> only accepts a Foo.
> > Yes, that's it:
> >
> > /home/thomasp/repos/llvm-project/llvm/lib/Support/FileCheck.cpp:107:10: error: no matching constructor for initialization of 'Expected<FileCheckPattern::VariableProperties>'
> > return {Name, IsPseudo};
> > ^~~~~~~~~~~~~~~~
> > /home/thomasp/repos/llvm-project/llvm/include/llvm/Support/Error.h:474:3: note: candidate template ignored: requirement 'std::is_convertible<StringRef &, VariableProperties>::value' was not satisfied [with OtherT = llvm::StringRef &]
> > Expected(OtherT &&Val,
> > ^
> >
> > It tries to convert Name into a VariableProperties and fails. All the other constructors expect an Error or another Expected and fail as well.
> Maybe `return VariableProperties{Name, IsPseudo}`would work?
Yes of course. I think you could still do it inline if you want, (not tried, so not 100% certain off the top of my head) and don't mind either way:
```
return VariableProperties {Name, IsPseudo};
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60387/new/
https://reviews.llvm.org/D60387
More information about the llvm-commits
mailing list