Up until now, all references to errno were marked with NOLINT, since
it was technically calling an external function. This fixes the lint
rules so that errno, as well as malloc, calloc, realloc, and
free are all allowed to be called as external functions. All of the
relevant NOLINT comments have been removed, and the documentation has
been updated.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp | ||
---|---|---|
59 | Look like diag() is used to print messages in this module? |
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp | ||
---|---|---|
1 | You should add tests for this exception check. See https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp. | |
13 | Looks like this is present only for the debug printf? | |
39 | May be static const std::uordered_set<llvm::StringRef>? It would likely make the lookup below much neater. | |
59 | This looks like a debug printf? |
clean up the code and remove debug statements
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp | ||
---|---|---|
13 | yes, I didn't mean to leave that in there. | |
39 | an unordered set is a good idea, but the documentation for StringRef says it's best not to use them for storage, so I went with std::string instead. The code is still a lot nicer. | |
59 | yes, I didn't mean to leave that in there. |
For libc requirements, LGTM. Please wait for @aaron.ballman for stamping the clang-tidy parts.
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp | ||
---|---|---|
39 | Literal strings will not count as "storage". They are global data. On the other hand, std::string will make copies of the literals and require "storage". |
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp | ||
---|---|---|
39 | When I tried to put a StringRef into an unordered_set it told me that StringRef doesn't have a hash function, so I went looking for what the proper, LLVM way of doing this was. In the end, I discovered that unordered_set is not recommended, and that StringSet does exactly what we need here, so I've switched to that. |
You should add tests for this exception check. See https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp.