[cfe-commits] r124035 - in /cfe/trunk: include/clang/Sema/DeclSpec.h lib/Parse/ParseDeclCXX.cpp lib/Sema/DeclSpec.cpp
Anders Carlsson
andersca at mac.com
Sat Jan 22 07:58:16 PST 2011
Author: andersca
Date: Sat Jan 22 09:58:16 2011
New Revision: 124035
URL: http://llvm.org/viewvc/llvm-project?rev=124035&view=rev
Log:
More work on ClassVirtSpecifiers.
Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=124035&r1=124034&r2=124035&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Sat Jan 22 09:58:16 2011
@@ -1480,8 +1480,8 @@
VirtSpecifiers() : Specifiers(0) { }
- bool SetVirtSpecifier(VirtSpecifier VS, SourceLocation Loc,
- const char *&PrevSpec);
+ bool SetSpecifier(VirtSpecifier VS, SourceLocation Loc,
+ const char *&PrevSpec);
bool isOverrideSpecified() const { return Specifiers & VS_Override; }
SourceLocation getOverrideLoc() const { return VS_overrideLoc; }
@@ -1512,6 +1512,9 @@
ClassVirtSpecifiers() : Specifiers(0) { }
+ bool SetSpecifier(ClassVirtSpecifier CVS, SourceLocation Loc,
+ const char *&PrevSpec);
+
bool isFinalSpecified() const { return Specifiers & CVS_Final; }
SourceLocation getFinalLoc() const { return CVS_finalLoc; }
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=124035&r1=124034&r2=124035&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sat Jan 22 09:58:16 2011
@@ -1308,7 +1308,7 @@
// C++ [class.mem]p8:
// A virt-specifier-seq shall contain at most one of each virt-specifier.
const char* PrevSpec = 0;
- if (VS.SetVirtSpecifier(Specifier, Tok.getLocation(), PrevSpec))
+ if (VS.SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
<< PrevSpec
<< FixItHint::CreateRemoval(Tok.getLocation());
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=124035&r1=124034&r2=124035&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Sat Jan 22 09:58:16 2011
@@ -669,8 +669,8 @@
}
}
-bool VirtSpecifiers::SetVirtSpecifier(VirtSpecifier VS, SourceLocation Loc,
- const char *&PrevSpec) {
+bool VirtSpecifiers::SetSpecifier(VirtSpecifier VS, SourceLocation Loc,
+ const char *&PrevSpec) {
if (Specifiers & VS) {
PrevSpec = getSpecifierName(VS);
return true;
@@ -684,6 +684,7 @@
case VS_Final: VS_finalLoc = Loc; break;
case VS_New: VS_newLoc = Loc; break;
}
+
return false;
}
@@ -695,3 +696,31 @@
case VS_New: return "new";
}
}
+
+bool ClassVirtSpecifiers::SetSpecifier(ClassVirtSpecifier CVS,
+ SourceLocation Loc,
+ const char *&PrevSpec) {
+ if (Specifiers & CVS) {
+ PrevSpec = getSpecifierName(CVS);
+ return true;
+ }
+
+ Specifiers |= CVS;
+
+ switch (CVS) {
+ default: assert(0 && "Unknown specifier!");
+ case CVS_Final: CVS_finalLoc = Loc; break;
+ case CVS_Explicit: CVS_explicitLoc = Loc; break;
+ }
+
+ return false;
+}
+
+const char *ClassVirtSpecifiers::getSpecifierName(ClassVirtSpecifier CVS) {
+ switch (CVS) {
+ default: assert(0 && "Unknown specifier");
+ case CVS_Final: return "final";
+ case CVS_Explicit: return "explicit";
+ }
+}
+
More information about the cfe-commits
mailing list