diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2013-01-12 00:54:16 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2013-01-12 00:54:16 +0000 |
commit | b1e71a7d0cde313a2515bd2def492001e28ecf79 (patch) | |
tree | 683d4f0e5124111e083f0d09fa60a474aaaeac8d /clang/lib/Basic/SourceManager.cpp | |
parent | 37494a176c8bfe274375c1deef124c149ba28150 (diff) | |
download | llvm-b1e71a7d0cde313a2515bd2def492001e28ecf79.zip llvm-b1e71a7d0cde313a2515bd2def492001e28ecf79.tar.gz llvm-b1e71a7d0cde313a2515bd2def492001e28ecf79.tar.bz2 |
Fix -Wunused-comparison for comparisons in arguments to function-like macros.
Previously, -Wunused-comparison ignored comparisons in both macro bodies and
macro arguments, but we would still emit a -Wunused-value warning for either.
Now we correctly emit -Wunused-comparison for expressions in macro arguments.
Also, add isMacroBodyExpansion to SourceManager, to go along with
isMacroArgExpansion.
llvm-svn: 172279
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index f1965e7..6910191 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -974,11 +974,18 @@ bool SourceManager::isMacroArgExpansion(SourceLocation Loc) const { if (!Loc.isMacroID()) return false; FileID FID = getFileID(Loc); - const SrcMgr::SLocEntry *E = &getSLocEntry(FID); - const SrcMgr::ExpansionInfo &Expansion = E->getExpansion(); + const SrcMgr::ExpansionInfo &Expansion = getSLocEntry(FID).getExpansion(); return Expansion.isMacroArgExpansion(); } +bool SourceManager::isMacroBodyExpansion(SourceLocation Loc) const { + if (!Loc.isMacroID()) return false; + + FileID FID = getFileID(Loc); + const SrcMgr::ExpansionInfo &Expansion = getSLocEntry(FID).getExpansion(); + return Expansion.isMacroBodyExpansion(); +} + //===----------------------------------------------------------------------===// // Queries about the code at a SourceLocation. |