- fopen() should include "e" in their mode string. [android-fopen-mode]
Details
Diff Detail
Event Timeline
clang-tidy/android/FopenModeCheck.h | ||
---|---|---|
20 | Is there a guideline/code style describing it? If so, would be nice to add the link. And I'd suggest you to put the detailed document to the rst instead of code comments -- because users usually read documents. | |
27 | nit: remove the blank line. | |
34 | No need to put utility functions/variables inside the class, you can define them in an anonymous namespace in the implementation file, the same below. | |
docs/clang-tidy/checks/android-fopen-mode.rst | ||
5 | nit: remove extra trailing === | |
test/clang-tidy/android-fopen-mode.cpp | ||
14 | Use completed statements fopen("filename", "re"); to do the fix verification. The same below. | |
17 | You can use a shorter string here -- It is sufficient as we have a completed message check in the first CHECK-MESSAGES. |
clang-tidy/android/FopenModeCheck.h | ||
---|---|---|
20 | Adding 'e' is like adding the "O_CLOEXEC". The reason is the same with part1(https://reviews.llvm.org/D33304). Added more text in doc. | |
34 | Inline one and move the other and the variable to anonymous namespace. | |
test/clang-tidy/android-fopen-mode.cpp | ||
14 | The fix will mark the corresponding argument and suggest the fix like:
Is this clear to show the fix? |
clang-tidy/android/FopenModeCheck.cpp | ||
---|---|---|
32 | We may not need this utility function, see my comment on your part 2. | |
58 | How about if (const auto* ModeStr = dyn_cast<StringLiteral>(...))? | |
70 | remove the trailing ., clang-tidy message is not a sentence. And we can simplify the code like: diag(...) << FD << FixItHint::CreateReplacement(ModeRange.getSourceRange(), ReplacementText); | |
test/clang-tidy/android-fopen-mode.cpp | ||
14 | CHECK-FIXES is not used to check the message of the fix. It is used to check the code after the generated-fix is applied. So here should be // CHECK-FIXES: fopen("filename", "re");. |
clang-tidy/android/FopenModeCheck.cpp | ||
---|---|---|
31 | You can use Twine here which is more efficient: (getSourceText(...) + " \"" + Twine(Mode) + "\"").str(). The same below. | |
65 | We'd prefer early return in llvm, and with that the flag "MayHaveE" can be removed. | |
76 | I think you can use ModeArg->getSourceRange(). Moreover, as ModeRange is used only once, you can ModeArg->getSourceRange() directly in FixtItHint below. |
One comment on test, otherwise looks good.
test/clang-tidy/android-fopen-mode.cpp | ||
---|---|---|
29 | What if str = "re" here? Seems to me the check will omit this case. Would be nice to add this test case. |
Is there a guideline/code style describing it? If so, would be nice to add the link.
And I'd suggest you to put the detailed document to the rst instead of code comments -- because users usually read documents.