summaryrefslogtreecommitdiff
path: root/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-03-02 05:58:18 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-03-02 05:58:18 +0000
commit1cafcfd06bb10505a7e570eb62148906c185879e (patch)
tree619139c0c2e3016f72f88f3a97497dffdcb52750 /lib/Lex/ModuleMap.cpp
parentf4481e0e412e3f817e65d5ce1c835381dc7a7773 (diff)
downloadclang-1cafcfd06bb10505a7e570eb62148906c185879e.tar.gz
clang-1cafcfd06bb10505a7e570eb62148906c185879e.tar.bz2
clang-1cafcfd06bb10505a7e570eb62148906c185879e.tar.xz
Add [extern_c] attribute for modules, allowing a C module to be imported within an extern "C" block in C++ code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/ModuleMap.cpp')
-rw-r--r--lib/Lex/ModuleMap.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp
index 05238278ba..0d9cd10953 100644
--- a/lib/Lex/ModuleMap.cpp
+++ b/lib/Lex/ModuleMap.cpp
@@ -906,11 +906,14 @@ namespace clang {
/// \brief The set of attributes that can be attached to a module.
struct Attributes {
- Attributes() : IsSystem(), IsExhaustive() { }
+ Attributes() : IsSystem(), IsExternC(), IsExhaustive() { }
/// \brief Whether this is a system module.
unsigned IsSystem : 1;
+ /// \brief Whether this is an extern "C" module.
+ unsigned IsExternC : 1;
+
/// \brief Whether this is an exhaustive set of configuration macros.
unsigned IsExhaustive : 1;
};
@@ -1178,6 +1181,8 @@ namespace {
AT_unknown,
/// \brief The 'system' attribute.
AT_system,
+ /// \brief The 'extern_c' attribute.
+ AT_extern_c,
/// \brief The 'exhaustive' attribute.
AT_exhaustive
};
@@ -1334,7 +1339,9 @@ void ModuleMapParser::parseModuleDecl() {
ActiveModule->DefinitionLoc = ModuleNameLoc;
if (Attrs.IsSystem || IsSystem)
ActiveModule->IsSystem = true;
-
+ if (Attrs.IsExternC)
+ ActiveModule->IsExternC = true;
+
bool Done = false;
do {
switch (Tok.Kind) {
@@ -2097,6 +2104,7 @@ bool ModuleMapParser::parseOptionalAttributes(Attributes &Attrs) {
AttributeKind Attribute
= llvm::StringSwitch<AttributeKind>(Tok.getString())
.Case("exhaustive", AT_exhaustive)
+ .Case("extern_c", AT_extern_c)
.Case("system", AT_system)
.Default(AT_unknown);
switch (Attribute) {
@@ -2109,6 +2117,10 @@ bool ModuleMapParser::parseOptionalAttributes(Attributes &Attrs) {
Attrs.IsSystem = true;
break;
+ case AT_extern_c:
+ Attrs.IsExternC = true;
+ break;
+
case AT_exhaustive:
Attrs.IsExhaustive = true;
break;