From: Craig Topper Date: Thu, 22 Aug 2013 06:02:26 +0000 (+0000) Subject: Constify some more ASTContext& uses. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b4b98b7cb18cc4a99cca0aefa515cc8756dc06d;p=clang Constify some more ASTContext& uses. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188989 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 07e31530f6..4674ea0e71 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -380,7 +380,7 @@ public: /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST /// back to its original source language syntax. - void dumpPretty(ASTContext &Context) const; + void dumpPretty(const ASTContext &Context) const; void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation = 0) const; @@ -559,7 +559,7 @@ public: CompoundStmtBits.NumStmts = 0; } - void setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts); + void setStmts(const ASTContext &C, Stmt **Stmts, unsigned NumStmts); bool body_empty() const { return CompoundStmtBits.NumStmts == 0; } unsigned size() const { return CompoundStmtBits.NumStmts; } @@ -1406,7 +1406,7 @@ public: //===--- Asm String Analysis ---===// /// Assemble final IR asm string. - std::string generateAsmString(ASTContext &C) const; + std::string generateAsmString(const ASTContext &C) const; //===--- Output operands ---===// @@ -1575,10 +1575,10 @@ public: /// translation of strings from GCC syntax to LLVM IR syntax, and handles //// flattening of named references like %[foo] to Operand AsmStringPiece's. unsigned AnalyzeAsmString(SmallVectorImpl &Pieces, - ASTContext &C, unsigned &DiagOffs) const; + const ASTContext &C, unsigned &DiagOffs) const; /// Assemble final IR asm string. - std::string generateAsmString(ASTContext &C) const; + std::string generateAsmString(const ASTContext &C) const; //===--- Output operands ---===// @@ -1638,7 +1638,7 @@ public: } private: - void setOutputsAndInputsAndClobbers(ASTContext &C, + void setOutputsAndInputsAndClobbers(const ASTContext &C, IdentifierInfo **Names, StringLiteral **Constraints, Stmt **Exprs, @@ -1709,7 +1709,7 @@ public: StringRef getAsmString() const { return AsmStr; } /// Assemble final IR asm string. - std::string generateAsmString(ASTContext &C) const; + std::string generateAsmString(const ASTContext &C) const; //===--- Output operands ---===// diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index ff9e2721d2..2711e9ba97 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -264,7 +264,8 @@ CompoundStmt::CompoundStmt(const ASTContext &C, ArrayRef Stmts, std::copy(Stmts.begin(), Stmts.end(), Body); } -void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) { +void CompoundStmt::setStmts(const ASTContext &C, Stmt **Stmts, + unsigned NumStmts) { if (this->Body) C.Deallocate(Body); this->CompoundStmtBits.NumStmts = NumStmts; @@ -295,7 +296,7 @@ AttributedStmt *AttributedStmt::CreateEmpty(const ASTContext &C, return new (Mem) AttributedStmt(EmptyShell(), NumAttrs); } -std::string AsmStmt::generateAsmString(ASTContext &C) const { +std::string AsmStmt::generateAsmString(const ASTContext &C) const { if (const GCCAsmStmt *gccAsmStmt = dyn_cast(this)) return gccAsmStmt->generateAsmString(C); if (const MSAsmStmt *msAsmStmt = dyn_cast(this)) @@ -381,14 +382,14 @@ StringRef GCCAsmStmt::getInputConstraint(unsigned i) const { return getInputConstraintLiteral(i)->getString(); } -void GCCAsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C, - IdentifierInfo **Names, - StringLiteral **Constraints, - Stmt **Exprs, - unsigned NumOutputs, - unsigned NumInputs, - StringLiteral **Clobbers, - unsigned NumClobbers) { +void GCCAsmStmt::setOutputsAndInputsAndClobbers(const ASTContext &C, + IdentifierInfo **Names, + StringLiteral **Constraints, + Stmt **Exprs, + unsigned NumOutputs, + unsigned NumInputs, + StringLiteral **Clobbers, + unsigned NumClobbers) { this->NumOutputs = NumOutputs; this->NumInputs = NumInputs; this->NumClobbers = NumClobbers; @@ -436,7 +437,7 @@ int GCCAsmStmt::getNamedOperand(StringRef SymbolicName) const { /// it into pieces. If the asm string is erroneous, emit errors and return /// true, otherwise return false. unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl&Pieces, - ASTContext &C, unsigned &DiagOffs) const { + const ASTContext &C, unsigned &DiagOffs) const { StringRef Str = getAsmString()->getString(); const char *StrStart = Str.begin(); const char *StrEnd = Str.end(); @@ -574,7 +575,7 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl&Pieces, } /// Assemble final IR asm string (GCC-style). -std::string GCCAsmStmt::generateAsmString(ASTContext &C) const { +std::string GCCAsmStmt::generateAsmString(const ASTContext &C) const { // Analyze the asm string to decompose it into its pieces. We know that Sema // has already done this, so it is guaranteed to be successful. SmallVector Pieces; @@ -595,7 +596,7 @@ std::string GCCAsmStmt::generateAsmString(ASTContext &C) const { } /// Assemble final IR asm string (MS-style). -std::string MSAsmStmt::generateAsmString(ASTContext &C) const { +std::string MSAsmStmt::generateAsmString(const ASTContext &C) const { // FIXME: This needs to be translated into the IR string representation. return AsmStr; } diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index c1732cdfd1..d59475e48c 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -1960,7 +1960,7 @@ void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) { // Stmt method implementations //===----------------------------------------------------------------------===// -void Stmt::dumpPretty(ASTContext &Context) const { +void Stmt::dumpPretty(const ASTContext &Context) const { printPretty(llvm::errs(), 0, PrintingPolicy(Context.getLangOpts())); }