aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-02-14 01:18:37 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-02-14 01:18:37 +0000
commit950fee2555f7a6bd193e588d6b6a941fd182391a (patch)
treea0dd9afcad02780d91902e9510ea41187947662d /include
parentd3b4f0e27ffa8d73f8c69a717c39c39a4d47ff0c (diff)
Add a getLanguageLinkage method to VarDecls and FunctionDecls. Use it to fix
some cases where functions with no language linkage were being treated as having C language linkage. In particular, don't warn in extern "C" { static NonPod foo(); } Since getLanguageLinkage checks the language linkage, the linkage computation cannot use the language linkage. Break the loop by checking just the context in the linkage computation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/AST/Decl.h22
-rw-r--r--include/clang/AST/DeclBase.h4
-rw-r--r--include/clang/Basic/Linkage.h8
3 files changed, 24 insertions, 10 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index b6a650fea3..947525f691 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -898,11 +898,12 @@ public:
/// external, C linkage.
bool isExternC() const;
- /// Checks if this variable has C language linkage. Note that this is not the
- /// same as isExternC since decls with non external linkage can have C
- /// language linkage. They can also have C language linkage when they are not
- /// declared in an extern C context, but a previous decl is.
- bool hasCLanguageLinkage() const;
+ /// Compute the language linkage.
+ LanguageLinkage getLanguageLinkage() const;
+
+ bool hasCLanguageLinkage() const {
+ return getLanguageLinkage() == CLanguageLinkage;
+ }
/// isLocalVarDecl - Returns true for local variable declarations
/// other than parameters. Note that this includes static variables
@@ -1790,11 +1791,12 @@ public:
/// external, C linkage.
bool isExternC() const;
- /// Checks if this function has C language linkage. Note that this is not the
- /// same as isExternC since decls with non external linkage can have C
- /// language linkage. They can also have C language linkage when they are not
- /// declared in an extern C context, but a previous decl is.
- bool hasCLanguageLinkage() const;
+ /// Compute the language linkage.
+ LanguageLinkage getLanguageLinkage() const;
+
+ bool hasCLanguageLinkage() const {
+ return getLanguageLinkage() == CLanguageLinkage;
+ }
/// \brief Determines whether this is a global function.
bool isGlobal() const;
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 5a9e9fedfa..3248d23f42 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -1090,6 +1090,10 @@ public:
/// a C++ extern "C" linkage spec.
bool isExternCContext() const;
+ /// \brief Determines whether this context is, or is nested within,
+ /// a C++ extern "C++" linkage spec.
+ bool isExternCXXContext() const;
+
/// \brief Determine whether this declaration context is equivalent
/// to the declaration context DC.
bool Equals(const DeclContext *DC) const {
diff --git a/include/clang/Basic/Linkage.h b/include/clang/Basic/Linkage.h
index 6bc1f5d5ef..01b8db15f5 100644
--- a/include/clang/Basic/Linkage.h
+++ b/include/clang/Basic/Linkage.h
@@ -42,6 +42,14 @@ enum Linkage {
ExternalLinkage
};
+/// \brief Describes the different kinds of language linkage
+/// (C++ [dcl.link]) that an entity may have.
+enum LanguageLinkage {
+ CLanguageLinkage,
+ CXXLanguageLinkage,
+ NoLanguageLinkage
+};
+
/// \brief A more specific kind of linkage than enum Linkage.
///
/// This is relevant to CodeGen and AST file reading.