[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.
Yan Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 10:45:56 PDT 2017
yawanng added inline comments.
================
Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:61
+ SourceLocation EndLoc =
+ Lexer::getLocForEndOfToken(FlagArg->getLocEnd(), 0, SM, getLangOpts());
+
----------------
hokein wrote:
> Instead of using getLangOpts(), you should use `Result.Context.getLangOpts()`.
May I ask what's the difference between the `Result.Context.getLangOpts()` and `getLangOpts()`? Does `Result.Context.getLangOpts()` have a longer lifetime than `getLangOpts()`?
================
Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:79
+ std::pair<FileID, unsigned> ExpansionInfo = SM.getDecomposedLoc(Loc);
+ auto MacroName =
+ SM.getBufferData(ExpansionInfo.first)
----------------
hokein wrote:
> You could use `Lexer::getImmediateMacroName(Loc, SM, Opts);` to get the marco name, or doesn't it work here?
`getImmediateMacroName` sometimes cannot return the `O_CLOEXEC `, like
#define O_CLOEXEC _O_CLOEXEC
#define _O_CLOEXEC 1
`getImmediateMacroName` will return `_O_CLOEXEC`, whereas `O_CLOEXEC` is what we need. I change this to directly get the source text if it's a macro, which seems to be simpler.
https://reviews.llvm.org/D33304
More information about the cfe-commits
mailing list