summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/compat.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-04-02 17:53:43 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-04-02 17:53:43 +0200
commitb4e5b8bc1d6be0d53843ac68ba86da4d8cd0c2b0 (patch)
tree64c028ab67e2c8f1937e4d62e94c3c54713ad447 /compilerplugins/clang/compat.hxx
parent9db717d063ae60a56e2304e5bf53ae62652e3f97 (diff)
Add compat::isInMainFile
Change-Id: I0e155c6c68a43020110a8e1c0cb29cabdcade454
Diffstat (limited to 'compilerplugins/clang/compat.hxx')
-rw-r--r--compilerplugins/clang/compat.hxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 1f025e70472f..3d265722c044 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -20,6 +20,7 @@
#include "clang/AST/Type.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
@@ -101,6 +102,16 @@ inline unsigned getBuiltinCallee(clang::CallExpr const & expr) {
#endif
}
+inline bool isInMainFile(
+ clang::SourceManager const & manager, clang::SourceLocation Loc)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
+ return manager.isInMainFile(Loc);
+#else
+ return manager.isFromMainFile(Loc);
+#endif
+}
+
inline unsigned getCustomDiagID(
clang::DiagnosticsEngine & engine, clang::DiagnosticsEngine::Level L,
llvm::StringRef FormatString)