Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
238–245 | I'm getting a slight code smell here that we are slowly building towards a full C++ specification API. | |
468 | Prefer accepting const Twine & instead of std::string. It accepts many more parameter types (e.g. StringRef, std::string, llvm::formatv, etc.), and can easily be converted to string. | |
543–544 | Not sure this comment is true given that we have isPublic below. | |
552 | Missing comment here? | |
557 | nit: Drop the const, we don't generally add them. Also please document these fields. | |
700 | This needs some documentation. | |
mlir/include/mlir/TableGen/Format.h | ||
54 | nit: I'd use ArrayRef here instead. | |
mlir/lib/TableGen/AttrOrTypeDef.cpp | ||
115–116 | Can we just put the vector on the class and return ArrayRef instead? | |
mlir/lib/TableGen/Class.cpp | ||
362–371 | This needs some documentation. | |
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
161 |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
238–245 | I agree. I'm not necessarily happy about it, but it absolutely is more maintainable than writing to a naked raw_ostream. | |
468 | Good point, but what's your opinion on the stringify function I added? I wanted to elide copying std::string when it's passed in directly, and I've had some issues with const Twine &; for example, void one(const Twine &value = ""); void one(bool value = false); Confusingly, one("C string") calls one(bool) |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
423 | LLVM should have functionality for this: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/BitmaskEnum.h | |
468 | Which methods do we have that takes bool or Twine? If it isn't a lot of methods, we can always just add an overload specialized for const char */StringRef.
It's giving me an off feeling, but that may be that we generally try not to use std::string directly. | |
mlir/lib/TableGen/Class.cpp | ||
203–205 | AFAIR we rely on the compiler to warn/error about missing cases. | |
301–302 | Please switch this to an if/else to make it easier to read. | |
313 | Please use proper foreach loops for these, the llvm::for_each doesn't add much. | |
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
211–216 | I'd just use a proper foreach loop here, using llvm::for_each doesn't really add much. | |
431 | semi unrelated, but the name "reindent" is throwing me off. It doesn't read like something that is emitted to the stream, I keep expecting it to return a reindented string. Can we rename that to something better? | |
462–463 | ? | |
511–515 | raw_string_ostream would likely be cleaner here. | |
627 | Drop the consts, we don't really add them unless really necessary (i.e. if they add value). | |
mlir/tools/mlir-tblgen/OpClass.h | ||
26 | Can you document what this does? The doc on the other finalize was quite nice. | |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
754 | Same comment about () here and elsewhere. | |
852 | Can we drop the ()? | |
875–876 | Can we drop the ()? We generally don't wrap unless necessary. | |
1950–1953 | Is this right, AFAICT Method::Declaration & declaration is always false. |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
423 | Why is this defined outside of the namespace? |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
468 | I went for the stringify route because occasionally in ODS we create std::string and maybe something takes ownership of it. I got tired of debugging segmentation faults because .str() wasn't being called somewhere and a StringRef or Twine or format object was outliving its value. |
Review comments.
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
423 | I didn't know about this! But also, it doesn't seem to work because the functions need to be constexpr (and there are asserts in them...) | |
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
431 | I agree. I initially thought the same. | |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
1950–1953 | This actually expands to declaration ? Method::Declaration : Method::None. If that's not intuitive, I can remove it. |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
---|---|---|
1950–1953 | Are you implying Method::Declaration & declaration is the same as declaration ? Method::Declaration : Method::None? |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
436–439 | Please remove this, the code that this creates is not readable. | |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
1950–1953 | I see now, you've defined a custom operator& for that. Please remove that, it creates a hacky difference in behavior that is not what someone what naturally expect. |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
436–439 | In general, please avoid overloading operators like this. It creates code that is difficult to read/maintain just for the sake of saving a line or two. Prefer writing clean/readable code over "tricky" code. |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
436–439 | Very well. FYI I originally contemplated: props |= Method::Static & ~(isStatic - 1u) And so I thought that this would be "more readable" than that... |
llvm/include/llvm/ADT/STLExtras.h | ||
---|---|---|
1017 | Sorry haven't gotten to this review yet. Could we perhaps extract out the changes to ADT into parent change for separate review? |
llvm/include/llvm/ADT/STLExtras.h | ||
---|---|---|
1017 | Sure thing |
Sorry haven't gotten to this review yet. Could we perhaps extract out the changes to ADT into parent change for separate review?