- fopen() should include "e" in their mode string. [android-fopen-mode]
Details
Diff Detail
Event Timeline
| clang-tidy/android/FopenModeCheck.h | ||
|---|---|---|
| 19 ↗ | (On Diff #101129) | 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. |
| 26 ↗ | (On Diff #101129) | nit: remove the blank line. |
| 33 ↗ | (On Diff #101129) | 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 | ||
| 4 ↗ | (On Diff #101129) | nit: remove extra trailing === |
| test/clang-tidy/android-fopen-mode.cpp | ||
| 13 ↗ | (On Diff #101129) | Use completed statements fopen("filename", "re"); to do the fix verification. The same below. |
| 16 ↗ | (On Diff #101129) | 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 | ||
|---|---|---|
| 19 ↗ | (On Diff #101129) | 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. |
| 33 ↗ | (On Diff #101129) | Inline one and move the other and the variable to anonymous namespace. |
| test/clang-tidy/android-fopen-mode.cpp | ||
| 13 ↗ | (On Diff #101129) | The fix will mark the corresponding argument and suggest the fix like:
Is this clear to show the fix? |
| clang-tidy/android/FopenModeCheck.cpp | ||
|---|---|---|
| 31 ↗ | (On Diff #101270) | We may not need this utility function, see my comment on your part 2. |
| 57 ↗ | (On Diff #101251) | How about if (const auto* ModeStr = dyn_cast<StringLiteral>(...))? |
| 69 ↗ | (On Diff #101251) | 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 | ||
| 13 ↗ | (On Diff #101129) | 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 | ||
|---|---|---|
| 30 ↗ | (On Diff #103795) | You can use Twine here which is more efficient: (getSourceText(...) + " \"" + Twine(Mode) + "\"").str(). The same below. |
| 64 ↗ | (On Diff #101830) | We'd prefer early return in llvm, and with that the flag "MayHaveE" can be removed. |
| 75 ↗ | (On Diff #101830) | 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 | ||
|---|---|---|
| 28 ↗ | (On Diff #104004) | What if str = "re" here? Seems to me the check will omit this case. Would be nice to add this test case. |