aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorMatt Beaumont-Gay <matthewbg@google.com>2013-01-12 00:54:16 +0000
committerMatt Beaumont-Gay <matthewbg@google.com>2013-01-12 00:54:16 +0000
commitc3cd6f7a5d33ad44f6c9cf4faa7046c77baa128e (patch)
tree79504996f06f1957050e8acb8c99e878ee0aefe0 /include/clang/Basic/SourceManager.h
parentc328d9c22a4397dd7313d06be5b82d700297b246 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index a2d7a59032..6aa5347231 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -329,6 +329,11 @@ namespace SrcMgr {
SourceLocation::getFromRawEncoding(ExpansionLocEnd).isInvalid();
}
+ bool isMacroBodyExpansion() const {
+ return getExpansionLocStart().isValid() &&
+ SourceLocation::getFromRawEncoding(ExpansionLocEnd).isValid();
+ }
+
bool isFunctionMacroExpansion() const {
return getExpansionLocStart().isValid() &&
getExpansionLocStart() != getExpansionLocEnd();
@@ -1126,6 +1131,13 @@ public:
/// expanded.
bool isMacroArgExpansion(SourceLocation Loc) const;
+ /// \brief Tests whether the given source location represents the expansion of
+ /// a macro body.
+ ///
+ /// This is equivalent to testing whether the location is part of a macro
+ /// expansion but not the expansion of an argument to a function-like macro.
+ bool isMacroBodyExpansion(SourceLocation Loc) const;
+
/// \brief Returns true if \p Loc is inside the [\p Start, +\p Length)
/// chunk of the source location address space.
///