Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
219–226 | I'm getting a slight code smell here that we are slowly building towards a full C++ specification API. | |
412 | 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. | |
451–452 | Not sure this comment is true given that we have isPublic below. | |
460 | Missing comment here? | |
465 | nit: Drop the const, we don't generally add them. Also please document these fields. | |
610 | This needs some documentation. | |
mlir/include/mlir/TableGen/Format.h | ||
54 | nit: I'd use ArrayRef here instead. | |
mlir/lib/TableGen/AttrOrTypeDef.cpp | ||
110–117 | Can we just put the vector on the class and return ArrayRef instead? | |
mlir/lib/TableGen/Class.cpp | ||
301–310 | This needs some documentation. | |
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
161 |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
219–226 | I agree. I'm not necessarily happy about it, but it absolutely is more maintainable than writing to a naked raw_ostream. | |
412 | 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 | ||
---|---|---|
383 | LLVM should have functionality for this: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/BitmaskEnum.h | |
412 | 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 | ||
202–204 | AFAIR we rely on the compiler to warn/error about missing cases. | |
232–233 | Please switch this to an if/else to make it easier to read. | |
244 | 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. | |
432 | 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? | |
463–464 | ? | |
512–516 | raw_string_ostream would likely be cleaner here. | |
630 | 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 | ||
757 | Same comment about () here and elsewhere. | |
855 | Can we drop the ()? | |
879 | Can we drop the ()? We generally don't wrap unless necessary. | |
1953–1956 | Is this right, AFAICT Method::Declaration & declaration is always false. |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
379 | Why is this defined outside of the namespace? |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
412 | 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 | ||
---|---|---|
383 | 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 | ||
432 | I agree. I initially thought the same. | |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
1953–1956 | This actually expands to declaration ? Method::Declaration : Method::None. If that's not intuitive, I can remove it. |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
---|---|---|
1953–1956 | Are you implying Method::Declaration & declaration is the same as declaration ? Method::Declaration : Method::None? |
mlir/include/mlir/TableGen/Class.h | ||
---|---|---|
396–399 | Please remove this, the code that this creates is not readable. | |
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | ||
1953–1956 | 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 | ||
---|---|---|
396–399 | 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 | ||
---|---|---|
396–399 | 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 | ||
---|---|---|
1030 | 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 | ||
---|---|---|
1030 | 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?