Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),
which determines whether a particular file is actually a header that
is intended to be guarded from multiple inclusions within the same
translation unit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130808 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 28f1506..e6774dc 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -30,6 +30,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/STLExtras.h"
@@ -2890,6 +2891,16 @@
   return const_cast<FileEntry *>(FMgr.getFile(file_name));
 }
 
+unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file) {
+  if (!tu || !file)
+    return 0;
+
+  ASTUnit *CXXUnit = static_cast<ASTUnit *>(tu->TUData);
+  FileEntry *FEnt = static_cast<FileEntry *>(file);
+  return CXXUnit->getPreprocessor().getHeaderSearchInfo()
+                                          .isFileMultipleIncludeGuarded(FEnt);
+}
+
 } // end: extern "C"
 
 //===----------------------------------------------------------------------===//
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index 30c3fd1..7bba673 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -115,6 +115,7 @@
 _clang_isCursorDefinition
 _clang_isDeclaration
 _clang_isExpression
+_clang_isFileMultipleIncludeGuarded
 _clang_isInvalid
 _clang_isPODType
 _clang_isPreprocessing
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index 4e96e8a..5f2c362 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -115,6 +115,7 @@
 clang_isCursorDefinition
 clang_isDeclaration
 clang_isExpression
+clang_isFileMultipleIncludeGuarded
 clang_isInvalid
 clang_isPODType
 clang_isPreprocessing