[cfe-commits] r161647 - in /cfe/trunk: include/clang/AST/DeclCXX.h include/clang/AST/Type.h lib/AST/DeclPrinter.cpp lib/AST/DumpXML.cpp lib/AST/Expr.cpp lib/AST/ExprCXX.cpp lib/Sema/SemaCodeComplete.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaLambda.cpp
David Blaikie
dblaikie at gmail.com
Thu Aug 9 17:55:36 PDT 2012
Author: dblaikie
Date: Thu Aug 9 19:55:35 2012
New Revision: 161647
URL: http://llvm.org/viewvc/llvm-project?rev=161647&view=rev
Log:
Provide isConst/Volatile on CXXMethodDecl.
This also provides isConst/Volatile/Restrict on FunctionTypes to coalesce
the implementation with other callers (& update those other callers).
Patch contributed by Sam Panzer (panzer at google.com).
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/DumpXML.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug 9 19:55:35 2012
@@ -1549,6 +1549,9 @@
bool isStatic() const { return getStorageClass() == SC_Static; }
bool isInstance() const { return !isStatic(); }
+ bool isConst() { return getType()->castAs<FunctionType>()->isConst(); }
+ bool isVolatile() { return getType()->castAs<FunctionType>()->isVolatile(); }
+
bool isVirtual() const {
CXXMethodDecl *CD =
cast<CXXMethodDecl>(const_cast<CXXMethodDecl*>(this)->getCanonicalDecl());
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Aug 9 19:55:35 2012
@@ -2676,6 +2676,9 @@
bool getNoReturnAttr() const { return getExtInfo().getNoReturn(); }
CallingConv getCallConv() const { return getExtInfo().getCC(); }
ExtInfo getExtInfo() const { return ExtInfo(FunctionTypeBits.ExtInfo); }
+ bool isConst() const { return getTypeQuals() & Qualifiers::Const; }
+ bool isVolatile() const { return getTypeQuals() & Qualifiers::Volatile; }
+ bool isRestrict() const { return getTypeQuals() & Qualifiers::Restrict; }
/// \brief Determine the type of an expression that calls a function of
/// this type.
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Thu Aug 9 19:55:35 2012
@@ -440,13 +440,12 @@
Proto += ")";
- if (FT && FT->getTypeQuals()) {
- unsigned TypeQuals = FT->getTypeQuals();
- if (TypeQuals & Qualifiers::Const)
+ if (FT) {
+ if (FT->isConst())
Proto += " const";
- if (TypeQuals & Qualifiers::Volatile)
+ if (FT->isVolatile())
Proto += " volatile";
- if (TypeQuals & Qualifiers::Restrict)
+ if (FT->isRestrict())
Proto += " restrict";
}
Modified: cfe/trunk/lib/AST/DumpXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DumpXML.cpp?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DumpXML.cpp (original)
+++ cfe/trunk/lib/AST/DumpXML.cpp Thu Aug 9 19:55:35 2012
@@ -971,9 +971,9 @@
}
void visitFunctionProtoTypeAttrs(FunctionProtoType *T) {
- setFlag("const", T->getTypeQuals() & Qualifiers::Const);
- setFlag("volatile", T->getTypeQuals() & Qualifiers::Volatile);
- setFlag("restrict", T->getTypeQuals() & Qualifiers::Restrict);
+ setFlag("const", T->isConst());
+ setFlag("volatile", T->isVolatile());
+ setFlag("restrict", T->isRestrict());
}
void visitFunctionProtoTypeChildren(FunctionProtoType *T) {
push("parameters");
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Aug 9 19:55:35 2012
@@ -211,7 +211,7 @@
if ((Ctx.getLangOpts().CPlusPlus0x ?
Var->getType()->isLiteralType() :
Var->getType()->isIntegralOrEnumerationType()) &&
- (Var->getType().getCVRQualifiers() == Qualifiers::Const ||
+ (Var->getType().isConstQualified() ||
Var->getType()->isReferenceType())) {
if (const Expr *Init = Var->getAnyInitializer())
if (Init->isValueDependent()) {
@@ -440,10 +440,10 @@
POut << ")";
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
- Qualifiers ThisQuals = Qualifiers::fromCVRMask(MD->getTypeQualifiers());
- if (ThisQuals.hasConst())
+ const FunctionType *FT = cast<FunctionType>(MD->getType().getTypePtr());
+ if (FT->isConst())
POut << " const";
- if (ThisQuals.hasVolatile())
+ if (FT->isVolatile())
POut << " volatile";
RefQualifierKind Ref = MD->getRefQualifier();
if (Ref == RQ_LValue)
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Thu Aug 9 19:55:35 2012
@@ -943,7 +943,7 @@
}
bool LambdaExpr::isMutable() const {
- return (getCallOperator()->getTypeQualifiers() & Qualifiers::Const) == 0;
+ return !getCallOperator()->isConst();
}
ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Aug 9 19:55:35 2012
@@ -2369,11 +2369,11 @@
// Handle multiple qualifiers.
std::string QualsStr;
- if (Proto->getTypeQuals() & Qualifiers::Const)
+ if (Proto->isConst())
QualsStr += " const";
- if (Proto->getTypeQuals() & Qualifiers::Volatile)
+ if (Proto->isVolatile())
QualsStr += " volatile";
- if (Proto->getTypeQuals() & Qualifiers::Restrict)
+ if (Proto->isRestrict())
QualsStr += " restrict";
Result.AddInformativeChunk(Result.getAllocator().CopyString(QualsStr));
}
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 9 19:55:35 2012
@@ -4852,7 +4852,7 @@
bool NewFDisConst = false;
if (CXXMethodDecl *NewMD = dyn_cast<CXXMethodDecl>(NewFD))
- NewFDisConst = NewMD->getTypeQualifiers() & Qualifiers::Const;
+ NewFDisConst = NewMD->isConst();
for (llvm::SmallVector<std::pair<FunctionDecl*, unsigned>, 1>::iterator
NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
@@ -4860,7 +4860,7 @@
FunctionDecl *FD = NearMatch->first;
bool FDisConst = false;
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
- FDisConst = MD->getTypeQualifiers() & Qualifiers::Const;
+ FDisConst = MD->isConst();
if (unsigned Idx = NearMatch->second) {
ParmVarDecl *FDParam = FD->getParamDecl(Idx-1);
Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=161647&r1=161646&r2=161647&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Thu Aug 9 19:55:35 2012
@@ -437,7 +437,7 @@
LambdaScopeInfo *LSI
= enterLambdaScope(Method, Intro.Range, Intro.Default, ExplicitParams,
ExplicitResultType,
- (Method->getTypeQualifiers() & Qualifiers::Const) == 0);
+ !Method->isConst());
// Handle explicit captures.
SourceLocation PrevCaptureLoc
More information about the cfe-commits
mailing list