r253046 - Deduplicate three identical copies of isExplicitInstantiationOrSpecialization, NFC.
Yaron Keren via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 13 07:39:40 PST 2015
Author: yrnkrn
Date: Fri Nov 13 09:39:39 2015
New Revision: 253046
URL: http://llvm.org/viewvc/llvm-project?rev=253046&view=rev
Log:
Deduplicate three identical copies of isExplicitInstantiationOrSpecialization, NFC.
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/Basic/Specifiers.h
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=253046&r1=253045&r2=253046&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Nov 13 09:39:39 2015
@@ -448,17 +448,8 @@ public:
/// explicit instantiation declaration, or explicit instantiation
/// definition.
bool isExplicitInstantiationOrSpecialization() const {
- switch (getTemplateSpecializationKind()) {
- case TSK_ExplicitSpecialization:
- case TSK_ExplicitInstantiationDeclaration:
- case TSK_ExplicitInstantiationDefinition:
- return true;
-
- case TSK_Undeclared:
- case TSK_ImplicitInstantiation:
- return false;
- }
- llvm_unreachable("bad template specialization kind");
+ return isTemplateExplicitInstantiationOrSpecialization(
+ getTemplateSpecializationKind());
}
/// \brief Set the template specialization kind.
@@ -1644,17 +1635,8 @@ public:
/// explicit instantiation declaration, or explicit instantiation
/// definition.
bool isExplicitInstantiationOrSpecialization() const {
- switch (getTemplateSpecializationKind()) {
- case TSK_ExplicitSpecialization:
- case TSK_ExplicitInstantiationDeclaration:
- case TSK_ExplicitInstantiationDefinition:
- return true;
-
- case TSK_Undeclared:
- case TSK_ImplicitInstantiation:
- return false;
- }
- llvm_unreachable("bad template specialization kind");
+ return isTemplateExplicitInstantiationOrSpecialization(
+ getTemplateSpecializationKind());
}
void setSpecializationKind(TemplateSpecializationKind TSK) {
@@ -2499,17 +2481,8 @@ public:
/// explicit instantiation declaration, or explicit instantiation
/// definition.
bool isExplicitInstantiationOrSpecialization() const {
- switch (getTemplateSpecializationKind()) {
- case TSK_ExplicitSpecialization:
- case TSK_ExplicitInstantiationDeclaration:
- case TSK_ExplicitInstantiationDefinition:
- return true;
-
- case TSK_Undeclared:
- case TSK_ImplicitInstantiation:
- return false;
- }
- llvm_unreachable("bad template specialization kind");
+ return isTemplateExplicitInstantiationOrSpecialization(
+ getTemplateSpecializationKind());
}
void setSpecializationKind(TemplateSpecializationKind TSK) {
Modified: cfe/trunk/include/clang/Basic/Specifiers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Specifiers.h?rev=253046&r1=253045&r2=253046&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Specifiers.h (original)
+++ cfe/trunk/include/clang/Basic/Specifiers.h Fri Nov 13 09:39:39 2015
@@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/ErrorHandling.h"
namespace clang {
/// \brief Specifies the width of a type, e.g., short, long, or long long.
@@ -157,6 +158,24 @@ namespace clang {
return Kind != TSK_Undeclared && Kind != TSK_ExplicitSpecialization;
}
+ /// \brief True if this template specialization kind is an explicit
+ /// specialization, explicit instantiation declaration, or explicit
+ /// instantiation definition.
+ inline bool isTemplateExplicitInstantiationOrSpecialization(
+ TemplateSpecializationKind Kind) {
+ switch (Kind) {
+ case TSK_ExplicitSpecialization:
+ case TSK_ExplicitInstantiationDeclaration:
+ case TSK_ExplicitInstantiationDefinition:
+ return true;
+
+ case TSK_Undeclared:
+ case TSK_ImplicitInstantiation:
+ return false;
+ }
+ llvm_unreachable("bad template specialization kind");
+ }
+
/// \brief Thread storage-class-specifier.
enum ThreadStorageClassSpecifier {
TSCS_unspecified,
More information about the cfe-commits
mailing list