aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/AST/Decl.h37
-rw-r--r--include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--include/clang/CodeGen/ModuleBuilder.h3
-rw-r--r--include/clang/Parse/Action.h6
-rw-r--r--include/clang/Parse/Parser.h1
5 files changed, 49 insertions, 0 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 321eb4b70c..40af7bada0 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -70,6 +70,7 @@ public:
ObjCMethod,
ObjCClass,
ObjCForwardProtocol,
+ LinkageSpec,
// For each non-leaf class, we now define a mapping to the first/last member
// of the class, to allow efficient classof.
@@ -753,6 +754,42 @@ protected:
friend Decl* Decl::Create(llvm::Deserializer& D);
};
+
+/// LinkageSpecDecl - This represents a linkage specification. For example:
+/// extern "C" void foo();
+///
+class LinkageSpecDecl : public Decl {
+public:
+ /// LanguageIDs - Used to represent the language in a linkage
+ /// specification. The values are part of the serialization abi for
+ /// ASTs and cannot be changed without altering that abi. To help
+ /// ensure a stable abi for this, we choose the DW_LANG_ encodings
+ /// from the dwarf standard.
+ enum LanguageIDs { lang_c = /* DW_LANG_C */ 0x0002,
+ lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004 };
+private:
+ /// Language - The language for this linkage specification.
+ LanguageIDs Language;
+ /// D - This is the Decl of the linkage specification.
+ Decl *D;
+public:
+ LinkageSpecDecl(SourceLocation L, LanguageIDs lang, Decl *d)
+ : Decl(LinkageSpec, L), Language(lang), D(d) {}
+
+ LanguageIDs getLanguage() const { return Language; }
+ const Decl *getDecl() const { return D; }
+ Decl *getDecl() { return D; }
+
+ static bool classof(const Decl *D) {
+ return D->getKind() == LinkageSpec;
+ }
+ static bool classof(const LinkageSpecDecl *D) { return true; }
+
+protected:
+ void EmitInRec(llvm::Serializer& S) const;
+ void ReadInRec(llvm::Deserializer& D);
+};
+
} // end namespace clang
#endif
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 1191455d74..b91c7313f1 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -537,6 +537,8 @@ DIAG(err_invalid_reference_qualifier_application, ERROR,
"'%0' qualifier may not be applied to a reference")
DIAG(err_declarator_need_ident, ERROR,
"declarator requires an identifier")
+DIAG(err_bad_language, ERROR,
+ "unknown linkage language")
// Attributes
DIAG(err_attribute_wrong_number_arguments, ERROR,
diff --git a/include/clang/CodeGen/ModuleBuilder.h b/include/clang/CodeGen/ModuleBuilder.h
index 7fddcadae1..b27e3d35f5 100644
--- a/include/clang/CodeGen/ModuleBuilder.h
+++ b/include/clang/CodeGen/ModuleBuilder.h
@@ -22,6 +22,7 @@ namespace llvm {
namespace clang {
class ASTContext;
class FunctionDecl;
+ class LinkageSpecDecl;
class FileVarDecl;
struct LangOptions;
class Diagnostic;
@@ -37,6 +38,8 @@ namespace CodeGen {
/// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
///
void CodeGenFunction(CodeGenModule *Builder, FunctionDecl *D);
+
+ void CodeGenLinkageSpec(CodeGenModule *Builder, LinkageSpecDecl *LS);
/// CodeGenGlobalVar - Emit the specified global variable to LLVM.
void CodeGenGlobalVar(CodeGenModule *Builder, FileVarDecl *D);
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 8b4a0c1bfd..0e5ae2a79b 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -154,6 +154,12 @@ public:
virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
return 0;
}
+
+ virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace,
+ SourceLocation RBrace, const char *Lang,
+ unsigned StrSize, DeclTy *D) {
+ return 0;
+ }
//===--------------------------------------------------------------------===//
// Type Parsing Callbacks.
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index c1069c25f6..508dc306ad 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -437,6 +437,7 @@ private:
// C++ 7: Declarations [dcl.dcl]
DeclTy *ParseNamespace(unsigned Context);
+ DeclTy *ParseLinkage(unsigned Context);
};