From benny.kra at googlemail.com Mon Sep 7 06:12:05 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 07 Sep 2009 11:12:05 -0000 Subject: [cfe-commits] r81147 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp Message-ID: <200909071112.n87BC6BV020129@zion.cs.uiuc.edu> Author: d0k Date: Mon Sep 7 06:12:05 2009 New Revision: 81147 URL: http://llvm.org/viewvc/llvm-project?rev=81147&view=rev Log: Remove unnecessary #include . Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=81147&r1=81146&r2=81147&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Sep 7 06:12:05 2009 @@ -30,7 +30,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetData.h" -#include #include using namespace clang; From benny.kra at googlemail.com Mon Sep 7 07:33:47 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 07 Sep 2009 12:33:47 -0000 Subject: [cfe-commits] r81150 - in /cfe/trunk/lib: AST/StmtViz.cpp Frontend/RewriteBlocks.cpp Message-ID: <200909071233.n87CXl9q030874@zion.cs.uiuc.edu> Author: d0k Date: Mon Sep 7 07:33:46 2009 New Revision: 81150 URL: http://llvm.org/viewvc/llvm-project?rev=81150&view=rev Log: More removal. Modified: cfe/trunk/lib/AST/StmtViz.cpp cfe/trunk/lib/Frontend/RewriteBlocks.cpp Modified: cfe/trunk/lib/AST/StmtViz.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtViz.cpp?rev=81150&r1=81149&r2=81150&view=diff ============================================================================== --- cfe/trunk/lib/AST/StmtViz.cpp (original) +++ cfe/trunk/lib/AST/StmtViz.cpp Mon Sep 7 07:33:46 2009 @@ -15,7 +15,6 @@ #include "clang/AST/StmtGraphTraits.h" #include "clang/AST/Decl.h" #include "llvm/Support/GraphWriter.h" -#include using namespace clang; Modified: cfe/trunk/lib/Frontend/RewriteBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteBlocks.cpp?rev=81150&r1=81149&r2=81150&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/RewriteBlocks.cpp (original) +++ cfe/trunk/lib/Frontend/RewriteBlocks.cpp Mon Sep 7 07:33:46 2009 @@ -22,7 +22,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SmallPtrSet.h" -#include using namespace clang; using llvm::utostr; From andersca at mac.com Mon Sep 7 13:25:50 2009 From: andersca at mac.com (Anders Carlsson) Date: Mon, 07 Sep 2009 18:25:50 -0000 Subject: [cfe-commits] r81151 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaCXXCast.cpp test/SemaCXX/static-cast-complete-type.cpp Message-ID: <200909071825.n87IPpZm011375@zion.cs.uiuc.edu> Author: andersca Date: Mon Sep 7 13:25:47 2009 New Revision: 81151 URL: http://llvm.org/viewvc/llvm-project?rev=81151&view=rev Log: Check that the destination type of a static_cast expression is a complete type. Added: cfe/trunk/test/SemaCXX/static-cast-complete-type.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaCXXCast.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=81151&r1=81150&r2=81151&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep 7 13:25:47 2009 @@ -1515,6 +1515,7 @@ "cannot cast from type %1 to pointer type %2">; def err_bad_static_cast_member_pointer_nonmp : Error< "cannot cast from type %1 to member pointer type %2">; +def err_bad_static_cast_incomplete : Error<"%0 is an incomplete type">; // These messages don't adhere to the pattern. // FIXME: Display the path somehow better. Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=81151&r1=81150&r2=81151&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original) +++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Mon Sep 7 13:25:47 2009 @@ -759,6 +759,14 @@ bool CStyle, const SourceRange &OpRange, unsigned &msg, CXXMethodDecl *&ConversionDecl) { + if (DestType->isRecordType()) { + if (Self.RequireCompleteType(OpRange.getBegin(), DestType, + diag::err_bad_dynamic_cast_incomplete)) { + msg = 0; + return TC_Failed; + } + } + if (DestType->isReferenceType()) { // At this point of CheckStaticCast, if the destination is a reference, // this has to work. There is no other way that works. Added: cfe/trunk/test/SemaCXX/static-cast-complete-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-cast-complete-type.cpp?rev=81151&view=auto ============================================================================== --- cfe/trunk/test/SemaCXX/static-cast-complete-type.cpp (added) +++ cfe/trunk/test/SemaCXX/static-cast-complete-type.cpp Mon Sep 7 13:25:47 2009 @@ -0,0 +1,13 @@ +// RUN: clang-cc -fsyntax-only -verify %s +template struct S { + S(int); +}; + +struct T; // expected-note{{forward declaration of 'struct T'}} + +void f() { + S s0 = static_cast >(0); + S s1 = static_cast >(00); + + (void)static_cast(10); // expected-error{{'struct T' is an incomplete type}} +} From andersca at mac.com Mon Sep 7 17:23:31 2009 From: andersca at mac.com (Anders Carlsson) Date: Mon, 07 Sep 2009 22:23:31 -0000 Subject: [cfe-commits] r81160 - in /cfe/trunk/lib/Sema: Sema.h SemaDecl.cpp SemaDeclCXX.cpp SemaExprCXX.cpp SemaInit.cpp TreeTransform.h Message-ID: <200909072223.n87MNW2U009459@zion.cs.uiuc.edu> Author: andersca Date: Mon Sep 7 17:23:31 2009 New Revision: 81160 URL: http://llvm.org/viewvc/llvm-project?rev=81160&view=rev Log: BuildCXXConstructExpr now takes a MultiExprArg. Modified: cfe/trunk/lib/Sema/Sema.h cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/TreeTransform.h Modified: cfe/trunk/lib/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=81160&r1=81159&r2=81160&view=diff ============================================================================== --- cfe/trunk/lib/Sema/Sema.h (original) +++ cfe/trunk/lib/Sema/Sema.h Mon Sep 7 17:23:31 2009 @@ -1810,14 +1810,14 @@ bool InitializeVarWithConstructor(VarDecl *VD, CXXConstructorDecl *Constructor, QualType DeclInitType, - Expr **Exprs, unsigned NumExprs); + MultiExprArg Exprs); /// BuildCXXConstructExpr - Creates a complete call to a constructor, /// including handling of its default argument expressions. OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, - Expr **Exprs, unsigned NumExprs); + MultiExprArg Exprs); // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if // the constructor can be elidable? @@ -1825,7 +1825,7 @@ QualType DeclInitType, CXXConstructorDecl *Constructor, bool Elidable, - Expr **Exprs, unsigned NumExprs); + MultiExprArg Exprs); OwningExprResult BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Cons, QualType writtenTy, Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=81160&r1=81159&r2=81160&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Sep 7 17:23:31 2009 @@ -3284,7 +3284,8 @@ Var->setInvalidDecl(); else { if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor()) { - if (InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0)) + if (InitializeVarWithConstructor(Var, Constructor, InitType, + MultiExprArg(*this))) Var->setInvalidDecl(); } Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=81160&r1=81159&r2=81160&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Sep 7 17:23:31 2009 @@ -2809,8 +2809,8 @@ Sema::OwningExprResult Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, - CXXConstructorDecl *Constructor, - Expr **Exprs, unsigned NumExprs) { + CXXConstructorDecl *Constructor, + MultiExprArg ExprArgs) { bool Elidable = false; // [class.copy]p15: @@ -2821,8 +2821,8 @@ //all, even if the class copy constructor or destructor have side effects. // FIXME: Is this enough? - if (Constructor->isCopyConstructor(Context) && NumExprs == 1) { - Expr *E = Exprs[0]; + if (Constructor->isCopyConstructor(Context) && ExprArgs.size() == 1) { + Expr *E = ((Expr **)ExprArgs.get())[0]; while (CXXBindTemporaryExpr *BE = dyn_cast(E)) E = BE->getSubExpr(); @@ -2831,7 +2831,7 @@ } return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor, - Elidable, Exprs, NumExprs); + Elidable, move(ExprArgs)); } /// BuildCXXConstructExpr - Creates a complete call to a constructor, @@ -2839,7 +2839,10 @@ Sema::OwningExprResult Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, bool Elidable, - Expr **Exprs, unsigned NumExprs) { + MultiExprArg ExprArgs) { + unsigned NumExprs = ExprArgs.size(); + Expr **Exprs = (Expr **)ExprArgs.release(); + ExprOwningPtr Temp(this, CXXConstructExpr::Create(Context, DeclInitType, @@ -2897,10 +2900,10 @@ bool Sema::InitializeVarWithConstructor(VarDecl *VD, CXXConstructorDecl *Constructor, QualType DeclInitType, - Expr **Exprs, unsigned NumExprs) { + MultiExprArg Exprs) { OwningExprResult TempResult = BuildCXXConstructExpr(VD->getLocation(), DeclInitType, Constructor, - Exprs, NumExprs); + move(Exprs)); if (TempResult.isInvalid()) return true; @@ -3003,7 +3006,7 @@ else { VDecl->setCXXDirectInitializer(true); if (InitializeVarWithConstructor(VDecl, Constructor, DeclInitType, - (Expr**)Exprs.release(), NumExprs)) + move(Exprs))) RealDecl->setInvalidDecl(); FinalizeVarWithDestructor(VDecl, DeclInitType); } Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=81160&r1=81159&r2=81160&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Sep 7 17:23:31 2009 @@ -942,8 +942,8 @@ DefaultFunctionArrayConversion(From); OwningExprResult InitResult = BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(), - ToType.getNonReferenceType(), - CD, &From, 1); + ToType.getNonReferenceType(), CD, + MultiExprArg(*this, (void**)&From, 1)); // Take ownership of this expression. From = InitResult.takeAs(); CastKind = CastExpr::CK_ConstructorConversion ; @@ -988,7 +988,8 @@ OwningExprResult FromResult = BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(), - ToType, SCS.CopyConstructor, &From, 1); + ToType, SCS.CopyConstructor, + MultiExprArg(*this, (void**)&From, 1)); if (FromResult.isInvalid()) return true; Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=81160&r1=81159&r2=81160&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Sep 7 17:23:31 2009 @@ -182,7 +182,8 @@ OwningExprResult InitResult = BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(), - DeclType, Constructor, &Init, 1); + DeclType, Constructor, + MultiExprArg(*this, (void**)&Init, 1)); if (InitResult.isInvalid()) return true; Modified: cfe/trunk/lib/Sema/TreeTransform.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=81160&r1=81159&r2=81160&view=diff ============================================================================== --- cfe/trunk/lib/Sema/TreeTransform.h (original) +++ cfe/trunk/lib/Sema/TreeTransform.h Mon Sep 7 17:23:31 2009 @@ -1448,12 +1448,10 @@ CXXConstructorDecl *Constructor, bool IsElidable, MultiExprArg Args) { - unsigned NumArgs = Args.size(); - Expr **ArgsExprs = (Expr **)Args.release(); return getSema().BuildCXXConstructExpr(/*FIXME:ConstructLoc*/ SourceLocation(), T, Constructor, IsElidable, - ArgsExprs, NumArgs); + move(Args)); } /// \brief Build a new object-construction expression. From daniel at zuster.org Mon Sep 7 18:07:56 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 07 Sep 2009 23:07:56 -0000 Subject: [cfe-commits] r81169 - /cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Message-ID: <200909072307.n87N7vvb015225@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Sep 7 18:07:56 2009 New Revision: 81169 URL: http://llvm.org/viewvc/llvm-project?rev=81169&view=rev Log: Remove trailing whitespace. Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=81169&r1=81168&r2=81169&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original) +++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Mon Sep 7 18:07:56 2009 @@ -66,7 +66,7 @@ SourceLocation Begin = SM.getInstantiationLoc(R.getBegin()); SourceLocation End = SM.getInstantiationLoc(R.getEnd()); - + // If the End location and the start location are the same and are a macro // location, then the range was something that came from a macro expansion // or _Pragma. If this is an object-like macro, the best we can do is to @@ -74,15 +74,15 @@ // highlight the arguments. if (Begin == End && R.getEnd().isMacroID()) End = SM.getInstantiationRange(R.getEnd()).second; - + unsigned StartLineNo = SM.getInstantiationLineNumber(Begin); if (StartLineNo > LineNo || SM.getFileID(Begin) != FID) return; // No intersection. - + unsigned EndLineNo = SM.getInstantiationLineNumber(End); if (EndLineNo < LineNo || SM.getFileID(End) != FID) return; // No intersection. - + // Compute the column number of the start. unsigned StartColNo = 0; if (StartLineNo == LineNo) { @@ -94,21 +94,21 @@ while (StartColNo < SourceLine.size() && (SourceLine[StartColNo] == ' ' || SourceLine[StartColNo] == '\t')) ++StartColNo; - + // Compute the column number of the end. unsigned EndColNo = CaretLine.size(); if (EndLineNo == LineNo) { EndColNo = SM.getInstantiationColumnNumber(End); if (EndColNo) { --EndColNo; // Zero base the col #. - + // Add in the length of the token, so that we cover multi-char tokens. EndColNo += Lexer::MeasureTokenLength(End, SM, *LangOpts); } else { EndColNo = CaretLine.size(); } } - + // Pick the last non-whitespace column. if (EndColNo <= SourceLine.size()) while (EndColNo-1 && @@ -116,7 +116,7 @@ --EndColNo; else EndColNo = SourceLine.size(); - + // Fill the range with ~'s. assert(StartColNo <= EndColNo && "Invalid range!"); for (unsigned i = StartColNo; i < EndColNo; ++i) @@ -156,7 +156,7 @@ for (; FixItStart != FixItEnd; ++FixItStart) if (!isspace(FixItInsertionLine[FixItStart])) break; - + for (; FixItEnd != FixItStart; --FixItEnd) if (!isspace(FixItInsertionLine[FixItEnd - 1])) break; @@ -189,16 +189,16 @@ CaretStart = 0; else if (CaretStart > 1) { unsigned NewStart = CaretStart - 1; - + // Skip over any whitespace we see here; we're looking for // another bit of interesting text. while (NewStart && isspace(SourceLine[NewStart])) --NewStart; - + // Skip over this bit of "interesting" text. while (NewStart && !isspace(SourceLine[NewStart])) --NewStart; - + // Move up to the non-whitespace character we just saw. if (NewStart) ++NewStart; @@ -220,7 +220,7 @@ // another bit of interesting text. while (NewEnd != SourceLength && isspace(SourceLine[NewEnd - 1])) ++NewEnd; - + // Skip over this bit of "interesting" text. while (NewEnd != SourceLength && !isspace(SourceLine[NewEnd - 1])) ++NewEnd; @@ -244,7 +244,7 @@ CaretLine.erase(CaretEnd, std::string::npos); if (FixItInsertionLine.size() > CaretEnd) FixItInsertionLine.erase(CaretEnd, std::string::npos); - + if (CaretStart > 2) { SourceLine.replace(0, CaretStart, " ..."); CaretLine.replace(0, CaretStart, " "); @@ -271,7 +271,7 @@ EmitCaretDiagnostic(OneLevelUp, Ranges, NumRanges, SM, 0, 0, Columns); Loc = SM.getImmediateSpellingLoc(Loc); - + // Map the ranges. for (unsigned i = 0; i != NumRanges; ++i) { SourceLocation S = Ranges[i].getBegin(), E = Ranges[i].getEnd(); @@ -279,10 +279,10 @@ if (E.isMacroID()) E = SM.getImmediateSpellingLoc(E); Ranges[i] = SourceRange(S, E); } - + if (ShowLocation) { std::pair IInfo = SM.getDecomposedInstantiationLoc(Loc); - + // Emit the file/line/column that this expansion came from. OS << SM.getBuffer(IInfo.first)->getBufferIdentifier() << ':' << SM.getLineNumber(IInfo.first, IInfo.second) << ':'; @@ -291,75 +291,75 @@ OS << ' '; } OS << "note: instantiated from:\n"; - + EmitCaretDiagnostic(Loc, Ranges, NumRanges, SM, Hints, NumHints, Columns); return; } - + // Decompose the location into a FID/Offset pair. std::pair LocInfo = SM.getDecomposedLoc(Loc); FileID FID = LocInfo.first; unsigned FileOffset = LocInfo.second; - + // Get information about the buffer it points into. std::pair BufferInfo = SM.getBufferData(FID); const char *BufStart = BufferInfo.first; unsigned ColNo = SM.getColumnNumber(FID, FileOffset); - unsigned CaretEndColNo + unsigned CaretEndColNo = ColNo + Lexer::MeasureTokenLength(Loc, SM, *LangOpts); // Rewind from the current position to the start of the line. const char *TokPtr = BufStart+FileOffset; const char *LineStart = TokPtr-ColNo+1; // Column # is 1-based. - - + + // Compute the line end. Scan forward from the error position to the end of // the line. const char *LineEnd = TokPtr; while (*LineEnd != '\n' && *LineEnd != '\r' && *LineEnd != '\0') ++LineEnd; - + // Copy the line of code into an std::string for ease of manipulation. std::string SourceLine(LineStart, LineEnd); - + // Create a line for the caret that is filled with spaces that is the same // length as the line of source code. std::string CaretLine(LineEnd-LineStart, ' '); - + // Highlight all of the characters covered by Ranges with ~ characters. if (NumRanges) { unsigned LineNo = SM.getLineNumber(FID, FileOffset); - + for (unsigned i = 0, e = NumRanges; i != e; ++i) HighlightRange(Ranges[i], SM, LineNo, FID, CaretLine, SourceLine); } - + // Next, insert the caret itself. if (ColNo-1 < CaretLine.size()) CaretLine[ColNo-1] = '^'; else CaretLine.push_back('^'); - + // Scan the source line, looking for tabs. If we find any, manually expand // them to 8 characters and update the CaretLine to match. for (unsigned i = 0; i != SourceLine.size(); ++i) { if (SourceLine[i] != '\t') continue; - + // Replace this tab with at least one space. SourceLine[i] = ' '; - + // Compute the number of spaces we need to insert. unsigned NumSpaces = ((i+8)&~7) - (i+1); assert(NumSpaces < 8 && "Invalid computation of space amt"); - + // Insert spaces into the SourceLine. SourceLine.insert(i+1, NumSpaces, ' '); - + // Insert spaces or ~'s into CaretLine. CaretLine.insert(i+1, NumSpaces, CaretLine[i] == '~' ? '~' : ' '); } - + // If we are in -fdiagnostics-print-source-range-info mode, we are trying to // produce easily machine parsable output. Add a space before the source line // and the caret to make it trivial to tell the main diagnostic line from what @@ -368,7 +368,7 @@ SourceLine = ' ' + SourceLine; CaretLine = ' ' + CaretLine; } - + std::string FixItInsertionLine; if (NumHints && PrintFixItInfo) { for (const CodeModificationHint *Hint = Hints, *LastHint = Hints + NumHints; @@ -376,15 +376,15 @@ if (Hint->InsertionLoc.isValid()) { // We have an insertion hint. Determine whether the inserted // code is on the same line as the caret. - std::pair HintLocInfo + std::pair HintLocInfo = SM.getDecomposedInstantiationLoc(Hint->InsertionLoc); if (SM.getLineNumber(HintLocInfo.first, HintLocInfo.second) == SM.getLineNumber(FID, FileOffset)) { // Insert the new code into the line just below the code // that the user wrote. - unsigned HintColNo + unsigned HintColNo = SM.getColumnNumber(HintLocInfo.first, HintLocInfo.second); - unsigned LastColumnModified + unsigned LastColumnModified = HintColNo - 1 + Hint->CodeToInsert.size(); if (LastColumnModified > FixItInsertionLine.size()) FixItInsertionLine.resize(LastColumnModified, ' '); @@ -407,7 +407,7 @@ // Finally, remove any blank spaces from the end of CaretLine. while (CaretLine[CaretLine.size()-1] == ' ') CaretLine.erase(CaretLine.end()-1); - + // Emit what we have computed. OS << SourceLine << '\n'; @@ -421,7 +421,7 @@ if (UseColors) // Print fixit line in color OS.changeColor(fixitColor, false); - if (PrintRangeInfo) + if (PrintRangeInfo) OS << ' '; OS << FixItInsertionLine << '\n'; if (UseColors) @@ -435,7 +435,7 @@ /// \returns The index of the first non-whitespace character that is /// greater than or equal to Idx or, if no such character exists, /// returns the end of the string. -static unsigned skipWhitespace(unsigned Idx, +static unsigned skipWhitespace(unsigned Idx, const llvm::SmallVectorImpl &Str, unsigned Length) { while (Idx < Length && isspace(Str[Idx])) @@ -455,7 +455,7 @@ case '`': return '\''; case '"': return '"'; case '(': return ')'; - case '[': return ']'; + case '[': return ']'; case '{': return '}'; default: break; } @@ -468,9 +468,9 @@ /// /// \returns the index pointing one character past the end of the /// word. -unsigned findEndOfWord(unsigned Start, +unsigned findEndOfWord(unsigned Start, const llvm::SmallVectorImpl &Str, - unsigned Length, unsigned Column, + unsigned Length, unsigned Column, unsigned Columns) { unsigned End = Start + 1; @@ -535,13 +535,13 @@ /// /// \returns true if word-wrapping was required, or false if the /// string fit on the first line. -static bool PrintWordWrapped(llvm::raw_ostream &OS, - const llvm::SmallVectorImpl &Str, - unsigned Columns, +static bool PrintWordWrapped(llvm::raw_ostream &OS, + const llvm::SmallVectorImpl &Str, + unsigned Columns, unsigned Column = 0, unsigned Indentation = WordWrapIndentation) { unsigned Length = Str.size(); - + // If there is a newline in this message somewhere, find that // newline and split the message into the part before the newline // (which will be word-wrapped) and the part from the newline one @@ -556,7 +556,7 @@ llvm::SmallString<16> IndentStr; IndentStr.assign(Indentation, ' '); bool Wrapped = false; - for (unsigned WordStart = 0, WordEnd; WordStart < Length; + for (unsigned WordStart = 0, WordEnd; WordStart < Length; WordStart = WordEnd) { // Find the beginning of the next word. WordStart = skipWhitespace(WordStart, Str, Length); @@ -565,7 +565,7 @@ // Find the end of this word. WordEnd = findEndOfWord(WordStart, Str, Length, Column, Columns); - + // Does this word fit on the current line? unsigned WordLength = WordEnd - WordStart; if (Column + WordLength < Columns) { @@ -587,7 +587,7 @@ Column = Indentation + WordLength; Wrapped = true; } - + if (Length == Str.size()) return Wrapped; // We're done. @@ -597,7 +597,7 @@ return true; } -void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, +void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, const DiagnosticInfo &Info) { // Keeps track of the the starting position of the location // information (e.g., "foo.c:10:4:") that precedes the error @@ -611,7 +611,7 @@ const SourceManager &SM = Info.getLocation().getManager(); PresumedLoc PLoc = SM.getPresumedLoc(Info.getLocation()); unsigned LineNo = PLoc.getLine(); - + // First, if this diagnostic is not in the main file, print out the // "included from" lines. if (LastWarningLoc != PLoc.getIncludeLoc()) { @@ -619,7 +619,7 @@ PrintIncludeStack(LastWarningLoc, SM); StartOfLocationInfo = OS.tell(); } - + // Compute the column number. if (ShowLocation) { if (UseColors) @@ -628,12 +628,12 @@ if (ShowColumn) if (unsigned ColNo = PLoc.getColumn()) OS << ColNo << ':'; - + if (PrintRangeInfo && Info.getNumRanges()) { FileID CaretFileID = SM.getFileID(SM.getInstantiationLoc(Info.getLocation())); bool PrintedRange = false; - + for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i) { // Ignore invalid ranges. if (!Info.getRange(i).isValid()) continue; @@ -642,7 +642,7 @@ SourceLocation E = Info.getRange(i).getEnd(); B = SM.getInstantiationLoc(B); E = SM.getInstantiationLoc(E); - + // If the End location and the start location are the same and are a // macro location, then the range was something that came from a macro // expansion or _Pragma. If this is an object-like macro, the best we @@ -653,22 +653,22 @@ std::pair BInfo = SM.getDecomposedLoc(B); std::pair EInfo = SM.getDecomposedLoc(E); - + // If the start or end of the range is in another file, just discard // it. if (BInfo.first != CaretFileID || EInfo.first != CaretFileID) continue; - + // Add in the length of the token, so that we cover multi-char tokens. unsigned TokSize = Lexer::MeasureTokenLength(E, SM, *LangOpts); - + OS << '{' << SM.getLineNumber(BInfo.first, BInfo.second) << ':' << SM.getColumnNumber(BInfo.first, BInfo.second) << '-' << SM.getLineNumber(EInfo.first, EInfo.second) << ':' << (SM.getColumnNumber(EInfo.first, EInfo.second)+TokSize) << '}'; PrintedRange = true; } - + if (PrintedRange) OS << ':'; } @@ -688,7 +688,7 @@ case Diagnostic::Fatal: OS.changeColor(fatalColor, true); break; } } - + switch (Level) { case Diagnostic::Ignored: assert(0 && "Invalid diagnostic type"); case Diagnostic::Note: OS << "note: "; break; @@ -702,14 +702,14 @@ llvm::SmallString<100> OutStr; Info.FormatDiagnostic(OutStr); - + if (PrintDiagnosticOption) if (const char *Opt = Diagnostic::getWarningOptionForDiag(Info.getID())) { OutStr += " [-W"; OutStr += Opt; OutStr += ']'; } - + if (UseColors) { // Print warnings, errors and fatal errors in bold, no color switch (Level) { @@ -732,7 +732,7 @@ OS << '\n'; if (UseColors) OS.resetColor(); - + // If caret diagnostics are enabled and we have location, we want to // emit the caret. However, we only do this if the location moved // from the last diagnostic, if the last diagnostic was a note that @@ -740,7 +740,7 @@ // diagnostic has ranges. We don't want to emit the same caret // multiple times if one loc has multiple diagnostics. if (CaretDiagnostics && Info.getLocation().isValid() && - ((LastLoc != Info.getLocation()) || Info.getNumRanges() || + ((LastLoc != Info.getLocation()) || Info.getNumRanges() || (LastCaretDiagnosticWasNote && Level != Diagnostic::Note) || Info.getNumCodeModificationHints())) { // Cache the LastLoc, it allows us to omit duplicate source/caret spewage. @@ -753,7 +753,7 @@ assert(NumRanges < 20 && "Out of space"); for (unsigned i = 0; i != NumRanges; ++i) Ranges[i] = Info.getRange(i); - + unsigned NumHints = Info.getNumCodeModificationHints(); for (unsigned idx = 0; idx < NumHints; ++idx) { const CodeModificationHint &Hint = Info.getCodeModificationHint(idx); @@ -768,6 +768,6 @@ Info.getNumCodeModificationHints(), MessageLength); } - + OS.flush(); } From sabre at nondot.org Mon Sep 7 19:36:37 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 08 Sep 2009 00:36:37 -0000 Subject: [cfe-commits] r81176 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/block-return.c Message-ID: <200909080036.n880abxA026466@zion.cs.uiuc.edu> Author: lattner Date: Mon Sep 7 19:36:37 2009 New Revision: 81176 URL: http://llvm.org/viewvc/llvm-project?rev=81176&view=rev Log: reject returning a block expr even when it has parens and casts in the way. Modified: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/Sema/block-return.c Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=81176&r1=81175&r2=81176&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Sep 7 19:36:37 2009 @@ -1254,9 +1254,7 @@ << DR->getDecl()->getDeclName() << RetValExp->getSourceRange(); // Skip over implicit cast expressions when checking for block expressions. - if (ImplicitCastExpr *IcExpr = - dyn_cast_or_null(RetValExp)) - RetValExp = IcExpr->getSubExpr(); + RetValExp = RetValExp->IgnoreParenCasts(); if (BlockExpr *C = dyn_cast_or_null(RetValExp)) if (C->hasBlockDeclRefExprs()) Modified: cfe/trunk/test/Sema/block-return.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=81176&r1=81175&r2=81176&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-return.c (original) +++ cfe/trunk/test/Sema/block-return.c Mon Sep 7 19:36:37 2009 @@ -91,6 +91,8 @@ if (j) return ^{ ^{ i=0; }(); }; // expected-error {{returning block that lives on the local stack}} return ^{ i=0; }; // expected-error {{returning block that lives on the local stack}} + return (^{ i=0; }); // expected-error {{returning block that lives on the local stack}} + return (void*)(^{ i=0; }); // expected-error {{returning block that lives on the local stack}} } int (*funcptr3[5])(long); From andersca at mac.com Mon Sep 7 20:23:37 2009 From: andersca at mac.com (Anders Carlsson) Date: Tue, 08 Sep 2009 01:23:37 -0000 Subject: [cfe-commits] r81178 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/AST/ExprCXX.cpp Message-ID: <200909080123.n881Nbp3032680@zion.cs.uiuc.edu> Author: andersca Date: Mon Sep 7 20:23:37 2009 New Revision: 81178 URL: http://llvm.org/viewvc/llvm-project?rev=81178&view=rev Log: Clean up the CXXConstructExpr constructor, add Arg getters. Modified: cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/lib/AST/ExprCXX.cpp Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=81178&r1=81177&r2=81178&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Sep 7 20:23:37 2009 @@ -517,6 +517,16 @@ unsigned getNumArgs() const { return NumArgs; } + /// getArg - Return the specified argument. + Expr *getArg(unsigned Arg) { + assert(Arg < NumArgs && "Arg access out of range!"); + return cast(Args[Arg]); + } + const Expr *getArg(unsigned Arg) const { + assert(Arg < NumArgs && "Arg access out of range!"); + return cast(Args[Arg]); + } + /// setArg - Set the specified argument. void setArg(unsigned Arg, Expr *ArgExpr) { assert(Arg < NumArgs && "Arg access out of range!"); Modified: cfe/trunk/lib/AST/ExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=81178&r1=81177&r2=81178&view=diff ============================================================================== --- cfe/trunk/lib/AST/ExprCXX.cpp (original) +++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Sep 7 20:23:37 2009 @@ -396,15 +396,22 @@ CallExpr::hasAnyValueDependentArguments(args, numargs))), Constructor(D), Elidable(elidable), Args(0), NumArgs(numargs) { // leave room for default arguments; - FunctionDecl *FDecl = cast(D); - unsigned NumArgsInProto = FDecl->param_size(); - NumArgs += (NumArgsInProto - numargs); - if (NumArgs > 0) { - Args = new (C) Stmt*[NumArgs]; - for (unsigned i = 0; i < numargs; ++i) + const FunctionProtoType *FTy = + cast(D)->getType()->getAsFunctionProtoType(); + + unsigned NumArgsInProto = FTy->getNumArgs(); + unsigned NumArgsToAllocate = FTy->isVariadic() ? NumArgs : NumArgsInProto; + if (NumArgsToAllocate) { + Args = new (C) Stmt*[NumArgsToAllocate]; + + for (unsigned i = 0; i != NumArgs; ++i) Args[i] = args[i]; - for (unsigned i = numargs; i < NumArgs; ++i) + + // Set default arguments to 0. + for (unsigned i = NumArgs; i != NumArgsToAllocate; ++i) Args[i] = 0; + + NumArgs = NumArgsToAllocate; } } From andersca at mac.com Mon Sep 7 20:48:42 2009 From: andersca at mac.com (Anders Carlsson) Date: Tue, 08 Sep 2009 01:48:42 -0000 Subject: [cfe-commits] r81181 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp test/SemaCXX/vararg-non-pod.cpp Message-ID: <200909080148.n881mhcj003499@zion.cs.uiuc.edu> Author: andersca Date: Mon Sep 7 20:48:42 2009 New Revision: 81181 URL: http://llvm.org/viewvc/llvm-project?rev=81181&view=rev Log: Handle variadic constructors better. Share code between BuildCXXConstructExpr and BuildCXXTemporaryObjectExpr. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/Sema.h cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/test/SemaCXX/vararg-non-pod.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=81181&r1=81180&r2=81181&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep 7 20:48:42 2009 @@ -1706,7 +1706,7 @@ def warn_cannot_pass_non_pod_arg_to_vararg : Warning< "cannot pass object of non-POD type %0 through variadic " - "%select{function|block|method}1; call will abort at runtime">; + "%select{function|block|method|constructor}1; call will abort at runtime">; def err_typecheck_call_invalid_ordered_compare : Error< "ordered compare requires two args of floating point type (%0 and %1)">; Modified: cfe/trunk/lib/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=81181&r1=81180&r2=81181&view=diff ============================================================================== --- cfe/trunk/lib/Sema/Sema.h (original) +++ cfe/trunk/lib/Sema/Sema.h Mon Sep 7 20:48:42 2009 @@ -3287,7 +3287,8 @@ enum VariadicCallType { VariadicFunction, VariadicBlock, - VariadicMethod + VariadicMethod, + VariadicConstructor }; // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=81181&r1=81180&r2=81181&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Sep 7 20:48:42 2009 @@ -2834,6 +2834,60 @@ Elidable, move(ExprArgs)); } +static bool +CheckConstructArgumentTypes(Sema &SemaRef, SourceLocation ConstructLoc, + CXXConstructExpr *E) { + CXXConstructorDecl *Ctor = E->getConstructor(); + const FunctionProtoType *Proto = Ctor->getType()->getAsFunctionProtoType(); + + unsigned NumArgs = E->getNumArgs(); + unsigned NumArgsInProto = Proto->getNumArgs(); + unsigned NumRequiredArgs = Ctor->getMinRequiredArguments(); + + for (unsigned i = 0; i != NumArgsInProto; ++i) { + QualType ProtoArgType = Proto->getArgType(i); + + Expr *Arg; + + if (i < NumRequiredArgs) { + Arg = E->getArg(i); + + // Pass the argument. + // FIXME: Do this. + } else { + // Build a default argument. + ParmVarDecl *Param = Ctor->getParamDecl(i); + + Sema::OwningExprResult ArgExpr = + SemaRef.BuildCXXDefaultArgExpr(ConstructLoc, Ctor, Param); + if (ArgExpr.isInvalid()) + return true; + + Arg = ArgExpr.takeAs(); + } + + E->setArg(i, Arg); + } + + // If this is a variadic call, handle args passed through "...". + if (Proto->isVariadic()) { + bool Invalid = false; + + // Promote the arguments (C99 6.5.2.2p7). + for (unsigned i = NumArgsInProto; i != NumArgs; i++) { + Expr *Arg = E->getArg(i); + Invalid |= + SemaRef.DefaultVariadicArgumentPromotion(Arg, + Sema::VariadicConstructor); + E->setArg(i, Arg); + } + + return Invalid; + } + + return false; +} + /// BuildCXXConstructExpr - Creates a complete call to a constructor, /// including handling of its default argument expressions. Sema::OwningExprResult @@ -2850,19 +2904,10 @@ Elidable, Exprs, NumExprs)); - // Default arguments must be added to constructor call expression. - FunctionDecl *FDecl = cast(Constructor); - unsigned NumArgsInProto = FDecl->param_size(); - for (unsigned j = NumExprs; j != NumArgsInProto; j++) { - ParmVarDecl *Param = FDecl->getParamDecl(j); - - OwningExprResult ArgExpr = - BuildCXXDefaultArgExpr(ConstructLoc, FDecl, Param); - if (ArgExpr.isInvalid()) - return ExprError(); + + if (CheckConstructArgumentTypes(*this, ConstructLoc, Temp.get())) + return ExprError(); - Temp->setArg(j, ArgExpr.takeAs()); - } return move(Temp); } @@ -2879,20 +2924,9 @@ ExprOwningPtr Temp(this, E); - // Default arguments must be added to constructor call expression. - FunctionDecl *FDecl = cast(Constructor); - unsigned NumArgsInProto = FDecl->param_size(); - for (unsigned j = Args.size(); j != NumArgsInProto; j++) { - ParmVarDecl *Param = FDecl->getParamDecl(j); - - OwningExprResult ArgExpr = BuildCXXDefaultArgExpr(TyBeginLoc, FDecl, Param); - if (ArgExpr.isInvalid()) - return ExprError(); - - Temp->setArg(j, ArgExpr.takeAs()); - } + if (CheckConstructArgumentTypes(*this, TyBeginLoc, Temp.get())) + return ExprError(); - Args.release(); return move(Temp); } Modified: cfe/trunk/test/SemaCXX/vararg-non-pod.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/vararg-non-pod.cpp?rev=81181&r1=81180&r2=81181&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/vararg-non-pod.cpp (original) +++ cfe/trunk/test/SemaCXX/vararg-non-pod.cpp Mon Sep 7 20:48:42 2009 @@ -51,6 +51,18 @@ D d; - d(10, c); // expected-warning{{Line 48: cannot pass object of non-POD type 'class C' through variadic method; call will abort at runtime}} + d(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic method; call will abort at runtime}} d(10, version); } + +class E { + E(int, ...); +}; + +void t5() +{ + C c(10); + + E e(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic constructor; call will abort at runtime}} + (void)E(10, c); // expected-warning{{cannot pass object of non-POD type 'class C' through variadic constructor; call will abort at runtime}} +} \ No newline at end of file From andersca at mac.com Mon Sep 7 20:49:08 2009 From: andersca at mac.com (Anders Carlsson) Date: Mon, 07 Sep 2009 18:49:08 -0700 Subject: [cfe-commits] r81123 - in /cfe/trunk: lib/AST/ExprCXX.cpp lib/Sema/SemaDeclCXX.cpp test/SemaTemplate/default-expr-arguments.cpp In-Reply-To: <4AA3F2F3.1090208@getdesigned.at> References: <200909061654.n86Gs2q3027612@zion.cs.uiuc.edu> <4AA3F2F3.1090208@getdesigned.at> Message-ID: <8B67C07C-6D26-4B3A-BD1A-153D23787711@mac.com> 6 sep 2009 kl. 10.35 skrev Sebastian Redl: > Anders Carlsson wrote: >> Author: andersca >> Date: Sun Sep 6 11:54:02 2009 >> New Revision: 81123 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=81123&view=rev >> Log: >> Reapply 81096, now with a fix. Spot the bug: >> >> for (unsigned i = numargs; i < NumArgs; ++i) >> Args[0] = 0; >> > Aside from the actual bug, wouldn't it also be a good idea to rename > one > of the two numargs variables? Turns out the code didn't handle variadic constructors, so I cleaned up the code in r81178. Anders -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/cfe-commits/attachments/20090907/713134ba/attachment.html From daniel at zuster.org Tue Sep 8 11:39:16 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 16:39:16 -0000 Subject: [cfe-commits] r81224 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/darwin-ld.c Message-ID: <200909081639.n88GdHBn002229@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 11:39:16 2009 New Revision: 81224 URL: http://llvm.org/viewvc/llvm-project?rev=81224&view=rev Log: Remove FIXMEs for pedantically-gcc-bug-compatible behavior. - We aren't going to fix these since they haven't caused problems in practice. - Similarly, don't forward -object to Darwin ld. Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/darwin-ld.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=81224&r1=81223&r2=81224&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Tue Sep 8 11:39:16 2009 @@ -77,6 +77,7 @@ CmdArgs.push_back(DepFile); // Add an -MT option if the user didn't specify their own. + // // FIXME: This should use -MQ, when we support it. if (!Args.hasArg(options::OPT_MT) && !Args.hasArg(options::OPT_MQ)) { const char *DepTarget; @@ -109,13 +110,13 @@ Args.AddLastArg(CmdArgs, options::OPT_MP); Args.AddAllArgs(CmdArgs, options::OPT_MT); - // FIXME: Use iterator. - // Add -i* options, and automatically translate to // -include-pch/-include-pth for transparent PCH support. It's // wonky, but we include looking for .gch so we can support seamless // replacement into a build system already set up to be generating // .gch files. + // + // FIXME: Use iterator. for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { const Arg *A = *it; @@ -879,8 +880,6 @@ void darwin::CC1::AddCC1Args(const ArgList &Args, ArgStringList &CmdArgs) const { // Derived from cc1 spec. - - // FIXME: -fapple-kext seems to disable this too. Investigate. if (!Args.hasArg(options::OPT_mkernel) && !Args.hasArg(options::OPT_static) && !Args.hasArg(options::OPT_mdynamic_no_pic)) CmdArgs.push_back("-fPIC"); @@ -889,15 +888,6 @@ // and no -miphoneos-version-min is present, but this never happens // due to tool chain specific argument translation. - // FIXME: Remove mthumb - // FIXME: Remove mno-thumb - // FIXME: Remove faltivec - // FIXME: Remove mno-fused-madd - // FIXME: Remove mlong-branch - // FIXME: Remove mlongcall - // FIXME: Remove mcpu=G4 - // FIXME: Remove mcpu=G5 - if (Args.hasArg(options::OPT_g_Flag) && !Args.hasArg(options::OPT_fno_eliminate_unused_debug_symbols)) CmdArgs.push_back("-feliminate-unused-debug-symbols"); @@ -1230,9 +1220,6 @@ } else { CmdArgs.push_back("-fpreprocessed"); - // FIXME: There is a spec command to remove - // -fpredictive-compilation args here. Investigate. - for (InputInfoList::const_iterator it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { const InputInfo &II = *it; @@ -1618,20 +1605,16 @@ const ArgList &Args, const char *LinkingOutput) const { assert(Output.getType() == types::TY_Image && "Invalid linker output type."); + // The logic here is derived from gcc's behavior; most of which // comes from specs (starting with link_command). Consult gcc for // more information. - - // FIXME: The spec references -fdump= which seems to have - // disappeared? - ArgStringList CmdArgs; // I'm not sure why this particular decomposition exists in gcc, but // we follow suite for ease of comparison. AddLinkArgs(Args, CmdArgs); - // FIXME: gcc has %{x} in here. How could this ever happen? Cruft? Args.AddAllArgs(CmdArgs, options::OPT_d_Flag); Args.AddAllArgs(CmdArgs, options::OPT_s); Args.AddAllArgs(CmdArgs, options::OPT_t); @@ -1642,11 +1625,6 @@ Args.AddAllArgs(CmdArgs, options::OPT_m_Separate); Args.AddAllArgs(CmdArgs, options::OPT_r); - // FIXME: This is just being pedantically bug compatible, gcc - // doesn't *mean* to forward this, it just does (yay for pattern - // matching). It doesn't work, of course. - Args.AddAllArgs(CmdArgs, options::OPT_object); - CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); Modified: cfe/trunk/test/Driver/darwin-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=81224&r1=81223&r2=81224&view=diff ============================================================================== --- cfe/trunk/test/Driver/darwin-ld.c (original) +++ cfe/trunk/test/Driver/darwin-ld.c Tue Sep 8 11:39:16 2009 @@ -32,8 +32,8 @@ // // Note that at conception, this exactly matches gcc. -// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -A ARG0 -F ARG1 -L ARG2 -Mach -T ARG4 -X -Z -all_load -allowable_client ARG8 -bind_at_load -compatibility_version ARG11 -current_version ARG12 -d -dead_strip -dylib_file ARG14 -dylinker -dylinker_install_name ARG16 -dynamic -dynamiclib -e ARG19 -exported_symbols_list ARG20 -fexceptions -flat_namespace -fnested-functions -fopenmp -force_cpusubtype_ALL -fpie -fprofile-arcs -headerpad_max_install_names -image_base ARG29 -init ARG30 -install_name ARG31 -m ARG33 -miphoneos-version-min=2.0 -mmacosx-version-min=10.3.2 -multi_module -multiply_defined ARG37 -multiply_defined_unused ARG38 -no_dead_strip_inits_and_terms -nodefaultlibs -nofixprebinding -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdlib -object -pagezero_size ARG54 -pg -prebind -prebind_all_twolevel_modules -preload -r -read_only_relocs ARG55 -s -sectalign ARG57_0 ARG57_1 ARG57_2 -sectcreate ARG58_0 ARG58_1 ARG58_2 -sectobjectsymbols ARG59_0 ARG59_1 -sec! torder ARG60_0 ARG60_1 ARG60_2 -seg1addr ARG61 -seg_addr_table ARG62 -seg_addr_table_filename ARG63 -segaddr ARG64_0 ARG64_1 -segcreate ARG65_0 ARG65_1 ARG65_2 -seglinkedit -segprot ARG67_0 ARG67_1 ARG67_2 -segs_read_FOO -segs_read_only_addr ARG69 -segs_read_write_addr ARG70 -shared-libgcc -single_module -static -static-libgcc -sub_library ARG77 -sub_umbrella ARG78 -t -twolevel_namespace -twolevel_namespace_hints -u ARG82 -umbrella ARG83 -undefined ARG84 -unexported_symbols_list ARG85 -w -weak_reference_mismatches ARG87 -whatsloaded -whyload -y -filelist FOO 2> %t.log && -// RUN: grep '".*ld" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename"! "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-object" "-o" "a.out" "-L" "ARG2" "-lgomp" "-L/usr/lib/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../../i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../.." "-filelist" "FOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -A ARG0 -F ARG1 -L ARG2 -Mach -T ARG4 -X -Z -all_load -allowable_client ARG8 -bind_at_load -compatibility_version ARG11 -current_version ARG12 -d -dead_strip -dylib_file ARG14 -dylinker -dylinker_install_name ARG16 -dynamic -dynamiclib -e ARG19 -exported_symbols_list ARG20 -fexceptions -flat_namespace -fnested-functions -fopenmp -force_cpusubtype_ALL -fpie -fprofile-arcs -headerpad_max_install_names -image_base ARG29 -init ARG30 -install_name ARG31 -m ARG33 -miphoneos-version-min=2.0 -mmacosx-version-min=10.3.2 -multi_module -multiply_defined ARG37 -multiply_defined_unused ARG38 -no_dead_strip_inits_and_terms -nodefaultlibs -nofixprebinding -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdlib -pagezero_size ARG54 -pg -prebind -prebind_all_twolevel_modules -preload -r -read_only_relocs ARG55 -s -sectalign ARG57_0 ARG57_1 ARG57_2 -sectcreate ARG58_0 ARG58_1 ARG58_2 -sectobjectsymbols ARG59_0 ARG59_1 -sectorder A! RG60_0 ARG60_1 ARG60_2 -seg1addr ARG61 -seg_addr_table ARG62 -seg_addr_table_filename ARG63 -segaddr ARG64_0 ARG64_1 -segcreate ARG65_0 ARG65_1 ARG65_2 -seglinkedit -segprot ARG67_0 ARG67_1 ARG67_2 -segs_read_FOO -segs_read_only_addr ARG69 -segs_read_write_addr ARG70 -shared-libgcc -single_module -static -static-libgcc -sub_library ARG77 -sub_umbrella ARG78 -t -twolevel_namespace -twolevel_namespace_hints -u ARG82 -umbrella ARG83 -undefined ARG84 -unexported_symbols_list ARG85 -w -weak_reference_mismatches ARG87 -whatsloaded -whyload -y -filelist FOO 2> %t.log && +// RUN: grep '".*ld" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename"! "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-o" "a.out" "-L" "ARG2" "-lgomp" "-L/usr/lib/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../../i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../.." "-filelist" "FOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log && // Don't run dsymutil on a fat build of an executable. // RUN: clang -ccc-host-triple i386-apple-darwin9 -### -arch i386 -arch x86_64 -g %s 2> %t.log && From daniel at zuster.org Tue Sep 8 11:39:23 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 16:39:23 -0000 Subject: [cfe-commits] r81225 - in /cfe/trunk/test: Makefile lit.cfg Message-ID: <200909081639.n88GdN7B002260@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 11:39:23 2009 New Revision: 81225 URL: http://llvm.org/viewvc/llvm-project?rev=81225&view=rev Log: Support running tests using the new 'lit', via 'make test LIT2=1'. Modified: cfe/trunk/test/Makefile cfe/trunk/test/lit.cfg Modified: cfe/trunk/test/Makefile URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Makefile?rev=81225&r1=81224&r2=81225&view=diff ============================================================================== --- cfe/trunk/test/Makefile (original) +++ cfe/trunk/test/Makefile Tue Sep 8 11:39:23 2009 @@ -22,6 +22,14 @@ VGARG= endif +ifdef LIT2 +all:: + @ echo '--- Running clang tests for $(TARGET_TRIPLE) ---' + @ $(LLVM_SRC_ROOT)/utils/lit/lit.py \ + --path $(ToolDir) \ + --path $(LLVM_SRC_ROOT)/test/Scripts \ + $(TESTARGS) $(TESTDIRS) $(VGARG) +else all:: @ echo '--- Running clang tests for $(TARGET_TRIPLE) ---' @ $(PROJ_SRC_DIR)/../utils/test/MultiTestRunner.py \ @@ -29,6 +37,7 @@ --path $(ToolDir) \ --path $(LLVM_SRC_ROOT)/test/Scripts \ $(TESTARGS) $(TESTDIRS) $(VGARG) +endif clean:: @ rm -rf Output/ Modified: cfe/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=81225&r1=81224&r2=81225&view=diff ============================================================================== --- cfe/trunk/test/lit.cfg (original) +++ cfe/trunk/test/lit.cfg Tue Sep 8 11:39:23 2009 @@ -1,10 +1,92 @@ # -*- Python -*- +def config_new(): + # Configuration file for the 'lit' test runner. + + # name: The name of this test suite. + config.name = 'Clang' + + # testFormat: The test format to use to interpret tests. + # + # For now we require '&&' between commands, until they get globally killed and + # the test runner updated. + config.test_format = lit.formats.ShTest(execute_external = True, + require_and_and = True) + + # suffixes: A list of file extensions to treat as test files. + config.suffixes = ['.c', '.cpp', '.m', '.mm'] + + ### + + # Discover the 'clang' and 'clangcc' to use. + + import os + + def inferClang(PATH): + # Determine which clang to use. + clang = os.getenv('CLANG') + + # If the user set clang in the environment, definitely use that and don't + # try to validate. + if clang: + return clang + + # Otherwise look in the path. + clang = lit.util.which('clang', PATH) + + if not clang: + lit.fatal("couldn't find 'clang' program, try setting " + "CLANG in your environment") + + return clang + + def inferClangCC(clang, PATH): + clangcc = os.getenv('CLANGCC') + + # If the user set clang in the environment, definitely use that and don't + # try to validate. + if clangcc: + return clangcc + + # Otherwise try adding -cc since we expect to be looking in a build + # directory. + if clang.endswith('.exe'): + clangccName = clang[:-4] + '-cc.exe' + else: + clangccName = clang + '-cc' + clangcc = lit.util.which(clangccName, PATH) + if not clangcc: + # Otherwise ask clang. + res = lit.util.capture([clang, '-print-prog-name=clang-cc']) + res = res.strip() + if res and os.path.exists(res): + clangcc = res + + if not clangcc: + lit.fatal("couldn't find 'clang-cc' program, try setting " + "CLANGCC in your environment") + + return clangcc + + clang = inferClang(config.environment['PATH']) + if not lit.quiet: + lit.note('using clang: %r' % clang) + config.substitutions.append( (' clang ', ' ' + clang + ' ') ) + + clang_cc = inferClangCC(clang, config.environment['PATH']) + if not lit.quiet: + lit.note('using clang-cc: %r' % clang_cc) + config.substitutions.append( (' clang-cc ', ' ' + clang_cc + ' ') ) + +if 'config' in globals(): + config_new() + raise SystemExit # End configuration. + # Configuration file for the 'lit' test runner. # suffixes: A list of file extensions to treat as test files. suffixes = ['.c', '.cpp', '.m', '.mm'] - + # environment: The base environment to use when running test commands. # # The 'PATH' and 'SYSTEMROOT' variables will be set automatically from the lit From dgregor at apple.com Tue Sep 8 11:42:36 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 8 Sep 2009 09:42:36 -0700 Subject: [cfe-commits] r81057 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Decl.h include/clang/AST/Type.h include/clang/AST/TypeNodes.def include/clang/Frontend/PCHBitCodes.h lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/CodeGen/CGDebugInfo.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp lib/Sema/TreeTransform.h In-Reply-To: <200909050015.n850FmLG028505@zion.cs.uiuc.edu> References: <200909050015.n850FmLG028505@zion.cs.uiuc.edu> Message-ID: <98324385-0E6F-4996-B99E-E93AC0352821@apple.com> On Sep 4, 2009, at 5:15 PM, John McCall wrote: > Author: rjmccall > Date: Fri Sep 4 19:15:47 2009 > New Revision: 81057 > > URL: http://llvm.org/viewvc/llvm-project?rev=81057&view=rev > Log: > Basic support for representing elaborated type specifiers > directly in the AST. The current thinking is to create these > only in C++ mode for efficiency. But for now, they're not being > created at all; patch to follow. > > This will let us do things like verify that tags match during > template instantation, as well as signal that an elaborated type > specifier was used for clients that actually care. Very nice! > Modified: cfe/trunk/lib/Sema/TreeTransform.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=81057&r1=81056&r2=81057&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- cfe/trunk/lib/Sema/TreeTransform.h (original) > +++ cfe/trunk/lib/Sema/TreeTransform.h Fri Sep 4 19:15:47 2009 > @@ -441,6 +441,11 @@ > QualType RebuildEnumType(EnumDecl *Enum) { > return SemaRef.Context.getTypeDeclType(Enum); > } > + > + /// \brief Build a new elaborated type. > + QualType RebuildElaboratedType(QualType T, > ElaboratedType::TagKind Tag) { > + return SemaRef.Context.getElaboratedType(T, Tag); > + } I assume that the TemplateInstantiator class will (eventually) be overriding RebuildElaboratedType, to complain about class-key mismatches? (struct vs. union, etc.) - Doug From dgregor at apple.com Tue Sep 8 11:56:56 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 8 Sep 2009 09:56:56 -0700 Subject: [cfe-commits] r81070 - /cfe/trunk/lib/CodeGen/Mangle.cpp In-Reply-To: <200909050756.n857uIce030932@zion.cs.uiuc.edu> References: <200909050756.n857uIce030932@zion.cs.uiuc.edu> Message-ID: <662852E1-DE5B-4A95-82B7-34A4C66E905D@apple.com> On Sep 5, 2009, at 12:56 AM, John McCall wrote: > Author: rjmccall > Date: Sat Sep 5 02:56:18 2009 > New Revision: 81070 > > URL: http://llvm.org/viewvc/llvm-project?rev=81070&view=rev > Log: > Overhaul the mangler to use a visitor pattern, at least for types. *THANK YOU* > We can safely > ignore non-canonical type classes, but apparently we need to know > how to mangle > dependent names. Yes, because function template specializations are mangled as the function template's signature (including dependent types, dependent names, etc.) along with the template arguments. - Doug From rjmccall at apple.com Tue Sep 8 11:59:00 2009 From: rjmccall at apple.com (John McCall) Date: Tue, 08 Sep 2009 09:59:00 -0700 Subject: [cfe-commits] r81057 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Decl.h include/clang/AST/Type.h include/clang/AST/TypeNodes.def include/clang/Frontend/PCHBitCodes.h lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/CodeGen/CGDebugInfo.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp lib/Sema/TreeTransform.h In-Reply-To: <98324385-0E6F-4996-B99E-E93AC0352821@apple.com> References: <200909050015.n850FmLG028505@zion.cs.uiuc.edu> <98324385-0E6F-4996-B99E-E93AC0352821@apple.com> Message-ID: <4AA68D54.5070508@apple.com> Douglas Gregor wrote: > I assume that the TemplateInstantiator class will (eventually) be > overriding RebuildElaboratedType, to complain about class-key > mismatches? (struct vs. union, etc.) Yep. That'll be next after getting friend templateids working. John. From rjmccall at apple.com Tue Sep 8 12:47:30 2009 From: rjmccall at apple.com (John McCall) Date: Tue, 08 Sep 2009 17:47:30 -0000 Subject: [cfe-commits] r81233 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.decls/temp.friend/p1.cpp Message-ID: <200909081747.n88HlUZs012329@zion.cs.uiuc.edu> Author: rjmccall Date: Tue Sep 8 12:47:29 2009 New Revision: 81233 URL: http://llvm.org/viewvc/llvm-project?rev=81233&view=rev Log: Support templateids in friend declarations. Fixes bug 4859. Modified: cfe/trunk/include/clang/Parse/Action.h cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Sema/Sema.h cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp Modified: cfe/trunk/include/clang/Parse/Action.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=81233&r1=81232&r2=81233&view=diff ============================================================================== --- cfe/trunk/include/clang/Parse/Action.h (original) +++ cfe/trunk/include/clang/Parse/Action.h Tue Sep 8 12:47:29 2009 @@ -1591,21 +1591,34 @@ /// /// \param Template A template whose specialization results in a /// type, e.g., a class template or template template parameter. - /// - /// \param TagSpec The tag spec that was provided as part of the - /// elaborated-type-specifier, or TST_unspecified if this was not - /// an elaborated type. virtual TypeResult ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation *TemplateArgLocs, - SourceLocation RAngleLoc, - DeclSpec::TST TagSpec = DeclSpec::TST_unspecified, - SourceLocation TagLoc = SourceLocation()) { + SourceLocation RAngleLoc) { return TypeResult(); }; + /// \brief Note that a template ID was used with a tag. + /// + /// \param Type The result of ActOnTemplateIdType. + /// + /// \param TUK Either TUK_Reference or TUK_Friend. Declarations and + /// definitions are interpreted as explicit instantiations or + /// specializations. + /// + /// \param TagSpec The tag keyword that was provided as part of the + /// elaborated-type-specifier; either class, struct, union, or enum. + /// + /// \param TagLoc The location of the tag keyword. + virtual TypeResult ActOnTagTemplateIdType(TypeResult Type, + TagUseKind TUK, + DeclSpec::TST TagSpec, + SourceLocation TagLoc) { + return TypeResult(); + } + /// \brief Form a reference to a template-id (that will refer to a function) /// from a template and a list of template arguments. /// Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=81233&r1=81232&r2=81233&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Sep 8 12:47:29 2009 @@ -651,26 +651,27 @@ TemplateId->RAngleLoc, Attr); } else if (TUK == Action::TUK_Reference || TUK == Action::TUK_Friend) { - Action::TypeResult TypeResult = - Actions.ActOnTemplateIdType(TemplateTy::make(TemplateId->Template), - TemplateId->TemplateNameLoc, - TemplateId->LAngleLoc, - TemplateArgsPtr, - TemplateId->getTemplateArgLocations(), - TemplateId->RAngleLoc, - TagType, StartLoc); + Action::TypeResult Type + = Actions.ActOnTemplateIdType(TemplateTy::make(TemplateId->Template), + TemplateId->TemplateNameLoc, + TemplateId->LAngleLoc, + TemplateArgsPtr, + TemplateId->getTemplateArgLocations(), + TemplateId->RAngleLoc); + + Type = Actions.ActOnTagTemplateIdType(Type, TUK, TagType, StartLoc); TemplateId->Destroy(); - if (TypeResult.isInvalid()) { + if (Type.isInvalid()) { DS.SetTypeSpecError(); return; } - + const char *PrevSpec = 0; unsigned DiagID; if (DS.SetTypeSpecType(DeclSpec::TST_typename, StartLoc, PrevSpec, - DiagID, TypeResult.get())) + DiagID, Type.get())) Diag(StartLoc, DiagID) << PrevSpec; return; Modified: cfe/trunk/lib/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=81233&r1=81232&r2=81233&view=diff ============================================================================== --- cfe/trunk/lib/Sema/Sema.h (original) +++ cfe/trunk/lib/Sema/Sema.h Tue Sep 8 12:47:29 2009 @@ -2401,10 +2401,13 @@ SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation *TemplateArgLocs, - SourceLocation RAngleLoc, - DeclSpec::TST TagSpec, - SourceLocation TagLoc); - + SourceLocation RAngleLoc); + + virtual TypeResult ActOnTagTemplateIdType(TypeResult Type, + TagUseKind TUK, + DeclSpec::TST TagSpec, + SourceLocation TagLoc); + OwningExprResult BuildTemplateIdExpr(TemplateName Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=81233&r1=81232&r2=81233&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep 8 12:47:29 2009 @@ -3917,61 +3917,60 @@ assert(DS.isFriendSpecified()); assert(DS.getStorageClassSpec() == DeclSpec::SCS_unspecified); - // Check to see if the decl spec was syntactically like "struct foo". - RecordDecl *RD = NULL; - - switch (DS.getTypeSpecType()) { - case DeclSpec::TST_class: - case DeclSpec::TST_struct: - case DeclSpec::TST_union: - RD = dyn_cast_or_null((Decl*) DS.getTypeRep()); - if (!RD) return DeclPtrTy(); - - // The parser doesn't quite handle - // friend class A {} - // as we'd like, because it might have been the (valid) prefix of - // friend class A {} foo(); - // So even in C++0x mode we don't want to - IsDefinition |= RD->isDefinition(); - break; - - default: break; - } - - FriendDecl::FriendUnion FU = RD; + // Try to convert the decl specifier to a type. + bool invalid = false; + QualType T = ConvertDeclSpecToType(DS, Loc, invalid); + if (invalid) return DeclPtrTy(); // C++ [class.friend]p2: // An elaborated-type-specifier shall be used in a friend declaration // for a class.* // * The class-key of the elaborated-type-specifier is required. - // So if we didn't get a record decl above, we're invalid in C++98 mode. - if (!RD) { - bool invalid = false; - QualType T = ConvertDeclSpecToType(DS, Loc, invalid); - if (invalid) return DeclPtrTy(); - + // This is one of the rare places in Clang where it's legitimate to + // ask about the "spelling" of the type. + if (!getLangOptions().CPlusPlus0x && !isa(T)) { + // If we evaluated the type to a record type, suggest putting + // a tag in front. if (const RecordType *RT = T->getAs()) { - FU = RD = cast(RT->getDecl()); - - // Untagged typenames are invalid prior to C++0x, but we can - // suggest an easy fix which should work. - if (!getLangOptions().CPlusPlus0x) { - Diag(DS.getFriendSpecLoc(), diag::err_unelaborated_friend_type) - << (RD->isUnion()) - << CodeModificationHint::CreateInsertion(DS.getTypeSpecTypeLoc(), - RD->isUnion() ? " union" : " class"); - return DeclPtrTy(); - } - }else if (!getLangOptions().CPlusPlus0x) { - Diag(DS.getFriendSpecLoc(), diag::err_unexpected_friend) - << DS.getSourceRange(); + RecordDecl *RD = RT->getDecl(); + + std::string InsertionText = std::string(" ") + RD->getKindName(); + + Diag(DS.getFriendSpecLoc(), diag::err_unelaborated_friend_type) + << (RD->isUnion()) + << CodeModificationHint::CreateInsertion(DS.getTypeSpecTypeLoc(), + InsertionText); return DeclPtrTy(); }else { - FU = T.getTypePtr(); + Diag(DS.getFriendSpecLoc(), diag::err_unexpected_friend) + << DS.getSourceRange(); + return DeclPtrTy(); } } - assert(FU && "should have a friend decl/type by here!"); + FriendDecl::FriendUnion FU = T.getTypePtr(); + + // The parser doesn't quite handle + // friend class A { ... } + // optimally, because it might have been the (valid) prefix of + // friend class A { ... } foo(); + // So in a very particular set of circumstances, we need to adjust + // IsDefinition. + // + // Also, if we made a RecordDecl in ActOnTag, we want that to be the + // object of our friend declaration. + switch (DS.getTypeSpecType()) { + default: break; + case DeclSpec::TST_class: + case DeclSpec::TST_struct: + case DeclSpec::TST_union: + CXXRecordDecl *RD = cast_or_null((Decl*) DS.getTypeRep()); + if (RD) { + IsDefinition |= RD->isDefinition(); + FU = RD; + } + break; + } // C++ [class.friend]p2: A class shall not be defined inside // a friend declaration. @@ -3986,11 +3985,10 @@ // But that's a silly restriction which nobody implements for // inner classes, and C++0x removes it anyway, so we only report // this (as a warning) if we're being pedantic. - if (!getLangOptions().CPlusPlus0x) { - assert(RD && "must have a record decl in C++98 mode"); - if (RD->getDeclContext() == CurContext) - Diag(DS.getFriendSpecLoc(), diag::ext_friend_inner_class); - } + if (!getLangOptions().CPlusPlus0x) + if (const RecordType *RT = T->getAs()) + if (RT->getDecl()->getDeclContext() == CurContext) + Diag(DS.getFriendSpecLoc(), diag::ext_friend_inner_class); FriendDecl *FD = FriendDecl::Create(Context, CurContext, Loc, FU, DS.getFriendSpecLoc()); Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=81233&r1=81232&r2=81233&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Sep 8 12:47:29 2009 @@ -1121,9 +1121,7 @@ SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation *TemplateArgLocs, - SourceLocation RAngleLoc, - DeclSpec::TST TagSpec, - SourceLocation TagLoc) { + SourceLocation RAngleLoc) { TemplateName Template = TemplateD.getAsVal(); // Translate the parser's template argument list in our AST format. @@ -1139,26 +1137,38 @@ if (Result.isNull()) return true; - // If we were given a tag specifier, verify it. - if (TagSpec != DeclSpec::TST_unspecified) { - TagDecl::TagKind TagKind = TagDecl::getTagKindForTypeSpec(TagSpec); - - if (const RecordType *T = Result->getAs()) { - RecordDecl *D = T->getDecl(); - - IdentifierInfo *Id = D->getIdentifier(); - assert(Id && "templated class must have an identifier"); - - if (!isAcceptableTagRedeclaration(D, TagKind, TagLoc, *Id)) { - Diag(TagLoc, diag::err_use_with_wrong_tag) - << Id - << CodeModificationHint::CreateReplacement(SourceRange(TagLoc), - D->getKindName()); - } + return Result.getAsOpaquePtr(); +} + +Sema::TypeResult Sema::ActOnTagTemplateIdType(TypeResult TypeResult, + TagUseKind TUK, + DeclSpec::TST TagSpec, + SourceLocation TagLoc) { + if (TypeResult.isInvalid()) + return Sema::TypeResult(); + + QualType Type = QualType::getFromOpaquePtr(TypeResult.get()); + + // Verify the tag specifier. + TagDecl::TagKind TagKind = TagDecl::getTagKindForTypeSpec(TagSpec); + + if (const RecordType *RT = Type->getAs()) { + RecordDecl *D = RT->getDecl(); + + IdentifierInfo *Id = D->getIdentifier(); + assert(Id && "templated class must have an identifier"); + + if (!isAcceptableTagRedeclaration(D, TagKind, TagLoc, *Id)) { + Diag(TagLoc, diag::err_use_with_wrong_tag) + << Id + << CodeModificationHint::CreateReplacement(SourceRange(TagLoc), + D->getKindName()); } } - return Result.getAsOpaquePtr(); + QualType ElabType = Context.getElaboratedType(Type, TagKind); + + return ElabType.getAsOpaquePtr(); } Sema::OwningExprResult Sema::BuildTemplateIdExpr(TemplateName Template, Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp?rev=81233&r1=81232&r2=81233&view=diff ============================================================================== --- cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp (original) +++ cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp Tue Sep 8 12:47:29 2009 @@ -36,6 +36,11 @@ template friend bool iszero(const A &a) throw(); }; +template class B_iterator; +template class B { + friend class B_iterator; +}; + int calc1() { Num left = -1; Num right = 1; From sabre at nondot.org Tue Sep 8 13:10:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 08 Sep 2009 18:10:11 -0000 Subject: [cfe-commits] r81234 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp Message-ID: <200909081810.n88IABnh015325@zion.cs.uiuc.edu> Author: lattner Date: Tue Sep 8 13:10:11 2009 New Revision: 81234 URL: http://llvm.org/viewvc/llvm-project?rev=81234&view=rev Log: reduce indentation. Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=81234&r1=81233&r2=81234&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Sep 8 13:10:11 2009 @@ -1887,23 +1887,22 @@ /// DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak /// applied to it, possibly with an alias. void Sema::DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W) { - if (!W.getUsed()) { // only do this once - W.setUsed(true); - if (W.getAlias()) { // clone decl, impersonate __attribute(weak,alias(...)) - IdentifierInfo *NDId = ND->getIdentifier(); - NamedDecl *NewD = DeclClonePragmaWeak(ND, W.getAlias()); - NewD->addAttr(::new (Context) AliasAttr(NDId->getName())); - NewD->addAttr(::new (Context) WeakAttr()); - WeakTopLevelDecl.push_back(NewD); - // FIXME: "hideous" code from Sema::LazilyCreateBuiltin - // to insert Decl at TU scope, sorry. - DeclContext *SavedContext = CurContext; - CurContext = Context.getTranslationUnitDecl(); - PushOnScopeChains(NewD, S); - CurContext = SavedContext; - } else { // just add weak to existing - ND->addAttr(::new (Context) WeakAttr()); - } + if (W.getUsed()) return; // only do this once + W.setUsed(true); + if (W.getAlias()) { // clone decl, impersonate __attribute(weak,alias(...)) + IdentifierInfo *NDId = ND->getIdentifier(); + NamedDecl *NewD = DeclClonePragmaWeak(ND, W.getAlias()); + NewD->addAttr(::new (Context) AliasAttr(NDId->getName())); + NewD->addAttr(::new (Context) WeakAttr()); + WeakTopLevelDecl.push_back(NewD); + // FIXME: "hideous" code from Sema::LazilyCreateBuiltin + // to insert Decl at TU scope, sorry. + DeclContext *SavedContext = CurContext; + CurContext = Context.getTranslationUnitDecl(); + PushOnScopeChains(NewD, S); + CurContext = SavedContext; + } else { // just add weak to existing + ND->addAttr(::new (Context) WeakAttr()); } } From sabre at nondot.org Tue Sep 8 13:19:27 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 08 Sep 2009 18:19:27 -0000 Subject: [cfe-commits] r81236 - in /cfe/trunk/lib: Frontend/PCHReader.cpp Frontend/PCHWriter.cpp Sema/Sema.cpp Sema/Sema.h Sema/SemaDecl.cpp Message-ID: <200909081819.n88IJSLI016464@zion.cs.uiuc.edu> Author: lattner Date: Tue Sep 8 13:19:27 2009 New Revision: 81236 URL: http://llvm.org/viewvc/llvm-project?rev=81236&view=rev Log: Fix PR4922, where Sema would complete tentative definitions in nondeterminstic order because it was doing so while iterating over a densemap. There are still similar problems in other places, for example WeakUndeclaredIdentifiers is still written to the PCH file in a nondeterminstic order, and we emit warnings about #pragma weak in nondeterminstic order. Modified: cfe/trunk/lib/Frontend/PCHReader.cpp cfe/trunk/lib/Frontend/PCHWriter.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/Sema.h cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Frontend/PCHReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=81236&r1=81235&r2=81236&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/PCHReader.cpp (original) +++ cfe/trunk/lib/Frontend/PCHReader.cpp Tue Sep 8 13:19:27 2009 @@ -2225,6 +2225,7 @@ for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) { VarDecl *Var = cast(GetDecl(TentativeDefinitions[I])); SemaObj->TentativeDefinitions[Var->getDeclName()] = Var; + SemaObj->TentativeDefinitionList.push_back(Var->getDeclName()); } // If there were any locally-scoped external declarations, Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=81236&r1=81235&r2=81236&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/PCHWriter.cpp (original) +++ cfe/trunk/lib/Frontend/PCHWriter.cpp Tue Sep 8 13:19:27 2009 @@ -1800,19 +1800,22 @@ getIdentifierRef(&Table.get(BuiltinNames[I])); } - // Build a record containing all of the tentative definitions in - // this header file. Generally, this record will be empty. + // Build a record containing all of the tentative definitions in this file, in + // TentativeDefinitionList order. Generally, this record will be empty for + // headers. RecordData TentativeDefinitions; - for (llvm::DenseMap::iterator - TD = SemaRef.TentativeDefinitions.begin(), - TDEnd = SemaRef.TentativeDefinitions.end(); - TD != TDEnd; ++TD) - AddDeclRef(TD->second, TentativeDefinitions); + for (unsigned i = 0, e = SemaRef.TentativeDefinitionList.size(); i != e; ++i){ + VarDecl *VD = + SemaRef.TentativeDefinitions.lookup(SemaRef.TentativeDefinitionList[i]); + if (VD) AddDeclRef(VD, TentativeDefinitions); + } // Build a record containing all of the locally-scoped external // declarations in this header file. Generally, this record will be // empty. RecordData LocallyScopedExternalDecls; + // FIXME: This is filling in the PCH file in densemap order which is + // nondeterminstic! for (llvm::DenseMap::iterator TD = SemaRef.LocallyScopedExternalDecls.begin(), TDEnd = SemaRef.LocallyScopedExternalDecls.end(); Modified: cfe/trunk/lib/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=81236&r1=81235&r2=81236&view=diff ============================================================================== --- cfe/trunk/lib/Sema/Sema.cpp (original) +++ cfe/trunk/lib/Sema/Sema.cpp Tue Sep 8 13:19:27 2009 @@ -256,13 +256,16 @@ // template instantiations earlier. PerformPendingImplicitInstantiations(); - // check for #pragma weak identifiers that were never declared + // Check for #pragma weak identifiers that were never declared + // FIXME: This will cause diagnostics to be emitted in a non-determinstic + // order! Iterating over a densemap like this is bad. for (llvm::DenseMap::iterator - I = WeakUndeclaredIdentifiers.begin(), - E = WeakUndeclaredIdentifiers.end(); I != E; ++I) { - if (!I->second.getUsed()) - Diag(I->second.getLocation(), diag::warn_weak_identifier_undeclared) - << I->first; + I = WeakUndeclaredIdentifiers.begin(), + E = WeakUndeclaredIdentifiers.end(); I != E; ++I) { + if (I->second.getUsed()) continue; + + Diag(I->second.getLocation(), diag::warn_weak_identifier_undeclared) + << I->first; } if (!CompleteTranslationUnit) @@ -279,31 +282,30 @@ // translation unit contains a file scope declaration of that // identifier, with the composite type as of the end of the // translation unit, with an initializer equal to 0. - for (llvm::DenseMap::iterator - D = TentativeDefinitions.begin(), - DEnd = TentativeDefinitions.end(); - D != DEnd; ++D) { - VarDecl *VD = D->second; - - if (VD->isInvalidDecl() || !VD->isTentativeDefinition(Context)) + for (unsigned i = 0, e = TentativeDefinitionList.size(); i != e; ++i) { + VarDecl *VD = TentativeDefinitions.lookup(TentativeDefinitionList[i]); + + // If the tentative definition was completed, it will be in the list, but + // not the map. + if (VD == 0 || VD->isInvalidDecl() || !VD->isTentativeDefinition(Context)) continue; if (const IncompleteArrayType *ArrayT = Context.getAsIncompleteArrayType(VD->getType())) { if (RequireCompleteType(VD->getLocation(), ArrayT->getElementType(), - diag::err_tentative_def_incomplete_type_arr)) + diag::err_tentative_def_incomplete_type_arr)) { VD->setInvalidDecl(); - else { - // Set the length of the array to 1 (C99 6.9.2p5). - Diag(VD->getLocation(), diag::warn_tentative_incomplete_array); - llvm::APInt One(Context.getTypeSize(Context.getSizeType()), - true); - QualType T - = Context.getConstantArrayWithoutExprType(ArrayT->getElementType(), - One, ArrayType::Normal, 0); - VD->setType(T); + continue; } + + // Set the length of the array to 1 (C99 6.9.2p5). + Diag(VD->getLocation(), diag::warn_tentative_incomplete_array); + llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true); + QualType T + = Context.getConstantArrayWithoutExprType(ArrayT->getElementType(), + One, ArrayType::Normal, 0); + VD->setType(T); } else if (RequireCompleteType(VD->getLocation(), VD->getType(), diag::err_tentative_def_incomplete_type)) VD->setInvalidDecl(); Modified: cfe/trunk/lib/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=81236&r1=81235&r2=81236&view=diff ============================================================================== --- cfe/trunk/lib/Sema/Sema.h (original) +++ cfe/trunk/lib/Sema/Sema.h Tue Sep 8 13:19:27 2009 @@ -266,6 +266,7 @@ /// declaration, and only the most recent tentative declaration for /// a given variable will be recorded here. llvm::DenseMap TentativeDefinitions; + std::vector TentativeDefinitionList; /// WeakUndeclaredIdentifiers - Identifiers contained in /// #pragma weak before declared. rare. may alias another Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=81236&r1=81235&r2=81236&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 8 13:19:27 2009 @@ -3208,11 +3208,8 @@ // remove it from the set of tentative definitions. if (VDecl->getPreviousDeclaration() && VDecl->getPreviousDeclaration()->isTentativeDefinition(Context)) { - llvm::DenseMap::iterator Pos - = TentativeDefinitions.find(VDecl->getDeclName()); - assert(Pos != TentativeDefinitions.end() && - "Unrecorded tentative definition?"); - TentativeDefinitions.erase(Pos); + bool Deleted = TentativeDefinitions.erase(VDecl->getDeclName()); + assert(Deleted && "Unrecorded tentative definition?"); Deleted=Deleted; } return; @@ -3230,8 +3227,20 @@ QualType Type = Var->getType(); // Record tentative definitions. - if (Var->isTentativeDefinition(Context)) - TentativeDefinitions[Var->getDeclName()] = Var; + if (Var->isTentativeDefinition(Context)) { + std::pair::iterator, bool> + InsertPair = + TentativeDefinitions.insert(std::make_pair(Var->getDeclName(), Var)); + + // Keep the latest definition in the map. If we see 'int i; int i;' we + // want the second one in the map. + InsertPair.first->second = Var; + + // However, for the list, we don't care about the order, just make sure + // that there are no dupes for a given declaration name. + if (InsertPair.second) + TentativeDefinitionList.push_back(Var->getDeclName()); + } // C++ [dcl.init.ref]p3: // The initializer can be omitted for a reference only in a From andersca at mac.com Tue Sep 8 13:24:22 2009 From: andersca at mac.com (Anders Carlsson) Date: Tue, 08 Sep 2009 18:24:22 -0000 Subject: [cfe-commits] r81237 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclObjC.h include/clang/AST/Expr.h lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/AST/Expr.cpp lib/CodeGen/CGExpr.cpp lib/Sema/SemaExpr.cpp test/CodeGen/predefined-expr.c test/CodeGenCXX/predefined-expr.cpp test/CodeGenObjC/predefined-expr-in-method.m test/CodeGenObjC/predefined-expr.m Message-ID: <200909081824.n88IOMgf017222@zion.cs.uiuc.edu> Author: andersca Date: Tue Sep 8 13:24:21 2009 New Revision: 81237 URL: http://llvm.org/viewvc/llvm-project?rev=81237&view=rev Log: Vastly improve PredefinedExpr output, both in Sema and CodeGen. Patch by Sam Weinig! Added: cfe/trunk/test/CodeGen/predefined-expr.c cfe/trunk/test/CodeGenCXX/predefined-expr.cpp cfe/trunk/test/CodeGenObjC/predefined-expr.m Removed: cfe/trunk/test/CodeGenObjC/predefined-expr-in-method.m Modified: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclObjC.h cfe/trunk/include/clang/AST/Expr.h cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/AST/DeclObjC.cpp cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Tue Sep 8 13:24:21 2009 @@ -121,6 +121,7 @@ /// Creating this name is expensive, so it should be called only when /// performance doesn't matter. std::string getQualifiedNameAsString() const; + std::string getQualifiedNameAsString(const PrintingPolicy &Policy) const; /// declarationReplaces - Determine whether this declaration, if /// known to be well-formed within its context, will replace the Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Sep 8 13:24:21 2009 @@ -195,7 +195,7 @@ } Selector getSelector() const { return getDeclName().getObjCSelector(); } - unsigned getSynthesizedMethodSize() const; + QualType getResultType() const { return MethodDeclType; } void setResultType(QualType T) { MethodDeclType = T; } Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Tue Sep 8 13:24:21 2009 @@ -375,11 +375,9 @@ SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - // FIXME: The logic for computing the value of a predefined expr should go - // into a method here that takes the inner-most code decl (a block, function - // or objc method) that the expr lives in. This would allow sema and codegen - // to be consistent for things like sizeof(__func__) etc. - + static std::string ComputeName(ASTContext &Context, IdentType IT, + const Decl *CurrentDecl); + virtual SourceRange getSourceRange() const { return SourceRange(Loc); } static bool classof(const Stmt *T) { Modified: cfe/trunk/lib/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/lib/AST/Decl.cpp (original) +++ cfe/trunk/lib/AST/Decl.cpp Tue Sep 8 13:24:21 2009 @@ -216,6 +216,10 @@ //===----------------------------------------------------------------------===// std::string NamedDecl::getQualifiedNameAsString() const { + return getQualifiedNameAsString(getASTContext().getLangOptions()); +} + +std::string NamedDecl::getQualifiedNameAsString(const PrintingPolicy &P) const { std::vector Names; std::string QualName; const DeclContext *Ctx = getDeclContext(); @@ -232,12 +236,11 @@ if (const ClassTemplateSpecializationDecl *Spec = dyn_cast(Ctx)) { const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs(); - PrintingPolicy Policy(getASTContext().getLangOptions()); std::string TemplateArgsStr = TemplateSpecializationType::PrintTemplateArgumentList( TemplateArgs.getFlatArgumentList(), TemplateArgs.flat_size(), - Policy); + P); Names.push_back(Spec->getIdentifier()->getName() + TemplateArgsStr); } else if (const NamedDecl *ND = dyn_cast(Ctx)) Names.push_back(ND->getNameAsString()); @@ -259,7 +262,6 @@ return QualName; } - bool NamedDecl::declarationReplaces(NamedDecl *OldD) const { assert(getDeclName() == OldD->getDeclName() && "Declaration name mismatch"); Modified: cfe/trunk/lib/AST/DeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/lib/AST/DeclObjC.cpp (original) +++ cfe/trunk/lib/AST/DeclObjC.cpp Tue Sep 8 13:24:21 2009 @@ -290,23 +290,6 @@ Context.getObjCSelType())); } - - -/// getSynthesizedMethodSize - Compute size of synthesized method name -/// as done be the rewrite. -/// -unsigned ObjCMethodDecl::getSynthesizedMethodSize() const { - // syntesized method name is a concatenation of -/+[class-name selector] - // Get length of this name. - unsigned length = 3; // _I_ or _C_ - length += getClassInterface()->getNameAsString().size()+1; // extra for _ - if (const ObjCCategoryImplDecl *CID = - dyn_cast(getDeclContext())) - length += CID->getNameAsString().size()+1; - length += getSelector().getAsString().size(); // selector name - return length; -} - ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { if (ObjCInterfaceDecl *ID = dyn_cast(getDeclContext())) return ID; Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Tue Sep 8 13:24:21 2009 @@ -22,6 +22,7 @@ #include "clang/AST/StmtVisitor.h" #include "clang/Basic/Builtins.h" #include "clang/Basic/TargetInfo.h" +#include "llvm/Support/raw_ostream.h" #include using namespace clang; @@ -29,6 +30,82 @@ // Primary Expressions. //===----------------------------------------------------------------------===// +// FIXME: Maybe this should use DeclPrinter with a special "print predefined +// expr" policy instead. +std::string PredefinedExpr::ComputeName(ASTContext &Context, IdentType IT, + const Decl *CurrentDecl) { + if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) { + if (IT != PrettyFunction) + return FD->getNameAsString(); + + llvm::SmallString<256> Name; + llvm::raw_svector_ostream Out(Name); + + if (const CXXMethodDecl *MD = dyn_cast(FD)) { + if (MD->isVirtual()) + Out << "virtual "; + } + + PrintingPolicy Policy(Context.getLangOptions()); + Policy.SuppressTagKind = true; + + std::string Proto = FD->getQualifiedNameAsString(Policy); + + const FunctionType *AFT = FD->getType()->getAsFunctionType(); + const FunctionProtoType *FT = 0; + if (FD->hasWrittenPrototype()) + FT = dyn_cast(AFT); + + Proto += "("; + if (FT) { + llvm::raw_string_ostream POut(Proto); + for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) { + if (i) POut << ", "; + std::string Param; + FD->getParamDecl(i)->getType().getAsStringInternal(Param, Policy); + POut << Param; + } + + if (FT->isVariadic()) { + if (FD->getNumParams()) POut << ", "; + POut << "..."; + } + } + Proto += ")"; + + AFT->getResultType().getAsStringInternal(Proto, Policy); + + Out << Proto; + + Out.flush(); + return Name.str().str(); + } + if (const ObjCMethodDecl *MD = dyn_cast(CurrentDecl)) { + llvm::SmallString<256> Name; + llvm::raw_svector_ostream Out(Name); + Out << (MD->isInstanceMethod() ? '-' : '+'); + Out << '['; + Out << MD->getClassInterface()->getNameAsString(); + if (const ObjCCategoryImplDecl *CID = + dyn_cast(MD->getDeclContext())) { + Out << '('; + Out << CID->getNameAsString(); + Out << ')'; + } + Out << ' '; + Out << MD->getSelector().getAsString(); + Out << ']'; + + Out.flush(); + return Name.str().str(); + } + if (isa(CurrentDecl) && IT == PrettyFunction) { + // __PRETTY_FUNCTION__ -> "top level", the others produce an empty string. + return "top level"; + } + return ""; +} + /// getValueAsApproximateDouble - This returns the value as an inaccurate /// double. Note that this may cause loss of precision, but is useful for /// debugging dumps, etc. Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Sep 8 13:24:21 2009 @@ -845,24 +845,13 @@ GlobalVarName = "__FUNCTION__."; break; case PredefinedExpr::PrettyFunction: - // FIXME:: Demangle C++ method names GlobalVarName = "__PRETTY_FUNCTION__."; break; } - // FIXME: This isn't right at all. The logic for computing this should go - // into a method on PredefinedExpr. This would allow sema and codegen to be - // consistent for things like sizeof(__func__) etc. - std::string FunctionName; - if (const FunctionDecl *FD = dyn_cast_or_null(CurCodeDecl)) { - FunctionName = CGM.getMangledName(FD); - } else { - // Just get the mangled name; skipping the asm prefix if it - // exists. - FunctionName = CurFn->getName(); - if (FunctionName[0] == '\01') - FunctionName = FunctionName.substr(1, std::string::npos); - } + std::string FunctionName = + PredefinedExpr::ComputeName(getContext(), (PredefinedExpr::IdentType)Type, + CurCodeDecl); GlobalVarName += FunctionName; llvm::Constant *C = Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=81237&r1=81236&r2=81237&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Sep 8 13:24:21 2009 @@ -1151,17 +1151,15 @@ // Pre-defined identifiers are of type char[x], where x is the length of the // string. - unsigned Length; - if (FunctionDecl *FD = getCurFunctionDecl()) - Length = FD->getIdentifier()->getLength(); - else if (ObjCMethodDecl *MD = getCurMethodDecl()) - Length = MD->getSynthesizedMethodSize(); - else { + + Decl *currentDecl = getCurFunctionOrMethodDecl(); + if (!currentDecl) { Diag(Loc, diag::ext_predef_outside_function); - // __PRETTY_FUNCTION__ -> "top level", the others produce an empty string. - Length = IT == PredefinedExpr::PrettyFunction ? strlen("top level") : 0; + currentDecl = Context.getTranslationUnitDecl(); } + unsigned Length = + PredefinedExpr::ComputeName(Context, IT, currentDecl).length(); llvm::APInt LengthI(32, Length + 1); QualType ResTy = Context.CharTy.getQualifiedType(QualType::Const); Added: cfe/trunk/test/CodeGen/predefined-expr.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/predefined-expr.c?rev=81237&view=auto ============================================================================== --- cfe/trunk/test/CodeGen/predefined-expr.c (added) +++ cfe/trunk/test/CodeGen/predefined-expr.c Tue Sep 8 13:24:21 2009 @@ -0,0 +1,45 @@ +// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s + +// CHECK: @__func__.plainFunction = private constant [14 x i8] c"plainFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void plainFunction()" = private constant [21 x i8] c"void plainFunction()\00" +// CHECK: @__func__.externFunction = private constant [15 x i8] c"externFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void externFunction()" = private constant [22 x i8] c"void externFunction()\00" +// CHECK: @__func__.privateExternFunction = private constant [22 x i8] c"privateExternFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void privateExternFunction()" = private constant [29 x i8] c"void privateExternFunction()\00" +// CHECK: @__func__.staticFunction = private constant [15 x i8] c"staticFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void staticFunction()" = private constant [22 x i8] c"void staticFunction()\00" + +#include + +void plainFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); +} + +extern void externFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); +} + +__private_extern__ void privateExternFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); +} + +static void staticFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); +} + +int main() { + plainFunction(); + externFunction(); + privateExternFunction(); + staticFunction(); + + return 0; +} Added: cfe/trunk/test/CodeGenCXX/predefined-expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/predefined-expr.cpp?rev=81237&view=auto ============================================================================== --- cfe/trunk/test/CodeGenCXX/predefined-expr.cpp (added) +++ cfe/trunk/test/CodeGenCXX/predefined-expr.cpp Tue Sep 8 13:24:21 2009 @@ -0,0 +1,226 @@ +// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s + +// CHECK: @__func__.externFunction = private constant [15 x i8] c"externFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::externFunction()" = private constant [26 x i8] c"void NS::externFunction()\00" + +// CHECK: @__func__.classTemplateFunction = private constant [22 x i8] c"classTemplateFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::ClassTemplate::classTemplateFunction()" = private constant [60 x i8] c"void NS::ClassTemplate::classTemplateFunction()\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::ClassTemplate::classTemplateFunction()" = private constant [53 x i8] c"void NS::ClassTemplate::classTemplateFunction()\00" + +// CHECK: @__func__.functionTemplate1 = private constant [18 x i8] c"functionTemplate1\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::functionTemplate1(NS::Base *)" = private constant [45 x i8] c"void NS::Base::functionTemplate1(NS::Base *)\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::functionTemplate1(int)" = private constant [38 x i8] c"void NS::Base::functionTemplate1(int)\00" + +// CHECK: @"__func__.~Destructor" = private constant [12 x i8] c"~Destructor\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Destructor::~Destructor()" = private constant [35 x i8] c"void NS::Destructor::~Destructor()\00" + +// CHECK: @__func__.Constructor = private constant [12 x i8] c"Constructor\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Constructor::Constructor(NS::Base *)" = private constant [46 x i8] c"void NS::Constructor::Constructor(NS::Base *)\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Constructor::Constructor(int)" = private constant [39 x i8] c"void NS::Constructor::Constructor(int)\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Constructor::Constructor()" = private constant [36 x i8] c"void NS::Constructor::Constructor()\00" + +// CHECK: @__func__.virtualFunction = private constant [16 x i8] c"virtualFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.virtual void NS::Derived::virtualFunction()" = private constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00" + +// CHECK: @__func__.functionReturingTemplate2 = private constant [26 x i8] c"functionReturingTemplate2\00" +// CHECK: @"__PRETTY_FUNCTION__.ClassTemplate NS::Base::functionReturingTemplate2()" = private constant [64 x i8] c"ClassTemplate NS::Base::functionReturingTemplate2()\00" + +// CHECK: @__func__.functionReturingTemplate1 = private constant [26 x i8] c"functionReturingTemplate1\00" +// CHECK: @"__PRETTY_FUNCTION__.ClassTemplate NS::Base::functionReturingTemplate1()" = private constant [57 x i8] c"ClassTemplate NS::Base::functionReturingTemplate1()\00" + +// CHECK: @__func__.withTemplateParameter2 = private constant [23 x i8] c"withTemplateParameter2\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::withTemplateParameter2(ClassTemplate)" = private constant [65 x i8] c"void NS::Base::withTemplateParameter2(ClassTemplate)\00" + +// CHECK: @__func__.withTemplateParameter1 = private constant [23 x i8] c"withTemplateParameter1\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::withTemplateParameter1(ClassTemplate)" = private constant [58 x i8] c"void NS::Base::withTemplateParameter1(ClassTemplate)\00" + +// CHECK: @__func__.functionReturningClass = private constant [23 x i8] c"functionReturningClass\00" +// CHECK: @"__PRETTY_FUNCTION__.NS::Base *NS::Base::functionReturningClass()" = private constant [45 x i8] c"NS::Base *NS::Base::functionReturningClass()\00" + +// CHECK: @__func__.functionWithParameters = private constant [23 x i8] c"functionWithParameters\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::functionWithParameters(int, float *, NS::Base *)" = private constant [64 x i8] c"void NS::Base::functionWithParameters(int, float *, NS::Base *)\00" + +// CHECK: @__func__.variadicFunction = private constant [17 x i8] c"variadicFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::variadicFunction(int, ...)" = private constant [42 x i8] c"void NS::Base::variadicFunction(int, ...)\00" + +// CHECK: @"__PRETTY_FUNCTION__.virtual void NS::Base::virtualFunction()" = private constant [41 x i8] c"virtual void NS::Base::virtualFunction()\00" + +// CHECK: @__func__.inlineFunction = private constant [15 x i8] c"inlineFunction\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::inlineFunction()" = private constant [32 x i8] c"void NS::Base::inlineFunction()\00" + +// CHECK: @__func__.staticFunc = private constant [11 x i8] c"staticFunc\00" +// CHECK: @"__PRETTY_FUNCTION__.void NS::Base::staticFunc()" = private constant [28 x i8] c"void NS::Base::staticFunc()\00" + +#include + +namespace NS { + +template +class ClassTemplate { +public: + void classTemplateFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } +}; + +class Base { +public: + static void staticFunc() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + inline void inlineFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + virtual void virtualFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + void functionWithParameters(int, float*, Base* base) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + Base *functionReturningClass() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + return 0; + } + + void variadicFunction(int, ...) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + void withTemplateParameter1(ClassTemplate) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + void withTemplateParameter2(ClassTemplate) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + ClassTemplate functionReturingTemplate1() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + return ClassTemplate(); + } + + ClassTemplate functionReturingTemplate2() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + return ClassTemplate(); + } + + template + void functionTemplate1(T t) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } +}; + +class Derived : public Base { +public: + // Virtual function without being explicitally written. + void virtualFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } +}; + +class Constructor { +public: + Constructor() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + Constructor(int) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + + Constructor(Base *) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } + +}; + +class Destructor { +public: + ~Destructor() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + } +}; + +extern void externFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); +} + +} + +int main() { + NS::Base::staticFunc(); + + NS::Base b; + b.inlineFunction(); + b.virtualFunction(); + b.variadicFunction(0); + b.functionWithParameters(0, 0, 0); + b.functionReturningClass(); + + b.withTemplateParameter1(NS::ClassTemplate()); + b.withTemplateParameter2(NS::ClassTemplate()); + b.functionReturingTemplate1(); + b.functionReturingTemplate2(); + b.functionTemplate1(0); + b.functionTemplate1(0); + + NS::Derived d; + d.virtualFunction(); + + NS::ClassTemplate t1; + t1.classTemplateFunction(); + NS::ClassTemplate t2; + t2.classTemplateFunction(); + + NS::Constructor c1; + NS::Constructor c2(0); + NS::Constructor c3((NS::Base *)0); + + { + NS::Destructor destructor; + } + + NS::externFunction(); + + return 0; +} Removed: cfe/trunk/test/CodeGenObjC/predefined-expr-in-method.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/predefined-expr-in-method.m?rev=81236&view=auto ============================================================================== --- cfe/trunk/test/CodeGenObjC/predefined-expr-in-method.m (original) +++ cfe/trunk/test/CodeGenObjC/predefined-expr-in-method.m (removed) @@ -1,17 +0,0 @@ -// RUN: clang-cc -fnext-runtime --emit-llvm -o %t %s - - at interface A - at end - at implementation A -+(void) foo { - printf("__func__: %s\n", __func__); - printf("__FUNCTION__: %s\n", __FUNCTION__); - printf("__PRETTY_FUNCTION__: %s\n", __PRETTY_FUNCTION__); - return 0; -} - at end - -int main() { - [A foo]; - return 0; -} Added: cfe/trunk/test/CodeGenObjC/predefined-expr.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/predefined-expr.m?rev=81237&view=auto ============================================================================== --- cfe/trunk/test/CodeGenObjC/predefined-expr.m (added) +++ cfe/trunk/test/CodeGenObjC/predefined-expr.m Tue Sep 8 13:24:21 2009 @@ -0,0 +1,90 @@ +// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s + +// CHECK: @"__func__.-[Foo instanceTest1]" = private constant [21 x i8] c"-[Foo instanceTest1]\00" +// CHECK: @"__func__.-[Foo instanceTest2:]" = private constant [22 x i8] c"-[Foo instanceTest2:]\00" +// CHECK: @"__func__.-[Foo instanceTest3:withB:]" = private constant [28 x i8] c"-[Foo instanceTest3:withB:]\00" +// CHECK: @"__func__.-[Foo instanceTest4]" = private constant [21 x i8] c"-[Foo instanceTest4]\00" +// CHECK: @"__func__.+[Foo classTest1]" = private constant [18 x i8] c"+[Foo classTest1]\00" +// CHECK: @"__func__.+[Foo classTest2:]" = private constant [19 x i8] c"+[Foo classTest2:]\00" +// CHECK: @"__func__.+[Foo classTest3:withB:]" = private constant [25 x i8] c"+[Foo classTest3:withB:]\00" +// CHECK: @"__func__.+[Foo classTest4]" = private constant [18 x i8] c"+[Foo classTest4]\00" +// CHECK: @"__func__.-[Foo(Category) instanceTestWithCategory]" = private constant [42 x i8] c"-[Foo(Category) instanceTestWithCategory]\00" +// CHECK: @"__func__.+[Foo(Category) classTestWithCategory]" = private constant [39 x i8] c"+[Foo(Category) classTestWithCategory]\00" + +#include + + at interface Foo + at end + + at implementation Foo + +- (void)instanceTest1 { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + +- (void)instanceTest2:(int)i { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + +- (void)instanceTest3:(int)a withB:(double)b { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + +- (int)instanceTest4 { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); + return 0; +} + ++ (void)classTest1 { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + ++ (void)classTest2:(int)i { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + ++ (void)classTest3:(int)a withB:(double)b { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + ++ (int)classTest4 { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); + return 0; +} + + at end + + at interface Foo (Category) + at end + + at implementation Foo (Category) + +- (void)instanceTestWithCategory { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + ++ (void)classTestWithCategory { + printf("__func__: %s\n", __func__); + printf("__FUNCTION__: %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__); +} + + at end From sabre at nondot.org Tue Sep 8 13:43:45 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 08 Sep 2009 18:43:45 -0000 Subject: [cfe-commits] r81238 - /cfe/trunk/test/CodeGen/pragma-weak.c Message-ID: <200909081843.n88Ihk3M019772@zion.cs.uiuc.edu> Author: lattner Date: Tue Sep 8 13:43:45 2009 New Revision: 81238 URL: http://llvm.org/viewvc/llvm-project?rev=81238&view=rev Log: convert this to filecheck, hopefully it will fix PR4888. If nothing else it will make tests run faster and make 4888 easier to diagnose. Modified: cfe/trunk/test/CodeGen/pragma-weak.c Modified: cfe/trunk/test/CodeGen/pragma-weak.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pragma-weak.c?rev=81238&r1=81237&r2=81238&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/pragma-weak.c (original) +++ cfe/trunk/test/CodeGen/pragma-weak.c Tue Sep 8 13:43:45 2009 @@ -1,37 +1,53 @@ -// RUN: clang-cc -emit-llvm -o %t %s && +// RUN: clang-cc -emit-llvm %s -o - -verify | FileCheck %s + +// CHECK: @weakvar = weak global +// CHECK: @__weakvar_alias = common global +// CHECK: @correct_linkage = weak global + + +// CHECK: @both = alias void ()* @__both +// CHECK: @both2 = alias void ()* @__both2 +// CHECK: @both3 = alias weak void ()* @__both3 +// CHECK: @a3 = alias weak void ()* @__a3 +// CHECK: @weakvar_alias = alias weak i32* @__weakvar_alias +// CHECK: @foo = alias weak void ()* @__foo +// CHECK: @foo2 = alias weak void ()* @__foo2 +// CHECK: @stutter = alias weak void ()* @__stutter +// CHECK: @stutter2 = alias weak void ()* @__stutter2 +// CHECK: @declfirst = alias weak void ()* @__declfirst +// CHECK: @declfirstattr = alias weak void ()* @__declfirstattr +// CHECK: @mix2 = alias weak void ()* @__mix2 +// CHECK: @a1 = alias weak void ()* @__a1 +// CHECK: @xxx = alias weak void ()* @__xxx + + + +// CHECK: define weak void @weakdef() + #pragma weak weakvar int weakvar; -// RUN: grep '@weakvar = weak global' %t | count 1 && #pragma weak weakdef void weakdef(void) {} -// RUN: grep 'define weak void @weakdef()' %t | count 1 && #pragma weak param // expected-warning {{weak identifier 'param' never declared}} #pragma weak correct_linkage void f(int param) { int correct_linkage; } -int correct_linkage; -// RUN: grep '@correct_linkage = weak global' %t | count 1 && #pragma weak weakvar_alias = __weakvar_alias int __weakvar_alias; -// RUN: grep '@__weakvar_alias = common global' %t | count 1 && -// RUN: grep '@weakvar_alias = alias weak i32\* @__weakvar_alias' %t | count 1 && -//@weakvar_alias = alias weak i32* @__weakvar_alias #pragma weak foo = __foo void __foo(void) {} -// RUN: grep '@foo = alias weak void ()\* @__foo\>' %t | count 1 && -// RUN: grep 'define void @__foo()' %t | count 1 && +// CHECK: define void @__foo() void __foo2(void) {} #pragma weak foo2 = __foo2 -// RUN: grep '@foo2 = alias weak void ()\* @__foo2\>' %t | count 1 && -// RUN: grep 'define void @__foo2()' %t | count 1 && +// CHECK: define void @__foo2() ///// test errors @@ -53,14 +69,12 @@ #pragma weak stutter = __stutter #pragma weak stutter = __stutter void __stutter(void) {} -// RUN: grep '@stutter = alias weak void ()\* @__stutter\>' %t | count 1 && -// RUN: grep 'define void @__stutter()' %t | count 1 && +// CHECK: define void @__stutter() void __stutter2(void) {} #pragma weak stutter2 = __stutter2 #pragma weak stutter2 = __stutter2 -// RUN: grep '@stutter2 = alias weak void ()\* @__stutter2\>' %t | count 1 && -// RUN: grep 'define void @__stutter2()' %t | count 1 && +// CHECK: define void @__stutter2() // test decl/pragma weak order @@ -68,14 +82,12 @@ void __declfirst(void); #pragma weak declfirst = __declfirst void __declfirst(void) {} -// RUN: grep '@declfirst = alias weak void ()\* @__declfirst\>' %t | count 1 && -// RUN: grep 'define void @__declfirst()' %t | count 1 && +// CHECK: define void @__declfirst() void __declfirstattr(void) __attribute((noinline)); #pragma weak declfirstattr = __declfirstattr void __declfirstattr(void) {} -// RUN: grep '@declfirstattr = alias weak void ()\* @__declfirstattr\>' %t | count 1 && -// RUN: grep 'define void @__declfirstattr()' %t | count 1 && +// CHECK: define void @__declfirstattr() //// test that other attributes are preserved @@ -84,7 +96,7 @@ void mix(void); #pragma weak mix __attribute((weak)) void mix(void) { } -// RUN: grep 'define weak void @mix()' %t | count 1 && +// CHECK: define weak void @mix() // ensure following __attributes are preserved and that only a single // alias is generated @@ -92,8 +104,7 @@ void __mix2(void) __attribute((noinline)); void __mix2(void) __attribute((noinline)); void __mix2(void) {} -// RUN: grep '@mix2 = alias weak void ()\* @__mix2\>' %t | count 1 && -// RUN: grep 'define void @__mix2()' %t | count 1 && +// CHECK: define void @__mix2() ////////////// test #pragma weak/__attribute combinations @@ -102,8 +113,7 @@ void both(void) __attribute((alias("__both"))); #pragma weak both = __both void __both(void) {} -// RUN: grep '@both = alias void ()\* @__both\>' %t | count 1 && -// RUN: grep 'define void @__both()' %t | count 1 && +// CHECK: define void @__both() // if the TARGET is previously declared then whichever aliasing method // comes first applies and subsequent aliases are discarded. @@ -113,23 +123,20 @@ void both2(void) __attribute((alias("__both2"))); // first, wins #pragma weak both2 = __both2 void __both2(void) {} -// RUN: grep '@both2 = alias void ()\* @__both2\>' %t | count 1 && -// RUN: grep 'define void @__both2()' %t | count 1 && +// CHECK: define void @__both2() void __both3(void); #pragma weak both3 = __both3 // first, wins void both3(void) __attribute((alias("__both3"))); void __both3(void) {} -// RUN: grep '@both3 = alias weak void ()\* @__both3\>' %t | count 1 && -// RUN: grep 'define void @__both3()' %t | count 1 && +// CHECK: define void @__both3() ///////////// ensure that #pragma weak does not alter existing __attributes() void __a1(void) __attribute((noinline)); #pragma weak a1 = __a1 void __a1(void) {} -// RUN: grep '@a1 = alias weak void ()\* @__a1\>' %t | count 1 && -// RUN: grep 'define void @__a1()' %t | count 1 && +// CHECK: define void @__a1() // attributes introduced BEFORE a combination of #pragma weak and alias() // hold... @@ -137,13 +144,11 @@ #pragma weak a3 = __a3 void a3(void) __attribute((alias("__a3"))); void __a3(void) {} -// RUN: grep '@a3 = alias weak void ()\* @__a3\>' %t | count 1 && -// RUN: grep 'define void @__a3()' %t | count 1 && +// CHECK: define void @__a3() #pragma weak xxx = __xxx __attribute((pure,noinline,const,fastcall)) void __xxx(void) { } -// RUN: grep '@xxx = alias weak void ()\* @__xxx\>' %t | count 1 && -// RUN: grep 'define .*fastcall.* void @__xxx()' %t | count 1 && +// CHECK: void @__xxx() /// TODO: stuff that still doesn't work @@ -155,4 +160,6 @@ void zzz(void){} #pragma weak yyy // NOTE: weak doesn't apply, not before or in same TopLevelDec(!) -// RUN: grep 'define void @yyy()' %t | count 1 +// CHECK: define void @yyy() + +int correct_linkage; From fjahanian at apple.com Tue Sep 8 14:45:48 2009 From: fjahanian at apple.com (Fariborz Jahanian) Date: Tue, 08 Sep 2009 19:45:48 -0000 Subject: [cfe-commits] r81244 - in /cfe/trunk: include/clang/AST/Type.h test/CodeGenObjC/objc2-strong-cast-4.m Message-ID: <200909081945.n88Jjmeo028132@zion.cs.uiuc.edu> Author: fjahanian Date: Tue Sep 8 14:45:47 2009 New Revision: 81244 URL: http://llvm.org/viewvc/llvm-project?rev=81244&view=rev Log: Fixes a regression in generating objc's GC API in assiging to c pointer types with a GC'able attribute. Added: cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m Modified: cfe/trunk/include/clang/AST/Type.h Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=81244&r1=81243&r2=81244&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Tue Sep 8 14:45:47 2009 @@ -2235,6 +2235,9 @@ return EXTQT->getObjCGCAttr(); if (const ObjCObjectPointerType *PT = CT->getAsObjCObjectPointerType()) return PT->getPointeeType().getObjCGCAttr(); + // We most look at all pointer types, not just pointer to interface types. + if (const PointerType *PT = CT->getAs()) + return PT->getPointeeType().getObjCGCAttr(); return GCNone; } Added: cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m?rev=81244&view=auto ============================================================================== --- cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m (added) +++ cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m Tue Sep 8 14:45:47 2009 @@ -0,0 +1,23 @@ +// RUN: clang-cc -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s && +// RUN: grep objc_assign_strongCast %t | count 3 && +// RUN: true + +struct Slice { + void *__strong * items; +}; + +typedef struct Slice Slice; + + at interface ISlice { + at public + void *__strong * items; +} + at end + +void foo () { + Slice *slice; + slice->items = 0; + + ISlice *islice; + islice->items = 0; +} From dgregor at apple.com Tue Sep 8 14:57:34 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 08 Sep 2009 19:57:34 -0000 Subject: [cfe-commits] r81251 - in /cfe/trunk: include/clang/AST/APValue.h lib/AST/APValue.cpp Message-ID: <200909081957.n88JvYAu029868@zion.cs.uiuc.edu> Author: dgregor Date: Tue Sep 8 14:57:33 2009 New Revision: 81251 URL: http://llvm.org/viewvc/llvm-project?rev=81251&view=rev Log: Make sure to access APValue's data via a char array (rather than through an array of void*), so that we don't run afoul of the strict-aliasing rules in C++ 3.10p15. Unfortunately, GCC 4.4 still complains about this code. Modified: cfe/trunk/include/clang/AST/APValue.h cfe/trunk/lib/AST/APValue.cpp Modified: cfe/trunk/include/clang/AST/APValue.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=81251&r1=81250&r2=81251&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/APValue.h (original) +++ cfe/trunk/include/clang/AST/APValue.h Tue Sep 8 14:57:33 2009 @@ -62,11 +62,12 @@ MaxSize = (sizeof(ComplexAPSInt) > sizeof(ComplexAPFloat) ? sizeof(ComplexAPSInt) : sizeof(ComplexAPFloat)) }; - - /// Data - space for the largest member in units of void*. This is an effort - /// to ensure that the APSInt/APFloat values have proper alignment. - void *Data[(MaxSize+sizeof(void*)-1)/sizeof(void*)]; - + + union { + void *Aligner; + char Data[MaxSize]; + }; + public: APValue() : Kind(Uninitialized) {} explicit APValue(const APSInt &I) : Kind(Uninitialized) { @@ -108,7 +109,7 @@ APSInt &getInt() { assert(isInt() && "Invalid accessor"); - return *(APSInt*)(void*)Data; + return *(APSInt*)(char*)Data; } const APSInt &getInt() const { return const_cast(this)->getInt(); @@ -116,7 +117,7 @@ APFloat &getFloat() { assert(isFloat() && "Invalid accessor"); - return *(APFloat*)(void*)Data; + return *(APFloat*)(char*)Data; } const APFloat &getFloat() const { return const_cast(this)->getFloat(); @@ -124,7 +125,7 @@ APValue &getVectorElt(unsigned i) const { assert(isVector() && "Invalid accessor"); - return ((Vec*)(void*)Data)->Elts[i]; + return ((Vec*)(char*)Data)->Elts[i]; } unsigned getVectorLength() const { assert(isVector() && "Invalid accessor"); @@ -133,7 +134,7 @@ APSInt &getComplexIntReal() { assert(isComplexInt() && "Invalid accessor"); - return ((ComplexAPSInt*)(void*)Data)->Real; + return ((ComplexAPSInt*)(char*)Data)->Real; } const APSInt &getComplexIntReal() const { return const_cast(this)->getComplexIntReal(); @@ -141,7 +142,7 @@ APSInt &getComplexIntImag() { assert(isComplexInt() && "Invalid accessor"); - return ((ComplexAPSInt*)(void*)Data)->Imag; + return ((ComplexAPSInt*)(char*)Data)->Imag; } const APSInt &getComplexIntImag() const { return const_cast(this)->getComplexIntImag(); @@ -149,7 +150,7 @@ APFloat &getComplexFloatReal() { assert(isComplexFloat() && "Invalid accessor"); - return ((ComplexAPFloat*)(void*)Data)->Real; + return ((ComplexAPFloat*)(char*)Data)->Real; } const APFloat &getComplexFloatReal() const { return const_cast(this)->getComplexFloatReal(); @@ -157,7 +158,7 @@ APFloat &getComplexFloatImag() { assert(isComplexFloat() && "Invalid accessor"); - return ((ComplexAPFloat*)(void*)Data)->Imag; + return ((ComplexAPFloat*)(char*)Data)->Imag; } const APFloat &getComplexFloatImag() const { return const_cast(this)->getComplexFloatImag(); @@ -174,37 +175,37 @@ void setInt(const APSInt &I) { assert(isInt() && "Invalid accessor"); - *(APSInt*)(void*)Data = I; + *(APSInt*)(char*)Data = I; } void setFloat(const APFloat &F) { assert(isFloat() && "Invalid accessor"); - *(APFloat*)(void*)Data = F; + *(APFloat*)(char*)Data = F; } void setVector(const APValue *E, unsigned N) { assert(isVector() && "Invalid accessor"); - ((Vec*)(void*)Data)->Elts = new APValue[N]; - ((Vec*)(void*)Data)->NumElts = N; + ((Vec*)(char*)Data)->Elts = new APValue[N]; + ((Vec*)(char*)Data)->NumElts = N; for (unsigned i = 0; i != N; ++i) - ((Vec*)(void*)Data)->Elts[i] = E[i]; + ((Vec*)(char*)Data)->Elts[i] = E[i]; } void setComplexInt(const APSInt &R, const APSInt &I) { assert(R.getBitWidth() == I.getBitWidth() && "Invalid complex int (type mismatch)."); assert(isComplexInt() && "Invalid accessor"); - ((ComplexAPSInt*)(void*)Data)->Real = R; - ((ComplexAPSInt*)(void*)Data)->Imag = I; + ((ComplexAPSInt*)(char*)Data)->Real = R; + ((ComplexAPSInt*)(char*)Data)->Imag = I; } void setComplexFloat(const APFloat &R, const APFloat &I) { assert(&R.getSemantics() == &I.getSemantics() && "Invalid complex float (type mismatch)."); assert(isComplexFloat() && "Invalid accessor"); - ((ComplexAPFloat*)(void*)Data)->Real = R; - ((ComplexAPFloat*)(void*)Data)->Imag = I; + ((ComplexAPFloat*)(char*)Data)->Real = R; + ((ComplexAPFloat*)(char*)Data)->Imag = I; } void setLValue(Expr *B, uint64_t O) { assert(isLValue() && "Invalid accessor"); - ((LV*)(void*)Data)->Base = B; - ((LV*)(void*)Data)->Offset = O; + ((LV*)(char*)Data)->Base = B; + ((LV*)(char*)Data)->Offset = O; } const APValue &operator=(const APValue &RHS); @@ -218,27 +219,27 @@ } void MakeFloat() { assert(isUninit() && "Bad state change"); - new ((APFloat*)(void*)Data) APFloat(0.0); + new ((void*)(char*)Data) APFloat(0.0); Kind = Float; } void MakeVector() { assert(isUninit() && "Bad state change"); - new ((Vec*)(void*)Data) Vec(); + new ((void*)(char*)Data) Vec(); Kind = Vector; } void MakeComplexInt() { assert(isUninit() && "Bad state change"); - new ((ComplexAPSInt*)(void*)Data) ComplexAPSInt(); + new ((void*)(char*)Data) ComplexAPSInt(); Kind = ComplexInt; } void MakeComplexFloat() { assert(isUninit() && "Bad state change"); - new ((ComplexAPFloat*)(void*)Data) ComplexAPFloat(); + new ((void*)(char*)Data) ComplexAPFloat(); Kind = ComplexFloat; } void MakeLValue() { assert(isUninit() && "Bad state change"); - new ((LV*)(void*)Data) LV(); + new ((void*)(char*)Data) LV(); Kind = LValue; } }; Modified: cfe/trunk/lib/AST/APValue.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/APValue.cpp?rev=81251&r1=81250&r2=81251&view=diff ============================================================================== --- cfe/trunk/lib/AST/APValue.cpp (original) +++ cfe/trunk/lib/AST/APValue.cpp Tue Sep 8 14:57:33 2009 @@ -37,7 +37,7 @@ else if (isFloat()) setFloat(RHS.getFloat()); else if (isVector()) - setVector(((Vec*)(void*)RHS.Data)->Elts, RHS.getVectorLength()); + setVector(((Vec*)(char*)RHS.Data)->Elts, RHS.getVectorLength()); else if (isComplexInt()) setComplexInt(RHS.getComplexIntReal(), RHS.getComplexIntImag()); else if (isComplexFloat()) @@ -49,17 +49,17 @@ void APValue::MakeUninit() { if (Kind == Int) - ((APSInt*)(void*)Data)->~APSInt(); + ((APSInt*)(char*)Data)->~APSInt(); else if (Kind == Float) - ((APFloat*)(void*)Data)->~APFloat(); + ((APFloat*)(char*)Data)->~APFloat(); else if (Kind == Vector) - ((Vec*)(void*)Data)->~Vec(); + ((Vec*)(char*)Data)->~Vec(); else if (Kind == ComplexInt) - ((ComplexAPSInt*)(void*)Data)->~ComplexAPSInt(); + ((ComplexAPSInt*)(char*)Data)->~ComplexAPSInt(); else if (Kind == ComplexFloat) - ((ComplexAPFloat*)(void*)Data)->~ComplexAPFloat(); + ((ComplexAPFloat*)(char*)Data)->~ComplexAPFloat(); else if (Kind == LValue) { - ((LV*)(void*)Data)->~LV(); + ((LV*)(char*)Data)->~LV(); } Kind = Uninitialized; } From mrs at apple.com Tue Sep 8 15:16:11 2009 From: mrs at apple.com (Mike Stump) Date: Tue, 8 Sep 2009 13:16:11 -0700 Subject: [cfe-commits] r81251 - in /cfe/trunk: include/clang/AST/APValue.h lib/AST/APValue.cpp In-Reply-To: <200909081957.n88JvYAu029868@zion.cs.uiuc.edu> References: <200909081957.n88JvYAu029868@zion.cs.uiuc.edu> Message-ID: <2D2C8367-E3C4-4B26-ACDB-1A50ACE297B5@apple.com> On Sep 8, 2009, at 12:57 PM, Douglas Gregor wrote: > Make sure to access APValue's data via a char array (rather than > through an array of void*), so that we don't run afoul of the > strict-aliasing rules in C++ 3.10p15. > Unfortunately, GCC 4.4 still complains about this code. > - return *(APSInt*)(void*)Data; > + return *(APSInt*)(char*)Data; This doesn't match your description. If you think this access is through a char to ensure this conforms to the standard... I'd be happy to give you the aliasing rules class... This is an access through a type of APSInt, which is unrelated to char. gcc still would give an error, as this code is still runs afoul of the rules (I bet). p = new APSInt newobj; memcpy (p, Data, sizeof(newobj); is an access through type char. ? From dgregor at apple.com Tue Sep 8 15:22:38 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 8 Sep 2009 13:22:38 -0700 Subject: [cfe-commits] r81251 - in /cfe/trunk: include/clang/AST/APValue.h lib/AST/APValue.cpp In-Reply-To: <2D2C8367-E3C4-4B26-ACDB-1A50ACE297B5@apple.com> References: <200909081957.n88JvYAu029868@zion.cs.uiuc.edu> <2D2C8367-E3C4-4B26-ACDB-1A50ACE297B5@apple.com> Message-ID: <5C14EC53-D20B-43B6-8300-64BE045F2FD5@apple.com> On Sep 8, 2009, at 1:16 PM, Mike Stump wrote: > On Sep 8, 2009, at 12:57 PM, Douglas Gregor wrote: >> Make sure to access APValue's data via a char array (rather than >> through an array of void*), so that we don't run afoul of the >> strict-aliasing rules in C++ 3.10p15. > >> Unfortunately, GCC 4.4 still complains about this code. > >> - return *(APSInt*)(void*)Data; >> + return *(APSInt*)(char*)Data; > > This doesn't match your description. If you think this access is > through a char to ensure this conforms to the standard... I'd be > happy to give you the aliasing rules class... This is an access > through a type of APSInt, which is unrelated to char. Where do I enroll? Alternatively, do you see how to eliminate the strict-aliasing violations in APValue? I'm clearly missing something. - Doug From mrs at apple.com Tue Sep 8 16:16:28 2009 From: mrs at apple.com (Mike Stump) Date: Tue, 8 Sep 2009 14:16:28 -0700 Subject: [cfe-commits] r81251 - in /cfe/trunk: include/clang/AST/APValue.h lib/AST/APValue.cpp In-Reply-To: <5C14EC53-D20B-43B6-8300-64BE045F2FD5@apple.com> References: <200909081957.n88JvYAu029868@zion.cs.uiuc.edu> <2D2C8367-E3C4-4B26-ACDB-1A50ACE297B5@apple.com> <5C14EC53-D20B-43B6-8300-64BE045F2FD5@apple.com> Message-ID: On Sep 8, 2009, at 1:22 PM, Douglas Gregor wrote: > On Sep 8, 2009, at 1:16 PM, Mike Stump wrote: > >> On Sep 8, 2009, at 12:57 PM, Douglas Gregor wrote: >>> Make sure to access APValue's data via a char array (rather than >>> through an array of void*), so that we don't run afoul of the >>> strict-aliasing rules in C++ 3.10p15. >> >>> Unfortunately, GCC 4.4 still complains about this code. >> >>> - return *(APSInt*)(void*)Data; >>> + return *(APSInt*)(char*)Data; >> >> This doesn't match your description. If you think this access is >> through a char to ensure this conforms to the standard... I'd be >> happy to give you the aliasing rules class... This is an access >> through a type of APSInt, which is unrelated to char. > > > Where do I enroll? You're enrolled. :-) Tomorrow I will fly out to your location, should be there by 11am. I'll just wait around until you're ready then we can have the class. I'll have to leave by 7pm to make the trip back home. > Alternatively, do you see how to eliminate the strict-aliasing > violations in APValue? I'm clearly missing something. In short: union { int i; float f; } *up, u; up->i = 1; up->f = 1.0; u.i =1; u.f = 1.0; is the canonical way to do this. As long as you only access the last type stored, this conforms to the language standards. If you have a proclivity of doing this with other than the last type stored, this will work with gcc, as long as you leave the source code that does the access as up-> or u (as a gcc extension). If you memcpy through a character array, this also conforms to the standard. For example: i.i = 1; memmove (&i.f, &i.i, sizeof (i.f)); printf (i.f); is required to work by the standard (1). The optimizer isn't allow to reorder the store of 1 past the read of the floating point value. 1 - This maybe contentious. I don't think it is and in the C++ standard, we refined the object model somewhat from c to clarify this. From daniel at zuster.org Tue Sep 8 18:36:43 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 23:36:43 -0000 Subject: [cfe-commits] r81275 - /cfe/trunk/lib/Driver/Driver.cpp Message-ID: <200909082336.n88NahQd027741@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 18:36:43 2009 New Revision: 81275 URL: http://llvm.org/viewvc/llvm-project?rev=81275&view=rev Log: Tweak & reflow comments, and delete trailing whitespace. Modified: cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81275&r1=81274&r2=81275&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 8 18:36:43 2009 @@ -43,23 +43,23 @@ Driver::Driver(const char *_Name, const char *_Dir, const char *_DefaultHostTriple, const char *_DefaultImageName, - Diagnostic &_Diags) - : Opts(new OptTable()), Diags(_Diags), + Diagnostic &_Diags) + : Opts(new OptTable()), Diags(_Diags), Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple), DefaultImageName(_DefaultImageName), Host(0), CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false), CCCGenericGCCName("gcc"), CCCUseClang(true), #ifdef USE_PRODUCTION_CLANG - CCCUseClangCXX(false), + CCCUseClangCXX(false), #else - CCCUseClangCXX(true), + CCCUseClangCXX(true), #endif CCCUseClangCPP(true), CCCUsePCH(true), SuppressMissingInputWarning(false) { #ifdef USE_PRODUCTION_CLANG - // Only use clang on i386 and x86_64 by default, in a "production" build. + // In a "production" build, only use clang on architectures we expect to work. CCCClangArchs.insert("i386"); CCCClangArchs.insert("x86_64"); CCCClangArchs.insert("arm"); @@ -74,20 +74,20 @@ delete Host; } -InputArgList *Driver::ParseArgStrings(const char **ArgBegin, +InputArgList *Driver::ParseArgStrings(const char **ArgBegin, const char **ArgEnd) { llvm::PrettyStackTraceString CrashInfo("Command line argument parsing"); InputArgList *Args = new InputArgList(ArgBegin, ArgEnd); - + // FIXME: Handle '@' args (or at least error on them). unsigned Index = 0, End = ArgEnd - ArgBegin; while (Index < End) { - // gcc's handling of empty arguments doesn't make - // sense, but this is not a common use case. :) + // gcc's handling of empty arguments doesn't make sense, but this is not a + // common use case. :) // - // We just ignore them here (note that other things may - // still take them as arguments). + // We just ignore them here (note that other things may still take them as + // arguments). if (Args->getArgString(Index)[0] == '\0') { ++Index; continue; @@ -119,28 +119,27 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) { llvm::PrettyStackTraceString CrashInfo("Compilation construction"); - // FIXME: Handle environment options which effect driver behavior, - // somewhere (client?). GCC_EXEC_PREFIX, COMPILER_PATH, - // LIBRARY_PATH, LPATH, CC_PRINT_OPTIONS, QA_OVERRIDE_GCC3_OPTIONS. + // FIXME: Handle environment options which effect driver behavior, somewhere + // (client?). GCC_EXEC_PREFIX, COMPILER_PATH, LIBRARY_PATH, LPATH, + // CC_PRINT_OPTIONS. // FIXME: What are we going to do with -V and -b? - // FIXME: This stuff needs to go into the Compilation, not the - // driver. + // FIXME: This stuff needs to go into the Compilation, not the driver. bool CCCPrintOptions = false, CCCPrintActions = false; const char **Start = argv + 1, **End = argv + argc; const char *HostTriple = DefaultHostTriple.c_str(); - // Read -ccc args. + // Read -ccc args. // - // FIXME: We need to figure out where this behavior should - // live. Most of it should be outside in the client; the parts that - // aren't should have proper options, either by introducing new ones - // or by overloading gcc ones like -V or -b. + // FIXME: We need to figure out where this behavior should live. Most of it + // should be outside in the client; the parts that aren't should have proper + // options, either by introducing new ones or by overloading gcc ones like -V + // or -b. for (; Start != End && memcmp(*Start, "-ccc-", 5) == 0; ++Start) { const char *Opt = *Start + 5; - + if (!strcmp(Opt, "print-options")) { CCCPrintOptions = true; } else if (!strcmp(Opt, "print-phases")) { @@ -151,7 +150,7 @@ CCCIsCXX = true; } else if (!strcmp(Opt, "echo")) { CCCEcho = true; - + } else if (!strcmp(Opt, "gcc-name")) { assert(Start+1 < End && "FIXME: -ccc- argument handling."); CCCGenericGCCName = *++Start; @@ -171,7 +170,7 @@ } else if (!strcmp(Opt, "clang-archs")) { assert(Start+1 < End && "FIXME: -ccc- argument handling."); const char *Cur = *++Start; - + CCCClangArchs.clear(); for (;;) { const char *Next = strchr(Cur, ','); @@ -218,10 +217,10 @@ if (!HandleImmediateArgs(*C)) return C; - // Construct the list of abstract actions to perform for this - // compilation. We avoid passing a Compilation here simply to - // enforce the abstraction that pipelining is not host or toolchain - // dependent (other than the driver driver test). + // Construct the list of abstract actions to perform for this compilation. We + // avoid passing a Compilation here simply to enforce the abstraction that + // pipelining is not host or toolchain dependent (other than the driver driver + // test). if (Host->useDriverDriver()) BuildUniversalActions(C->getArgs(), C->getActions()); else @@ -250,7 +249,7 @@ const Command *FailingCommand = 0; int Res = C.ExecuteJob(C.getJobs(), FailingCommand); - + // Remove temp files. C.CleanupFileList(C.getTempFiles()); @@ -274,10 +273,10 @@ if (!IsFriendlyTool || Res != 1) { // FIXME: See FIXME above regarding result code interpretation. if (Res < 0) - Diag(clang::diag::err_drv_command_signalled) + Diag(clang::diag::err_drv_command_signalled) << Source.getClassName() << -Res; else - Diag(clang::diag::err_drv_command_failed) + Diag(clang::diag::err_drv_command_failed) << Source.getClassName() << Res; } } @@ -287,7 +286,7 @@ void Driver::PrintOptions(const ArgList &Args) const { unsigned i = 0; - for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); + for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it, ++i) { Arg *A = *it; llvm::errs() << "Option " << i << " - " @@ -304,10 +303,10 @@ static std::string getOptionHelpName(const OptTable &Opts, options::ID Id) { std::string Name = Opts.getOptionName(Id); - + // Add metavar, if used. switch (Opts.getOptionKind(Id)) { - case Option::GroupClass: case Option::InputClass: case Option::UnknownClass: + case Option::GroupClass: case Option::InputClass: case Option::UnknownClass: assert(0 && "Invalid option with help text."); case Option::MultiArgClass: case Option::JoinedAndSeparateClass: @@ -384,15 +383,14 @@ "arguments to prepend to the command line")); } - // Find the maximum option length. + // Find the maximum option length. unsigned OptionFieldWidth = 0; for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) { // Skip titles. if (!OptionHelp[i].second) continue; - // Limit the amount of padding we are willing to give up for - // alignment. + // Limit the amount of padding we are willing to give up for alignment. unsigned Length = OptionHelp[i].first.size(); if (Length <= 23) OptionFieldWidth = std::max(OptionFieldWidth, Length); @@ -424,10 +422,10 @@ #else const char *revision = ""; #endif - // FIXME: The following handlers should use a callback mechanism, we - // don't know what the client would like to do. - OS << "clang version " CLANG_VERSION_STRING " (" - << vers << " " << revision << ")" << '\n'; + // FIXME: The following handlers should use a callback mechanism, we don't + // know what the client would like to do. + OS << "clang version " CLANG_VERSION_STRING " (" + << vers << " " << revision << ")" << '\n'; const ToolChain &TC = C.getDefaultToolChain(); OS << "Target: " << TC.getTripleString() << '\n'; @@ -439,28 +437,27 @@ } bool Driver::HandleImmediateArgs(const Compilation &C) { - // The order these options are handled in in gcc is all over the - // place, but we don't expect inconsistencies w.r.t. that to matter - // in practice. + // The order these options are handled in in gcc is all over the place, but we + // don't expect inconsistencies w.r.t. that to matter in practice. if (C.getArgs().hasArg(options::OPT_dumpversion)) { llvm::outs() << CLANG_VERSION_STRING "\n"; return false; } - if (C.getArgs().hasArg(options::OPT__help) || + if (C.getArgs().hasArg(options::OPT__help) || C.getArgs().hasArg(options::OPT__help_hidden)) { PrintHelp(C.getArgs().hasArg(options::OPT__help_hidden)); return false; } if (C.getArgs().hasArg(options::OPT__version)) { - // Follow gcc behavior and use stdout for --version and stderr for -v + // Follow gcc behavior and use stdout for --version and stderr for -v. PrintVersion(C, llvm::outs()); return false; } - if (C.getArgs().hasArg(options::OPT_v) || + if (C.getArgs().hasArg(options::OPT_v) || C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) { PrintVersion(C, llvm::errs()); SuppressMissingInputWarning = true; @@ -477,7 +474,7 @@ } llvm::outs() << "\n"; llvm::outs() << "libraries: ="; - for (ToolChain::path_list::const_iterator it = TC.getFilePaths().begin(), + for (ToolChain::path_list::const_iterator it = TC.getFilePaths().begin(), ie = TC.getFilePaths().end(); it != ie; ++it) { if (it != TC.getFilePaths().begin()) llvm::outs() << ':'; @@ -487,16 +484,16 @@ return false; } - // FIXME: The following handlers should use a callback mechanism, we - // don't know what the client would like to do. + // FIXME: The following handlers should use a callback mechanism, we don't + // know what the client would like to do. if (Arg *A = C.getArgs().getLastArg(options::OPT_print_file_name_EQ)) { - llvm::outs() << GetFilePath(A->getValue(C.getArgs()), TC).str() + llvm::outs() << GetFilePath(A->getValue(C.getArgs()), TC).str() << "\n"; return false; } if (Arg *A = C.getArgs().getLastArg(options::OPT_print_prog_name_EQ)) { - llvm::outs() << GetProgramPath(A->getValue(C.getArgs()), TC).str() + llvm::outs() << GetProgramPath(A->getValue(C.getArgs()), TC).str() << "\n"; return false; } @@ -513,7 +510,7 @@ switch (C.getDefaultToolChain().getTriple().getArch()) { default: break; - + case llvm::Triple::x86_64: llvm::outs() << "x86_64;@m64" << "\n"; break; @@ -535,7 +532,7 @@ case llvm::Triple::ppc: llvm::outs() << "." << "\n"; break; - + case llvm::Triple::x86_64: llvm::outs() << "x86_64" << "\n"; break; @@ -550,20 +547,19 @@ return true; } -static unsigned PrintActions1(const Compilation &C, - Action *A, +static unsigned PrintActions1(const Compilation &C, Action *A, std::map &Ids) { if (Ids.count(A)) return Ids[A]; - + std::string str; llvm::raw_string_ostream os(str); - + os << Action::getClassName(A->getKind()) << ", "; - if (InputAction *IA = dyn_cast(A)) { + if (InputAction *IA = dyn_cast(A)) { os << "\"" << IA->getInputArg().getValue(C.getArgs()) << "\""; } else if (BindArchAction *BIA = dyn_cast(A)) { - os << '"' << (BIA->getArchName() ? BIA->getArchName() : + os << '"' << (BIA->getArchName() ? BIA->getArchName() : C.getDefaultToolChain().getArchName()) << '"' << ", {" << PrintActions1(C, *BIA->begin(), Ids) << "}"; } else { @@ -579,7 +575,7 @@ unsigned Id = Ids.size(); Ids[A] = Id; - llvm::errs() << Id << ": " << os.str() << ", " + llvm::errs() << Id << ": " << os.str() << ", " << types::getTypeName(A->getType()) << "\n"; return Id; @@ -587,19 +583,19 @@ void Driver::PrintActions(const Compilation &C) const { std::map Ids; - for (ActionList::const_iterator it = C.getActions().begin(), + for (ActionList::const_iterator it = C.getActions().begin(), ie = C.getActions().end(); it != ie; ++it) PrintActions1(C, *it, Ids); } -void Driver::BuildUniversalActions(const ArgList &Args, +void Driver::BuildUniversalActions(const ArgList &Args, ActionList &Actions) const { - llvm::PrettyStackTraceString CrashInfo("Building actions for universal build"); - // Collect the list of architectures. Duplicates are allowed, but - // should only be handled once (in the order seen). + llvm::PrettyStackTraceString CrashInfo("Building universal build actions"); + // Collect the list of architectures. Duplicates are allowed, but should only + // be handled once (in the order seen). llvm::StringSet<> ArchNames; llvm::SmallVector Archs; - for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); + for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { Arg *A = *it; @@ -615,37 +611,33 @@ } } - // When there is no explicit arch for this platform, make sure we - // still bind the architecture (to the default) so that -Xarch_ is - // handled correctly. + // When there is no explicit arch for this platform, make sure we still bind + // the architecture (to the default) so that -Xarch_ is handled correctly. if (!Archs.size()) Archs.push_back(0); - // FIXME: We killed off some others but these aren't yet detected in - // a functional manner. If we added information to jobs about which - // "auxiliary" files they wrote then we could detect the conflict - // these cause downstream. + // FIXME: We killed off some others but these aren't yet detected in a + // functional manner. If we added information to jobs about which "auxiliary" + // files they wrote then we could detect the conflict these cause downstream. if (Archs.size() > 1) { // No recovery needed, the point of this is just to prevent // overwriting the same files. if (const Arg *A = Args.getLastArg(options::OPT_save_temps)) - Diag(clang::diag::err_drv_invalid_opt_with_multiple_archs) + Diag(clang::diag::err_drv_invalid_opt_with_multiple_archs) << A->getAsString(Args); } ActionList SingleActions; BuildActions(Args, SingleActions); - // Add in arch binding and lipo (if necessary) for every top level - // action. + // Add in arch binding and lipo (if necessary) for every top level action. for (unsigned i = 0, e = SingleActions.size(); i != e; ++i) { Action *Act = SingleActions[i]; - // Make sure we can lipo this kind of output. If not (and it is an - // actual output) then we disallow, since we can't create an - // output file with the right name without overwriting it. We - // could remove this oddity by just changing the output names to - // include the arch, which would also fix + // Make sure we can lipo this kind of output. If not (and it is an actual + // output) then we disallow, since we can't create an output file with the + // right name without overwriting it. We could remove this oddity by just + // changing the output names to include the arch, which would also fix // -save-temps. Compatibility wins for now. if (Archs.size() > 1 && !types::canLipoType(Act->getType())) @@ -656,8 +648,8 @@ for (unsigned i = 0, e = Archs.size(); i != e; ++i) Inputs.push_back(new BindArchAction(Act, Archs[i])); - // Lipo if necessary, We do it this way because we need to set the - // arch flag so that -Xarch_ gets overwritten. + // Lipo if necessary, we do it this way because we need to set the arch flag + // so that -Xarch_ gets overwritten. if (Inputs.size() == 1 || Act->getType() == types::TY_Nothing) Actions.append(Inputs.begin(), Inputs.end()); else @@ -669,15 +661,14 @@ llvm::PrettyStackTraceString CrashInfo("Building compilation actions"); // Start by constructing the list of inputs and their types. - // Track the current user specified (-x) input. We also explicitly - // track the argument used to set the type; we only want to claim - // the type when we actually use it, so we warn about unused -x - // arguments. + // Track the current user specified (-x) input. We also explicitly track the + // argument used to set the type; we only want to claim the type when we + // actually use it, so we warn about unused -x arguments. types::ID InputType = types::TY_Nothing; Arg *InputTypeArg = 0; llvm::SmallVector, 16> Inputs; - for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); + for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { Arg *A = *it; @@ -693,19 +684,18 @@ // stdin must be handled specially. if (memcmp(Value, "-", 2) == 0) { - // If running with -E, treat as a C input (this changes the - // builtin macros, for example). This may be overridden by - // -ObjC below. + // If running with -E, treat as a C input (this changes the builtin + // macros, for example). This may be overridden by -ObjC below. // - // Otherwise emit an error but still use a valid type to - // avoid spurious errors (e.g., no inputs). + // Otherwise emit an error but still use a valid type to avoid + // spurious errors (e.g., no inputs). if (!Args.hasArg(options::OPT_E, false)) Diag(clang::diag::err_drv_unknown_stdin_type); Ty = types::TY_C; } else { - // Otherwise lookup by extension, and fallback to ObjectType - // if not found. We use a host hook here because Darwin at - // least has its own idea of what .s is. + // Otherwise lookup by extension, and fallback to ObjectType if not + // found. We use a host hook here because Darwin at least has its own + // idea of what .s is. if (const char *Ext = strrchr(Value, '.')) Ty = Host->lookupTypeForExtension(Ext + 1); @@ -716,7 +706,7 @@ // -ObjC and -ObjC++ override the default language, but only for "source // files". We just treat everything that isn't a linker input as a // source file. - // + // // FIXME: Clean this up if we move the phase sequence into the type. if (Ty != types::TY_Object) { if (Args.hasArg(options::OPT_ObjC)) @@ -730,28 +720,26 @@ Ty = InputType; } - // Check that the file exists. It isn't clear this is worth - // doing, since the tool presumably does this anyway, and this - // just adds an extra stat to the equation, but this is gcc - // compatible. + // Check that the file exists. It isn't clear this is worth doing, since + // the tool presumably does this anyway, and this just adds an extra stat + // to the equation, but this is gcc compatible. if (memcmp(Value, "-", 2) != 0 && !llvm::sys::Path(Value).exists()) Diag(clang::diag::err_drv_no_such_file) << A->getValue(Args); else Inputs.push_back(std::make_pair(Ty, A)); } else if (A->getOption().isLinkerInput()) { - // Just treat as object type, we could make a special type for - // this if necessary. + // Just treat as object type, we could make a special type for this if + // necessary. Inputs.push_back(std::make_pair(types::TY_Object, A)); } else if (A->getOption().getId() == options::OPT_x) { - InputTypeArg = A; + InputTypeArg = A; InputType = types::lookupTypeForTypeSpecifier(A->getValue(Args)); // Follow gcc behavior and treat as linker input for invalid -x - // options. Its not clear why we shouldn't just revert to - // unknown; but this isn't very important, we might as well be - // bug comatible. + // options. Its not clear why we shouldn't just revert to unknown; but + // this isn't very important, we might as well be bug comatible. if (!InputType) { Diag(clang::diag::err_drv_unknown_language) << A->getValue(Args); InputType = types::TY_Object; @@ -764,9 +752,9 @@ return; } - // Determine which compilation mode we are in. We look for options - // which affect the phase, starting with the earliest phases, and - // record which option we used to determine the final phase. + // Determine which compilation mode we are in. We look for options which + // affect the phase, starting with the earliest phases, and record which + // option we used to determine the final phase. Arg *FinalPhaseArg = 0; phases::ID FinalPhase; @@ -775,7 +763,7 @@ (FinalPhaseArg = Args.getLastArg(options::OPT_M)) || (FinalPhaseArg = Args.getLastArg(options::OPT_MM))) { FinalPhase = phases::Preprocess; - + // -{fsyntax-only,-analyze,emit-ast,S} only run up to the compiler. } else if ((FinalPhaseArg = Args.getLastArg(options::OPT_fsyntax_only)) || (FinalPhaseArg = Args.getLastArg(options::OPT__analyze, @@ -787,13 +775,13 @@ // -c only runs up to the assembler. } else if ((FinalPhaseArg = Args.getLastArg(options::OPT_c))) { FinalPhase = phases::Assemble; - + // Otherwise do everything. } else FinalPhase = phases::Link; - // Reject -Z* at the top level, these options should never have been - // exposed by gcc. + // Reject -Z* at the top level, these options should never have been exposed + // by gcc. if (Arg *A = Args.getLastArg(options::OPT_Z_Joined)) Diag(clang::diag::err_drv_use_of_Z_option) << A->getAsString(Args); @@ -806,19 +794,19 @@ unsigned NumSteps = types::getNumCompilationPhases(InputType); assert(NumSteps && "Invalid number of steps!"); - // If the first step comes after the final phase we are doing as - // part of this compilation, warn the user about it. + // If the first step comes after the final phase we are doing as part of + // this compilation, warn the user about it. phases::ID InitialPhase = types::getCompilationPhase(InputType, 0); if (InitialPhase > FinalPhase) { // Claim here to avoid the more general unused warning. InputArg->claim(); - Diag(clang::diag::warn_drv_input_file_unused) + Diag(clang::diag::warn_drv_input_file_unused) << InputArg->getAsString(Args) << getPhaseName(InitialPhase) << FinalPhaseArg->getOption().getName(); continue; } - + // Build the pipeline for this file. Action *Current = new InputAction(*InputArg, InputType); for (unsigned i = 0; i != NumSteps; ++i) { @@ -836,9 +824,9 @@ break; } - // Some types skip the assembler phase (e.g., llvm-bc), but we - // can't encode this in the steps because the intermediate type - // depends on arguments. Just special case here. + // Some types skip the assembler phase (e.g., llvm-bc), but we can't + // encode this in the steps because the intermediate type depends on + // arguments. Just special case here. if (Phase == phases::Assemble && Current->getType() != types::TY_PP_Asm) continue; @@ -877,7 +865,7 @@ return new PreprocessJobAction(Input, OutputTy); } case phases::Precompile: - return new PrecompileJobAction(Input, types::TY_PCH); + return new PrecompileJobAction(Input, types::TY_PCH); case phases::Compile: { if (Args.hasArg(options::OPT_fsyntax_only)) { return new CompileJobAction(Input, types::TY_Nothing); @@ -888,7 +876,7 @@ } else if (Args.hasArg(options::OPT_emit_llvm) || Args.hasArg(options::OPT_flto) || Args.hasArg(options::OPT_O4)) { - types::ID Output = + types::ID Output = Args.hasArg(options::OPT_S) ? types::TY_LLVMAsm : types::TY_LLVMBC; return new CompileJobAction(Input, Output); } else { @@ -908,11 +896,10 @@ bool SaveTemps = C.getArgs().hasArg(options::OPT_save_temps); bool UsePipes = C.getArgs().hasArg(options::OPT_pipe); - // FIXME: Pipes are forcibly disabled until we support executing - // them. + // FIXME: Pipes are forcibly disabled until we support executing them. if (!CCCPrintBindings) UsePipes = false; - + // -save-temps inhibits pipes. if (SaveTemps && UsePipes) { Diag(clang::diag::warn_drv_pipe_ignored_with_save_temps); @@ -921,32 +908,31 @@ Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o); - // It is an error to provide a -o option if we are making multiple - // output files. + // It is an error to provide a -o option if we are making multiple output + // files. if (FinalOutput) { unsigned NumOutputs = 0; - for (ActionList::const_iterator it = C.getActions().begin(), + for (ActionList::const_iterator it = C.getActions().begin(), ie = C.getActions().end(); it != ie; ++it) if ((*it)->getType() != types::TY_Nothing) ++NumOutputs; - + if (NumOutputs > 1) { Diag(clang::diag::err_drv_output_argument_with_multiple_files); FinalOutput = 0; } } - for (ActionList::const_iterator it = C.getActions().begin(), + for (ActionList::const_iterator it = C.getActions().begin(), ie = C.getActions().end(); it != ie; ++it) { Action *A = *it; - // If we are linking an image for multiple archs then the linker - // wants -arch_multiple and -final_output . Unfortunately, this doesn't fit in cleanly because we - // have to pass this information down. + // If we are linking an image for multiple archs then the linker wants + // -arch_multiple and -final_output . Unfortunately, this + // doesn't fit in cleanly because we have to pass this information down. // - // FIXME: This is a hack; find a cleaner way to integrate this - // into the process. + // FIXME: This is a hack; find a cleaner way to integrate this into the + // process. const char *LinkingOutput = 0; if (isa(A)) { if (FinalOutput) @@ -956,41 +942,40 @@ } InputInfo II; - BuildJobsForAction(C, A, &C.getDefaultToolChain(), + BuildJobsForAction(C, A, &C.getDefaultToolChain(), /*CanAcceptPipe*/ true, /*AtTopLevel*/ true, /*LinkingOutput*/ LinkingOutput, II); } - // If the user passed -Qunused-arguments or there were errors, don't - // warn about any unused arguments. - if (Diags.getNumErrors() || + // If the user passed -Qunused-arguments or there were errors, don't warn + // about any unused arguments. + if (Diags.getNumErrors() || C.getArgs().hasArg(options::OPT_Qunused_arguments)) return; // Claim -### here. (void) C.getArgs().hasArg(options::OPT__HASH_HASH_HASH); - + for (ArgList::const_iterator it = C.getArgs().begin(), ie = C.getArgs().end(); it != ie; ++it) { Arg *A = *it; - + // FIXME: It would be nice to be able to send the argument to the - // Diagnostic, so that extra values, position, and so on could be - // printed. + // Diagnostic, so that extra values, position, and so on could be printed. if (!A->isClaimed()) { if (A->getOption().hasNoArgumentUnused()) continue; - // Suppress the warning automatically if this is just a flag, - // and it is an instance of an argument we already claimed. + // Suppress the warning automatically if this is just a flag, and it is an + // instance of an argument we already claimed. const Option &Opt = A->getOption(); if (isa(Opt)) { bool DuplicateClaimed = false; // FIXME: Use iterator. - for (ArgList::const_iterator it = C.getArgs().begin(), + for (ArgList::const_iterator it = C.getArgs().begin(), ie = C.getArgs().end(); it != ie; ++it) { if ((*it)->isClaimed() && (*it)->getOption().matches(Opt.getId())) { DuplicateClaimed = true; @@ -1002,7 +987,7 @@ continue; } - Diag(clang::diag::warn_drv_unused_argument) + Diag(clang::diag::warn_drv_unused_argument) << A->getAsString(C.getArgs()); } } @@ -1015,17 +1000,16 @@ bool AtTopLevel, const char *LinkingOutput, InputInfo &Result) const { - llvm::PrettyStackTraceString CrashInfo("Building compilation jobs for action"); + llvm::PrettyStackTraceString CrashInfo("Building compilation jobs"); bool UsePipes = C.getArgs().hasArg(options::OPT_pipe); - // FIXME: Pipes are forcibly disabled until we support executing - // them. + // FIXME: Pipes are forcibly disabled until we support executing them. if (!CCCPrintBindings) UsePipes = false; if (const InputAction *IA = dyn_cast(A)) { - // FIXME: It would be nice to not claim this here; maybe the old - // scheme of just using Args was better? + // FIXME: It would be nice to not claim this here; maybe the old scheme of + // just using Args was better? const Arg &Input = IA->getInputArg(); Input.claim(); if (isa(Input)) { @@ -1044,7 +1028,7 @@ ArchName = Arch.c_str(); } BuildJobsForAction(C, - *BAA->begin(), + *BAA->begin(), Host->getToolChain(C.getArgs(), ArchName), CanAcceptPipe, AtTopLevel, @@ -1055,10 +1039,10 @@ const JobAction *JA = cast(A); const Tool &T = TC->SelectTool(C, *JA); - - // See if we should use an integrated preprocessor. We do so when we - // have exactly one input, since this is the only use case we care - // about (irrelevant since we don't support combine yet). + + // See if we should use an integrated preprocessor. We do so when we have + // exactly one input, since this is the only use case we care about + // (irrelevant since we don't support combine yet). bool UseIntegratedCPP = false; const ActionList *Inputs = &A->getInputs(); if (Inputs->size() == 1 && isa(*Inputs->begin())) { @@ -1077,7 +1061,7 @@ for (ActionList::const_iterator it = Inputs->begin(), ie = Inputs->end(); it != ie; ++it) { InputInfo II; - BuildJobsForAction(C, *it, TC, TryToUsePipeInput, + BuildJobsForAction(C, *it, TC, TryToUsePipeInput, /*AtTopLevel*/false, LinkingOutput, II); @@ -1087,8 +1071,8 @@ // Determine if we should output to a pipe. bool OutputToPipe = false; if (CanAcceptPipe && T.canPipeOutput()) { - // Some actions default to writing to a pipe if they are the top - // level phase and there was no user override. + // Some actions default to writing to a pipe if they are the top level phase + // and there was no user override. // // FIXME: Is there a better way to handle this? if (AtTopLevel) { @@ -1109,8 +1093,8 @@ // Always use the first input as the base input. const char *BaseInput = InputInfos[0].getBaseInput(); - // Determine the place to write output to (nothing, pipe, or - // filename) and where to put the new job. + // Determine the place to write output to (nothing, pipe, or filename) and + // where to put the new job. if (JA->getType() == types::TY_Nothing) { Result = InputInfo(A->getType(), BaseInput); } else if (OutputToPipe) { @@ -1118,8 +1102,8 @@ PipedJob *PJ = dyn_cast(Dest); if (!PJ) { PJ = new PipedJob(); - // FIXME: Temporary hack so that -ccc-print-bindings work until - // we have pipe support. Please remove later. + // FIXME: Temporary hack so that -ccc-print-bindings work until we have + // pipe support. Please remove later. if (!CCCPrintBindings) cast(Dest)->addJob(PJ); Dest = PJ; @@ -1140,12 +1124,12 @@ } llvm::errs() << "], output: " << Result.getAsString() << "\n"; } else { - T.ConstructJob(C, *JA, *Dest, Result, InputInfos, + T.ConstructJob(C, *JA, *Dest, Result, InputInfos, C.getArgsForToolChain(TC), LinkingOutput); } } -const char *Driver::GetNamedOutputPath(Compilation &C, +const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, const char *BaseInput, bool AtTopLevel) const { @@ -1158,7 +1142,7 @@ // Output to a temporary file? if (!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) { - std::string TmpName = + std::string TmpName = GetTemporaryPath(types::getTypeTempSuffix(JA.getType())); return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str())); } @@ -1183,8 +1167,7 @@ NamedOutput = C.getArgs().MakeArgString(Suffixed.c_str()); } - // As an annoying special case, PCH generation doesn't strip the - // pathname. + // As an annoying special case, PCH generation doesn't strip the pathname. if (JA.getType() == types::TY_PCH) { BasePath.eraseComponent(); if (BasePath.isEmpty()) @@ -1200,7 +1183,7 @@ llvm::sys::Path Driver::GetFilePath(const char *Name, const ToolChain &TC) const { const ToolChain::path_list &List = TC.getFilePaths(); - for (ToolChain::path_list::const_iterator + for (ToolChain::path_list::const_iterator it = List.begin(), ie = List.end(); it != ie; ++it) { llvm::sys::Path P(*it); P.appendComponent(Name); @@ -1211,11 +1194,11 @@ return llvm::sys::Path(Name); } -llvm::sys::Path Driver::GetProgramPath(const char *Name, +llvm::sys::Path Driver::GetProgramPath(const char *Name, const ToolChain &TC, bool WantFile) const { const ToolChain::path_list &List = TC.getProgramPaths(); - for (ToolChain::path_list::const_iterator + for (ToolChain::path_list::const_iterator it = List.begin(), ie = List.end(); it != ie; ++it) { llvm::sys::Path P(*it); P.appendComponent(Name); @@ -1232,8 +1215,8 @@ } std::string Driver::GetTemporaryPath(const char *Suffix) const { - // FIXME: This is lame; sys::Path should provide this function (in - // particular, it should know how to find the temporary files dir). + // FIXME: This is lame; sys::Path should provide this function (in particular, + // it should know how to find the temporary files dir). std::string Error; const char *TmpDir = ::getenv("TMPDIR"); if (!TmpDir) @@ -1249,8 +1232,7 @@ return ""; } - // FIXME: Grumble, makeUnique sometimes leaves the file around!? - // PR3837. + // FIXME: Grumble, makeUnique sometimes leaves the file around!? PR3837. P.eraseFromDisk(false, 0); P.appendSuffix(Suffix); @@ -1288,8 +1270,8 @@ else if (ArchNameStr == "powerpc64") ArchName = "ppc64"; - // Check if user requested no clang, or clang doesn't understand - // this type (we only handle single inputs for now). + // Check if user requested no clang, or clang doesn't understand this type (we + // only handle single inputs for now). if (!CCCUseClang || JA.size() != 1 || !types::isAcceptedByClang((*JA.begin())->getType())) return false; @@ -1309,13 +1291,12 @@ return false; } - // Always use clang for precompiling and AST generation, regardless of - // archs. + // Always use clang for precompiling and AST generation, regardless of archs. if (isa(JA) || JA.getType() == types::TY_AST) return true; - // Finally, don't use clang if this isn't one of the user specified - // archs to build. + // Finally, don't use clang if this isn't one of the user specified archs to + // build. if (!CCCClangArchs.empty() && !CCCClangArchs.count(ArchName)) { Diag(clang::diag::warn_drv_not_using_clang_arch) << ArchName; return false; @@ -1324,19 +1305,18 @@ return true; } -/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and -/// return the grouped values as integers. Numbers which are not -/// provided are set to 0. +/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and return the +/// grouped values as integers. Numbers which are not provided are set to 0. /// -/// \return True if the entire string was parsed (9.2), or all groups -/// were parsed (10.3.5extrastuff). -bool Driver::GetReleaseVersion(const char *Str, unsigned &Major, +/// \return True if the entire string was parsed (9.2), or all groups were +/// parsed (10.3.5extrastuff). +bool Driver::GetReleaseVersion(const char *Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra) { HadExtra = false; Major = Minor = Micro = 0; - if (*Str == '\0') + if (*Str == '\0') return true; char *End; @@ -1345,7 +1325,7 @@ return true; if (*End != '.') return false; - + Str = End+1; Minor = (unsigned) strtol(Str, &End, 10); if (*Str != '\0' && *End == '\0') From daniel at zuster.org Tue Sep 8 18:36:55 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 23:36:55 -0000 Subject: [cfe-commits] r81276 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Driver.cpp lib/Driver/ToolChains.cpp test/Driver/bindings.c Message-ID: <200909082336.n88NauY6027782@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 18:36:55 2009 New Revision: 81276 URL: http://llvm.org/viewvc/llvm-project?rev=81276&view=rev Log: Fix ShouldUseClangCompiler to use llvm::Triple. - -1 FIXME, and fixes 'clang -arch armv4t ...', for example. Modified: cfe/trunk/include/clang/Driver/Driver.h cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/test/Driver/bindings.c Modified: cfe/trunk/include/clang/Driver/Driver.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=81276&r1=81275&r2=81276&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Driver.h (original) +++ cfe/trunk/include/clang/Driver/Driver.h Tue Sep 8 18:36:55 2009 @@ -15,6 +15,7 @@ #include "clang/Driver/Phases.h" #include "clang/Driver/Util.h" +#include "llvm/ADT/Triple.h" #include "llvm/System/Path.h" // FIXME: Kill when CompilationInfo // lands. #include @@ -102,7 +103,7 @@ private: /// Only use clang for the given architectures (only used when /// non-empty). - std::set CCCClangArchs; + std::set CCCClangArchs; /// Certain options suppress the 'no input files' warning. bool SuppressMissingInputWarning : 1; @@ -260,7 +261,7 @@ /// ShouldUseClangCompilar - Should the clang compiler be used to /// handle this action. bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA, - const std::string &ArchName) const; + const llvm::Triple &ArchName) const; /// @} Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81276&r1=81275&r2=81276&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 8 18:36:55 2009 @@ -60,12 +60,9 @@ { #ifdef USE_PRODUCTION_CLANG // In a "production" build, only use clang on architectures we expect to work. - CCCClangArchs.insert("i386"); - CCCClangArchs.insert("x86_64"); - CCCClangArchs.insert("arm"); - CCCClangArchs.insert("armv5"); - CCCClangArchs.insert("armv6"); - CCCClangArchs.insert("armv7"); + CCCClangArchs.insert(llvm::Triple::x86); + CCCClangArchs.insert(llvm::Triple::x86_64); + CCCClangArchs.insert(llvm::Triple::arm); #endif } @@ -169,23 +166,27 @@ CCCUseClangCPP = false; } else if (!strcmp(Opt, "clang-archs")) { assert(Start+1 < End && "FIXME: -ccc- argument handling."); - const char *Cur = *++Start; + llvm::StringRef Cur = *++Start; CCCClangArchs.clear(); - for (;;) { - const char *Next = strchr(Cur, ','); + while (!Cur.empty()) { + std::pair Split = Cur.split(','); - if (Next) { - if (Cur != Next) - CCCClangArchs.insert(std::string(Cur, Next)); - Cur = Next + 1; - } else { - if (*Cur != '\0') - CCCClangArchs.insert(std::string(Cur)); - break; + if (!Split.first.empty()) { + llvm::Triple::ArchType Arch = + llvm::Triple(Split.first, "", "").getArch(); + + if (Arch == llvm::Triple::UnknownArch) { + // FIXME: Error handling. + llvm::errs() << "invalid arch name: " << Split.first << "\n"; + exit(1); + } + + CCCClangArchs.insert(Arch); } - } + Cur = Split.second; + } } else if (!strcmp(Opt, "host-triple")) { assert(Start+1 < End && "FIXME: -ccc- argument handling."); HostTriple = *++Start; @@ -1262,14 +1263,7 @@ } bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA, - const std::string &ArchNameStr) const { - // FIXME: Remove this hack. - const char *ArchName = ArchNameStr.c_str(); - if (ArchNameStr == "powerpc") - ArchName = "ppc"; - else if (ArchNameStr == "powerpc64") - ArchName = "ppc64"; - + const llvm::Triple &Triple) const { // Check if user requested no clang, or clang doesn't understand this type (we // only handle single inputs for now). if (!CCCUseClang || JA.size() != 1 || @@ -1297,8 +1291,8 @@ // Finally, don't use clang if this isn't one of the user specified archs to // build. - if (!CCCClangArchs.empty() && !CCCClangArchs.count(ArchName)) { - Diag(clang::diag::warn_drv_not_using_clang_arch) << ArchName; + if (!CCCClangArchs.empty() && !CCCClangArchs.count(Triple.getArch())) { + Diag(clang::diag::warn_drv_not_using_clang_arch) << Triple.getArchName(); return false; } Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=81276&r1=81275&r2=81276&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Sep 8 18:36:55 2009 @@ -103,7 +103,7 @@ Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -338,7 +338,7 @@ Tool &Generic_GCC::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -404,7 +404,7 @@ Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -439,7 +439,7 @@ Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -480,7 +480,7 @@ Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); @@ -545,7 +545,7 @@ Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA) const { Action::ActionClass Key; - if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName())) + if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple())) Key = Action::AnalyzeJobClass; else Key = JA.getKind(); Modified: cfe/trunk/test/Driver/bindings.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/bindings.c?rev=81276&r1=81275&r2=81276&view=diff ============================================================================== --- cfe/trunk/test/Driver/bindings.c (original) +++ cfe/trunk/test/Driver/bindings.c Tue Sep 8 18:36:55 2009 @@ -39,7 +39,7 @@ // RUN: grep '"clang", inputs: \[".*\.i"\], output: (nothing)' %t && // RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs i386 %s -S -arch ppc 2> %t && // RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t && -// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs ppc %s -S -arch ppc 2> %t && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs powerpc %s -S -arch ppc 2> %t && // RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t && // RUN: clang -ccc-host-triple powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "" %s -S 2> %t && From daniel at zuster.org Tue Sep 8 18:37:02 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 23:37:02 -0000 Subject: [cfe-commits] r81277 - /cfe/trunk/lib/Driver/Driver.cpp Message-ID: <200909082337.n88Nb20f027808@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 18:37:02 2009 New Revision: 81277 URL: http://llvm.org/viewvc/llvm-project?rev=81277&view=rev Log: Simplify. Modified: cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81277&r1=81276&r2=81277&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 8 18:37:02 2009 @@ -601,14 +601,9 @@ Arg *A = *it; if (A->getOption().getId() == options::OPT_arch) { - const char *Name = A->getValue(Args); - - // FIXME: We need to handle canonicalization of the specified - // arch? - A->claim(); - if (ArchNames.insert(Name)) - Archs.push_back(Name); + if (ArchNames.insert(A->getValue(Args))) + Archs.push_back(A->getValue(Args)); } } From daniel at zuster.org Tue Sep 8 18:37:09 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 23:37:09 -0000 Subject: [cfe-commits] r81278 - /cfe/trunk/lib/Driver/HostInfo.cpp Message-ID: <200909082337.n88Nb9rm027833@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 18:37:08 2009 New Revision: 81278 URL: http://llvm.org/viewvc/llvm-project?rev=81278&view=rev Log: Delete trailing whitespace. Modified: cfe/trunk/lib/Driver/HostInfo.cpp Modified: cfe/trunk/lib/Driver/HostInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=81278&r1=81277&r2=81278&view=diff ============================================================================== --- cfe/trunk/lib/Driver/HostInfo.cpp (original) +++ cfe/trunk/lib/Driver/HostInfo.cpp Tue Sep 8 18:37:08 2009 @@ -22,13 +22,13 @@ #include "ToolChains.h" #include - + using namespace clang::driver; HostInfo::HostInfo(const Driver &D, const llvm::Triple &_Triple) : TheDriver(D), Triple(_Triple) { - + } HostInfo::~HostInfo() { @@ -66,14 +66,14 @@ return Ty; } - virtual ToolChain *getToolChain(const ArgList &Args, + virtual ToolChain *getToolChain(const ArgList &Args, const char *ArchName) const; }; DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple) : HostInfo(D, Triple) { - - assert((getArchName() == "i386" || getArchName() == "x86_64" || + + assert((getArchName() == "i386" || getArchName() == "x86_64" || getArchName() == "powerpc" || getArchName() == "powerpc64" || getArchName() == "arm") && "Unknown Darwin arch."); @@ -81,13 +81,13 @@ assert(memcmp(&getOSName()[0], "darwin", 6) == 0 && "Unknown Darwin platform."); bool HadExtra; - if (!Driver::GetReleaseVersion(&getOSName()[6], - DarwinVersion[0], DarwinVersion[1], + if (!Driver::GetReleaseVersion(&getOSName()[6], + DarwinVersion[0], DarwinVersion[1], DarwinVersion[2], HadExtra)) { D.Diag(clang::diag::err_drv_invalid_darwin_version) << getOSName(); } - + // We can only call 4.2.1 for now. GCCVersion[0] = 4; GCCVersion[1] = 2; @@ -100,11 +100,11 @@ delete it->second; } -bool DarwinHostInfo::useDriverDriver() const { +bool DarwinHostInfo::useDriverDriver() const { return true; } -ToolChain *DarwinHostInfo::getToolChain(const ArgList &Args, +ToolChain *DarwinHostInfo::getToolChain(const ArgList &Args, const char *ArchName) const { std::string Arch; if (!ArchName) { @@ -115,7 +115,7 @@ // things which rely on a default architecture. We just use the last -arch // to find the default tool chain. Arch = A->getValue(Args); - + // Normalize arch name; we shouldn't be doing this here. // // FIXME: This should be unnecessary once everything moves over to using @@ -129,17 +129,17 @@ Arch = getArchName(); } ArchName = Arch.c_str(); - + // Honor -m32 and -m64 when finding the default tool chain. if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { if (Arch == "i386" || Arch == "x86_64") { - ArchName = (A->getOption().getId() == options::OPT_m32) ? "i386" : + ArchName = (A->getOption().getId() == options::OPT_m32) ? "i386" : "x86_64"; } else if (Arch == "powerpc" || Arch == "powerpc64") { - ArchName = (A->getOption().getId() == options::OPT_m32) ? "powerpc" : + ArchName = (A->getOption().getId() == options::OPT_m32) ? "powerpc" : "powerpc64"; } - } + } } else { // Normalize arch name; we shouldn't be doing this here. // @@ -192,11 +192,11 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, + virtual ToolChain *getToolChain(const ArgList &Args, const char *ArchName) const; }; -UnknownHostInfo::UnknownHostInfo(const Driver &D, const llvm::Triple& Triple) +UnknownHostInfo::UnknownHostInfo(const Driver &D, const llvm::Triple& Triple) : HostInfo(D, Triple) { } @@ -206,15 +206,15 @@ delete it->second; } -bool UnknownHostInfo::useDriverDriver() const { +bool UnknownHostInfo::useDriverDriver() const { return false; } -ToolChain *UnknownHostInfo::getToolChain(const ArgList &Args, +ToolChain *UnknownHostInfo::getToolChain(const ArgList &Args, const char *ArchName) const { - assert(!ArchName && + assert(!ArchName && "Unexpected arch name on platform without driver driver support."); - + // Automatically handle some instances of -m32/-m64 we know about. std::string Arch = getArchName(); ArchName = Arch.c_str(); @@ -228,8 +228,8 @@ ArchName = (A->getOption().getId() == options::OPT_m32) ? "powerpc" : "powerpc64"; } - } - + } + ToolChain *&TC = ToolChains[ArchName]; if (!TC) { llvm::Triple TCTriple(getTriple()); @@ -249,7 +249,7 @@ mutable llvm::StringMap ToolChains; public: - OpenBSDHostInfo(const Driver &D, const llvm::Triple& Triple) + OpenBSDHostInfo(const Driver &D, const llvm::Triple& Triple) : HostInfo(D, Triple) {} ~OpenBSDHostInfo(); @@ -259,7 +259,7 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, + virtual ToolChain *getToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -269,18 +269,18 @@ delete it->second; } -bool OpenBSDHostInfo::useDriverDriver() const { +bool OpenBSDHostInfo::useDriverDriver() const { return false; } -ToolChain *OpenBSDHostInfo::getToolChain(const ArgList &Args, +ToolChain *OpenBSDHostInfo::getToolChain(const ArgList &Args, const char *ArchName) const { - assert(!ArchName && + assert(!ArchName && "Unexpected arch name on platform without driver driver support."); - + std::string Arch = getArchName(); ArchName = Arch.c_str(); - + ToolChain *&TC = ToolChains[ArchName]; if (!TC) { llvm::Triple TCTriple(getTriple()); @@ -311,12 +311,12 @@ } virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + const char *ArchName) const; }; AuroraUXHostInfo::~AuroraUXHostInfo() { for (llvm::StringMap::iterator - it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) + it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) delete it->second; } @@ -325,9 +325,9 @@ } ToolChain *AuroraUXHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { + const char *ArchName) const { assert(!ArchName && - "Unexpected arch name on platform without driver driver support."); + "Unexpected arch name on platform without driver driver support."); ToolChain *&TC = ToolChains[getArchName()]; @@ -349,7 +349,7 @@ mutable llvm::StringMap ToolChains; public: - FreeBSDHostInfo(const Driver &D, const llvm::Triple& Triple) + FreeBSDHostInfo(const Driver &D, const llvm::Triple& Triple) : HostInfo(D, Triple) {} ~FreeBSDHostInfo(); @@ -359,7 +359,7 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, + virtual ToolChain *getToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -369,17 +369,17 @@ delete it->second; } -bool FreeBSDHostInfo::useDriverDriver() const { +bool FreeBSDHostInfo::useDriverDriver() const { return false; } -ToolChain *FreeBSDHostInfo::getToolChain(const ArgList &Args, +ToolChain *FreeBSDHostInfo::getToolChain(const ArgList &Args, const char *ArchName) const { bool Lib32 = false; - assert(!ArchName && + assert(!ArchName && "Unexpected arch name on platform without driver driver support."); - + // On x86_64 we need to be able to compile 32-bits binaries as well. // Compiling 64-bit binaries on i386 is not supported. We don't have a // lib64. @@ -388,8 +388,8 @@ if (Args.hasArg(options::OPT_m32) && getArchName() == "x86_64") { ArchName = "i386"; Lib32 = true; - } - + } + ToolChain *&TC = ToolChains[ArchName]; if (!TC) { llvm::Triple TCTriple(getTriple()); @@ -419,7 +419,7 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, + virtual ToolChain *getToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -429,13 +429,13 @@ delete it->second; } -bool DragonFlyHostInfo::useDriverDriver() const { +bool DragonFlyHostInfo::useDriverDriver() const { return false; } -ToolChain *DragonFlyHostInfo::getToolChain(const ArgList &Args, +ToolChain *DragonFlyHostInfo::getToolChain(const ArgList &Args, const char *ArchName) const { - assert(!ArchName && + assert(!ArchName && "Unexpected arch name on platform without driver driver support."); ToolChain *&TC = ToolChains[getArchName()]; @@ -468,7 +468,7 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, + virtual ToolChain *getToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -478,14 +478,14 @@ delete it->second; } -bool LinuxHostInfo::useDriverDriver() const { +bool LinuxHostInfo::useDriverDriver() const { return false; } -ToolChain *LinuxHostInfo::getToolChain(const ArgList &Args, +ToolChain *LinuxHostInfo::getToolChain(const ArgList &Args, const char *ArchName) const { - assert(!ArchName && + assert(!ArchName && "Unexpected arch name on platform without driver driver support."); // Automatically handle some instances of -m32/-m64 we know about. @@ -519,7 +519,7 @@ const HostInfo * clang::driver::createAuroraUXHostInfo(const Driver &D, - const llvm::Triple& Triple){ + const llvm::Triple& Triple){ return new AuroraUXHostInfo(D, Triple); } @@ -530,13 +530,13 @@ } const HostInfo * -clang::driver::createOpenBSDHostInfo(const Driver &D, +clang::driver::createOpenBSDHostInfo(const Driver &D, const llvm::Triple& Triple) { return new OpenBSDHostInfo(D, Triple); } const HostInfo * -clang::driver::createFreeBSDHostInfo(const Driver &D, +clang::driver::createFreeBSDHostInfo(const Driver &D, const llvm::Triple& Triple) { return new FreeBSDHostInfo(D, Triple); } From daniel at zuster.org Tue Sep 8 18:37:19 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 23:37:19 -0000 Subject: [cfe-commits] r81279 - in /cfe/trunk: include/clang/Driver/HostInfo.h lib/Driver/Driver.cpp lib/Driver/HostInfo.cpp Message-ID: <200909082337.n88NbJYL027861@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 18:37:19 2009 New Revision: 81279 URL: http://llvm.org/viewvc/llvm-project?rev=81279&view=rev Log: Rename HostInfo::getToolChain to HostInfo::CreateToolChain, and don't recreate the default tool chain when binding the default architecture. Modified: cfe/trunk/include/clang/Driver/HostInfo.h cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/HostInfo.cpp Modified: cfe/trunk/include/clang/Driver/HostInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/HostInfo.h?rev=81279&r1=81278&r2=81279&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/HostInfo.h (original) +++ cfe/trunk/include/clang/Driver/HostInfo.h Tue Sep 8 18:37:19 2009 @@ -20,13 +20,13 @@ class Driver; class ToolChain; -/// HostInfo - Config information about a particular host which may -/// interact with driver behavior. +/// HostInfo - Config information about a particular host which may interact +/// with driver behavior. /// -/// The host information is used for controlling the parts of the -/// driver which interact with the platform the driver is ostensibly -/// being run from. For testing purposes, the HostInfo used by the -/// driver may differ from the actual host. +/// The host information is used for controlling the parts of the driver which +/// interact with the platform the driver is ostensibly being run from. For +/// testing purposes, the HostInfo used by the driver may differ from the actual +/// host. class HostInfo { protected: const Driver &TheDriver; @@ -44,27 +44,28 @@ std::string getPlatformName() const { return Triple.getVendorName(); } std::string getOSName() const { return Triple.getOSName(); } - /// useDriverDriver - Whether the driver should act as a driver - /// driver for this host and support -arch, -Xarch, etc. + /// useDriverDriver - Whether the driver should act as a driver driver for + /// this host and support -arch, -Xarch, etc. virtual bool useDriverDriver() const = 0; - /// lookupTypeForExtension - Return the default language type to use - /// for the given extension. + /// lookupTypeForExtension - Return the default language type to use for the + /// given extension. virtual types::ID lookupTypeForExtension(const char *Ext) const = 0; - /// getToolChain - Construct the toolchain to use for this host. + /// CreateToolChain - Construct the toolchain to use for this host (which the + /// host retains ownership of). /// - /// \param Args - The argument list, which may be used to alter the - /// default toolchain, for example in the presence of -m32 or -m64. + /// \param Args - The argument list, which may be used to alter the default + /// toolchain, for example in the presence of -m32 or -m64. /// - /// \param ArchName - The architecture to return a toolchain for, or - /// 0 if unspecified. This will only ever be non-zero for hosts - /// which support a driver driver. + /// \param ArchName - The architecture to return a toolchain for, or 0 if + /// unspecified. This will only ever be non-zero for hosts which support a + /// driver driver. // FIXME: Pin down exactly what the HostInfo is allowed to use Args // for here. Currently this is for -m32 / -m64 defaulting. - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName=0) const = 0; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName=0) const = 0; }; const HostInfo *createAuroraUXHostInfo(const Driver &D, Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81279&r1=81278&r2=81279&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 8 18:37:19 2009 @@ -207,7 +207,7 @@ Host = GetHostInfo(HostTriple); // The compilation takes ownership of Args. - Compilation *C = new Compilation(*this, *Host->getToolChain(*Args), Args); + Compilation *C = new Compilation(*this, *Host->CreateToolChain(*Args), Args); // FIXME: This behavior shouldn't be here. if (CCCPrintOptions) { @@ -1017,19 +1017,14 @@ } if (const BindArchAction *BAA = dyn_cast(A)) { - const char *ArchName = BAA->getArchName(); + const ToolChain *TC = &C.getDefaultToolChain(); + std::string Arch; - if (!ArchName) { - Arch = C.getDefaultToolChain().getArchName(); - ArchName = Arch.c_str(); - } - BuildJobsForAction(C, - *BAA->begin(), - Host->getToolChain(C.getArgs(), ArchName), - CanAcceptPipe, - AtTopLevel, - LinkingOutput, - Result); + if (BAA->getArchName()) + TC = Host->CreateToolChain(C.getArgs(), BAA->getArchName()); + + BuildJobsForAction(C, *BAA->begin(), TC, CanAcceptPipe, AtTopLevel, + LinkingOutput, Result); return; } Modified: cfe/trunk/lib/Driver/HostInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=81279&r1=81278&r2=81279&view=diff ============================================================================== --- cfe/trunk/lib/Driver/HostInfo.cpp (original) +++ cfe/trunk/lib/Driver/HostInfo.cpp Tue Sep 8 18:37:19 2009 @@ -66,8 +66,8 @@ return Ty; } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple) @@ -104,8 +104,8 @@ return true; } -ToolChain *DarwinHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { std::string Arch; if (!ArchName) { // If we aren't looking for a specific arch, infer the default architecture @@ -192,8 +192,8 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; UnknownHostInfo::UnknownHostInfo(const Driver &D, const llvm::Triple& Triple) @@ -210,8 +210,8 @@ return false; } -ToolChain *UnknownHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *UnknownHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -259,8 +259,8 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; OpenBSDHostInfo::~OpenBSDHostInfo() { @@ -273,8 +273,8 @@ return false; } -ToolChain *OpenBSDHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *OpenBSDHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -310,8 +310,8 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; AuroraUXHostInfo::~AuroraUXHostInfo() { @@ -324,8 +324,8 @@ return false; } -ToolChain *AuroraUXHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *AuroraUXHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -359,8 +359,8 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; FreeBSDHostInfo::~FreeBSDHostInfo() { @@ -373,8 +373,8 @@ return false; } -ToolChain *FreeBSDHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *FreeBSDHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { bool Lib32 = false; assert(!ArchName && @@ -419,8 +419,8 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; DragonFlyHostInfo::~DragonFlyHostInfo() { @@ -433,8 +433,8 @@ return false; } -ToolChain *DragonFlyHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *DragonFlyHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -468,8 +468,8 @@ return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; LinuxHostInfo::~LinuxHostInfo() { @@ -482,8 +482,8 @@ return false; } -ToolChain *LinuxHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *LinuxHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); From daniel at zuster.org Tue Sep 8 18:37:30 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 23:37:30 -0000 Subject: [cfe-commits] r81281 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.td lib/Driver/Driver.cpp Message-ID: <200909082337.n88NbUkS027922@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 18:37:30 2009 New Revision: 81281 URL: http://llvm.org/viewvc/llvm-project?rev=81281&view=rev Log: Validate arguments to -arch. Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=81281&r1=81280&r2=81281&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Sep 8 18:37:30 2009 @@ -14,6 +14,8 @@ def err_drv_unknown_stdin_type : Error< "-E or -x required when input is from standard input">; def err_drv_unknown_language : Error<"language not recognized: '%0'">; +def err_drv_invalid_arch_name : Error< + "invalid arch name '%0'">; def err_drv_invalid_opt_with_multiple_archs : Error< "option '%0' cannot be used with multiple -arch options">; def err_drv_invalid_output_with_multiple_archs : Error< Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81281&r1=81280&r2=81281&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 8 18:37:30 2009 @@ -601,6 +601,16 @@ Arg *A = *it; if (A->getOption().getId() == options::OPT_arch) { + // Validate the option here; we don't save the type here because its + // particular spelling may participate in other driver choices. + llvm::Triple::ArchType Arch = + llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args)); + if (Arch == llvm::Triple::UnknownArch) { + Diag(clang::diag::err_drv_invalid_arch_name) + << A->getAsString(Args); + continue; + } + A->claim(); if (ArchNames.insert(A->getValue(Args))) Archs.push_back(A->getValue(Args)); From daniel at zuster.org Tue Sep 8 18:37:36 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 08 Sep 2009 23:37:36 -0000 Subject: [cfe-commits] r81282 - /cfe/trunk/lib/Driver/HostInfo.cpp Message-ID: <200909082337.n88Nba7j027948@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Sep 8 18:37:36 2009 New Revision: 81282 URL: http://llvm.org/viewvc/llvm-project?rev=81282&view=rev Log: Change Darwin toolchain lookup to use llvm::Triple. - -2+1 FIXMEs. Modified: cfe/trunk/lib/Driver/HostInfo.cpp Modified: cfe/trunk/lib/Driver/HostInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=81282&r1=81281&r2=81282&view=diff ============================================================================== --- cfe/trunk/lib/Driver/HostInfo.cpp (original) +++ cfe/trunk/lib/Driver/HostInfo.cpp Tue Sep 8 18:37:36 2009 @@ -47,7 +47,7 @@ unsigned GCCVersion[3]; /// Cache of tool chains we have created. - mutable llvm::StringMap ToolChains; + mutable llvm::DenseMap ToolChains; public: DarwinHostInfo(const Driver &D, const llvm::Triple &Triple); @@ -73,20 +73,14 @@ DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple) : HostInfo(D, Triple) { - assert((getArchName() == "i386" || getArchName() == "x86_64" || - getArchName() == "powerpc" || getArchName() == "powerpc64" || - getArchName() == "arm") && - "Unknown Darwin arch."); - + assert(Triple.getArch() != llvm::Triple::UnknownArch && "Invalid arch!"); assert(memcmp(&getOSName()[0], "darwin", 6) == 0 && "Unknown Darwin platform."); bool HadExtra; if (!Driver::GetReleaseVersion(&getOSName()[6], DarwinVersion[0], DarwinVersion[1], - DarwinVersion[2], HadExtra)) { - D.Diag(clang::diag::err_drv_invalid_darwin_version) - << getOSName(); - } + DarwinVersion[2], HadExtra)) + D.Diag(clang::diag::err_drv_invalid_darwin_version) << getOSName(); // We can only call 4.2.1 for now. GCCVersion[0] = 4; @@ -95,7 +89,7 @@ } DarwinHostInfo::~DarwinHostInfo() { - for (llvm::StringMap::iterator + for (llvm::DenseMap::iterator it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) delete it->second; } @@ -106,66 +100,57 @@ ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args, const char *ArchName) const { - std::string Arch; + llvm::Triple::ArchType Arch; + if (!ArchName) { // If we aren't looking for a specific arch, infer the default architecture // based on -arch and -m32/-m64 command line options. if (Arg *A = Args.getLastArg(options::OPT_arch)) { // The gcc driver behavior with multiple -arch flags wasn't consistent for // things which rely on a default architecture. We just use the last -arch - // to find the default tool chain. - Arch = A->getValue(Args); + // to find the default tool chain (assuming it is valid.. + Arch = llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args)); - // Normalize arch name; we shouldn't be doing this here. - // - // FIXME: This should be unnecessary once everything moves over to using - // the ID based Triple interface. - if (Arch == "ppc") - Arch = "powerpc"; - else if (Arch == "ppc64") - Arch = "powerpc64"; + // If it was invalid just use the host, we will reject this command line + // later. + if (Arch == llvm::Triple::UnknownArch) + Arch = getTriple().getArch(); } else { // Otherwise default to the arch of the host. - Arch = getArchName(); + Arch = getTriple().getArch(); } - ArchName = Arch.c_str(); // Honor -m32 and -m64 when finding the default tool chain. + // + // FIXME: Should this information be in llvm::Triple? if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { - if (Arch == "i386" || Arch == "x86_64") { - ArchName = (A->getOption().getId() == options::OPT_m32) ? "i386" : - "x86_64"; - } else if (Arch == "powerpc" || Arch == "powerpc64") { - ArchName = (A->getOption().getId() == options::OPT_m32) ? "powerpc" : - "powerpc64"; + if (A->getOption().getId() == options::OPT_m32) { + if (Arch == llvm::Triple::x86_64) + Arch = llvm::Triple::x86; + if (Arch == llvm::Triple::ppc64) + Arch = llvm::Triple::ppc; + } else { + if (Arch == llvm::Triple::x86) + Arch = llvm::Triple::x86_64; + if (Arch == llvm::Triple::ppc) + Arch = llvm::Triple::ppc64; } } - } else { - // Normalize arch name; we shouldn't be doing this here. - // - // FIXME: This should be unnecessary once everything moves over to using the - // ID based Triple interface. - if (strcmp(ArchName, "ppc") == 0) - ArchName = "powerpc"; - else if (strcmp(ArchName, "ppc64") == 0) - ArchName = "powerpc64"; - } + } else + Arch = llvm::Triple::getArchTypeForDarwinArchName(ArchName); - ToolChain *&TC = ToolChains[ArchName]; + assert(Arch != llvm::Triple::UnknownArch && "Unexpected arch!"); + ToolChain *&TC = ToolChains[Arch]; if (!TC) { llvm::Triple TCTriple(getTriple()); - TCTriple.setArchName(ArchName); + TCTriple.setArch(Arch); - if (strcmp(ArchName, "i386") == 0 || strcmp(ArchName, "x86_64") == 0) - TC = new toolchains::Darwin(*this, TCTriple, - DarwinVersion, - GCCVersion, + // If we recognized the arch, match it to the toolchains we support. + if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) + TC = new toolchains::Darwin(*this, TCTriple, DarwinVersion, GCCVersion, false); - else if (strncmp(ArchName, "arm", 3) == 0 || - strncmp(ArchName, "thumb", 5) == 0) - TC = new toolchains::Darwin(*this, TCTriple, - DarwinVersion, - GCCVersion, + else if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) + TC = new toolchains::Darwin(*this, TCTriple, DarwinVersion, GCCVersion, true); else TC = new toolchains::Darwin_GCC(*this, TCTriple); From fjahanian at apple.com Tue Sep 8 18:38:54 2009 From: fjahanian at apple.com (Fariborz Jahanian) Date: Tue, 08 Sep 2009 23:38:54 -0000 Subject: [cfe-commits] r81283 - in /cfe/trunk: lib/AST/Expr.cpp test/CodeGenObjC/objc2-strong-cast-4.m Message-ID: <200909082338.n88NcsiB028127@zion.cs.uiuc.edu> Author: fjahanian Date: Tue Sep 8 18:38:54 2009 New Revision: 81283 URL: http://llvm.org/viewvc/llvm-project?rev=81283&view=rev Log: More objc GC's API work for array of pointers declared as __strong. Modified: cfe/trunk/lib/AST/Expr.cpp cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=81283&r1=81282&r2=81283&view=diff ============================================================================== --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Tue Sep 8 18:38:54 2009 @@ -1092,7 +1092,7 @@ } /// isOBJCGCCandidate - Check if an expression is objc gc'able. -/// +/// returns true, if it is; false otherwise. bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const { switch (getStmtClass()) { default: @@ -1114,11 +1114,8 @@ if (VD->hasGlobalStorage()) return true; QualType T = VD->getType(); - // dereferencing to an object pointer is always a gc'able candidate - if (T->isPointerType() && - T->getAs()->getPointeeType()->isObjCObjectPointerType()) - return true; - + // dereferencing to a pointer is always a gc'able candidate + return T->isPointerType(); } return false; } Modified: cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m?rev=81283&r1=81282&r2=81283&view=diff ============================================================================== --- cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m (original) +++ cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m Tue Sep 8 18:38:54 2009 @@ -1,5 +1,5 @@ // RUN: clang-cc -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s && -// RUN: grep objc_assign_strongCast %t | count 3 && +// RUN: grep objc_assign_strongCast %t | count 7 && // RUN: true struct Slice { @@ -10,14 +10,26 @@ @interface ISlice { @public - void *__strong * items; + void *__strong * IvarItem; } @end -void foo () { +void foo (int i) { + // storing into an array of strong pointer types. + void *__strong* items; + items[i] = 0; + + // storing indirectly into an array of strong pointer types. + void *__strong* *vitems; + *vitems[i] = 0; + Slice *slice; slice->items = 0; + // storing into a struct element of an array of strong pointer types. + slice->items[i] = 0; ISlice *islice; - islice->items = 0; + islice->IvarItem = 0; + // Storing into an ivar of an array of strong pointer types. + islice->IvarItem[i] = (void*)0; } From dgregor at apple.com Tue Sep 8 18:54:02 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 8 Sep 2009 16:54:02 -0700 Subject: [cfe-commits] r81233 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.decls/temp.friend/p1.cpp In-Reply-To: <200909081747.n88HlUZs012329@zion.cs.uiuc.edu> References: <200909081747.n88HlUZs012329@zion.cs.uiuc.edu> Message-ID: <86FBC2A2-1C3F-47FD-B1CC-775D22C4A5C2@apple.com> On Sep 8, 2009, at 10:47 AM, John McCall wrote: > Author: rjmccall > Date: Tue Sep 8 12:47:29 2009 > New Revision: 81233 > > URL: http://llvm.org/viewvc/llvm-project?rev=81233&view=rev > Log: > Support templateids in friend declarations. Fixes bug 4859. Nifty. > + // The parser doesn't quite handle > + // friend class A { ... } > + // optimally, because it might have been the (valid) prefix of > + // friend class A { ... } foo(); > + // So in a very particular set of circumstances, we need to adjust > + // IsDefinition. "friend class A { ... } foo();" is ill-formed, since types cannot be defined in a return type (C++ [dcl.fct]p6). Is this mainly an issue of recovery? > + > + if (const RecordType *RT = Type->getAs()) { > + RecordDecl *D = RT->getDecl(); > + > + IdentifierInfo *Id = D->getIdentifier(); > + assert(Id && "templated class must have an identifier"); > + > + if (!isAcceptableTagRedeclaration(D, TagKind, TagLoc, *Id)) { > + Diag(TagLoc, diag::err_use_with_wrong_tag) > + << Id > + << CodeModificationHint::CreateReplacement(SourceRange > (TagLoc), > + D->getKindName()); Very nice fix-it hint. - Doug From dgregor at apple.com Tue Sep 8 19:23:06 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 09 Sep 2009 00:23:06 -0000 Subject: [cfe-commits] r81300 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/AST/TemplateName.h lib/AST/ASTContext.cpp lib/AST/ExprCXX.cpp lib/AST/NestedNameSpecifier.cpp lib/AST/StmtPrinter.cpp lib/AST/TemplateName.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplate.cpp lib/Sema/TreeTransform.h test/SemaTemplate/member-template-access-expr.cpp Message-ID: <200909090023.n890N7UT004141@zion.cs.uiuc.edu> Author: dgregor Date: Tue Sep 8 19:23:06 2009 New Revision: 81300 URL: http://llvm.org/viewvc/llvm-project?rev=81300&view=rev Log: Initial stab at implement dependent member references to member templates, e.g., x.template get We can now parse these, represent them within an UnresolvedMemberExpr expression, then instantiate that expression node in simple cases. This allows us to stumble through parsing LLVM's Casting.h. Added: cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp (with props) Modified: cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/TemplateName.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ExprCXX.cpp cfe/trunk/lib/AST/NestedNameSpecifier.cpp cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/AST/TemplateName.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/lib/Sema/TreeTransform.h Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Sep 8 19:23:06 2009 @@ -1407,8 +1407,12 @@ /// \brief Whether this member expression used the '->' operator or /// the '.' operator. - bool IsArrow; + bool IsArrow : 1; + /// \brief Whether this member expression has explicitly-specified template + /// arguments. + bool HasExplicitTemplateArgumentList : 1; + /// \brief The location of the '->' or '.' operator. SourceLocation OperatorLoc; @@ -1435,6 +1439,36 @@ /// \brief The location of the member name. SourceLocation MemberLoc; + /// \brief Retrieve the explicit template argument list that followed the + /// member template name, if any. + ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { + if (!HasExplicitTemplateArgumentList) + return 0; + + return reinterpret_cast(this + 1); + } + + /// \brief Retrieve the explicit template argument list that followed the + /// member template name, if any. + const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { + return const_cast(this) + ->getExplicitTemplateArgumentList(); + } + + CXXUnresolvedMemberExpr(ASTContext &C, + Expr *Base, bool IsArrow, + SourceLocation OperatorLoc, + NestedNameSpecifier *Qualifier, + SourceRange QualifierRange, + NamedDecl *FirstQualifierFoundInScope, + DeclarationName Member, + SourceLocation MemberLoc, + bool HasExplicitTemplateArgs, + SourceLocation LAngleLoc, + const TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs, + SourceLocation RAngleLoc); + public: CXXUnresolvedMemberExpr(ASTContext &C, Expr *Base, bool IsArrow, @@ -1444,12 +1478,28 @@ NamedDecl *FirstQualifierFoundInScope, DeclarationName Member, SourceLocation MemberLoc) - : Expr(CXXUnresolvedMemberExprClass, C.DependentTy, true, true), - Base(Base), IsArrow(IsArrow), OperatorLoc(OperatorLoc), - Qualifier(Qualifier), QualifierRange(QualifierRange), - FirstQualifierFoundInScope(FirstQualifierFoundInScope), - Member(Member), MemberLoc(MemberLoc) { } - + : Expr(CXXUnresolvedMemberExprClass, C.DependentTy, true, true), + Base(Base), IsArrow(IsArrow), HasExplicitTemplateArgumentList(false), + OperatorLoc(OperatorLoc), + Qualifier(Qualifier), QualifierRange(QualifierRange), + FirstQualifierFoundInScope(FirstQualifierFoundInScope), + Member(Member), MemberLoc(MemberLoc) { } + + static CXXUnresolvedMemberExpr * + Create(ASTContext &C, + Expr *Base, bool IsArrow, + SourceLocation OperatorLoc, + NestedNameSpecifier *Qualifier, + SourceRange QualifierRange, + NamedDecl *FirstQualifierFoundInScope, + DeclarationName Member, + SourceLocation MemberLoc, + bool HasExplicitTemplateArgs, + SourceLocation LAngleLoc, + const TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs, + SourceLocation RAngleLoc); + /// \brief Retrieve the base object of this member expressions, /// e.g., the \c x in \c x.m. Expr *getBase() { return cast(Base); } @@ -1497,10 +1547,57 @@ SourceLocation getMemberLoc() const { return MemberLoc; } void setMemberLoc(SourceLocation L) { MemberLoc = L; } + /// \brief Determines whether this member expression actually had a C++ + /// template argument list explicitly specified, e.g., x.f. + bool hasExplicitTemplateArgumentList() { + return HasExplicitTemplateArgumentList; + } + + /// \brief Retrieve the location of the left angle bracket following the + /// member name ('<'), if any. + SourceLocation getLAngleLoc() const { + if (!HasExplicitTemplateArgumentList) + return SourceLocation(); + + return getExplicitTemplateArgumentList()->LAngleLoc; + } + + /// \brief Retrieve the template arguments provided as part of this + /// template-id. + const TemplateArgument *getTemplateArgs() const { + if (!HasExplicitTemplateArgumentList) + return 0; + + return getExplicitTemplateArgumentList()->getTemplateArgs(); + } + + /// \brief Retrieve the number of template arguments provided as part of this + /// template-id. + unsigned getNumTemplateArgs() const { + if (!HasExplicitTemplateArgumentList) + return 0; + + return getExplicitTemplateArgumentList()->NumTemplateArgs; + } + + /// \brief Retrieve the location of the right angle bracket following the + /// template arguments ('>'). + SourceLocation getRAngleLoc() const { + if (!HasExplicitTemplateArgumentList) + return SourceLocation(); + + return getExplicitTemplateArgumentList()->RAngleLoc; + } + virtual SourceRange getSourceRange() const { + if (HasExplicitTemplateArgumentList) + return SourceRange(Base->getSourceRange().getBegin(), + getRAngleLoc()); + return SourceRange(Base->getSourceRange().getBegin(), MemberLoc); } + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXUnresolvedMemberExprClass; } Modified: cfe/trunk/include/clang/AST/TemplateName.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/TemplateName.h (original) +++ cfe/trunk/include/clang/AST/TemplateName.h Tue Sep 8 19:23:06 2009 @@ -217,7 +217,7 @@ /// resolved prior to template instantiation. /// /// This kind of template name refers to a dependent template name, -/// including its nested name specifier. For example, +/// including its nested name specifier (if any). For example, /// DependentTemplateName can refer to "MetaFun::template apply", /// where "MetaFun::" is the nested name specifier and "apply" is the /// template name referenced. The "template" keyword is implied. Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Tue Sep 8 19:23:06 2009 @@ -3319,7 +3319,8 @@ /// template name such as \c MetaFun::template apply. TemplateName ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) { - assert(NNS->isDependent() && "Nested name specifier must be dependent"); + assert((!NNS || NNS->isDependent()) && + "Nested name specifier must be dependent"); llvm::FoldingSetNodeID ID; DependentTemplateName::Profile(ID, NNS, Name); Modified: cfe/trunk/lib/AST/ExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/AST/ExprCXX.cpp (original) +++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Sep 8 19:23:06 2009 @@ -523,6 +523,77 @@ return child_iterator(reinterpret_cast(this + 1) + NumArgs); } +CXXUnresolvedMemberExpr::CXXUnresolvedMemberExpr(ASTContext &C, + Expr *Base, bool IsArrow, + SourceLocation OperatorLoc, + NestedNameSpecifier *Qualifier, + SourceRange QualifierRange, + NamedDecl *FirstQualifierFoundInScope, + DeclarationName Member, + SourceLocation MemberLoc, + bool HasExplicitTemplateArgs, + SourceLocation LAngleLoc, + const TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs, + SourceLocation RAngleLoc) + : Expr(CXXUnresolvedMemberExprClass, C.DependentTy, true, true), + Base(Base), IsArrow(IsArrow), + HasExplicitTemplateArgumentList(HasExplicitTemplateArgs), + OperatorLoc(OperatorLoc), + Qualifier(Qualifier), QualifierRange(QualifierRange), + FirstQualifierFoundInScope(FirstQualifierFoundInScope), + Member(Member), MemberLoc(MemberLoc) +{ + if (HasExplicitTemplateArgumentList) { + ExplicitTemplateArgumentList *ETemplateArgs + = getExplicitTemplateArgumentList(); + ETemplateArgs->LAngleLoc = LAngleLoc; + ETemplateArgs->RAngleLoc = RAngleLoc; + ETemplateArgs->NumTemplateArgs = NumTemplateArgs; + + TemplateArgument *SavedTemplateArgs = ETemplateArgs->getTemplateArgs(); + for (unsigned I = 0; I < NumTemplateArgs; ++I) + new (SavedTemplateArgs + I) TemplateArgument(TemplateArgs[I]); + } +} + +CXXUnresolvedMemberExpr * +CXXUnresolvedMemberExpr::Create(ASTContext &C, + Expr *Base, bool IsArrow, + SourceLocation OperatorLoc, + NestedNameSpecifier *Qualifier, + SourceRange QualifierRange, + NamedDecl *FirstQualifierFoundInScope, + DeclarationName Member, + SourceLocation MemberLoc, + bool HasExplicitTemplateArgs, + SourceLocation LAngleLoc, + const TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs, + SourceLocation RAngleLoc) +{ + if (!HasExplicitTemplateArgs) + return new (C) CXXUnresolvedMemberExpr(C, Base, IsArrow, OperatorLoc, + Qualifier, QualifierRange, + FirstQualifierFoundInScope, + Member, MemberLoc); + + void *Mem = C.Allocate(sizeof(CXXUnresolvedMemberExpr) + + sizeof(ExplicitTemplateArgumentList) + + sizeof(TemplateArgument) * NumTemplateArgs, + llvm::alignof()); + return new (Mem) CXXUnresolvedMemberExpr(C, Base, IsArrow, OperatorLoc, + Qualifier, QualifierRange, + FirstQualifierFoundInScope, + Member, + MemberLoc, + HasExplicitTemplateArgs, + LAngleLoc, + TemplateArgs, + NumTemplateArgs, + RAngleLoc); +} + Stmt::child_iterator CXXUnresolvedMemberExpr::child_begin() { return child_iterator(&Base); } Modified: cfe/trunk/lib/AST/NestedNameSpecifier.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/NestedNameSpecifier.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/AST/NestedNameSpecifier.cpp (original) +++ cfe/trunk/lib/AST/NestedNameSpecifier.cpp Tue Sep 8 19:23:06 2009 @@ -42,7 +42,7 @@ NestedNameSpecifier::Create(ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II) { assert(II && "Identifier cannot be NULL"); - assert(Prefix && Prefix->isDependent() && "Prefix must be dependent"); + assert((!Prefix || Prefix->isDependent()) && "Prefix must be dependent"); NestedNameSpecifier Mockup; Mockup.Prefix.setPointer(Prefix); Modified: cfe/trunk/lib/AST/StmtPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/AST/StmtPrinter.cpp (original) +++ cfe/trunk/lib/AST/StmtPrinter.cpp Tue Sep 8 19:23:06 2009 @@ -493,12 +493,10 @@ if (Node->getQualifier()) Node->getQualifier()->print(OS, Policy); Node->getTemplateName().print(OS, Policy, true); - OS << '<'; OS << TemplateSpecializationType::PrintTemplateArgumentList( Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy); - OS << '>'; } void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) { @@ -1154,7 +1152,18 @@ OS << (Node->isArrow() ? "->" : "."); if (NestedNameSpecifier *Qualifier = Node->getQualifier()) Qualifier->print(OS, Policy); + else if (Node->hasExplicitTemplateArgumentList()) + // FIXME: Track use of "template" keyword explicitly? + OS << "template "; + OS << Node->getMember().getAsString(); + + if (Node->hasExplicitTemplateArgumentList()) { + OS << TemplateSpecializationType::PrintTemplateArgumentList( + Node->getTemplateArgs(), + Node->getNumTemplateArgs(), + Policy); + } } static const char *getTypeTraitName(UnaryTypeTrait UTT) { Modified: cfe/trunk/lib/AST/TemplateName.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TemplateName.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/AST/TemplateName.cpp (original) +++ cfe/trunk/lib/AST/TemplateName.cpp Tue Sep 8 19:23:06 2009 @@ -67,7 +67,7 @@ OS << "template "; OS << QTN->getDecl()->getNameAsString(); } else if (DependentTemplateName *DTN = getAsDependentTemplateName()) { - if (!SuppressNNS) + if (!SuppressNNS && DTN->getQualifier()) DTN->getQualifier()->print(OS, Policy); OS << "template "; // FIXME: Shouldn't we have a more general kind of name? Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Sep 8 19:23:06 2009 @@ -918,8 +918,10 @@ ConsumeParen(); break; } - case tok::arrow: // postfix-expression: p-e '->' identifier - case tok::period: { // postfix-expression: p-e '.' identifier + case tok::arrow: + case tok::period: { + // postfix-expression: p-e '->' template[opt] id-expression + // postfix-expression: p-e '.' template[opt] id-expression tok::TokenKind OpKind = Tok.getKind(); SourceLocation OpLoc = ConsumeToken(); // Eat the "." or "->" token. Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Tue Sep 8 19:23:06 2009 @@ -76,7 +76,9 @@ if (HasScopeSpecifier) { // C++ [basic.lookup.classref]p5: // If the qualified-id has the form + // // ::class-name-or-namespace-name::... + // // the class-name-or-namespace-name is looked up in global scope as a // class-name or namespace-name. // Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Sep 8 19:23:06 2009 @@ -2029,14 +2029,17 @@ FirstQualifierInScope = FindFirstQualifierInScope(S, Qualifier); } - return Owned(new (Context) CXXUnresolvedMemberExpr(Context, - BaseExpr, true, - OpLoc, - Qualifier, + return Owned(CXXUnresolvedMemberExpr::Create(Context, BaseExpr, true, + OpLoc, Qualifier, SS? SS->getRange() : SourceRange(), - FirstQualifierInScope, - MemberName, - MemberLoc)); + FirstQualifierInScope, + MemberName, + MemberLoc, + HasExplicitTemplateArgs, + LAngleLoc, + ExplicitTemplateArgs, + NumExplicitTemplateArgs, + RAngleLoc)); } else if (const PointerType *PT = BaseType->getAs()) BaseType = PT->getPointeeType(); @@ -2067,14 +2070,19 @@ FirstQualifierInScope = FindFirstQualifierInScope(S, Qualifier); } - return Owned(new (Context) CXXUnresolvedMemberExpr(Context, - BaseExpr, false, - OpLoc, - Qualifier, + return Owned(CXXUnresolvedMemberExpr::Create(Context, + BaseExpr, false, + OpLoc, + Qualifier, SS? SS->getRange() : SourceRange(), - FirstQualifierInScope, - MemberName, - MemberLoc)); + FirstQualifierInScope, + MemberName, + MemberLoc, + HasExplicitTemplateArgs, + LAngleLoc, + ExplicitTemplateArgs, + NumExplicitTemplateArgs, + RAngleLoc)); } } } Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Sep 8 19:23:06 2009 @@ -1229,7 +1229,7 @@ else if (OverloadedFunctionDecl *Ovl = Template.getAsOverloadedFunctionDecl()) Name = Ovl->getDeclName(); else - assert(false && "Cannot support dependent template names yet"); + Name = Template.getAsDependentTemplateName()->getName(); // Translate the parser's template argument list in our AST format. llvm::SmallVector TemplateArgs; @@ -1287,11 +1287,6 @@ return Template; } - // FIXME: We need to be able to create a dependent template name with just - // an identifier, to handle the x->template f case. - assert(!ObjectType && - "Cannot handle dependent template names without a nested-name-specifier"); - NestedNameSpecifier *Qualifier = static_cast(SS.getScopeRep()); return TemplateTy::make(Context.getDependentTemplateName(Qualifier, &Name)); Modified: cfe/trunk/lib/Sema/TreeTransform.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=81300&r1=81299&r2=81300&view=diff ============================================================================== --- cfe/trunk/lib/Sema/TreeTransform.h (original) +++ cfe/trunk/lib/Sema/TreeTransform.h Tue Sep 8 19:23:06 2009 @@ -261,7 +261,8 @@ /// By default, transforms the template name by transforming the declarations /// and nested-name-specifiers that occur within the template name. /// Subclasses may override this function to provide alternate behavior. - TemplateName TransformTemplateName(TemplateName Name); + TemplateName TransformTemplateName(TemplateName Name, + QualType ObjectType = QualType()); /// \brief Transform the given template argument. /// @@ -567,7 +568,8 @@ /// template name. Subclasses may override this routine to provide different /// behavior. TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier, - const IdentifierInfo &II); + const IdentifierInfo &II, + QualType ObjectType); /// \brief Build a new compound statement. @@ -1510,16 +1512,58 @@ SS.setRange(QualifierRange); SS.setScopeRep(Qualifier); - Base = SemaRef.BuildMemberReferenceExpr(/*Scope=*/0, + return SemaRef.BuildMemberReferenceExpr(/*Scope=*/0, move(Base), OperatorLoc, OpKind, MemberLoc, Name, /*FIXME?*/Sema::DeclPtrTy::make((Decl*)0), &SS, FirstQualifierInScope); - return move(Base); } + /// \brief Build a new member reference expression with explicit template + /// arguments. + /// + /// By default, performs semantic analysis to build the new expression. + /// Subclasses may override this routine to provide different behavior. + OwningExprResult RebuildCXXUnresolvedMemberExpr(ExprArg BaseE, + bool IsArrow, + SourceLocation OperatorLoc, + NestedNameSpecifier *Qualifier, + SourceRange QualifierRange, + TemplateName Template, + SourceLocation TemplateNameLoc, + NamedDecl *FirstQualifierInScope, + SourceLocation LAngleLoc, + const TemplateArgument *TemplateArgs, + unsigned NumTemplateArgs, + SourceLocation RAngleLoc) { + OwningExprResult Base = move(BaseE); + tok::TokenKind OpKind = IsArrow? tok::arrow : tok::period; + + CXXScopeSpec SS; + SS.setRange(QualifierRange); + SS.setScopeRep(Qualifier); + + // FIXME: We're going to end up looking up the template based on its name, + // twice! Also, duplicates part of Sema::ActOnMemberTemplateIdReferenceExpr. + DeclarationName Name; + if (TemplateDecl *ActualTemplate = Template.getAsTemplateDecl()) + Name = ActualTemplate->getDeclName(); + else if (OverloadedFunctionDecl *Ovl + = Template.getAsOverloadedFunctionDecl()) + Name = Ovl->getDeclName(); + else + Name = Template.getAsDependentTemplateName()->getName(); + + return SemaRef.BuildMemberReferenceExpr(/*Scope=*/0, move(Base), + OperatorLoc, OpKind, + TemplateNameLoc, Name, true, + LAngleLoc, TemplateArgs, + NumTemplateArgs, RAngleLoc, + Sema::DeclPtrTy(), &SS); + } + /// \brief Build a new Objective-C @encode expression. /// /// By default, performs semantic analysis to build the new expression. @@ -1746,7 +1790,8 @@ template TemplateName -TreeTransform::TransformTemplateName(TemplateName Name) { +TreeTransform::TransformTemplateName(TemplateName Name, + QualType ObjectType) { if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) { NestedNameSpecifier *NNS = getDerived().TransformNestedNameSpecifier(QTN->getQualifier(), @@ -1789,14 +1834,14 @@ NestedNameSpecifier *NNS = getDerived().TransformNestedNameSpecifier(DTN->getQualifier(), /*FIXME:*/SourceRange(getDerived().getBaseLocation())); - if (!NNS) + if (!NNS && DTN->getQualifier()) return TemplateName(); if (!getDerived().AlwaysRebuild() && NNS == DTN->getQualifier()) return Name; - return getDerived().RebuildTemplateName(NNS, *DTN->getName()); + return getDerived().RebuildTemplateName(NNS, *DTN->getName(), ObjectType); } if (TemplateDecl *Template = Name.getAsTemplateDecl()) { @@ -4195,6 +4240,9 @@ if (Base.isInvalid()) return SemaRef.ExprError(); + // FIXME: The first qualifier found might be a template type parameter, + // in which case there is no transformed declaration to refer to (it might + // refer to a built-in type!). NamedDecl *FirstQualifierInScope = cast_or_null( getDerived().TransformDecl(E->getFirstQualifierFoundInScope())); @@ -4214,21 +4262,60 @@ if (!Name) return SemaRef.ExprError(); - if (!getDerived().AlwaysRebuild() && - Base.get() == E->getBase() && - Qualifier == E->getQualifier() && - Name == E->getMember() && - FirstQualifierInScope == E->getFirstQualifierFoundInScope()) - return SemaRef.Owned(E->Retain()); + if (!E->hasExplicitTemplateArgumentList()) { + // This is a reference to a member without an explicitly-specified + // template argument list. Optimize for this common case. + if (!getDerived().AlwaysRebuild() && + Base.get() == E->getBase() && + Qualifier == E->getQualifier() && + Name == E->getMember() && + FirstQualifierInScope == E->getFirstQualifierFoundInScope()) + return SemaRef.Owned(E->Retain()); + + return getDerived().RebuildCXXUnresolvedMemberExpr(move(Base), + E->isArrow(), + E->getOperatorLoc(), + Qualifier, + E->getQualifierRange(), + Name, + E->getMemberLoc(), + FirstQualifierInScope); + } + + // FIXME: This is an ugly hack, which forces the same template name to + // be looked up multiple times. Yuck! + // FIXME: This also won't work for, e.g., x->template operator+ + TemplateName OrigTemplateName + = SemaRef.Context.getDependentTemplateName(0, Name.getAsIdentifierInfo()); + + TemplateName Template + = getDerived().TransformTemplateName(OrigTemplateName, + QualType::getFromOpaquePtr(ObjectType)); + if (Template.isNull()) + return SemaRef.ExprError(); + + llvm::SmallVector TransArgs; + for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) { + TemplateArgument TransArg + = getDerived().TransformTemplateArgument(E->getTemplateArgs()[I]); + if (TransArg.isNull()) + return SemaRef.ExprError(); + + TransArgs.push_back(TransArg); + } return getDerived().RebuildCXXUnresolvedMemberExpr(move(Base), E->isArrow(), E->getOperatorLoc(), Qualifier, E->getQualifierRange(), - Name, + Template, E->getMemberLoc(), - FirstQualifierInScope); + FirstQualifierInScope, + E->getLAngleLoc(), + TransArgs.data(), + TransArgs.size(), + E->getRAngleLoc()); } template @@ -4643,33 +4730,18 @@ template TemplateName TreeTransform::RebuildTemplateName(NestedNameSpecifier *Qualifier, - const IdentifierInfo &II) { - if (Qualifier->isDependent()) - return SemaRef.Context.getDependentTemplateName(Qualifier, &II); - - // Somewhat redundant with ActOnDependentTemplateName. + const IdentifierInfo &II, + QualType ObjectType) { CXXScopeSpec SS; SS.setRange(SourceRange(getDerived().getBaseLocation())); - SS.setScopeRep(Qualifier); - Sema::TemplateTy Template; - TemplateNameKind TNK = SemaRef.isTemplateName(0, II, - /*FIXME:*/getDerived().getBaseLocation(), - &SS, - /*FIXME:ObjectType=*/0, false, - Template); - if (TNK == TNK_Non_template) { - SemaRef.Diag(getDerived().getBaseLocation(), - diag::err_template_kw_refers_to_non_template) - << &II; - return TemplateName(); - } else if (TNK == TNK_Function_template) { - SemaRef.Diag(getDerived().getBaseLocation(), - diag::err_template_kw_refers_to_non_template) - << &II; - return TemplateName(); - } - - return Template.getAsVal(); + SS.setScopeRep(Qualifier); + return getSema().ActOnDependentTemplateName( + /*FIXME:*/getDerived().getBaseLocation(), + II, + /*FIXME:*/getDerived().getBaseLocation(), + SS, + ObjectType.getAsOpaquePtr()) + .template getAsVal(); } template Added: cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp?rev=81300&view=auto ============================================================================== --- cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp (added) +++ cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp Tue Sep 8 19:23:06 2009 @@ -0,0 +1,30 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +template +U f0(T t) { + return t.template get(); +} + +template +int &f1(T t) { + // FIXME: When we pretty-print this, we lose the "template" keyword. + return t.U::template get(); +} + +struct X { + template T get(); +}; + +void test_f0(X x) { + int i = f0(x); + int &ir = f0(x); +} + +struct XDerived : public X { +}; + +void test_f1(XDerived xd) { + // FIXME: Not quite functional yet. +// int &ir = f1(xd); +} + Propchange: cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp ------------------------------------------------------------------------------ svn:keywords = Id Propchange: cfe/trunk/test/SemaTemplate/member-template-access-expr.cpp ------------------------------------------------------------------------------ svn:mime-type = text/plain From clattner at apple.com Tue Sep 8 19:37:16 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 8 Sep 2009 17:37:16 -0700 Subject: [cfe-commits] r81300 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/AST/TemplateName.h lib/AST/ASTContext.cpp lib/AST/ExprCXX.cpp lib/AST/NestedNameSpecifier.cpp lib/AST/StmtPrinter.cpp lib/AST/TemplateName.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplate.cpp lib/Sema/TreeTransform.h test/SemaTemplate/member-template-access-expr.cpp In-Reply-To: <200909090023.n890N7UT004141@zion.cs.uiuc.edu> References: <200909090023.n890N7UT004141@zion.cs.uiuc.edu> Message-ID: <744697F9-DF5E-4F02-8C4B-3996260F22A9@apple.com> On Sep 8, 2009, at 5:23 PM, Douglas Gregor wrote: > Author: dgregor > Date: Tue Sep 8 19:23:06 2009 > New Revision: 81300 > > URL: http://llvm.org/viewvc/llvm-project?rev=81300&view=rev > Log: > Initial stab at implement dependent member references to member > templates, e.g., > > x.template get > > We can now parse these, represent them within an UnresolvedMemberExpr > expression, then instantiate that expression node in simple cases. > > This allows us to stumble through parsing LLVM's Casting.h. Nice! -Chris From dgregor at apple.com Tue Sep 8 20:45:29 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 09 Sep 2009 01:45:29 -0000 Subject: [cfe-commits] r81309 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/static-array-member.cpp Message-ID: <200909090145.n891jTsh015232@zion.cs.uiuc.edu> Author: dgregor Date: Tue Sep 8 20:45:28 2009 New Revision: 81309 URL: http://llvm.org/viewvc/llvm-project?rev=81309&view=rev Log: Allow a declaration of an array to complete a prior, incomplete declaration of that array in C++. Added: cfe/trunk/test/SemaCXX/static-array-member.cpp (with props) Modified: cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=81309&r1=81308&r2=81309&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 8 20:45:28 2009 @@ -980,6 +980,13 @@ if (getLangOptions().CPlusPlus) { if (Context.hasSameType(New->getType(), Old->getType())) MergedT = New->getType(); + // C++ [basic.types]p7: + // [...] The declared type of an array object might be an array of + // unknown size and therefore be incomplete at one point in a + // translation unit and complete later on; [...] + else if (Old->getType()->isIncompleteArrayType() && + New->getType()->isArrayType()) + MergedT = New->getType(); } else { MergedT = Context.mergeTypes(New->getType(), Old->getType()); } Added: cfe/trunk/test/SemaCXX/static-array-member.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-array-member.cpp?rev=81309&view=auto ============================================================================== --- cfe/trunk/test/SemaCXX/static-array-member.cpp (added) +++ cfe/trunk/test/SemaCXX/static-array-member.cpp Tue Sep 8 20:45:28 2009 @@ -0,0 +1,18 @@ +// RUN: clang-cc -fsyntax-only %s + +struct X0 { + static int array[]; + + int x; + int y; +}; + +int X0::array[sizeof(X0) * 2]; + +template +struct X1 { + static T array[]; +}; + +template +T X1::array[N]; Propchange: cfe/trunk/test/SemaCXX/static-array-member.cpp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cfe/trunk/test/SemaCXX/static-array-member.cpp ------------------------------------------------------------------------------ svn:keywords = Id Propchange: cfe/trunk/test/SemaCXX/static-array-member.cpp ------------------------------------------------------------------------------ svn:mime-type = text/plain From eli.friedman at gmail.com Tue Sep 8 20:50:49 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 8 Sep 2009 18:50:49 -0700 Subject: [cfe-commits] r81309 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/static-array-member.cpp In-Reply-To: <200909090145.n891jTsh015232@zion.cs.uiuc.edu> References: <200909090145.n891jTsh015232@zion.cs.uiuc.edu> Message-ID: On Tue, Sep 8, 2009 at 6:45 PM, Douglas Gregor wrote: > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep ?8 20:45:28 2009 > @@ -980,6 +980,13 @@ > ? if (getLangOptions().CPlusPlus) { > ? ? if (Context.hasSameType(New->getType(), Old->getType())) > ? ? ? MergedT = New->getType(); > + ? ?// C++ [basic.types]p7: > + ? ?// ? [...] The declared type of an array object might be an array of > + ? ?// ? unknown size and therefore be incomplete at one point in a > + ? ?// ? translation unit and complete later on; [...] > + ? ?else if (Old->getType()->isIncompleteArrayType() && > + ? ? ? ? ? ? New->getType()->isArrayType()) > + ? ? ?MergedT = New->getType(); > ? } else { > ? ? MergedT = Context.mergeTypes(New->getType(), Old->getType()); > ? } Do you need to check that the element types are the same? -Eli From andersca at mac.com Tue Sep 8 21:51:03 2009 From: andersca at mac.com (Anders Carlsson) Date: Wed, 09 Sep 2009 02:51:03 -0000 Subject: [cfe-commits] r81315 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGDecl.cpp CodeGenFunction.h Message-ID: <200909090251.n892p3W1023510@zion.cs.uiuc.edu> Author: andersca Date: Tue Sep 8 21:51:03 2009 New Revision: 81315 URL: http://llvm.org/viewvc/llvm-project?rev=81315&view=rev Log: Make BuildByRefType take a ValueDecl instead of a QualType and an alignment. Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=81315&r1=81314&r2=81315&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Sep 8 21:51:03 2009 @@ -185,8 +185,7 @@ const BlockDeclRefExpr *BDRE = dyn_cast(E); QualType Ty = E->getType(); if (BDRE && BDRE->isByRef()) { - uint64_t Align = getContext().getDeclAlignInBytes(BDRE->getDecl()); - Types[i+5] = llvm::PointerType::get(BuildByRefType(Ty, Align), 0); + Types[i+5] = llvm::PointerType::get(BuildByRefType(BDRE->getDecl()), 0); } else Types[i+5] = ConvertType(Ty); } @@ -464,9 +463,8 @@ "block.literal"); if (E->isByRef()) { bool needsCopyDispose = BlockRequiresCopying(E->getType()); - uint64_t Align = getContext().getDeclAlignInBytes(E->getDecl()); const llvm::Type *PtrStructTy - = llvm::PointerType::get(BuildByRefType(E->getType(), Align), 0); + = llvm::PointerType::get(BuildByRefType(E->getDecl()), 0); // The block literal will need a copy/destroy helper. BlockHasCopyDispose = true; Ty = PtrStructTy; Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=81315&r1=81314&r2=81315&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Sep 8 21:51:03 2009 @@ -213,8 +213,10 @@ /// } x /// /// Align is the alignment needed in bytes for x. -const llvm::Type *CodeGenFunction::BuildByRefType(QualType Ty, - uint64_t Align) { +const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) { + QualType Ty = D->getType(); + uint64_t Align = getContext().getDeclAlignInBytes(D); + const llvm::Type *LTy = ConvertType(Ty); bool needsCopyDispose = BlockRequiresCopying(Ty); std::vector Types(needsCopyDispose*2+5); @@ -251,7 +253,7 @@ const llvm::Type *LTy = ConvertTypeForMem(Ty); Align = getContext().getDeclAlignInBytes(&D); if (isByRef) - LTy = BuildByRefType(Ty, Align); + LTy = BuildByRefType(&D); llvm::AllocaInst *Alloc = CreateTempAlloca(LTy); Alloc->setName(D.getNameAsString().c_str()); @@ -326,6 +328,12 @@ if (Target.useGlobalsForAutomaticVariables()) { DI->EmitGlobalVariable(static_cast(DeclPtr), &D); } else if (isByRef) { + // FIXME: This code is broken and will not emit debug info for the + // variable. The right way to do this would be to tell LLVM that this is a + // byref pointer, and what the offset is. Unfortunately, right now it's + // not possible unless we create a DIType that corresponds to the byref + // struct. + /* llvm::Value *Loc; bool needsCopyDispose = BlockRequiresCopying(Ty); Loc = Builder.CreateStructGEP(DeclPtr, 1, "forwarding"); @@ -333,6 +341,7 @@ Loc = Builder.CreateBitCast(Loc, DeclPtr->getType()); Loc = Builder.CreateStructGEP(Loc, needsCopyDispose*2+4, "x"); DI->EmitDeclareOfAutoVariable(&D, Loc, Builder); + */ } else DI->EmitDeclareOfAutoVariable(&D, DeclPtr, Builder); } Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=81315&r1=81314&r2=81315&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Sep 8 21:51:03 2009 @@ -343,8 +343,7 @@ llvm::Value *LoadBlockStruct(); llvm::Value *GetAddrOfBlockDecl(const BlockDeclRefExpr *E); - - const llvm::Type *BuildByRefType(QualType Ty, uint64_t Align); + const llvm::Type *BuildByRefType(const ValueDecl *D); void GenerateCode(const FunctionDecl *FD, llvm::Function *Fn); From dgregor at apple.com Wed Sep 9 01:04:30 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 09 Sep 2009 06:04:30 -0000 Subject: [cfe-commits] r81317 - /cfe/trunk/lib/Sema/SemaDecl.cpp Message-ID: <200909090604.n8964VFt015274@zion.cs.uiuc.edu> Author: dgregor Date: Wed Sep 9 01:04:29 2009 New Revision: 81317 URL: http://llvm.org/viewvc/llvm-project?rev=81317&view=rev Log: Fix a thinko Modified: cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=81317&r1=81316&r2=81317&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 9 01:04:29 2009 @@ -985,8 +985,14 @@ // unknown size and therefore be incomplete at one point in a // translation unit and complete later on; [...] else if (Old->getType()->isIncompleteArrayType() && - New->getType()->isArrayType()) - MergedT = New->getType(); + New->getType()->isArrayType()) { + CanQual OldArray + = Context.getCanonicalType(Old->getType())->getAs(); + CanQual NewArray + = Context.getCanonicalType(New->getType())->getAs(); + if (OldArray->getElementType() == NewArray->getElementType()) + MergedT = New->getType(); + } } else { MergedT = Context.mergeTypes(New->getType(), Old->getType()); } From dgregor at apple.com Wed Sep 9 01:06:29 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 8 Sep 2009 23:06:29 -0700 Subject: [cfe-commits] r81309 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/static-array-member.cpp In-Reply-To: References: <200909090145.n891jTsh015232@zion.cs.uiuc.edu> Message-ID: <7C60BC9E-4DE5-4B4D-AAD9-BC384F39CDB8@apple.com> On Sep 8, 2009, at 6:50 PM, Eli Friedman wrote: > On Tue, Sep 8, 2009 at 6:45 PM, Douglas Gregor > wrote: >> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 8 20:45:28 2009 >> @@ -980,6 +980,13 @@ >> if (getLangOptions().CPlusPlus) { >> if (Context.hasSameType(New->getType(), Old->getType())) >> MergedT = New->getType(); >> + // C++ [basic.types]p7: >> + // [...] The declared type of an array object might be an >> array of >> + // unknown size and therefore be incomplete at one point in a >> + // translation unit and complete later on; [...] >> + else if (Old->getType()->isIncompleteArrayType() && >> + New->getType()->isArrayType()) >> + MergedT = New->getType(); >> } else { >> MergedT = Context.mergeTypes(New->getType(), Old->getType()); >> } > > Do you need to check that the element types are the same? Err... yes... fixed in r81317. Thanks. - Doug From rjmccall at apple.com Wed Sep 9 02:00:51 2009 From: rjmccall at apple.com (John McCall) Date: Wed, 09 Sep 2009 00:00:51 -0700 Subject: [cfe-commits] r81233 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.decls/temp.friend/p1.cpp In-Reply-To: <86FBC2A2-1C3F-47FD-B1CC-775D22C4A5C2@apple.com> References: <200909081747.n88HlUZs012329@zion.cs.uiuc.edu> <86FBC2A2-1C3F-47FD-B1CC-775D22C4A5C2@apple.com> Message-ID: <4AA752A3.8000509@apple.com> Douglas Gregor wrote: >> + // The parser doesn't quite handle >> + // friend class A { ... } >> + // optimally, because it might have been the (valid) prefix of >> + // friend class A { ... } foo(); >> + // So in a very particular set of circumstances, we need to adjust >> + // IsDefinition. > > "friend class A { ... } foo();" is ill-formed, since types cannot be > defined in a return type (C++ [dcl.fct]p6). Really? Huh. The more you know. I'll change the comment. Anyway, my problem is that the bit of parser (ParseCXXClassMemberDeclaration) that calls ActOnFriendDecl for standalone decl specs has already forgotten whether it saw a definition (which is known by ParseClassSpecifier but not propagated outward in a parser-sensible way), so it actually just lies to Sema and says it didn't. This is how Sema recovers that information. I can't really defend my design here; it's an evolved hack, no question. I'm balancing a couple of different ways to fix it. John. From mrs at apple.com Wed Sep 9 08:00:44 2009 From: mrs at apple.com (Mike Stump) Date: Wed, 09 Sep 2009 13:00:44 -0000 Subject: [cfe-commits] r81337 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGExpr.cpp CGExprComplex.cpp CGExprScalar.cpp Message-ID: <200909091300.n89D0jV5022978@zion.cs.uiuc.edu> Author: mrs Date: Wed Sep 9 08:00:44 2009 New Revision: 81337 URL: http://llvm.org/viewvc/llvm-project?rev=81337&view=rev Log: Reflow comments and some minor whitespace fixups. Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=81337&r1=81336&r2=81337&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Sep 9 08:00:44 2009 @@ -459,7 +459,7 @@ llvm::Value *BlockLiteral = LoadBlockStruct(); llvm::Value *V = Builder.CreateGEP(BlockLiteral, llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), - offset), + offset), "block.literal"); if (E->isByRef()) { bool needsCopyDispose = BlockRequiresCopying(E->getType()); Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=81337&r1=81336&r2=81337&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Sep 9 08:00:44 2009 @@ -46,9 +46,9 @@ /// EmitAnyExpr - Emit code to compute the specified expression which can have /// any type. The result is returned as an RValue struct. If this is an -/// aggregate expression, the aggloc/agglocvolatile arguments indicate where -/// the result should be returned. -RValue CodeGenFunction::EmitAnyExpr(const Expr *E, llvm::Value *AggLoc, +/// aggregate expression, the aggloc/agglocvolatile arguments indicate where the +/// result should be returned. +RValue CodeGenFunction::EmitAnyExpr(const Expr *E, llvm::Value *AggLoc, bool IsAggLocVolatile, bool IgnoreResult, bool IsInitializer) { if (!hasAggregateLLVMType(E->getType())) @@ -56,23 +56,22 @@ else if (E->getType()->isAnyComplexType()) return RValue::getComplex(EmitComplexExpr(E, false, false, IgnoreResult, IgnoreResult)); - + EmitAggExpr(E, AggLoc, IsAggLocVolatile, IgnoreResult, IsInitializer); return RValue::getAggregate(AggLoc, IsAggLocVolatile); } -/// EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result -/// will always be accessible even if no aggregate location is -/// provided. -RValue CodeGenFunction::EmitAnyExprToTemp(const Expr *E, +/// EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result will +/// always be accessible even if no aggregate location is provided. +RValue CodeGenFunction::EmitAnyExprToTemp(const Expr *E, bool IsAggLocVolatile, bool IsInitializer) { llvm::Value *AggLoc = 0; - - if (hasAggregateLLVMType(E->getType()) && + + if (hasAggregateLLVMType(E->getType()) && !E->getType()->isAnyComplexType()) AggLoc = CreateTempAlloca(ConvertType(E->getType()), "agg.tmp"); - return EmitAnyExpr(E, AggLoc, IsAggLocVolatile, /*IgnoreResult=*/false, + return EmitAnyExpr(E, AggLoc, IsAggLocVolatile, /*IgnoreResult=*/false, IsInitializer); } @@ -92,15 +91,15 @@ // if B inherits from A. Val = EmitAnyExprToTemp(E, /*IsAggLocVolatile=*/false, IsInitializer); - + if (IsInitializer) { // We might have to destroy the temporary variable. if (const RecordType *RT = E->getType()->getAs()) { if (CXXRecordDecl *ClassDecl = dyn_cast(RT->getDecl())) { if (!ClassDecl->hasTrivialDestructor()) { - const CXXDestructorDecl *Dtor = + const CXXDestructorDecl *Dtor = ClassDecl->getDestructor(getContext()); - + CleanupScope scope(*this); EmitCXXDestructorCall(Dtor, Dtor_Complete, Val.getAggregateAddr()); } @@ -113,7 +112,7 @@ Val = RValue::get(Val.getAggregateAddr()); } else { // Create a temporary variable that we can bind the reference to. - llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(E->getType()), + llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(E->getType()), "reftmp"); if (Val.isScalar()) EmitStoreOfScalar(Val.getScalarVal(), Temp, false, E->getType()); @@ -126,13 +125,13 @@ } -/// getAccessedFieldNo - Given an encoded value and a result number, return -/// the input field number being accessed. -unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx, +/// getAccessedFieldNo - Given an encoded value and a result number, return the +/// input field number being accessed. +unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts) { if (isa(Elts)) return 0; - + return cast(Elts->getOperand(Idx))->getZExtValue(); } @@ -175,32 +174,31 @@ /// EmitLValue - Emit code to compute a designator that specifies the location /// of the expression. /// -/// This can return one of two things: a simple address or a bitfield -/// reference. In either case, the LLVM Value* in the LValue structure is -/// guaranteed to be an LLVM pointer type. +/// This can return one of two things: a simple address or a bitfield reference. +/// In either case, the LLVM Value* in the LValue structure is guaranteed to be +/// an LLVM pointer type. /// -/// If this returns a bitfield reference, nothing about the pointee type of -/// the LLVM value is known: For example, it may not be a pointer to an -/// integer. +/// If this returns a bitfield reference, nothing about the pointee type of the +/// LLVM value is known: For example, it may not be a pointer to an integer. /// -/// If this returns a normal address, and if the lvalue's C type is fixed -/// size, this method guarantees that the returned pointer type will point to -/// an LLVM type of the same size of the lvalue's type. If the lvalue has a -/// variable length type, this is not possible. +/// If this returns a normal address, and if the lvalue's C type is fixed size, +/// this method guarantees that the returned pointer type will point to an LLVM +/// type of the same size of the lvalue's type. If the lvalue has a variable +/// length type, this is not possible. /// LValue CodeGenFunction::EmitLValue(const Expr *E) { switch (E->getStmtClass()) { default: return EmitUnsupportedLValue(E, "l-value expression"); - case Expr::BinaryOperatorClass: + case Expr::BinaryOperatorClass: return EmitBinaryOperatorLValue(cast(E)); - case Expr::CallExprClass: + case Expr::CallExprClass: case Expr::CXXMemberCallExprClass: case Expr::CXXOperatorCallExprClass: return EmitCallExprLValue(cast(E)); case Expr::VAArgExprClass: return EmitVAArgExprLValue(cast(E)); - case Expr::DeclRefExprClass: + case Expr::DeclRefExprClass: case Expr::QualifiedDeclRefExprClass: return EmitDeclRefLValue(cast(E)); case Expr::ParenExprClass:return EmitLValue(cast(E)->getSubExpr()); @@ -211,7 +209,7 @@ case Expr::ObjCEncodeExprClass: return EmitObjCEncodeExprLValue(cast(E)); - case Expr::BlockDeclRefExprClass: + case Expr::BlockDeclRefExprClass: return EmitBlockDeclRefLValue(cast(E)); case Expr::CXXConditionDeclExprClass: @@ -224,7 +222,7 @@ case Expr::ObjCMessageExprClass: return EmitObjCMessageExprLValue(cast(E)); - case Expr::ObjCIvarRefExprClass: + case Expr::ObjCIvarRefExprClass: return EmitObjCIvarRefLValue(cast(E)); case Expr::ObjCPropertyRefExprClass: return EmitObjCPropertyRefLValue(cast(E)); @@ -235,13 +233,13 @@ case Expr::StmtExprClass: return EmitStmtExprLValue(cast(E)); - case Expr::UnaryOperatorClass: + case Expr::UnaryOperatorClass: return EmitUnaryOpLValue(cast(E)); case Expr::ArraySubscriptExprClass: return EmitArraySubscriptExpr(cast(E)); case Expr::ExtVectorElementExprClass: return EmitExtVectorElementExpr(cast(E)); - case Expr::MemberExprClass: + case Expr::MemberExprClass: return EmitMemberExpr(cast(E)); case Expr::CompoundLiteralExprClass: return EmitCompoundLiteralLValue(cast(E)); @@ -268,52 +266,52 @@ if (Ty->isBooleanType()) if (V->getType() != llvm::Type::getInt1Ty(VMContext)) V = Builder.CreateTrunc(V, llvm::Type::getInt1Ty(VMContext), "tobool"); - + return V; } void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr, bool Volatile, QualType Ty) { - + if (Ty->isBooleanType()) { // Bool can have different representation in memory than in registers. const llvm::Type *SrcTy = Value->getType(); const llvm::PointerType *DstPtr = cast(Addr->getType()); if (DstPtr->getElementType() != SrcTy) { - const llvm::Type *MemTy = + const llvm::Type *MemTy = llvm::PointerType::get(SrcTy, DstPtr->getAddressSpace()); Addr = Builder.CreateBitCast(Addr, MemTy, "storetmp"); } } - Builder.CreateStore(Value, Addr, Volatile); + Builder.CreateStore(Value, Addr, Volatile); } -/// EmitLoadOfLValue - Given an expression that represents a value lvalue, -/// this method emits the address of the lvalue, then loads the result as an -/// rvalue, returning the rvalue. +/// EmitLoadOfLValue - Given an expression that represents a value lvalue, this +/// method emits the address of the lvalue, then loads the result as an rvalue, +/// returning the rvalue. RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) { if (LV.isObjCWeak()) { - // load of a __weak object. + // load of a __weak object. llvm::Value *AddrWeakObj = LV.getAddress(); - llvm::Value *read_weak = CGM.getObjCRuntime().EmitObjCWeakRead(*this, + llvm::Value *read_weak = CGM.getObjCRuntime().EmitObjCWeakRead(*this, AddrWeakObj); return RValue::get(read_weak); } - + if (LV.isSimple()) { llvm::Value *Ptr = LV.getAddress(); const llvm::Type *EltTy = cast(Ptr->getType())->getElementType(); - + // Simple scalar l-value. if (EltTy->isSingleValueType()) - return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(), + return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(), ExprType)); - + assert(ExprType->isFunctionType() && "Unknown scalar value"); return RValue::get(Ptr); } - + if (LV.isVectorElt()) { llvm::Value *Vec = Builder.CreateLoad(LV.getVectorAddr(), LV.isVolatileQualified(), "tmp"); @@ -342,58 +340,58 @@ unsigned BitfieldSize = LV.getBitfieldSize(); llvm::Value *Ptr = LV.getBitfieldAddr(); - const llvm::Type *EltTy = + const llvm::Type *EltTy = cast(Ptr->getType())->getElementType(); unsigned EltTySize = CGM.getTargetData().getTypeSizeInBits(EltTy); - // In some cases the bitfield may straddle two memory locations. - // Currently we load the entire bitfield, then do the magic to - // sign-extend it if necessary. This results in somewhat more code - // than necessary for the common case (one load), since two shifts - // accomplish both the masking and sign extension. + // In some cases the bitfield may straddle two memory locations. Currently we + // load the entire bitfield, then do the magic to sign-extend it if + // necessary. This results in somewhat more code than necessary for the common + // case (one load), since two shifts accomplish both the masking and sign + // extension. unsigned LowBits = std::min(BitfieldSize, EltTySize - StartBit); llvm::Value *Val = Builder.CreateLoad(Ptr, LV.isVolatileQualified(), "tmp"); - + // Shift to proper location. if (StartBit) - Val = Builder.CreateLShr(Val, llvm::ConstantInt::get(EltTy, StartBit), + Val = Builder.CreateLShr(Val, llvm::ConstantInt::get(EltTy, StartBit), "bf.lo"); - + // Mask off unused bits. - llvm::Constant *LowMask = llvm::ConstantInt::get(VMContext, + llvm::Constant *LowMask = llvm::ConstantInt::get(VMContext, llvm::APInt::getLowBitsSet(EltTySize, LowBits)); Val = Builder.CreateAnd(Val, LowMask, "bf.lo.cleared"); - + // Fetch the high bits if necessary. if (LowBits < BitfieldSize) { unsigned HighBits = BitfieldSize - LowBits; llvm::Value *HighPtr = Builder.CreateGEP(Ptr, llvm::ConstantInt::get( - llvm::Type::getInt32Ty(VMContext), 1), "bf.ptr.hi"); - llvm::Value *HighVal = Builder.CreateLoad(HighPtr, + llvm::Type::getInt32Ty(VMContext), 1), "bf.ptr.hi"); + llvm::Value *HighVal = Builder.CreateLoad(HighPtr, LV.isVolatileQualified(), "tmp"); - + // Mask off unused bits. llvm::Constant *HighMask = llvm::ConstantInt::get(VMContext, llvm::APInt::getLowBitsSet(EltTySize, HighBits)); HighVal = Builder.CreateAnd(HighVal, HighMask, "bf.lo.cleared"); // Shift to proper location and or in to bitfield value. - HighVal = Builder.CreateShl(HighVal, + HighVal = Builder.CreateShl(HighVal, llvm::ConstantInt::get(EltTy, LowBits)); Val = Builder.CreateOr(Val, HighVal, "bf.val"); } // Sign extend if necessary. if (LV.isBitfieldSigned()) { - llvm::Value *ExtraBits = llvm::ConstantInt::get(EltTy, + llvm::Value *ExtraBits = llvm::ConstantInt::get(EltTy, EltTySize - BitfieldSize); - Val = Builder.CreateAShr(Builder.CreateShl(Val, ExtraBits), + Val = Builder.CreateAShr(Builder.CreateShl(Val, ExtraBits), ExtraBits, "bf.val.sext"); } - // The bitfield type and the normal type differ when the storage sizes - // differ (currently just _Bool). + // The bitfield type and the normal type differ when the storage sizes differ + // (currently just _Bool). Val = Builder.CreateIntCast(Val, ConvertType(ExprType), false, "tmp"); return RValue::get(Val); @@ -415,11 +413,11 @@ QualType ExprType) { llvm::Value *Vec = Builder.CreateLoad(LV.getExtVectorAddr(), LV.isVolatileQualified(), "tmp"); - + const llvm::Constant *Elts = LV.getExtVectorElts(); - - // If the result of the expression is a non-vector type, we must be - // extracting a single element. Just codegen as an extractelement. + + // If the result of the expression is a non-vector type, we must be extracting + // a single element. Just codegen as an extractelement. const VectorType *ExprVT = ExprType->getAsVectorType(); if (!ExprVT) { unsigned InIdx = getAccessedFieldNo(0, Elts); @@ -430,14 +428,14 @@ // Always use shuffle vector to try to retain the original program structure unsigned NumResultElts = ExprVT->getNumElements(); - + llvm::SmallVector Mask; for (unsigned i = 0; i != NumResultElts; ++i) { unsigned InIdx = getAccessedFieldNo(i, Elts); Mask.push_back(llvm::ConstantInt::get( llvm::Type::getInt32Ty(VMContext), InIdx)); } - + llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size()); Vec = Builder.CreateShuffleVector(Vec, llvm::UndefValue::get(Vec->getType()), @@ -450,7 +448,7 @@ /// EmitStoreThroughLValue - Store the specified rvalue into the specified /// lvalue, where both are guaranteed to the have the same type, and that type /// is 'Ty'. -void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, +void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty) { if (!Dst.isSimple()) { if (Dst.isVectorElt()) { @@ -462,7 +460,7 @@ Builder.CreateStore(Vec, Dst.getVectorAddr(),Dst.isVolatileQualified()); return; } - + // If this is an update of extended vector elements, insert them as // appropriate. if (Dst.isExtVectorElt()) @@ -479,21 +477,21 @@ assert(0 && "Unknown LValue type"); } - + if (Dst.isObjCWeak() && !Dst.isNonGC()) { - // load of a __weak object. + // load of a __weak object. llvm::Value *LvalueDst = Dst.getAddress(); llvm::Value *src = Src.getScalarVal(); CGM.getObjCRuntime().EmitObjCWeakAssign(*this, src, LvalueDst); return; } - + if (Dst.isObjCStrong() && !Dst.isNonGC()) { - // load of a __strong object. + // load of a __strong object. llvm::Value *LvalueDst = Dst.getAddress(); llvm::Value *src = Src.getScalarVal(); #if 0 - // FIXME. We cannot positively determine if we have an 'ivar' assignment, + // FIXME: We cannot positively determine if we have an 'ivar' assignment, // object assignment or an unknown assignment. For now, generate call to // objc_assign_strongCast assignment which is a safe, but consevative // assumption. @@ -508,25 +506,25 @@ CGM.getObjCRuntime().EmitObjCStrongCastAssign(*this, src, LvalueDst); return; } - + assert(Src.isScalar() && "Can't emit an agg store with this method"); EmitStoreOfScalar(Src.getScalarVal(), Dst.getAddress(), Dst.isVolatileQualified(), Ty); } void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, - QualType Ty, + QualType Ty, llvm::Value **Result) { unsigned StartBit = Dst.getBitfieldStartBit(); unsigned BitfieldSize = Dst.getBitfieldSize(); llvm::Value *Ptr = Dst.getBitfieldAddr(); - const llvm::Type *EltTy = + const llvm::Type *EltTy = cast(Ptr->getType())->getElementType(); unsigned EltTySize = CGM.getTargetData().getTypeSizeInBits(EltTy); - // Get the new value, cast to the appropriate type and masked to - // exactly the size of the bit-field. + // Get the new value, cast to the appropriate type and masked to exactly the + // size of the bit-field. llvm::Value *SrcVal = Src.getScalarVal(); llvm::Value *NewVal = Builder.CreateIntCast(SrcVal, EltTy, false, "tmp"); llvm::Constant *Mask = llvm::ConstantInt::get(VMContext, @@ -545,34 +543,33 @@ unsigned SrcTySize = CGM.getTargetData().getTypeSizeInBits(SrcTy); llvm::Value *ExtraBits = llvm::ConstantInt::get(SrcTy, SrcTySize - BitfieldSize); - SrcTrunc = Builder.CreateAShr(Builder.CreateShl(SrcTrunc, ExtraBits), + SrcTrunc = Builder.CreateAShr(Builder.CreateShl(SrcTrunc, ExtraBits), ExtraBits, "bf.reload.sext"); } *Result = SrcTrunc; } - // In some cases the bitfield may straddle two memory locations. - // Emit the low part first and check to see if the high needs to be - // done. + // In some cases the bitfield may straddle two memory locations. Emit the low + // part first and check to see if the high needs to be done. unsigned LowBits = std::min(BitfieldSize, EltTySize - StartBit); llvm::Value *LowVal = Builder.CreateLoad(Ptr, Dst.isVolatileQualified(), "bf.prev.low"); // Compute the mask for zero-ing the low part of this bitfield. - llvm::Constant *InvMask = + llvm::Constant *InvMask = llvm::ConstantInt::get(VMContext, ~llvm::APInt::getBitsSet(EltTySize, StartBit, StartBit + LowBits)); - + // Compute the new low part as // LowVal = (LowVal & InvMask) | (NewVal << StartBit), // with the shift of NewVal implicitly stripping the high bits. - llvm::Value *NewLowVal = - Builder.CreateShl(NewVal, llvm::ConstantInt::get(EltTy, StartBit), - "bf.value.lo"); + llvm::Value *NewLowVal = + Builder.CreateShl(NewVal, llvm::ConstantInt::get(EltTy, StartBit), + "bf.value.lo"); LowVal = Builder.CreateAnd(LowVal, InvMask, "bf.prev.lo.cleared"); LowVal = Builder.CreateOr(LowVal, NewLowVal, "bf.new.lo"); - + // Write back. Builder.CreateStore(LowVal, Ptr, Dst.isVolatileQualified()); @@ -580,26 +577,26 @@ if (LowBits < BitfieldSize) { unsigned HighBits = BitfieldSize - LowBits; llvm::Value *HighPtr = Builder.CreateGEP(Ptr, llvm::ConstantInt::get( - llvm::Type::getInt32Ty(VMContext), 1), "bf.ptr.hi"); - llvm::Value *HighVal = Builder.CreateLoad(HighPtr, + llvm::Type::getInt32Ty(VMContext), 1), "bf.ptr.hi"); + llvm::Value *HighVal = Builder.CreateLoad(HighPtr, Dst.isVolatileQualified(), "bf.prev.hi"); - + // Compute the mask for zero-ing the high part of this bitfield. - llvm::Constant *InvMask = - llvm::ConstantInt::get(VMContext, ~llvm::APInt::getLowBitsSet(EltTySize, + llvm::Constant *InvMask = + llvm::ConstantInt::get(VMContext, ~llvm::APInt::getLowBitsSet(EltTySize, HighBits)); - + // Compute the new high part as // HighVal = (HighVal & InvMask) | (NewVal lshr LowBits), // where the high bits of NewVal have already been cleared and the // shift stripping the low bits. - llvm::Value *NewHighVal = - Builder.CreateLShr(NewVal, llvm::ConstantInt::get(EltTy, LowBits), - "bf.value.high"); + llvm::Value *NewHighVal = + Builder.CreateLShr(NewVal, llvm::ConstantInt::get(EltTy, LowBits), + "bf.value.high"); HighVal = Builder.CreateAnd(HighVal, InvMask, "bf.prev.hi.cleared"); HighVal = Builder.CreateOr(HighVal, NewHighVal, "bf.new.hi"); - + // Write back. Builder.CreateStore(HighVal, HighPtr, Dst.isVolatileQualified()); } @@ -625,24 +622,24 @@ llvm::Value *Vec = Builder.CreateLoad(Dst.getExtVectorAddr(), Dst.isVolatileQualified(), "tmp"); const llvm::Constant *Elts = Dst.getExtVectorElts(); - + llvm::Value *SrcVal = Src.getScalarVal(); - + if (const VectorType *VTy = Ty->getAsVectorType()) { unsigned NumSrcElts = VTy->getNumElements(); unsigned NumDstElts = cast(Vec->getType())->getNumElements(); if (NumDstElts == NumSrcElts) { - // Use shuffle vector is the src and destination are the same number - // of elements and restore the vector mask since it is on the side - // it will be stored. + // Use shuffle vector is the src and destination are the same number of + // elements and restore the vector mask since it is on the side it will be + // stored. llvm::SmallVector Mask(NumDstElts); for (unsigned i = 0; i != NumSrcElts; ++i) { unsigned InIdx = getAccessedFieldNo(i, Elts); Mask[InIdx] = llvm::ConstantInt::get( llvm::Type::getInt32Ty(VMContext), i); } - + llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size()); Vec = Builder.CreateShuffleVector(SrcVal, llvm::UndefValue::get(Vec->getType()), @@ -662,7 +659,7 @@ llvm::Type::getInt32Ty(VMContext))); llvm::Value *ExtMaskV = llvm::ConstantVector::get(&ExtMask[0], ExtMask.size()); - llvm::Value *ExtSrcVal = + llvm::Value *ExtSrcVal = Builder.CreateShuffleVector(SrcVal, llvm::UndefValue::get(SrcVal->getType()), ExtMaskV, "tmp"); @@ -691,17 +688,17 @@ llvm::Type::getInt32Ty(VMContext), InIdx); Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp"); } - + Builder.CreateStore(Vec, Dst.getExtVectorAddr(), Dst.isVolatileQualified()); } LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { const VarDecl *VD = dyn_cast(E->getDecl()); - + if (VD && (VD->isBlockVarDecl() || isa(VD) || isa(VD))) { LValue LV; - bool NonGCable = VD->hasLocalStorage() && + bool NonGCable = VD->hasLocalStorage() && !VD->hasAttr(); if (VD->hasExternalStorage()) { llvm::Value *V = CGM.GetAddrOfGlobalVar(VD); @@ -778,7 +775,7 @@ } LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) { - return LValue::MakeAddr(GetAddrOfBlockDecl(E), + return LValue::MakeAddr(GetAddrOfBlockDecl(E), E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType()), E->getType().getAddressSpace()); @@ -788,7 +785,7 @@ // __extension__ doesn't affect lvalue-ness. if (E->getOpcode() == UnaryOperator::Extension) return EmitLValue(E->getSubExpr()); - + QualType ExprTy = getContext().getCanonicalType(E->getSubExpr()->getType()); switch (E->getOpcode()) { default: assert(0 && "Unknown unary operator lvalue!"); @@ -796,9 +793,9 @@ { QualType T = E->getSubExpr()->getType()->getPointeeType(); assert(!T.isNull() && "CodeGenFunction::EmitUnaryOpLValue: Illegal type"); - + LValue LV = LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()), - T.getCVRQualifiers(), + T.getCVRQualifiers(), getContext().getObjCGCAttrKind(T), ExprTy.getAddressSpace()); // We should not generate __weak write barrier on indirect reference @@ -854,12 +851,12 @@ CurCodeDecl); GlobalVarName += FunctionName; - llvm::Constant *C = + llvm::Constant *C = CGM.GetAddrOfConstantCString(FunctionName, GlobalVarName.c_str()); return LValue::MakeAddr(C, 0); } -LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { +LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { switch (E->getIdentType()) { default: return EmitUnsupportedLValue(E, "predefined expression"); @@ -882,15 +879,15 @@ // Emit the vector as an lvalue to get its address. LValue LHS = EmitLValue(E->getBase()); assert(LHS.isSimple() && "Can only subscript lvalue vectors here!"); - Idx = Builder.CreateIntCast(Idx, + Idx = Builder.CreateIntCast(Idx, llvm::Type::getInt32Ty(VMContext), IdxSigned, "vidx"); return LValue::MakeVectorElt(LHS.getAddress(), Idx, E->getBase()->getType().getCVRQualifiers()); } - + // The base must be a pointer, which is not an aggregate. Emit it. llvm::Value *Base = EmitScalarExpr(E->getBase()); - + // Extend or truncate the index type to 32 or 64-bits. unsigned IdxBitwidth = cast(Idx->getType())->getBitWidth(); if (IdxBitwidth != LLVMPointerWidth) @@ -898,28 +895,28 @@ llvm::IntegerType::get(VMContext, LLVMPointerWidth), IdxSigned, "idxprom"); - // We know that the pointer points to a type of the correct size, - // unless the size is a VLA or Objective-C interface. + // We know that the pointer points to a type of the correct size, unless the + // size is a VLA or Objective-C interface. llvm::Value *Address = 0; - if (const VariableArrayType *VAT = + if (const VariableArrayType *VAT = getContext().getAsVariableArrayType(E->getType())) { llvm::Value *VLASize = GetVLASize(VAT); - + Idx = Builder.CreateMul(Idx, VLASize); - + QualType BaseType = getContext().getBaseElementType(VAT); - + uint64_t BaseTypeSize = getContext().getTypeSize(BaseType) / 8; Idx = Builder.CreateUDiv(Idx, - llvm::ConstantInt::get(Idx->getType(), + llvm::ConstantInt::get(Idx->getType(), BaseTypeSize)); Address = Builder.CreateInBoundsGEP(Base, Idx, "arrayidx"); - } else if (const ObjCInterfaceType *OIT = + } else if (const ObjCInterfaceType *OIT = dyn_cast(E->getType())) { - llvm::Value *InterfaceSize = + llvm::Value *InterfaceSize = llvm::ConstantInt::get(Idx->getType(), getContext().getTypeSize(OIT) / 8); - + Idx = Builder.CreateMul(Idx, InterfaceSize); llvm::Type *i8PTy = @@ -930,11 +927,11 @@ } else { Address = Builder.CreateInBoundsGEP(Base, Idx, "arrayidx"); } - + QualType T = E->getBase()->getType()->getPointeeType(); - assert(!T.isNull() && + assert(!T.isNull() && "CodeGenFunction::EmitArraySubscriptExpr(): Illegal base type"); - + LValue LV = LValue::MakeAddr(Address, T.getCVRQualifiers(), getContext().getObjCGCAttrKind(T), @@ -945,11 +942,11 @@ return LV; } -static +static llvm::Constant *GenerateConstantVector(llvm::LLVMContext &VMContext, llvm::SmallVector &Elts) { llvm::SmallVector CElts; - + for (unsigned i = 0, e = Elts.size(); i != e; ++i) CElts.push_back(llvm::ConstantInt::get( llvm::Type::getInt32Ty(VMContext), Elts[i])); @@ -1011,7 +1008,7 @@ // If this is s.x, emit s as an lvalue. If it is s->x, emit s as a scalar. if (E->isArrow()) { BaseValue = EmitScalarExpr(BaseExpr); - const PointerType *PTy = + const PointerType *PTy = BaseExpr->getType()->getAs(); if (PTy->getPointeeType()->isUnionType()) isUnion = true; @@ -1055,7 +1052,7 @@ // FIXME: CodeGenTypes should expose a method to get the appropriate type for // FieldTy (the appropriate type is ABI-dependent). - const llvm::Type *FieldTy = + const llvm::Type *FieldTy = CGM.getTypes().ConvertTypeForMem(Field->getType()); const llvm::PointerType *BaseTy = cast(BaseValue->getType()); @@ -1063,11 +1060,11 @@ BaseValue = Builder.CreateBitCast(BaseValue, llvm::PointerType::get(FieldTy, AS), "tmp"); - - llvm::Value *Idx = + + llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), Info.FieldNo); llvm::Value *V = Builder.CreateGEP(BaseValue, Idx, "tmp"); - + return LValue::MakeBitfield(V, Info.Start, Info.Size, Field->getType()->isSignedIntegerType(), Field->getType().getCVRQualifiers()|CVRQualifiers); @@ -1080,19 +1077,19 @@ { if (Field->isBitField()) return EmitLValueForBitfield(BaseValue, Field, CVRQualifiers); - + unsigned idx = CGM.getTypes().getLLVMFieldNo(Field); llvm::Value *V = Builder.CreateStructGEP(BaseValue, idx, "tmp"); // Match union field type. if (isUnion) { - const llvm::Type *FieldTy = + const llvm::Type *FieldTy = CGM.getTypes().ConvertTypeForMem(Field->getType()); - const llvm::PointerType * BaseTy = + const llvm::PointerType * BaseTy = cast(BaseValue->getType()); unsigned AS = BaseTy->getAddressSpace(); - V = Builder.CreateBitCast(V, - llvm::PointerType::get(FieldTy, AS), + V = Builder.CreateBitCast(V, + llvm::PointerType::get(FieldTy, AS), "tmp"); } if (Field->getType()->isReferenceType()) @@ -1110,8 +1107,8 @@ } else if (Ty->isObjCObjectPointerType()) attr = QualType::Strong; } - LValue LV = - LValue::MakeAddr(V, + LValue LV = + LValue::MakeAddr(V, Field->getType().getCVRQualifiers()|CVRQualifiers, attr, Field->getType().getAddressSpace()); @@ -1143,7 +1140,7 @@ return EmitUnsupportedLValue(E, "conditional operator"); // ?: here should be an aggregate. - assert((hasAggregateLLVMType(E->getType()) && + assert((hasAggregateLLVMType(E->getType()) && !E->getType()->isAnyComplexType()) && "Unexpected conditional operator!"); @@ -1153,7 +1150,7 @@ return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType()), E->getType().getAddressSpace()); - + } /// EmitCastLValue - Casts are never lvalues. If a cast is needed by the code @@ -1163,15 +1160,15 @@ /// noop aggregate casts, and cast from scalar to union. LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) { - if (const CXXFunctionalCastExpr *CXXFExpr = + if (const CXXFunctionalCastExpr *CXXFExpr = dyn_cast(E)) return LValue::MakeAddr( EmitCXXFunctionalCastExpr(CXXFExpr).getScalarVal(), 0); - assert(isa(E) && + assert(isa(E) && "EmitCastLValue - Expected CStyleCastExpr"); return EmitLValue(E->getSubExpr()); } - + // If this is an aggregate-to-aggregate cast, just use the input's address as // the lvalue. if (E->getCastKind() == CastExpr::CK_NoOp) @@ -1186,11 +1183,11 @@ // Otherwise, we must have a cast from scalar to union. assert(E->getCastKind() == CastExpr::CK_ToUnion && "Expected scalar-to-union cast"); - + // Casts are only lvalues when the source and destination types are the same. llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType())); EmitAnyExpr(E->getSubExpr(), Temp, false); - + return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType()), E->getType().getAddressSpace()); @@ -1208,7 +1205,7 @@ if (const CXXMemberCallExpr *CE = dyn_cast(E)) return EmitCXXMemberCallExpr(CE); - + const Decl *TargetDecl = 0; if (const ImplicitCastExpr *CE = dyn_cast(E->getCallee())) { if (const DeclRefExpr *DRE = dyn_cast(CE->getSubExpr())) { @@ -1222,17 +1219,17 @@ if (const CXXOperatorCallExpr *CE = dyn_cast(E)) if (const CXXMethodDecl *MD = dyn_cast_or_null(TargetDecl)) return EmitCXXOperatorMemberCallExpr(CE, MD); - + if (isa(E->getCallee())) { // C++ [expr.pseudo]p1: - // The result shall only be used as the operand for the function call + // The result shall only be used as the operand for the function call // operator (), and the result of such a call has type void. The only // effect is the evaluation of the postfix-expression before the dot or // arrow. EmitScalarExpr(E->getCallee()); return RValue::get(0); } - + llvm::Value *Callee = EmitScalarExpr(E->getCallee()); return EmitCall(Callee, E->getCallee()->getType(), E->arg_begin(), E->arg_end(), TargetDecl); @@ -1244,7 +1241,7 @@ EmitAnyExpr(E->getLHS()); return EmitLValue(E->getRHS()); } - + // Can only get l-value for binary operator expressions which are a // simple assignment of aggregate type. if (E->getOpcode() != BinaryOperator::Assign) @@ -1265,12 +1262,12 @@ assert(E->getCallReturnType()->isReferenceType() && "Can't have a scalar return unless the return type is a " "reference type!"); - - return LValue::MakeAddr(RV.getScalarVal(), E->getType().getCVRQualifiers(), + + return LValue::MakeAddr(RV.getScalarVal(), E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType()), E->getType().getAddressSpace()); } - + return LValue::MakeAddr(RV.getAggregateAddr(), E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType()), @@ -1301,9 +1298,9 @@ LValue CodeGenFunction::EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E) { LValue LV = EmitLValue(E->getSubExpr()); - + PushCXXTemporary(E->getTemporary(), LV.getAddress()); - + return LV; } @@ -1351,18 +1348,18 @@ return EmitLValueForIvar(ObjectTy, BaseValue, E->getDecl(), CVRQualifiers); } -LValue +LValue CodeGenFunction::EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E) { - // This is a special l-value that just issues sends when we load or - // store through it. + // This is a special l-value that just issues sends when we load or store + // through it. return LValue::MakePropertyRef(E, E->getType().getCVRQualifiers()); } -LValue +LValue CodeGenFunction::EmitObjCKVCRefLValue( const ObjCImplicitSetterGetterRefExpr *E) { - // This is a special l-value that just issues sends when we load or - // store through it. + // This is a special l-value that just issues sends when we load or store + // through it. return LValue::MakeKVCRef(E, E->getType().getCVRQualifiers()); } @@ -1372,7 +1369,7 @@ } LValue CodeGenFunction::EmitStmtExprLValue(const StmtExpr *E) { - + // Can only get l-value for message expression returning aggregate type RValue RV = EmitAnyExprToTemp(E); // FIXME: can this be volatile? @@ -1383,13 +1380,13 @@ } -RValue CodeGenFunction::EmitCall(llvm::Value *Callee, QualType CalleeType, +RValue CodeGenFunction::EmitCall(llvm::Value *Callee, QualType CalleeType, CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgEnd, const Decl *TargetDecl) { - // Get the actual function type. The callee type will always be a - // pointer to function type or a block pointer type. - assert(CalleeType->isFunctionPointerType() && + // Get the actual function type. The callee type will always be a pointer to + // function type or a block pointer type. + assert(CalleeType->isFunctionPointerType() && "Call must have function pointer type!"); QualType FnType = CalleeType->getAs()->getPointeeType(); @@ -1398,6 +1395,6 @@ CallArgList Args; EmitCallArgs(Args, FnType->getAsFunctionProtoType(), ArgBeg, ArgEnd); - return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), + return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args), Callee, Args, TargetDecl); } Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=81337&r1=81336&r2=81337&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Wed Sep 9 08:00:44 2009 @@ -46,7 +46,7 @@ IgnoreRealAssign(irn), IgnoreImagAssign(iin) { } - + //===--------------------------------------------------------------------===// // Utilities //===--------------------------------------------------------------------===// @@ -82,23 +82,23 @@ if (LV.isPropertyRef()) return CGF.EmitObjCPropertyGet(LV.getPropertyRefExpr()).getComplexVal(); - + assert(LV.isKVCRef() && "Unknown LValue type!"); return CGF.EmitObjCPropertyGet(LV.getKVCRefExpr()).getComplexVal(); } - + /// EmitLoadOfComplex - Given a pointer to a complex value, emit code to load /// the real and imaginary pieces. ComplexPairTy EmitLoadOfComplex(llvm::Value *SrcPtr, bool isVolatile); - + /// EmitStoreOfComplex - Store the specified real/imag parts into the /// specified value pointer. void EmitStoreOfComplex(ComplexPairTy Val, llvm::Value *ResPtr, bool isVol); - + /// EmitComplexToComplexCast - Emit a cast from complex value Val to DestType. ComplexPairTy EmitComplexToComplexCast(ComplexPairTy Val, QualType SrcType, QualType DestType); - + //===--------------------------------------------------------------------===// // Visitor Methods //===--------------------------------------------------------------------===// @@ -111,10 +111,10 @@ ComplexPairTy VisitExpr(Expr *S); ComplexPairTy VisitParenExpr(ParenExpr *PE) { return Visit(PE->getSubExpr());} ComplexPairTy VisitImaginaryLiteral(const ImaginaryLiteral *IL); - + // l-values. ComplexPairTy VisitDeclRefExpr(const Expr *E) { return EmitLoadOfLValue(E); } - ComplexPairTy VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { + ComplexPairTy VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { return EmitLoadOfLValue(E); } ComplexPairTy VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { @@ -131,7 +131,7 @@ ComplexPairTy VisitMemberExpr(const Expr *E) { return EmitLoadOfLValue(E); } // FIXME: CompoundLiteralExpr - + ComplexPairTy EmitCast(Expr *Op, QualType DestTy); ComplexPairTy VisitImplicitCastExpr(ImplicitCastExpr *E) { // Unlike for scalars, we don't have to worry about function->ptr demotion @@ -182,24 +182,23 @@ ComplexPairTy VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) { assert(E->getType()->isAnyComplexType() && "Expected complex type!"); QualType Elem = E->getType()->getAsComplexType()->getElementType(); - llvm::Constant *Null = - llvm::Constant::getNullValue(CGF.ConvertType(Elem)); + llvm::Constant *Null = llvm::Constant::getNullValue(CGF.ConvertType(Elem)); return ComplexPairTy(Null, Null); } ComplexPairTy VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { assert(E->getType()->isAnyComplexType() && "Expected complex type!"); QualType Elem = E->getType()->getAsComplexType()->getElementType(); - llvm::Constant *Null = + llvm::Constant *Null = llvm::Constant::getNullValue(CGF.ConvertType(Elem)); return ComplexPairTy(Null, Null); } - + struct BinOpInfo { ComplexPairTy LHS; ComplexPairTy RHS; QualType Ty; // Computation Type. - }; - + }; + BinOpInfo EmitBinOps(const BinaryOperator *E); ComplexPairTy EmitCompoundAssign(const CompoundAssignOperator *E, ComplexPairTy (ComplexExprEmitter::*Func) @@ -209,7 +208,7 @@ ComplexPairTy EmitBinSub(const BinOpInfo &Op); ComplexPairTy EmitBinMul(const BinOpInfo &Op); ComplexPairTy EmitBinDiv(const BinOpInfo &Op); - + ComplexPairTy VisitBinMul(const BinaryOperator *E) { return EmitBinMul(EmitBinOps(E)); } @@ -222,7 +221,7 @@ ComplexPairTy VisitBinDiv(const BinaryOperator *E) { return EmitBinDiv(EmitBinOps(E)); } - + // Compound assignments. ComplexPairTy VisitBinAddAssign(const CompoundAssignOperator *E) { return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd); @@ -236,7 +235,7 @@ ComplexPairTy VisitBinDivAssign(const CompoundAssignOperator *E) { return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv); } - + // GCC rejects rem/and/or/xor for integer complex. // Logical and/or always return int, never complex. @@ -244,7 +243,7 @@ ComplexPairTy VisitBinAssign (const BinaryOperator *E); ComplexPairTy VisitBinComma (const BinaryOperator *E); - + ComplexPairTy VisitConditionalOperator(const ConditionalOperator *CO); ComplexPairTy VisitChooseExpr(ChooseExpr *CE); @@ -264,7 +263,7 @@ bool isVolatile) { llvm::SmallString<64> Name(SrcPtr->getName().begin(), SrcPtr->getName().end()); - + llvm::Value *Real=0, *Imag=0; if (!IgnoreReal) { @@ -279,10 +278,10 @@ Name.str().str().c_str()); Name.resize(Name.size()-4); // .real -> .imagp } - + if (!IgnoreImag) { Name += "imagp"; - + // FIXME: Clean this up once builder takes Twine/StringRef. llvm::Value *ImagPtr = Builder.CreateStructGEP(SrcPtr, 1, Name.str().str().c_str()); @@ -300,7 +299,7 @@ bool isVolatile) { llvm::Value *RealPtr = Builder.CreateStructGEP(Ptr, 0, "real"); llvm::Value *ImagPtr = Builder.CreateStructGEP(Ptr, 1, "imag"); - + Builder.CreateStore(Val.first, RealPtr, isVolatile); Builder.CreateStore(Val.second, ImagPtr, isVolatile); } @@ -313,7 +312,7 @@ ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) { CGF.ErrorUnsupported(E, "complex expression"); - const llvm::Type *EltTy = + const llvm::Type *EltTy = CGF.ConvertType(E->getType()->getAsComplexType()->getElementType()); llvm::Value *U = llvm::UndefValue::get(EltTy); return ComplexPairTy(U, U); @@ -358,7 +357,7 @@ // Two cases here: cast from (complex to complex) and (scalar to complex). if (Op->getType()->isAnyComplexType()) return EmitComplexToComplexCast(Visit(Op), Op->getType(), DestTy); - + // C99 6.3.1.7: When a value of real type is converted to a complex type, the // real part of the complex result value is determined by the rules of // conversion to the corresponding real type and the imaginary part of the @@ -368,7 +367,7 @@ // Convert the input element to the element type of the complex. DestTy = DestTy->getAsComplexType()->getElementType(); Elt = CGF.EmitScalarConversion(Elt, Op->getType(), DestTy); - + // Return (realval, 0). return ComplexPairTy(Elt, llvm::Constant::getNullValue(Elt->getType())); } @@ -378,12 +377,12 @@ LValue LV = CGF.EmitLValue(E->getSubExpr()); ComplexPairTy InVal = EmitLoadOfComplex(LV.getAddress(), LV.isVolatileQualified()); - + llvm::Value *NextVal; if (isa(InVal.first->getType())) { uint64_t AmountVal = isInc ? 1 : -1; NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal, true); - + // Add the inc/dec to the real part. NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); } else { @@ -392,16 +391,16 @@ if (!isInc) FVal.changeSign(); NextVal = llvm::ConstantFP::get(CGF.getLLVMContext(), FVal); - + // Add the inc/dec to the real part. NextVal = Builder.CreateFAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); } - + ComplexPairTy IncVal(NextVal, InVal.second); - + // Store the updated result through the lvalue. EmitStoreOfComplex(IncVal, LV.getAddress(), LV.isVolatileQualified()); - + // If this is a postinc, return the value read from memory, otherwise use the // updated value. return isPre ? IncVal : InVal; @@ -413,7 +412,7 @@ TestAndClearIgnoreRealAssign(); TestAndClearIgnoreImagAssign(); ComplexPairTy Op = Visit(E->getSubExpr()); - + llvm::Value *ResR, *ResI; if (Op.first->getType()->isFloatingPoint()) { ResR = Builder.CreateFNeg(Op.first, "neg.r"); @@ -437,13 +436,13 @@ ResI = Builder.CreateFNeg(Op.second, "conj.i"); else ResI = Builder.CreateNeg(Op.second, "conj.i"); - + return ComplexPairTy(Op.first, ResI); } ComplexPairTy ComplexExprEmitter::EmitBinAdd(const BinOpInfo &Op) { llvm::Value *ResR, *ResI; - + if (Op.LHS.first->getType()->isFloatingPoint()) { ResR = Builder.CreateFAdd(Op.LHS.first, Op.RHS.first, "add.r"); ResI = Builder.CreateFAdd(Op.LHS.second, Op.RHS.second, "add.i"); @@ -470,12 +469,12 @@ ComplexPairTy ComplexExprEmitter::EmitBinMul(const BinOpInfo &Op) { using llvm::Value; Value *ResR, *ResI; - + if (Op.LHS.first->getType()->isFloatingPoint()) { Value *ResRl = Builder.CreateFMul(Op.LHS.first, Op.RHS.first, "mul.rl"); Value *ResRr = Builder.CreateFMul(Op.LHS.second, Op.RHS.second,"mul.rr"); ResR = Builder.CreateFSub(ResRl, ResRr, "mul.r"); - + Value *ResIl = Builder.CreateFMul(Op.LHS.second, Op.RHS.first, "mul.il"); Value *ResIr = Builder.CreateFMul(Op.LHS.first, Op.RHS.second, "mul.ir"); ResI = Builder.CreateFAdd(ResIl, ResIr, "mul.i"); @@ -483,7 +482,7 @@ Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first, "mul.rl"); Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,"mul.rr"); ResR = Builder.CreateSub(ResRl, ResRr, "mul.r"); - + Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first, "mul.il"); Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second, "mul.ir"); ResI = Builder.CreateAdd(ResIl, ResIr, "mul.i"); @@ -494,7 +493,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const BinOpInfo &Op) { llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second; llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second; - + llvm::Value *DSTr, *DSTi; if (Op.LHS.first->getType()->isFloatingPoint()) { @@ -502,15 +501,15 @@ llvm::Value *Tmp1 = Builder.CreateFMul(LHSr, RHSr, "tmp"); // a*c llvm::Value *Tmp2 = Builder.CreateFMul(LHSi, RHSi, "tmp"); // b*d llvm::Value *Tmp3 = Builder.CreateFAdd(Tmp1, Tmp2, "tmp"); // ac+bd - + llvm::Value *Tmp4 = Builder.CreateFMul(RHSr, RHSr, "tmp"); // c*c llvm::Value *Tmp5 = Builder.CreateFMul(RHSi, RHSi, "tmp"); // d*d llvm::Value *Tmp6 = Builder.CreateFAdd(Tmp4, Tmp5, "tmp"); // cc+dd - + llvm::Value *Tmp7 = Builder.CreateFMul(LHSi, RHSr, "tmp"); // b*c llvm::Value *Tmp8 = Builder.CreateFMul(LHSr, RHSi, "tmp"); // a*d llvm::Value *Tmp9 = Builder.CreateFSub(Tmp7, Tmp8, "tmp"); // bc-ad - + DSTr = Builder.CreateFDiv(Tmp3, Tmp6, "tmp"); DSTi = Builder.CreateFDiv(Tmp9, Tmp6, "tmp"); } else { @@ -518,15 +517,15 @@ llvm::Value *Tmp1 = Builder.CreateMul(LHSr, RHSr, "tmp"); // a*c llvm::Value *Tmp2 = Builder.CreateMul(LHSi, RHSi, "tmp"); // b*d llvm::Value *Tmp3 = Builder.CreateAdd(Tmp1, Tmp2, "tmp"); // ac+bd - + llvm::Value *Tmp4 = Builder.CreateMul(RHSr, RHSr, "tmp"); // c*c llvm::Value *Tmp5 = Builder.CreateMul(RHSi, RHSi, "tmp"); // d*d llvm::Value *Tmp6 = Builder.CreateAdd(Tmp4, Tmp5, "tmp"); // cc+dd - + llvm::Value *Tmp7 = Builder.CreateMul(LHSi, RHSr, "tmp"); // b*c llvm::Value *Tmp8 = Builder.CreateMul(LHSr, RHSi, "tmp"); // a*d llvm::Value *Tmp9 = Builder.CreateSub(Tmp7, Tmp8, "tmp"); // bc-ad - + if (Op.Ty->getAsComplexType()->getElementType()->isUnsignedIntegerType()) { DSTr = Builder.CreateUDiv(Tmp3, Tmp6, "tmp"); DSTi = Builder.CreateUDiv(Tmp9, Tmp6, "tmp"); @@ -535,11 +534,11 @@ DSTi = Builder.CreateSDiv(Tmp9, Tmp6, "tmp"); } } - + return ComplexPairTy(DSTr, DSTi); } -ComplexExprEmitter::BinOpInfo +ComplexExprEmitter::BinOpInfo ComplexExprEmitter::EmitBinOps(const BinaryOperator *E) { TestAndClearIgnoreReal(); TestAndClearIgnoreImag(); @@ -564,27 +563,27 @@ QualType LHSTy = E->getLHS()->getType(), RHSTy = E->getRHS()->getType(); BinOpInfo OpInfo; - + // Load the RHS and LHS operands. // __block variables need to have the rhs evaluated first, plus this should // improve codegen a little. It is possible for the RHS to be complex or // scalar. OpInfo.Ty = E->getComputationResultType(); OpInfo.RHS = EmitCast(E->getRHS(), OpInfo.Ty); - + LValue LHSLV = CGF.EmitLValue(E->getLHS()); // We know the LHS is a complex lvalue. - OpInfo.LHS=EmitLoadOfComplex(LHSLV.getAddress(),LHSLV.isVolatileQualified()); + OpInfo.LHS=EmitLoadOfComplex(LHSLV.getAddress(), LHSLV.isVolatileQualified()); OpInfo.LHS=EmitComplexToComplexCast(OpInfo.LHS, LHSTy, OpInfo.Ty); - + // Expand the binary operator. ComplexPairTy Result = (this->*Func)(OpInfo); - + // Truncate the result back to the LHS type. Result = EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy); - + // Store the result value into the LHS lvalue. EmitStoreOfComplex(Result, LHSLV.getAddress(), LHSLV.isVolatileQualified()); // And now return the LHS @@ -608,7 +607,7 @@ // Compute the address to store into. LValue LHS = CGF.EmitLValue(E->getLHS()); - + // Store into it, if simple. if (LHS.isSimple()) { EmitStoreOfComplex(Val, LHS.getAddress(), LHS.isVolatileQualified()); @@ -620,7 +619,7 @@ IgnoreImagAssign = ignimag; return EmitLoadOfComplex(LHS.getAddress(), LHS.isVolatileQualified()); } - + // Otherwise we must have a property setter (no complex vector/bitfields). if (LHS.isPropertyRef()) CGF.EmitObjCPropertySet(LHS.getPropertyRefExpr(), RValue::getComplex(Val)); @@ -651,27 +650,27 @@ llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.true"); llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.false"); llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.end"); - + llvm::Value *Cond = CGF.EvaluateExprAsBool(E->getCond()); Builder.CreateCondBr(Cond, LHSBlock, RHSBlock); - + CGF.EmitBlock(LHSBlock); - + // Handle the GNU extension for missing LHS. assert(E->getLHS() && "Must have LHS for complex value"); ComplexPairTy LHS = Visit(E->getLHS()); LHSBlock = Builder.GetInsertBlock(); CGF.EmitBranch(ContBlock); - + CGF.EmitBlock(RHSBlock); - + ComplexPairTy RHS = Visit(E->getRHS()); RHSBlock = Builder.GetInsertBlock(); CGF.EmitBranch(ContBlock); - + CGF.EmitBlock(ContBlock); - + // Create a PHI node for the real part. llvm::PHINode *RealPN = Builder.CreatePHI(LHS.first->getType(), "cond.r"); RealPN->reserveOperandSpace(2); @@ -683,7 +682,7 @@ ImagPN->reserveOperandSpace(2); ImagPN->addIncoming(LHS.second, LHSBlock); ImagPN->addIncoming(RHS.second, RHSBlock); - + return ComplexPairTy(RealPN, ImagPN); } @@ -714,7 +713,7 @@ if (!ArgPtr) { CGF.ErrorUnsupported(E, "complex va_arg expression"); - const llvm::Type *EltTy = + const llvm::Type *EltTy = CGF.ConvertType(E->getType()->getAsComplexType()->getElementType()); llvm::Value *U = llvm::UndefValue::get(EltTy); return ComplexPairTy(U, U); @@ -734,7 +733,7 @@ bool IgnoreImag, bool IgnoreRealAssign, bool IgnoreImagAssign) { assert(E && E->getType()->isAnyComplexType() && "Invalid complex expression to emit"); - + return ComplexExprEmitter(*this, IgnoreReal, IgnoreImag, IgnoreRealAssign, IgnoreImagAssign) .Visit(const_cast(E)); @@ -760,7 +759,7 @@ } /// LoadComplexFromAddr - Load a complex number from the specified address. -ComplexPairTy CodeGenFunction::LoadComplexFromAddr(llvm::Value *SrcAddr, +ComplexPairTy CodeGenFunction::LoadComplexFromAddr(llvm::Value *SrcAddr, bool SrcIsVolatile) { return ComplexExprEmitter(*this).EmitLoadOfComplex(SrcAddr, SrcIsVolatile); } Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=81337&r1=81336&r2=81337&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Sep 9 08:00:44 2009 @@ -53,10 +53,10 @@ public: ScalarExprEmitter(CodeGenFunction &cgf, bool ira=false) - : CGF(cgf), Builder(CGF.Builder), IgnoreResultAssign(ira), + : CGF(cgf), Builder(CGF.Builder), IgnoreResultAssign(ira), VMContext(cgf.getLLVMContext()) { } - + //===--------------------------------------------------------------------===// // Utilities //===--------------------------------------------------------------------===// @@ -73,25 +73,25 @@ Value *EmitLoadOfLValue(LValue LV, QualType T) { return CGF.EmitLoadOfLValue(LV, T).getScalarVal(); } - + /// EmitLoadOfLValue - Given an expression with complex type that represents a /// value l-value, this method emits the address of the l-value, then loads /// and returns the result. Value *EmitLoadOfLValue(const Expr *E) { return EmitLoadOfLValue(EmitLValue(E), E->getType()); } - + /// EmitConversionToBool - Convert the specified expression value to a /// boolean (i1) truth value. This is equivalent to "Val != 0". Value *EmitConversionToBool(Value *Src, QualType DstTy); - + /// EmitScalarConversion - Emit a conversion from the specified type to the /// specified destination type, both of which are LLVM scalar types. Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy); /// EmitComplexToScalarConversion - Emit a conversion from the specified - /// complex type to the specified destination type, where the destination - /// type is an LLVM scalar type. + /// complex type to the specified destination type, where the destination type + /// is an LLVM scalar type. Value *EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src, QualType SrcTy, QualType DstTy); @@ -133,26 +133,26 @@ } Value *VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E); Value *VisitAddrLabelExpr(const AddrLabelExpr *E) { - llvm::Value *V = + llvm::Value *V = llvm::ConstantInt::get(llvm::Type::getInt32Ty(CGF.getLLVMContext()), CGF.GetIDForAddrOfLabel(E->getLabel())); - + return Builder.CreateIntToPtr(V, ConvertType(E->getType())); } - + // l-values. Value *VisitDeclRefExpr(DeclRefExpr *E) { if (const EnumConstantDecl *EC = dyn_cast(E->getDecl())) return llvm::ConstantInt::get(VMContext, EC->getInitVal()); return EmitLoadOfLValue(E); } - Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E) { - return CGF.EmitObjCSelectorExpr(E); + Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E) { + return CGF.EmitObjCSelectorExpr(E); } - Value *VisitObjCProtocolExpr(ObjCProtocolExpr *E) { - return CGF.EmitObjCProtocolExpr(E); + Value *VisitObjCProtocolExpr(ObjCProtocolExpr *E) { + return CGF.EmitObjCProtocolExpr(E); } - Value *VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { + Value *VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { return EmitLoadOfLValue(E); } Value *VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { @@ -177,7 +177,7 @@ Value *VisitObjCEncodeExpr(const ObjCEncodeExpr *E) { return EmitLValue(E).getAddress(); } - + Value *VisitPredefinedExpr(Expr *E) { return EmitLValue(E).getAddress(); } Value *VisitInitListExpr(InitListExpr *E) { @@ -185,24 +185,24 @@ (void)Ignore; assert (Ignore == false && "init list ignored"); unsigned NumInitElements = E->getNumInits(); - + if (E->hadArrayRangeDesignator()) { CGF.ErrorUnsupported(E, "GNU array range designator extension"); } - const llvm::VectorType *VType = + const llvm::VectorType *VType = dyn_cast(ConvertType(E->getType())); - + // We have a scalar in braces. Just use the first element. - if (!VType) + if (!VType) return Visit(E->getInit(0)); - + unsigned NumVectorElements = VType->getNumElements(); const llvm::Type *ElementType = VType->getElementType(); // Emit individual vector element stores. llvm::Value *V = llvm::UndefValue::get(VType); - + // Emit initializers unsigned i; for (i = 0; i < NumInitElements; ++i) { @@ -211,7 +211,7 @@ llvm::ConstantInt::get(llvm::Type::getInt32Ty(CGF.getLLVMContext()), i); V = Builder.CreateInsertElement(V, NewV, Idx); } - + // Emit remaining default initializers for (/* Do not initialize i*/; i < NumVectorElements; ++i) { Value *Idx = @@ -219,22 +219,22 @@ llvm::Value *NewV = llvm::Constant::getNullValue(ElementType); V = Builder.CreateInsertElement(V, NewV, Idx); } - + return V; } - + Value *VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E) { return llvm::Constant::getNullValue(ConvertType(E->getType())); } Value *VisitCastExpr(const CastExpr *E) { if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) { - if (const CXXFunctionalCastExpr *CXXFExpr = + if (const CXXFunctionalCastExpr *CXXFExpr = dyn_cast(E)) return CGF.EmitCXXFunctionalCastExpr(CXXFExpr).getScalarVal(); - assert(isa(E) && + assert(isa(E) && "VisitCastExpr - missing CStyleCastExpr"); } - + // Make sure to evaluate VLA bounds now so that we have them for later. if (E->getType()->isVariablyModifiedType()) CGF.EmitVLASize(E->getType()); @@ -246,14 +246,14 @@ Value *VisitCallExpr(const CallExpr *E) { if (E->getCallReturnType()->isReferenceType()) return EmitLoadOfLValue(E); - + return CGF.EmitCallExpr(E).getScalarVal(); } Value *VisitStmtExpr(const StmtExpr *E); Value *VisitBlockDeclRefExpr(const BlockDeclRefExpr *E); - + // Unary Operators. Value *VisitPrePostIncDec(const UnaryOperator *E, bool isInc, bool isPre); Value *VisitUnaryPostDec(const UnaryOperator *E) { @@ -286,15 +286,15 @@ return Visit(E->getSubExpr()); } Value *VisitUnaryOffsetOf(const UnaryOperator *E); - + // C++ Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) { return Visit(DAE->getExpr()); } Value *VisitCXXThisExpr(CXXThisExpr *TE) { return CGF.LoadCXXThis(); - } - + } + Value *VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) { return CGF.EmitCXXExprWithTemporaries(E).getScalarVal(); } @@ -305,17 +305,17 @@ CGF.EmitCXXDeleteExpr(E); return 0; } - + Value *VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *E) { // C++ [expr.pseudo]p1: - // The result shall only be used as the operand for the function call + // The result shall only be used as the operand for the function call // operator (), and the result of such a call has type void. The only // effect is the evaluation of the postfix-expression before the dot or // arrow. CGF.EmitScalarExpr(E->getBase()); return 0; } - + // Binary Operators. Value *EmitMul(const BinOpInfo &Ops) { if (CGF.getContext().getLangOptions().OverflowChecking @@ -382,7 +382,7 @@ VISITCOMP(EQ, ICMP_EQ , ICMP_EQ , FCMP_OEQ); VISITCOMP(NE, ICMP_NE , ICMP_NE , FCMP_UNE); #undef VISITCOMP - + Value *VisitBinAssign (const BinaryOperator *E); Value *VisitBinLAnd (const BinaryOperator *E); @@ -408,24 +408,24 @@ /// boolean (i1) truth value. This is equivalent to "Val != 0". Value *ScalarExprEmitter::EmitConversionToBool(Value *Src, QualType SrcType) { assert(SrcType->isCanonical() && "EmitScalarConversion strips typedefs"); - + if (SrcType->isRealFloatingType()) { // Compare against 0.0 for fp scalars. llvm::Value *Zero = llvm::Constant::getNullValue(Src->getType()); return Builder.CreateFCmpUNE(Src, Zero, "tobool"); } - + if (SrcType->isMemberPointerType()) { // FIXME: This is ABI specific. - + // Compare against -1. llvm::Value *NegativeOne = llvm::Constant::getAllOnesValue(Src->getType()); return Builder.CreateICmpNE(Src, NegativeOne, "tobool"); } - + assert((SrcType->isIntegerType() || isa(Src->getType())) && "Unknown scalar type to convert"); - + // Because of the type rules of C, we often end up computing a logical value, // then zero extending it to int, then wanting it as a logical value again. // Optimize this common case. @@ -441,7 +441,7 @@ return Result; } } - + // Compare against an integer or pointer null. llvm::Value *Zero = llvm::Constant::getNullValue(Src->getType()); return Builder.CreateICmpNE(Src, Zero, "tobool"); @@ -454,32 +454,31 @@ SrcType = CGF.getContext().getCanonicalType(SrcType); DstType = CGF.getContext().getCanonicalType(DstType); if (SrcType == DstType) return Src; - + if (DstType->isVoidType()) return 0; - + llvm::LLVMContext &VMContext = CGF.getLLVMContext(); // Handle conversions to bool first, they are special: comparisons against 0. if (DstType->isBooleanType()) return EmitConversionToBool(Src, SrcType); - + const llvm::Type *DstTy = ConvertType(DstType); // Ignore conversions like int -> uint. if (Src->getType() == DstTy) return Src; - // Handle pointer conversions next: pointers can only be converted - // to/from other pointers and integers. Check for pointer types in - // terms of LLVM, as some native types (like Obj-C id) may map to a - // pointer type. + // Handle pointer conversions next: pointers can only be converted to/from + // other pointers and integers. Check for pointer types in terms of LLVM, as + // some native types (like Obj-C id) may map to a pointer type. if (isa(DstTy)) { // The source value may be an integer, or a pointer. if (isa(Src->getType())) { // Some heavy lifting for derived to base conversion. - if (const CXXRecordDecl *ClassDecl = + if (const CXXRecordDecl *ClassDecl = SrcType->getCXXRecordDeclForPointerType()) - if (const CXXRecordDecl *BaseClassDecl = + if (const CXXRecordDecl *BaseClassDecl = DstType->getCXXRecordDeclForPointerType()) Src = CGF.AddressCXXOfBaseClass(Src, ClassDecl, BaseClassDecl); return Builder.CreateBitCast(Src, DstTy, "conv"); @@ -487,7 +486,7 @@ assert(SrcType->isIntegerType() && "Not ptr->ptr or int->ptr conversion?"); // First, convert to the correct width so that we control the kind of // extension. - const llvm::Type *MiddleTy = + const llvm::Type *MiddleTy = llvm::IntegerType::get(VMContext, CGF.LLVMPointerWidth); bool InputSigned = SrcType->isSignedIntegerType(); llvm::Value* IntResult = @@ -495,13 +494,13 @@ // Then, cast to pointer. return Builder.CreateIntToPtr(IntResult, DstTy, "conv"); } - + if (isa(Src->getType())) { // Must be an ptr to int cast. assert(isa(DstTy) && "not ptr->int?"); return Builder.CreatePtrToInt(Src, DstTy, "conv"); } - + // A scalar can be splatted to an extended vector of the same element type if (DstType->isExtVectorType() && !SrcType->isVectorType()) { // Cast the scalar to element type @@ -520,7 +519,7 @@ for (unsigned i = 0; i < NumElements; i++) Args.push_back(llvm::ConstantInt::get( llvm::Type::getInt32Ty(VMContext), 0)); - + llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], NumElements); llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat"); return Yay; @@ -530,7 +529,7 @@ if (isa(Src->getType()) || isa(DstTy)) return Builder.CreateBitCast(Src, DstTy, "conv"); - + // Finally, we have the arithmetic types: real int/float. if (isa(Src->getType())) { bool InputSigned = SrcType->isSignedIntegerType(); @@ -541,7 +540,7 @@ else return Builder.CreateUIToFP(Src, DstTy, "conv"); } - + assert(Src->getType()->isFloatingPoint() && "Unknown real conversion"); if (isa(DstTy)) { if (DstType->isSignedIntegerType()) @@ -557,15 +556,15 @@ return Builder.CreateFPExt(Src, DstTy, "conv"); } -/// EmitComplexToScalarConversion - Emit a conversion from the specified -/// complex type to the specified destination type, where the destination -/// type is an LLVM scalar type. +/// EmitComplexToScalarConversion - Emit a conversion from the specified complex +/// type to the specified destination type, where the destination type is an +/// LLVM scalar type. Value *ScalarExprEmitter:: EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src, QualType SrcTy, QualType DstTy) { // Get the source element type. SrcTy = SrcTy->getAsComplexType()->getElementType(); - + // Handle conversions to bool first, they are special: comparisons against 0. if (DstTy->isBooleanType()) { // Complex != 0 -> (Real != 0) | (Imag != 0) @@ -573,11 +572,11 @@ Src.second = EmitScalarConversion(Src.second, SrcTy, DstTy); return Builder.CreateOr(Src.first, Src.second, "tobool"); } - + // C99 6.3.1.7p2: "When a value of complex type is converted to a real type, // the imaginary part of the complex value is discarded and the value of the // real part is converted according to the conversion rules for the - // corresponding real type. + // corresponding real type. return EmitScalarConversion(Src.first, SrcTy, DstTy); } @@ -613,14 +612,14 @@ // so we can't get it as an lvalue. if (!E->getBase()->getType()->isVectorType()) return EmitLoadOfLValue(E); - + // Handle the vector case. The base must be a vector, the index must be an // integer value. Value *Base = Visit(E->getBase()); Value *Idx = Visit(E->getIdx()); bool IdxSigned = E->getIdx()->getType()->isSignedIntegerType(); Idx = Builder.CreateIntCast(Idx, - llvm::Type::getInt32Ty(CGF.getLLVMContext()), + llvm::Type::getInt32Ty(CGF.getLLVMContext()), IdxSigned, "vecidxcast"); return Builder.CreateExtractElement(Base, Idx, "vecext"); @@ -633,7 +632,7 @@ CastExpr::CastKind Kind) { if (!DestTy->isVoidType()) TestAndClearIgnoreResultAssign(); - + switch (Kind) { default: break; @@ -644,7 +643,7 @@ case CastExpr::CK_ArrayToPointerDecay: { assert(E->getType()->isArrayType() && "Array to pointer decay must have array source type!"); - + Value *V = EmitLValue(E).getAddress(); // Bitfields can't be arrays. // Note that VLA pointers are always decayed, so we don't need to do @@ -656,7 +655,7 @@ "Expected pointer to array"); V = Builder.CreateStructGEP(V, 0, "arraydecay"); } - + // The resultant pointer type can be implicitly casted to other pointer // types as well (e.g. void*) and can be implicitly converted to integer. const llvm::Type *DestLTy = ConvertType(DestTy); @@ -669,20 +668,20 @@ } } return V; - } + } case CastExpr::CK_NullToMemberPointer: return CGF.CGM.EmitNullConstant(DestTy); } - + // Handle cases where the source is an non-complex type. - + if (!CGF.hasAggregateLLVMType(E->getType())) { Value *Src = Visit(const_cast(E)); // Use EmitScalarConversion to perform the conversion. return EmitScalarConversion(Src, E->getType(), DestTy); } - + if (E->getType()->isAnyComplexType()) { // Handle cases where the source is a complex type. bool IgnoreImag = true; @@ -727,7 +726,7 @@ Value *InVal = CGF.EmitLoadOfLValue(LV, ValTy).getScalarVal(); llvm::LLVMContext &VMContext = CGF.getLLVMContext(); - + int AmountVal = isInc ? 1 : -1; if (ValTy->isPointerType() && @@ -737,26 +736,26 @@ } Value *NextVal; - if (const llvm::PointerType *PT = + if (const llvm::PointerType *PT = dyn_cast(InVal->getType())) { llvm::Constant *Inc = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), AmountVal); if (!isa(PT->getElementType())) { QualType PTEE = ValTy->getPointeeType(); - if (const ObjCInterfaceType *OIT = + if (const ObjCInterfaceType *OIT = dyn_cast(PTEE)) { // Handle interface types, which are not represented with a concrete type. int size = CGF.getContext().getTypeSize(OIT) / 8; if (!isInc) size = -size; Inc = llvm::ConstantInt::get(Inc->getType(), size); - const llvm::Type *i8Ty = + const llvm::Type *i8Ty = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext)); InVal = Builder.CreateBitCast(InVal, i8Ty); NextVal = Builder.CreateGEP(InVal, Inc, "add.ptr"); llvm::Value *lhs = LV.getAddress(); lhs = Builder.CreateBitCast(lhs, llvm::PointerType::getUnqual(i8Ty)); - LV = LValue::MakeAddr(lhs, ValTy.getCVRQualifiers(), + LV = LValue::MakeAddr(lhs, ValTy.getCVRQualifiers(), CGF.getContext().getObjCGCAttrKind(ValTy)); } else NextVal = Builder.CreateInBoundsGEP(InVal, Inc, "ptrincdec"); @@ -785,11 +784,11 @@ } else { // Add the inc/dec to the real part. if (InVal->getType() == llvm::Type::getFloatTy(VMContext)) - NextVal = - llvm::ConstantFP::get(VMContext, + NextVal = + llvm::ConstantFP::get(VMContext, llvm::APFloat(static_cast(AmountVal))); else if (InVal->getType() == llvm::Type::getDoubleTy(VMContext)) - NextVal = + NextVal = llvm::ConstantFP::get(VMContext, llvm::APFloat(static_cast(AmountVal))); else { @@ -801,7 +800,7 @@ } NextVal = Builder.CreateFAdd(InVal, NextVal, isInc ? "inc" : "dec"); } - + // Store the updated result through the lvalue. if (LV.isBitfield()) CGF.EmitStoreThroughBitfieldLValue(RValue::get(NextVal), LV, ValTy, @@ -832,12 +831,12 @@ Value *ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *E) { // Compare operand to zero. Value *BoolVal = CGF.EvaluateExprAsBool(E->getSubExpr()); - + // Invert value. // TODO: Could dynamically modify easy computations here. For example, if // the operand is an icmp ne, turn into icmp eq. BoolVal = Builder.CreateNot(BoolVal, "lnot"); - + // ZExt result to the expr type. return Builder.CreateZExt(BoolVal, ConvertType(E->getType()), "lnot.ext"); } @@ -848,7 +847,7 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) { QualType TypeToSize = E->getTypeOfArgument(); if (E->isSizeOf()) { - if (const VariableArrayType *VAT = + if (const VariableArrayType *VAT = CGF.getContext().getAsVariableArrayType(TypeToSize)) { if (E->isArgumentType()) { // sizeof(type) - make sure to emit the VLA size. @@ -858,13 +857,13 @@ // VLA, it is evaluated. CGF.EmitAnyExpr(E->getArgumentExpr()); } - + return CGF.GetVLASize(VAT); } } - // If this isn't sizeof(vla), the result must be constant; use the - // constant folding logic so we don't have to duplicate it here. + // If this isn't sizeof(vla), the result must be constant; use the constant + // folding logic so we don't have to duplicate it here. Expr::EvalResult Result; E->Evaluate(Result, CGF.getContext()); return llvm::ConstantInt::get(VMContext, Result.Val.getInt()); @@ -880,7 +879,7 @@ Expr *Op = E->getSubExpr(); if (Op->getType()->isAnyComplexType()) return CGF.EmitComplexExpr(Op, true, false, true, false).second; - + // __imag on a scalar returns zero. Emit the subexpr to ensure side // effects are evaluated, but not the actual value. if (E->isLvalue(CGF.getContext()) == Expr::LV_Valid) @@ -919,10 +918,10 @@ BinOpInfo OpInfo; if (E->getComputationResultType()->isAnyComplexType()) { - // This needs to go through the complex expression emitter, but - // it's a tad complicated to do that... I'm leaving it out for now. - // (Note that we do actually need the imaginary part of the RHS for - // multiplication and division.) + // This needs to go through the complex expression emitter, but it's a tad + // complicated to do that... I'm leaving it out for now. (Note that we do + // actually need the imaginary part of the RHS for multiplication and + // division.) CGF.ErrorUnsupported(E, "complex compound assignment"); return llvm::UndefValue::get(CGF.ConvertType(E->getType())); } @@ -937,17 +936,17 @@ OpInfo.LHS = EmitLoadOfLValue(LHSLV, LHSTy); OpInfo.LHS = EmitScalarConversion(OpInfo.LHS, LHSTy, E->getComputationLHSType()); - + // Expand the binary operator. Value *Result = (this->*Func)(OpInfo); - + // Convert the result back to the LHS type. Result = EmitScalarConversion(Result, E->getComputationResultType(), LHSTy); - // Store the result value into the LHS lvalue. Bit-fields are - // handled specially because the result is altered by the store, - // i.e., [C99 6.5.16p1] 'An assignment expression has the value of - // the left operand after the assignment...'. + // Store the result value into the LHS lvalue. Bit-fields are handled + // specially because the result is altered by the store, i.e., [C99 6.5.16p1] + // 'An assignment expression has the value of the left operand after the + // assignment...'. if (LHSLV.isBitfield()) { if (!LHSLV.isVolatileQualified()) { CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, LHSTy, @@ -1029,7 +1028,7 @@ Builder.SetInsertPoint(overflowBB); // Handler is: - // long long *__overflow_handler)(long long a, long long b, char op, + // long long *__overflow_handler)(long long a, long long b, char op, // char width) std::vector handerArgTypes; handerArgTypes.push_back(llvm::Type::getInt64Ty(VMContext)); @@ -1047,13 +1046,13 @@ Builder.CreateSExt(Ops.LHS, llvm::Type::getInt64Ty(VMContext)), Builder.CreateSExt(Ops.RHS, llvm::Type::getInt64Ty(VMContext)), llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), OpID), - llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), + llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), cast(opTy)->getBitWidth())); handlerResult = Builder.CreateTrunc(handlerResult, opTy); Builder.CreateBr(continueBB); - + // Set up the continuation Builder.SetInsertPoint(continueBB); // Get the correct result @@ -1070,7 +1069,7 @@ if (CGF.getContext().getLangOptions().OverflowChecking && Ops.Ty->isSignedIntegerType()) return EmitOverflowCheckedBinOp(Ops); - + if (Ops.LHS->getType()->isFPOrFPVector()) return Builder.CreateFAdd(Ops.LHS, Ops.RHS, "add"); @@ -1089,7 +1088,7 @@ Value *Ptr, *Idx; Expr *IdxExp; const PointerType *PT = Ops.E->getLHS()->getType()->getAs(); - const ObjCObjectPointerType *OPT = + const ObjCObjectPointerType *OPT = Ops.E->getLHS()->getType()->getAsObjCObjectPointerType(); if (PT || OPT) { Ptr = Ops.LHS; @@ -1116,10 +1115,9 @@ Idx = Builder.CreateZExt(Idx, IdxType, "idx.ext"); } const QualType ElementType = PT ? PT->getPointeeType() : OPT->getPointeeType(); - // Handle interface types, which are not represented with a concrete - // type. + // Handle interface types, which are not represented with a concrete type. if (const ObjCInterfaceType *OIT = dyn_cast(ElementType)) { - llvm::Value *InterfaceSize = + llvm::Value *InterfaceSize = llvm::ConstantInt::get(Idx->getType(), CGF.getContext().getTypeSize(OIT) / 8); Idx = Builder.CreateMul(Idx, InterfaceSize); @@ -1128,19 +1126,19 @@ Value *Casted = Builder.CreateBitCast(Ptr, i8Ty); Value *Res = Builder.CreateGEP(Casted, Idx, "add.ptr"); return Builder.CreateBitCast(Res, Ptr->getType()); - } + } - // Explicitly handle GNU void* and function pointer arithmetic - // extensions. The GNU void* casts amount to no-ops since our void* - // type is i8*, but this is future proof. + // Explicitly handle GNU void* and function pointer arithmetic extensions. The + // GNU void* casts amount to no-ops since our void* type is i8*, but this is + // future proof. if (ElementType->isVoidType() || ElementType->isFunctionType()) { const llvm::Type *i8Ty = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext)); Value *Casted = Builder.CreateBitCast(Ptr, i8Ty); Value *Res = Builder.CreateGEP(Casted, Idx, "add.ptr"); return Builder.CreateBitCast(Res, Ptr->getType()); - } - + } + return Builder.CreateInBoundsGEP(Ptr, Idx, "add.ptr"); } @@ -1182,38 +1180,37 @@ } Idx = Builder.CreateNeg(Idx, "sub.ptr.neg"); - // Handle interface types, which are not represented with a concrete - // type. - if (const ObjCInterfaceType *OIT = + // Handle interface types, which are not represented with a concrete type. + if (const ObjCInterfaceType *OIT = dyn_cast(LHSElementType)) { - llvm::Value *InterfaceSize = + llvm::Value *InterfaceSize = llvm::ConstantInt::get(Idx->getType(), CGF.getContext().getTypeSize(OIT) / 8); Idx = Builder.CreateMul(Idx, InterfaceSize); - const llvm::Type *i8Ty = + const llvm::Type *i8Ty = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext)); Value *LHSCasted = Builder.CreateBitCast(Ops.LHS, i8Ty); Value *Res = Builder.CreateGEP(LHSCasted, Idx, "add.ptr"); return Builder.CreateBitCast(Res, Ops.LHS->getType()); - } + } // Explicitly handle GNU void* and function pointer arithmetic - // extensions. The GNU void* casts amount to no-ops since our - // void* type is i8*, but this is future proof. + // extensions. The GNU void* casts amount to no-ops since our void* type is + // i8*, but this is future proof. if (LHSElementType->isVoidType() || LHSElementType->isFunctionType()) { const llvm::Type *i8Ty = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext)); Value *LHSCasted = Builder.CreateBitCast(Ops.LHS, i8Ty); Value *Res = Builder.CreateGEP(LHSCasted, Idx, "sub.ptr"); return Builder.CreateBitCast(Res, Ops.LHS->getType()); - } - + } + return Builder.CreateInBoundsGEP(Ops.LHS, Idx, "sub.ptr"); } else { // pointer - pointer Value *LHS = Ops.LHS; Value *RHS = Ops.RHS; - + uint64_t ElementSize; // Handle GCC extension for pointer arithmetic on void* and function pointer @@ -1223,19 +1220,19 @@ } else { ElementSize = CGF.getContext().getTypeSize(LHSElementType) / 8; } - + const llvm::Type *ResultType = ConvertType(Ops.Ty); LHS = Builder.CreatePtrToInt(LHS, ResultType, "sub.ptr.lhs.cast"); RHS = Builder.CreatePtrToInt(RHS, ResultType, "sub.ptr.rhs.cast"); Value *BytesBetween = Builder.CreateSub(LHS, RHS, "sub.ptr.sub"); - + // Optimize out the shift for element size of 1. if (ElementSize == 1) return BytesBetween; // Otherwise, do a full sdiv. This uses the "exact" form of sdiv, since - // pointer difference in C is only defined in the case where both - // operands are pointing to elements of an array. + // pointer difference in C is only defined in the case where both operands + // are pointing to elements of an array. Value *BytesPerElt = llvm::ConstantInt::get(ResultType, ElementSize); return Builder.CreateExactSDiv(BytesBetween, BytesPerElt, "sub.ptr.div"); } @@ -1247,7 +1244,7 @@ Value *RHS = Ops.RHS; if (Ops.LHS->getType() != RHS->getType()) RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom"); - + return Builder.CreateShl(Ops.LHS, RHS, "shl"); } @@ -1257,7 +1254,7 @@ Value *RHS = Ops.RHS; if (Ops.LHS->getType() != RHS->getType()) RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom"); - + if (Ops.Ty->isUnsignedIntegerType()) return Builder.CreateLShr(Ops.LHS, RHS, "shr"); return Builder.CreateAShr(Ops.LHS, RHS, "shr"); @@ -1271,7 +1268,7 @@ if (!LHSTy->isAnyComplexType()) { Value *LHS = Visit(E->getLHS()); Value *RHS = Visit(E->getRHS()); - + if (LHS->getType()->isFPOrFPVector()) { Result = Builder.CreateFCmp((llvm::CmpInst::Predicate)FCmpOpc, LHS, RHS, "cmp"); @@ -1288,14 +1285,14 @@ // vector integer type and return it (don't convert to bool). if (LHSTy->isVectorType()) return Builder.CreateSExt(Result, ConvertType(E->getType()), "sext"); - + } else { // Complex Comparison: can only be an equality comparison. CodeGenFunction::ComplexPairTy LHS = CGF.EmitComplexExpr(E->getLHS()); CodeGenFunction::ComplexPairTy RHS = CGF.EmitComplexExpr(E->getRHS()); - + QualType CETy = LHSTy->getAsComplexType()->getElementType(); - + Value *ResultR, *ResultI; if (CETy->isRealFloatingType()) { ResultR = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc, @@ -1310,7 +1307,7 @@ ResultI = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc, LHS.second, RHS.second, "cmp.i"); } - + if (E->getOpcode() == BinaryOperator::EQ) { Result = Builder.CreateAnd(ResultR, ResultI, "and.ri"); } else { @@ -1330,7 +1327,7 @@ // improve codegen just a little. Value *RHS = Visit(E->getRHS()); LValue LHS = EmitLValue(E->getLHS()); - + // Store the value into the LHS. Bit-fields are handled specially // because the result is altered by the store, i.e., [C99 6.5.16p1] // 'An assignment expression has the value of the left operand after @@ -1358,12 +1355,12 @@ // ZExt result to int. return Builder.CreateZExt(RHSCond, CGF.LLVMIntTy, "land.ext"); } - + // 0 && RHS: If it is safe, just elide the RHS, and return 0. if (!CGF.ContainsLabel(E->getRHS())) return llvm::Constant::getNullValue(CGF.LLVMIntTy); } - + llvm::BasicBlock *ContBlock = CGF.createBasicBlock("land.end"); llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("land.rhs"); @@ -1379,12 +1376,12 @@ for (llvm::pred_iterator PI = pred_begin(ContBlock), PE = pred_end(ContBlock); PI != PE; ++PI) PN->addIncoming(llvm::ConstantInt::getFalse(VMContext), *PI); - + CGF.PushConditionalTempDestruction(); CGF.EmitBlock(RHSBlock); Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); CGF.PopConditionalTempDestruction(); - + // Reaquire the RHS block, as there may be subblocks inserted. RHSBlock = Builder.GetInsertBlock(); @@ -1392,7 +1389,7 @@ // into the phi node for the edge with the value of RHSCond. CGF.EmitBlock(ContBlock); PN->addIncoming(RHSCond, RHSBlock); - + // ZExt result to int. return Builder.CreateZExt(PN, CGF.LLVMIntTy, "land.ext"); } @@ -1406,15 +1403,15 @@ // ZExt result to int. return Builder.CreateZExt(RHSCond, CGF.LLVMIntTy, "lor.ext"); } - + // 1 || RHS: If it is safe, just elide the RHS, and return 1. if (!CGF.ContainsLabel(E->getRHS())) return llvm::ConstantInt::get(CGF.LLVMIntTy, 1); } - + llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor.end"); llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("lor.rhs"); - + // Branch on the LHS first. If it is true, go to the success (cont) block. CGF.EmitBranchOnBoolExpr(E->getLHS(), ContBlock, RHSBlock); @@ -1433,17 +1430,17 @@ // Emit the RHS condition as a bool value. CGF.EmitBlock(RHSBlock); Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); - + CGF.PopConditionalTempDestruction(); - + // Reaquire the RHS block, as there may be subblocks inserted. RHSBlock = Builder.GetInsertBlock(); - + // Emit an unconditional branch from this block to ContBlock. Insert an entry // into the phi node for the edge with the value of RHSCond. CGF.EmitBlock(ContBlock); PN->addIncoming(RHSCond, RHSBlock); - + // ZExt result to int. return Builder.CreateZExt(PN, CGF.LLVMIntTy, "lor.ext"); } @@ -1465,19 +1462,19 @@ static bool isCheapEnoughToEvaluateUnconditionally(const Expr *E) { if (const ParenExpr *PE = dyn_cast(E)) return isCheapEnoughToEvaluateUnconditionally(PE->getSubExpr()); - + // TODO: Allow anything we can constant fold to an integer or fp constant. if (isa(E) || isa(E) || isa(E)) return true; - + // Non-volatile automatic variables too, to get "cond ? X : Y" where // X and Y are local variables. if (const DeclRefExpr *DRE = dyn_cast(E)) if (const VarDecl *VD = dyn_cast(DRE->getDecl())) if (VD->hasLocalStorage() && !VD->getType().isVolatileQualified()) return true; - + return false; } @@ -1491,7 +1488,7 @@ Expr *Live = E->getLHS(), *Dead = E->getRHS(); if (Cond == -1) std::swap(Live, Dead); - + // If the dead side doesn't have labels we need, and if the Live side isn't // the gnu missing ?: extension (which we could handle, but don't bother // to), just emit the Live part. @@ -1499,8 +1496,8 @@ Live) // Live part isn't missing. return Visit(Live); } - - + + // If this is a really simple expression (like x ? 4 : 5), emit this as a // select instead of as control flow. We can only do this if it is cheap and // safe to evaluate the LHS and RHS unconditionally. @@ -1511,15 +1508,15 @@ llvm::Value *RHS = Visit(E->getRHS()); return Builder.CreateSelect(CondV, LHS, RHS, "cond"); } - - + + llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.true"); llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.false"); llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.end"); Value *CondVal = 0; - // If we don't have the GNU missing condition extension, emit a branch on - // bool the normal way. + // If we don't have the GNU missing condition extension, emit a branch on bool + // the normal way. if (E->getLHS()) { // Otherwise, just use EmitBranchOnBoolExpr to get small and simple code for // the branch on bool. @@ -1529,7 +1526,7 @@ // convert it to bool the hard way. We do this explicitly because we need // the unconverted value for the missing middle value of the ?:. CondVal = CGF.EmitScalarExpr(E->getCond()); - + // In some cases, EmitScalarConversion will delete the "CondVal" expression // if there are no extra uses (an optimization). Inhibit this by making an // extra dead use, because we're going to add a use of CondVal later. We @@ -1537,7 +1534,7 @@ // away. This leaves dead code, but the ?: extension isn't common. new llvm::BitCastInst(CondVal, CondVal->getType(), "dummy?:holder", Builder.GetInsertBlock()); - + Value *CondBoolVal = CGF.EmitScalarConversion(CondVal, E->getCond()->getType(), CGF.getContext().BoolTy); @@ -1546,33 +1543,33 @@ CGF.PushConditionalTempDestruction(); CGF.EmitBlock(LHSBlock); - + // Handle the GNU extension for missing LHS. Value *LHS; if (E->getLHS()) LHS = Visit(E->getLHS()); else // Perform promotions, to handle cases like "short ?: int" LHS = EmitScalarConversion(CondVal, E->getCond()->getType(), E->getType()); - + CGF.PopConditionalTempDestruction(); LHSBlock = Builder.GetInsertBlock(); CGF.EmitBranch(ContBlock); - + CGF.PushConditionalTempDestruction(); CGF.EmitBlock(RHSBlock); - + Value *RHS = Visit(E->getRHS()); CGF.PopConditionalTempDestruction(); RHSBlock = Builder.GetInsertBlock(); CGF.EmitBranch(ContBlock); - + CGF.EmitBlock(ContBlock); - + if (!LHS || !RHS) { assert(E->getType()->isVoidType() && "Non-void value should have a value"); return 0; } - + // Create a PHI node for the real part. llvm::PHINode *PN = Builder.CreatePHI(LHS->getType(), "cond"); PN->reserveOperandSpace(2); @@ -1590,7 +1587,7 @@ llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, VE->getType()); // If EmitVAArg fails, we fall back to the LLVM instruction. - if (!ArgPtr) + if (!ArgPtr) return Builder.CreateVAArg(ArgValue, ConvertType(VE->getType())); // FIXME Volatility. @@ -1605,12 +1602,12 @@ // Entry Point into this File //===----------------------------------------------------------------------===// -/// EmitScalarExpr - Emit the computation of the specified expression of -/// scalar type, ignoring the result. +/// EmitScalarExpr - Emit the computation of the specified expression of scalar +/// type, ignoring the result. Value *CodeGenFunction::EmitScalarExpr(const Expr *E, bool IgnoreResultAssign) { assert(E && !hasAggregateLLVMType(E->getType()) && "Invalid scalar expression to emit"); - + return ScalarExprEmitter(*this, IgnoreResultAssign) .Visit(const_cast(E)); } @@ -1624,9 +1621,9 @@ return ScalarExprEmitter(*this).EmitScalarConversion(Src, SrcTy, DstTy); } -/// EmitComplexToScalarConversion - Emit a conversion from the specified -/// complex type to the specified destination type, where the destination -/// type is an LLVM scalar type. +/// EmitComplexToScalarConversion - Emit a conversion from the specified complex +/// type to the specified destination type, where the destination type is an +/// LLVM scalar type. Value *CodeGenFunction::EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy, QualType DstTy) { @@ -1639,40 +1636,40 @@ Value *CodeGenFunction::EmitShuffleVector(Value* V1, Value *V2, ...) { assert(V1->getType() == V2->getType() && "Vector operands must be of the same type"); - unsigned NumElements = + unsigned NumElements = cast(V1->getType())->getNumElements(); - + va_list va; va_start(va, V2); - + llvm::SmallVector Args; for (unsigned i = 0; i < NumElements; i++) { int n = va_arg(va, int); - assert(n >= 0 && n < (int)NumElements * 2 && + assert(n >= 0 && n < (int)NumElements * 2 && "Vector shuffle index out of bounds!"); Args.push_back(llvm::ConstantInt::get( llvm::Type::getInt32Ty(VMContext), n)); } - + const char *Name = va_arg(va, const char *); va_end(va); - + llvm::Constant *Mask = llvm::ConstantVector::get(&Args[0], NumElements); - + return Builder.CreateShuffleVector(V1, V2, Mask, Name); } -llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals, +llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals, unsigned NumVals, bool isSplat) { llvm::Value *Vec = llvm::UndefValue::get(llvm::VectorType::get(Vals[0]->getType(), NumVals)); - + for (unsigned i = 0, e = NumVals; i != e; ++i) { llvm::Value *Val = isSplat ? Vals[0] : Vals[i]; llvm::Value *Idx = llvm::ConstantInt::get( llvm::Type::getInt32Ty(VMContext), i); Vec = Builder.CreateInsertElement(Vec, Val, Idx, "tmp"); } - - return Vec; + + return Vec; } From mrs at apple.com Wed Sep 9 08:12:02 2009 From: mrs at apple.com (Mike Stump) Date: Wed, 09 Sep 2009 13:12:02 -0000 Subject: [cfe-commits] r81340 - in /cfe/trunk/include/clang: Basic/ConvertUTF.h Driver/HostInfo.h Lex/PreprocessorLexer.h Parse/Ownership.h Message-ID: <200909091312.n89DC208024481@zion.cs.uiuc.edu> Author: mrs Date: Wed Sep 9 08:12:01 2009 New Revision: 81340 URL: http://llvm.org/viewvc/llvm-project?rev=81340&view=rev Log: Remove tab characters. Modified: cfe/trunk/include/clang/Basic/ConvertUTF.h cfe/trunk/include/clang/Driver/HostInfo.h cfe/trunk/include/clang/Lex/PreprocessorLexer.h cfe/trunk/include/clang/Parse/Ownership.h Modified: cfe/trunk/include/clang/Basic/ConvertUTF.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ConvertUTF.h?rev=81340&r1=81339&r2=81340&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/ConvertUTF.h (original) +++ cfe/trunk/include/clang/Basic/ConvertUTF.h Wed Sep 9 08:12:01 2009 @@ -53,12 +53,12 @@ the respective buffers. Input parameters: - sourceStart - pointer to a pointer to the source buffer. - The contents of this are modified on return so that - it points at the next thing to be converted. - targetStart - similarly, pointer to pointer to the target buffer. - sourceEnd, targetEnd - respectively pointers to the ends of the - two buffers, for overflow checking only. + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. These conversion functions take a ConversionFlags argument. When this flag is set to strict, both irregular sequences and isolated surrogates @@ -75,15 +75,15 @@ they constitute an error. Output parameters: - The value "sourceIllegal" is returned from some routines if the input - sequence is malformed. When "sourceIllegal" is returned, the source - value will point to the illegal value that caused the problem. E.g., - in UTF-8 when a sequence is malformed, it points to the start of the - malformed sequence. + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. Author: Mark E. Davis, 1994. Rev History: Rick McGowan, fixes & updates May 2001. - Fixes & updates, Sept 2001. + Fixes & updates, Sept 2001. ------------------------------------------------------------------------ */ @@ -95,10 +95,10 @@ bit mask & shift operations. ------------------------------------------------------------------------ */ -typedef unsigned long UTF32; /* at least 32 bits */ -typedef unsigned short UTF16; /* at least 16 bits */ -typedef unsigned char UTF8; /* typically 8 bits */ -typedef unsigned char Boolean; /* 0 or 1 */ +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ /* Some fundamental constants */ #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD @@ -108,15 +108,15 @@ #define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF typedef enum { - conversionOK, /* conversion successful */ - sourceExhausted, /* partial character in source, but hit end */ - targetExhausted, /* insuff. room in target for conversion */ - sourceIllegal /* source sequence is illegal/malformed */ + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ } ConversionResult; typedef enum { - strictConversion = 0, - lenientConversion + strictConversion = 0, + lenientConversion } ConversionFlags; /* This is for C++ and does no harm in C */ @@ -125,29 +125,29 @@ #endif ConversionResult ConvertUTF8toUTF16 ( - const UTF8** sourceStart, const UTF8* sourceEnd, - UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); #ifdef CLANG_NEEDS_THESE_ONE_DAY ConversionResult ConvertUTF16toUTF8 ( - const UTF16** sourceStart, const UTF16* sourceEnd, - UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); - + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + ConversionResult ConvertUTF8toUTF32 ( - const UTF8** sourceStart, const UTF8* sourceEnd, - UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); ConversionResult ConvertUTF32toUTF8 ( - const UTF32** sourceStart, const UTF32* sourceEnd, - UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); - + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + ConversionResult ConvertUTF16toUTF32 ( - const UTF16** sourceStart, const UTF16* sourceEnd, - UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); ConversionResult ConvertUTF32toUTF16 ( - const UTF32** sourceStart, const UTF32* sourceEnd, - UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); #endif Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); Modified: cfe/trunk/include/clang/Driver/HostInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/HostInfo.h?rev=81340&r1=81339&r2=81340&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/HostInfo.h (original) +++ cfe/trunk/include/clang/Driver/HostInfo.h Wed Sep 9 08:12:01 2009 @@ -69,7 +69,7 @@ }; const HostInfo *createAuroraUXHostInfo(const Driver &D, - const llvm::Triple& Triple); + const llvm::Triple& Triple); const HostInfo *createDarwinHostInfo(const Driver &D, const llvm::Triple& Triple); const HostInfo *createOpenBSDHostInfo(const Driver &D, Modified: cfe/trunk/include/clang/Lex/PreprocessorLexer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorLexer.h?rev=81340&r1=81339&r2=81340&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/PreprocessorLexer.h (original) +++ cfe/trunk/include/clang/Lex/PreprocessorLexer.h Wed Sep 9 08:12:01 2009 @@ -18,7 +18,7 @@ #include "clang/Lex/Token.h" #include "llvm/ADT/SmallVector.h" #include - + namespace clang { class Preprocessor; Modified: cfe/trunk/include/clang/Parse/Ownership.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Ownership.h?rev=81340&r1=81339&r2=81340&view=diff ============================================================================== --- cfe/trunk/include/clang/Parse/Ownership.h (original) +++ cfe/trunk/include/clang/Parse/Ownership.h Wed Sep 9 08:12:01 2009 @@ -584,7 +584,7 @@ // Either way, a classic C-style hard cast resolves any issue. static ASTMultiPtr* hack(moving::ASTMultiMover & source) { return (ASTMultiPtr*)source.operator->(); - } + } #endif ASTMultiPtr(ASTMultiPtr&); // DO NOT IMPLEMENT From mrs at apple.com Wed Sep 9 10:08:16 2009 From: mrs at apple.com (Mike Stump) Date: Wed, 09 Sep 2009 15:08:16 -0000 Subject: [cfe-commits] r81346 [6/6] - in /cfe/trunk: include/clang/AST/ include/clang/Analysis/ include/clang/Analysis/Analyses/ include/clang/Analysis/FlowSensitive/ include/clang/Analysis/PathSensitive/ include/clang/Analysis/Support/ include/clang/Analysis/Visitors/ include/clang/Basic/ include/clang/CodeGen/ include/clang/Driver/ include/clang/Frontend/ include/clang/Index/ include/clang/Lex/ include/clang/Parse/ include/clang/Rewrite/ include/clang/Sema/ lib/AST/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Front... Message-ID: <200909091508.n89F8fco008190@zion.cs.uiuc.edu> Modified: cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp (original) +++ cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp Wed Sep 9 10:08:12 2009 @@ -7,9 +7,9 @@ struct C { - C() : iC(6) {printf("C()\n"); } - C(const C& c) { printf("C(const C& c)\n"); } - int iC; + C() : iC(6) {printf("C()\n"); } + C(const C& c) { printf("C(const C& c)\n"); } + int iC; }; C foo() { @@ -18,10 +18,10 @@ class X { // ... public: - X(int) {} - X(const X&, int i = 1, int j = 2, C c = foo()) { - printf("X(const X&, %d, %d, %d)\n", i, j, c.iC); - } + X(int) {} + X(const X&, int i = 1, int j = 2, C c = foo()) { + printf("X(const X&, %d, %d, %d)\n", i, j, c.iC); + } }; @@ -33,12 +33,11 @@ void Call(S) {}; -int main() -{ - X a(1); - X b(a, 2); - X c = b; - X d(a, 5, 6); - S s; - Call(s); +int main() { + X a(1); + X b(a, 2); + X c = b; + X d(a, 5, 6); + S s; + Call(s); } Modified: cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis.cpp (original) +++ cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis.cpp Wed Sep 9 10:08:12 2009 @@ -26,35 +26,36 @@ struct X : M, N, P { // ... - X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd), - au_i1(1234), au1_4("MASKED") {} - P p0; - void pr() { printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM); - printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP); - printf("f1 = %f d1 = %f i1 = %d name(%s) \n", f1, d1, i1, name); - printf("bf1 = %x bf2 = %x\n", bf1, bf2); - printf("au_i2 = %d\n", au_i2); - printf("au1_1 = %s\n", au1_1); - } - M m1; - P p1; - float f1; - double d1; - int i1; - const char *name; - unsigned bf1 : 8; - unsigned bf2 : 16; - - union { - int au_i1; - int au_i2; - }; - union { - const char * au1_1; - float au1_2; - int au1_3; - const char * au1_4; - }; + X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd), + au_i1(1234), au1_4("MASKED") {} + P p0; + void pr() { + printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM); + printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP); + printf("f1 = %f d1 = %f i1 = %d name(%s) \n", f1, d1, i1, name); + printf("bf1 = %x bf2 = %x\n", bf1, bf2); + printf("au_i2 = %d\n", au_i2); + printf("au1_1 = %s\n", au1_1); + } + M m1; + P p1; + float f1; + double d1; + int i1; + const char *name; + unsigned bf1 : 8; + unsigned bf2 : 16; + + union { + int au_i1; + int au_i2; + }; + union { + const char * au1_1; + float au1_2; + int au1_3; + const char * au1_4; + }; }; static int ix = 1; @@ -87,19 +88,19 @@ I ARR_I[3][2]; }; -int main() -{ - X a; - X b(a); - b.pr(); - X x; - X c(x); - c.pr(); - - XM m0; - XM m1 = m0; - m1.pr(); +int main() { + X a; + X b(a); + b.pr(); + X x; + X c(x); + c.pr(); + + XM m0; + XM m1 = m0; + m1.pr(); } + // CHECK-LP64: .globl __ZN1XC1ERK1X // CHECK-LP64: .weak_definition __ZN1XC1ERK1X // CHECK-LP64: __ZN1XC1ERK1X: Modified: cfe/trunk/test/CodeGenCXX/default-constructor-for-members.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/default-constructor-for-members.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/default-constructor-for-members.cpp (original) +++ cfe/trunk/test/CodeGenCXX/default-constructor-for-members.cpp Wed Sep 9 10:08:12 2009 @@ -19,6 +19,6 @@ M m1; } -// CHECK-LP64: call __ZN1SC1Ev +// CHECK-LP64: call __ZN1SC1Ev -// CHECK-LP32: call L__ZN1SC1Ev +// CHECK-LP32: call L__ZN1SC1Ev Modified: cfe/trunk/test/CodeGenCXX/default-destructor-synthesis.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/default-destructor-synthesis.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/default-destructor-synthesis.cpp (original) +++ cfe/trunk/test/CodeGenCXX/default-destructor-synthesis.cpp Wed Sep 9 10:08:12 2009 @@ -46,15 +46,15 @@ int main() {M m1;} -// CHECK-LP64: call __ZN1MC1Ev -// CHECK-LP64: call __ZN1MD1Ev -// CHECK-LP64: .globl __ZN1MD1Ev -// CHECK-LP64-NEXT: .weak_definition __ZN1MD1Ev -// CHECK-LP64-NEXT: __ZN1MD1Ev: +// CHECK-LP64: call __ZN1MC1Ev +// CHECK-LP64: call __ZN1MD1Ev +// CHECK-LP64: .globl __ZN1MD1Ev +// CHECK-LP64-NEXT: .weak_definition __ZN1MD1Ev +// CHECK-LP64-NEXT: __ZN1MD1Ev: -// CHECK-LP32: call L__ZN1MC1Ev -// CHECK-LP32: call L__ZN1MD1Ev -// CHECK-LP32: .globl __ZN1MD1Ev -// CHECK-LP32-NEXT: .weak_definition __ZN1MD1Ev -// CHECK-LP32-NEXT: __ZN1MD1Ev: +// CHECK-LP32: call L__ZN1MC1Ev +// CHECK-LP32: call L__ZN1MD1Ev +// CHECK-LP32: .globl __ZN1MD1Ev +// CHECK-LP32-NEXT: .weak_definition __ZN1MD1Ev +// CHECK-LP32-NEXT:__ZN1MD1Ev: Modified: cfe/trunk/test/CodeGenCXX/nested-base-member-access.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/nested-base-member-access.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/nested-base-member-access.cpp (original) +++ cfe/trunk/test/CodeGenCXX/nested-base-member-access.cpp Wed Sep 9 10:08:12 2009 @@ -35,14 +35,15 @@ struct N : M,P { N() : M(100), P(200) {} - void PR() { this->MPR(); this->PPR(); this->QPR(); - IQPR(); - printf("iM = %d\n", iM); - printf("iP = %d\n", iP); - printf("iQ = %d\n", iQ); - printf("iL = %d\n", iL); - printf("iIQ = %d\n", iIQ); - } + void PR() { + this->MPR(); this->PPR(); this->QPR(); + IQPR(); + printf("iM = %d\n", iM); + printf("iP = %d\n", iP); + printf("iQ = %d\n", iQ); + printf("iL = %d\n", iL); + printf("iIQ = %d\n", iIQ); + } }; int main() { Modified: cfe/trunk/test/CodeGenCXX/virt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/virt.cpp (original) +++ cfe/trunk/test/CodeGenCXX/virt.cpp Wed Sep 9 10:08:12 2009 @@ -308,7 +308,7 @@ // CHECK-LP32-NEXT: .space 4 // CHECK-LP32: .long 8 // CHECK-LP32 .space 4 -// CHECK-LP32 .space 4 FIXME +// CHECK-LP32 .space 4 FIXME // CHECK-LP32: .long 4 // CHECK-LP32-NEXT: .space 4 // CHECK-LP32-NEXT: .space 4 Modified: cfe/trunk/test/Lexer/comment-escape.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/comment-escape.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Lexer/comment-escape.c (original) +++ cfe/trunk/test/Lexer/comment-escape.c Wed Sep 9 10:08:12 2009 @@ -2,5 +2,5 @@ // rdar://6757323 // foo \ -#define blork 32 +#define blork 32 Modified: cfe/trunk/test/Parser/MicrosoftExtensions.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Parser/MicrosoftExtensions.c (original) +++ cfe/trunk/test/Parser/MicrosoftExtensions.c Wed Sep 9 10:08:12 2009 @@ -9,22 +9,22 @@ typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; void * __ptr64 PtrToPtr64(const void *p) { - return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p ); + return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p ); } void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) { - __asm { - mov eax, Bit - mov ecx, Base - lock bts [ecx], eax - setc al - }; + __asm { + mov eax, Bit + mov ecx, Base + lock bts [ecx], eax + setc al + }; } void *_alloca(int); void foo() { - __declspec(align(16)) int *buffer = (int *)_alloca(9); + __declspec(align(16)) int *buffer = (int *)_alloca(9); } typedef bool (__stdcall __stdcall *blarg)(int); Modified: cfe/trunk/test/Parser/cxx-friend.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-friend.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Parser/cxx-friend.cpp (original) +++ cfe/trunk/test/Parser/cxx-friend.cpp Wed Sep 9 10:08:12 2009 @@ -6,7 +6,7 @@ class A { public: - void f(); + void f(); }; friend int x; // expected-error {{'friend' used outside of class}} Modified: cfe/trunk/test/Parser/cxx-template-decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-template-decl.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Parser/cxx-template-decl.cpp (original) +++ cfe/trunk/test/Parser/cxx-template-decl.cpp Wed Sep 9 10:08:12 2009 @@ -50,7 +50,7 @@ // Template parameter shadowing template // expected-error{{declaration of 'T' shadows template parameter}} + typename T> // expected-error{{declaration of 'T' shadows template parameter}} void shadow1(); template // expected-note{{template parameter is declared here}} Modified: cfe/trunk/test/Preprocessor/assembler-with-cpp.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/assembler-with-cpp.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/assembler-with-cpp.c (original) +++ cfe/trunk/test/Preprocessor/assembler-with-cpp.c Wed Sep 9 10:08:12 2009 @@ -40,7 +40,7 @@ // rdar://6709206 // RUN: grep "5: expanded (" %t && #define M4 expanded -#define M5() M4 ## ( +#define M5() M4 ## ( 5: M5() Modified: cfe/trunk/test/Sema/array-init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/array-init.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/array-init.c (original) +++ cfe/trunk/test/Sema/array-init.c Wed Sep 9 10:08:12 2009 @@ -144,12 +144,11 @@ static char const yy[5] = "test"; static char const zz[3] = "test"; // expected-warning{{initializer-string for char array is too long}} -void charArrays() -{ - static char const test[] = "test"; - int test_sizecheck[(sizeof(test) / sizeof(char)) == 5? 1 : -1]; - static char const test2[] = { "weird stuff" }; - static char const test3[] = { "test", "excess stuff" }; // expected-warning{{excess elements in char array initializer}} +void charArrays() { + static char const test[] = "test"; + int test_sizecheck[(sizeof(test) / sizeof(char)) == 5? 1 : -1]; + static char const test2[] = { "weird stuff" }; + static char const test3[] = { "test", "excess stuff" }; // expected-warning{{excess elements in char array initializer}} char* cp[] = { "Hello" }; @@ -230,15 +229,15 @@ // ptrs are constant struct soft_segment_descriptor { - long ssd_base; + long ssd_base; }; static int dblfault_tss; union uniao { int ola; } xpto[1]; struct soft_segment_descriptor gdt_segs[] = { - {(long) &dblfault_tss}, - { (long)xpto}, + {(long) &dblfault_tss}, + { (long)xpto}, }; static void sppp_ipv6cp_up(); Modified: cfe/trunk/test/Sema/attr-deprecated.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/attr-deprecated.c (original) +++ cfe/trunk/test/Sema/attr-deprecated.c Wed Sep 9 10:08:12 2009 @@ -21,7 +21,7 @@ // test if attributes propagate to variables extern int var; int w() { - return var; // expected-warning {{'var' is deprecated}} + return var; // expected-warning {{'var' is deprecated}} } int old_fn() __attribute__ ((deprecated)); Modified: cfe/trunk/test/Sema/block-call.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-call.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-call.c (original) +++ cfe/trunk/test/Sema/block-call.c Wed Sep 9 10:08:12 2009 @@ -5,51 +5,47 @@ int (^II) (int); int main() { int (*FPL) (int) = FP; // C doesn't consider this an error. - + // For Blocks, the ASTContext::typesAreBlockCompatible() makes sure this is an error. int (^PFR) (int) = IFP; // OK - PFR = II; // OK - - int (^IFP) () = PFR; // OK - + PFR = II; // OK - const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}} + int (^IFP) () = PFR; // OK - const int (^CICC) () = CIC; + const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}} - int * const (^IPCC) () = 0; + const int (^CICC) () = CIC; - int * const (^IPCC1) () = IPCC; + int * const (^IPCC) () = 0; - int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}} + int * const (^IPCC1) () = IPCC; - int (^IPCC3) (const int) = PFR; + int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}} + int (^IPCC3) (const int) = PFR; - int (^IPCC4) (int, char (^CArg) (double)); + int (^IPCC4) (int, char (^CArg) (double)); + int (^IPCC5) (int, char (^CArg) (double)) = IPCC4; - int (^IPCC5) (int, char (^CArg) (double)) = IPCC4; + int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}} - int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}} - - IPCC2 = 0; - IPCC2 = 1; // expected-error {{invalid conversion assigning integer 'int', expected block pointer 'int *(^)()'}} - int (^x)() = 0; - int (^y)() = 3; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}} - int a = 1; - int (^z)() = a+4; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}} + IPCC2 = 0; + IPCC2 = 1; // expected-error {{invalid conversion assigning integer 'int', expected block pointer 'int *(^)()'}} + int (^x)() = 0; + int (^y)() = 3; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}} + int a = 1; + int (^z)() = a+4; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}} } int blah() { - int (^IFP) (float); - char (^PCP)(double, double, char); + int (^IFP) (float); + char (^PCP)(double, double, char); - IFP(1.0); - IFP (1.0, 2.0); // expected-error {{too many arguments to block call}} + IFP(1.0); + IFP (1.0, 2.0); // expected-error {{too many arguments to block call}} - char ch = PCP(1.0, 2.0, 'a'); - return PCP(1.0, 2.0); // expected-error {{too few arguments to block}} + char ch = PCP(1.0, 2.0, 'a'); + return PCP(1.0, 2.0); // expected-error {{too few arguments to block}} } - Modified: cfe/trunk/test/Sema/block-explicit-return-type.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-explicit-return-type.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-explicit-return-type.c (original) +++ cfe/trunk/test/Sema/block-explicit-return-type.c Wed Sep 9 10:08:12 2009 @@ -19,42 +19,39 @@ typedef double (^myblock)(int); double test(myblock I); -int main() -{ - __block int x = 1; - __block int y = 2; - - (void)^void *{ return 0; }; - - (void)^float(float y){ return y; }; - - (void)^double (float y, double d) - { - if (y) - return d; - else - return y; - }; - - const char * (^chb) (int flag, const char *arg, char *arg1) = ^ const char * (int flag, const char *arg, char *arg1) { - if (flag) - return 0; - if (flag == 1) - return arg; - else if (flag == 2) - return ""; - return arg1; - }; +int main() { + __block int x = 1; + __block int y = 2; + + (void)^void *{ return 0; }; + + (void)^float(float y){ return y; }; + + (void)^double (float y, double d) { + if (y) + return d; + else + return y; + }; + + const char * (^chb) (int flag, const char *arg, char *arg1) = ^ const char * (int flag, const char *arg, char *arg1) { + if (flag) + return 0; + if (flag == 1) + return arg; + else if (flag == 2) + return ""; + return arg1; + }; - (void)^PF { return &gf; }; + (void)^PF { return &gf; }; - some_func(^ NSView * (id whatever) { return [some_object some_method_that_returns_id]; }); + some_func(^ NSView * (id whatever) { return [some_object some_method_that_returns_id]; }); - double res = test(^(int z){x = y+z; return (double)z; }); + double res = test(^(int z){x = y+z; return (double)z; }); } -void func() -{ +void func() { completion_block_t X; completion_block_t (^blockx)(dispatch_item_t) = ^completion_block_t (dispatch_item_t item) { @@ -66,7 +63,6 @@ }; blockx = blocky; - } Modified: cfe/trunk/test/Sema/block-literal.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-literal.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-literal.c (original) +++ cfe/trunk/test/Sema/block-literal.c Wed Sep 9 10:08:12 2009 @@ -12,34 +12,34 @@ int takeintint(int (^C)(int)) { return C(4); } T somefunction() { - if (^{ }) - nothing(); + if (^{ }) + nothing(); - noop = ^{}; + noop = ^{}; - noop = ^{printf("\nClosure\n"); }; + noop = ^{printf("\nClosure\n"); }; - I(^{ }); + I(^{ }); - return ^{printf("\nClosure\n"); }; + return ^{printf("\nClosure\n"); }; } void test2() { - int x = 4; + int x = 4; - takeblock(^{ printf("%d\n", x); }); + takeblock(^{ printf("%d\n", x); }); while (1) { - takeblock(^{ - break; // expected-error {{'break' statement not in loop or switch statement}} - continue; // expected-error {{'continue' statement not in loop statement}} - while(1) break; // ok - goto foo; // expected-error {{goto not allowed}} - }); + takeblock(^{ + break; // expected-error {{'break' statement not in loop or switch statement}} + continue; // expected-error {{'continue' statement not in loop statement}} + while(1) break; // ok + goto foo; // expected-error {{goto not allowed}} + }); break; - } + } -foo: - takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}} + foo: + takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}} __block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}} takeblock(^{ y = 8; }); } @@ -59,11 +59,11 @@ void myfunc3(const int *x); void test5() { - int a; + int a; - myfunc(^(int abcd) { - myfunc3(&a); - return 1; + myfunc(^(int abcd) { + myfunc3(&a); + return 1; }); } Modified: cfe/trunk/test/Sema/block-misc.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-misc.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-misc.c (original) +++ cfe/trunk/test/Sema/block-misc.c Wed Sep 9 10:08:12 2009 @@ -4,37 +4,37 @@ int (^IFP) (); int (^II) (int); int test1() { - int (^PFR) (int) = 0; // OK - PFR = II; // OK + int (^PFR) (int) = 0; // OK + PFR = II; // OK - if (PFR == II) // OK + if (PFR == II) // OK donotwarn(); - if (PFR == IFP) // OK + if (PFR == IFP) // OK donotwarn(); if (PFR == (int (^) (int))IFP) // OK donotwarn(); - if (PFR == 0) // OK + if (PFR == 0) // OK donotwarn(); - if (PFR) // OK + if (PFR) // OK donotwarn(); - if (!PFR) // OK + if (!PFR) // OK donotwarn(); - return PFR != IFP; // OK + return PFR != IFP; // OK } int test2(double (^S)()) { double (^I)(int) = (void*) S; - (void*)I = (void *)S; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}} + (void*)I = (void *)S; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}} void *pv = I; - pv = S; + pv = S; I(1); @@ -114,7 +114,7 @@ void (^test12f)(void); void test12() { - test12f = ^test12f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} + test12f = ^test12f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} } // rdar://6808730 @@ -144,7 +144,7 @@ void (^test15f)(void); void test15() { - foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}} + foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}} } __block int test16i; // expected-error {{__block attribute not allowed, only allowed on local variables}} Modified: cfe/trunk/test/Sema/block-printf-attribute-1.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-printf-attribute-1.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-printf-attribute-1.c (original) +++ cfe/trunk/test/Sema/block-printf-attribute-1.c Wed Sep 9 10:08:12 2009 @@ -1,15 +1,12 @@ // RUN: clang-cc %s -fsyntax-only -verify -fblocks -int main() -{ - void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}} - ^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}} +int main() { + void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}} + ^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}} - void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {}; - - // FIXME: argument type poking not yet supportted. - z(1, "%s", 1); /* { dg-warning "format \\'\%s\\' expects type \\'char \\*\\'\, but argument 3 has type \\'int\\'" } */ - z(1, "%s", "HELLO"); // OK + void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {}; + // FIXME: argument type poking not yet supportted. + z(1, "%s", 1); /* { dg-warning "format \\'\%s\\' expects type \\'char \\*\\'\, but argument 3 has type \\'int\\'" } */ + z(1, "%s", "HELLO"); // OK } - Modified: cfe/trunk/test/Sema/block-return.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-return.c (original) +++ cfe/trunk/test/Sema/block-return.c Wed Sep 9 10:08:12 2009 @@ -31,7 +31,7 @@ return (float)1.0; else if (2) - return (double)2.0; + return (double)2.0; return 1; }; char *(^B)(void) = ^{ @@ -66,7 +66,7 @@ Boolean (*value_equal)(uintptr_t, uintptr_t) = 0; cb.isEqual = ^(const CFBasicHash *table, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key) { - return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2); + return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2); }; } Modified: cfe/trunk/test/Sema/block-sentinel-attribute.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-sentinel-attribute.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/block-sentinel-attribute.c (original) +++ cfe/trunk/test/Sema/block-sentinel-attribute.c Wed Sep 9 10:08:12 2009 @@ -2,24 +2,23 @@ void (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1))); -int main() -{ - void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{sentinel' attribute only supported for variadic blocks}} - void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}} - ^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {}; - void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}} +int main() { + void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{sentinel' attribute only supported for variadic blocks}} + void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}} + ^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {}; + void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}} - void (^y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))) = ^ __attribute__ ((__sentinel__ (5))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}} + void (^y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))) = ^ __attribute__ ((__sentinel__ (5))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}} - b(1, "%s", (void*)0); // OK - b(1, "%s", 0); // expected-warning {{missing sentinel in block call}} - z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}} - z(1, "%s", (void*)0, 1, 0); // OK + b(1, "%s", (void*)0); // OK + b(1, "%s", 0); // expected-warning {{missing sentinel in block call}} + z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}} + z(1, "%s", (void*)0, 1, 0); // OK - y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}} + y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}} - y(1, "%s", (void*)0,3,4,5,6,7); // OK + y(1, "%s", (void*)0,3,4,5,6,7); // OK } Modified: cfe/trunk/test/Sema/c89-2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/c89-2.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/c89-2.c (original) +++ cfe/trunk/test/Sema/c89-2.c Wed Sep 9 10:08:12 2009 @@ -1,5 +1,5 @@ /* RUN: clang-cc %s -std=c89 -pedantic-errors -verify */ -#if 1LL /* expected-error {{long long}} */ +#if 1LL /* expected-error {{long long}} */ #endif Modified: cfe/trunk/test/Sema/c89.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/c89.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/c89.c (original) +++ cfe/trunk/test/Sema/c89.c Wed Sep 9 10:08:12 2009 @@ -25,7 +25,7 @@ int A[i]; /* expected-warning {{variable length array}} */ } -int test4 = 0LL; /* expected-warning {{long long}} */ +int test4 = 0LL; /* expected-warning {{long long}} */ /* PR1999 */ void test5(register); Modified: cfe/trunk/test/Sema/complex-int.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/complex-int.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/complex-int.c (original) +++ cfe/trunk/test/Sema/complex-int.c Wed Sep 9 10:08:12 2009 @@ -44,9 +44,8 @@ // rdar://6097730 void test3(_Complex int *x) { *x = ~*x; -} +} void test4(_Complex float *x) { *x = ~*x; -} - +} Modified: cfe/trunk/test/Sema/conditional.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conditional.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/conditional.c (original) +++ cfe/trunk/test/Sema/conditional.c Wed Sep 9 10:08:12 2009 @@ -4,12 +4,10 @@ void _efree(void *ptr); -int _php_stream_free1() -{ - return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} +int _php_stream_free1() { + return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} } -int _php_stream_free2() -{ - return (1 ? _efree(0) : free(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} +int _php_stream_free2() { + return (1 ? _efree(0) : free(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} } Modified: cfe/trunk/test/Sema/darwin-align-cast.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/darwin-align-cast.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/darwin-align-cast.c (original) +++ cfe/trunk/test/Sema/darwin-align-cast.c Wed Sep 9 10:08:12 2009 @@ -8,10 +8,10 @@ #if 0 This code below comes from the following system headers: -sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct +sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct cmsghdr)) + __DARWIN_ALIGN(l)) -i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p) +i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES) #endif Modified: cfe/trunk/test/Sema/floating-point-compare.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/floating-point-compare.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/floating-point-compare.c (original) +++ cfe/trunk/test/Sema/floating-point-compare.c Wed Sep 9 10:08:12 2009 @@ -13,11 +13,11 @@ } int f4(float x) { - return x == 0.0; // no-warning {{comparing}} + return x == 0.0; // no-warning {{comparing}} } int f5(float x) { - return x == __builtin_inf(); // no-warning + return x == __builtin_inf(); // no-warning } int f7(float x) { Modified: cfe/trunk/test/Sema/function-pointer-sentinel-attribute.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function-pointer-sentinel-attribute.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/function-pointer-sentinel-attribute.c (original) +++ cfe/trunk/test/Sema/function-pointer-sentinel-attribute.c Wed Sep 9 10:08:12 2009 @@ -2,22 +2,19 @@ void (*e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1))); -int main() -{ - void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}} - void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}} +int main() { + void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}} + void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}} - void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}} + void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}} - b(1, "%s", (void*)0); // OK - b(1, "%s", 0); // expected-warning {{missing sentinel in function call}} - z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}} - z(1, "%s", (void*)0, 1, 0); // OK + b(1, "%s", (void*)0); // OK + b(1, "%s", 0); // expected-warning {{missing sentinel in function call}} + z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}} + z(1, "%s", (void*)0, 1, 0); // OK - y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}} - - y(1, "%s", (void*)0,3,4,5,6,7); // OK + y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}} + y(1, "%s", (void*)0,3,4,5,6,7); // OK } - Modified: cfe/trunk/test/Sema/function-sentinel-attr.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function-sentinel-attr.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/function-sentinel-attr.c (original) +++ cfe/trunk/test/Sema/function-sentinel-attr.c Wed Sep 9 10:08:12 2009 @@ -18,7 +18,7 @@ foo1(1, 0) ; // expected-warning {{missing sentinel in function call}} foo5(1, NULL, 2); // OK foo5(1,2,NULL, 1); // OK - foo5(1, NULL, 2, 1); // expected-warning {{missing sentinel in function call}} + foo5(1, NULL, 2, 1); // expected-warning {{missing sentinel in function call}} foo6(1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}} foo6(1,NULL,3,4,5,6,7); // OK Modified: cfe/trunk/test/Sema/implicit-int.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/implicit-int.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/implicit-int.c (original) +++ cfe/trunk/test/Sema/implicit-int.c Wed Sep 9 10:08:12 2009 @@ -12,15 +12,15 @@ // PR3702 #define PAD(ms10) { \ - register i; \ + register i; \ } -#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */ +#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */ void h19_insline(n) // expected-warning {{parameter 'n' was not declared, defaulting to type 'int'}} { - ILPAD(); // expected-warning {{type specifier missing, defaults to 'int'}} + ILPAD(); // expected-warning {{type specifier missing, defaults to 'int'}} } struct foo { Modified: cfe/trunk/test/Sema/predefined-function.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/predefined-function.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/predefined-function.c (original) +++ cfe/trunk/test/Sema/predefined-function.c Wed Sep 9 10:08:12 2009 @@ -8,31 +8,30 @@ int b(int c) {return 1;} int foo(); -int foo() -{ - int eli(int (int)); // expected-error {{conflicting types for 'eli'}} - eli(b); // expected-error{{incompatible type passing}} - return 0; +int foo() { + int eli(int (int)); // expected-error {{conflicting types for 'eli'}} + eli(b); // expected-error{{incompatible type passing}} + return 0; } int bar(); int bar(int i) // expected-note {{previous definition is here}} { - return 0; + return 0; } int bar() // expected-error {{redefinition of 'bar'}} { - return 0; + return 0; } int foobar(int); // note {{previous declaration is here}} int foobar() // error {{conflicting types for 'foobar'}} { - return 0; + return 0; } int wibble(); // expected-note {{previous declaration is here}} float wibble() // expected-error {{conflicting types for 'wibble'}} { - return 0.0f; + return 0.0f; } Modified: cfe/trunk/test/Sema/static-init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/static-init.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/static-init.c (original) +++ cfe/trunk/test/Sema/static-init.c Wed Sep 9 10:08:12 2009 @@ -11,11 +11,11 @@ union bar { - int i; + int i; }; struct foo { - unsigned ptr; + unsigned ptr; }; union bar u[1]; Modified: cfe/trunk/test/Sema/struct-decl.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-decl.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/struct-decl.c (original) +++ cfe/trunk/test/Sema/struct-decl.c Wed Sep 9 10:08:12 2009 @@ -1,26 +1,26 @@ // RUN: clang-cc -fsyntax-only -verify %s // PR3459 struct bar { - char n[1]; + char n[1]; }; struct foo { - char name[(int)&((struct bar *)0)->n]; - char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}} + char name[(int)&((struct bar *)0)->n]; + char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}} }; // PR3430 struct s { - struct st { - int v; - } *ts; + struct st { + int v; + } *ts; }; struct st; int foo() { - struct st *f; - return f->v + f[0].v; + struct st *f; + return f->v + f[0].v; } // PR3642, PR3671 @@ -29,8 +29,8 @@ char tag_data[]; }; struct datatag { - struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}} - char data; + struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}} + char data; }; Modified: cfe/trunk/test/Sema/transparent-union-pointer.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/transparent-union-pointer.c?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/Sema/transparent-union-pointer.c (original) +++ cfe/trunk/test/Sema/transparent-union-pointer.c Wed Sep 9 10:08:12 2009 @@ -1,14 +1,14 @@ // RUN: clang-cc %s -fsyntax-only -verify typedef union { - union wait *__uptr; - int *__iptr; + union wait *__uptr; + int *__iptr; } __WAIT_STATUS __attribute__ ((__transparent_union__)); extern int wait (__WAIT_STATUS __stat_loc); void fastcgi_cleanup() { - int status = 0; - wait(&status); + int status = 0; + wait(&status); } Modified: cfe/trunk/test/SemaCXX/abstract.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/abstract.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/abstract.cpp (original) +++ cfe/trunk/test/SemaCXX/abstract.cpp Wed Sep 9 10:08:12 2009 @@ -9,7 +9,7 @@ #endif class C { - virtual void f() = 0; // expected-note {{pure virtual function 'f'}} + virtual void f() = 0; // expected-note {{pure virtual function 'f'}} }; static_assert(__is_abstract(C), "C has a pure virtual function"); @@ -20,7 +20,7 @@ static_assert(__is_abstract(D), "D inherits from an abstract class"); class E : D { - virtual void f(); + virtual void f(); }; static_assert(!__is_abstract(E), "E inherits from an abstract class but implements f"); @@ -38,8 +38,8 @@ void t3(const C&); void f() { - C(); // expected-error {{allocation of an object of abstract type 'C'}} - t3(C()); // expected-error {{allocation of an object of abstract type 'C'}} + C(); // expected-error {{allocation of an object of abstract type 'C'}} + t3(C()); // expected-error {{allocation of an object of abstract type 'C'}} } C e1[2]; // expected-error {{variable type 'C' is an abstract class}} @@ -54,17 +54,17 @@ void t6(Func); class F { - F a() { while (1) {} } // expected-error {{return type 'F' is an abstract class}} + F a() { while (1) {} } // expected-error {{return type 'F' is an abstract class}} - class D { - void f(F c); // expected-error {{parameter type 'F' is an abstract class}} - }; - - union U { - void u(F c); // expected-error {{parameter type 'F' is an abstract class}} - }; + class D { + void f(F c); // expected-error {{parameter type 'F' is an abstract class}} + }; + + union U { + void u(F c); // expected-error {{parameter type 'F' is an abstract class}} + }; - virtual void f() = 0; // expected-note {{pure virtual function 'f'}} + virtual void f() = 0; // expected-note {{pure virtual function 'f'}} }; class Abstract; @@ -72,50 +72,47 @@ void t7(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} void t8() { - void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} + void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} } namespace N { - void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} +void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} } class Abstract { - virtual void f() = 0; // expected-note {{pure virtual function 'f'}} + virtual void f() = 0; // expected-note {{pure virtual function 'f'}} }; // class foo { public: - virtual foo *getFoo() = 0; + virtual foo *getFoo() = 0; }; class bar : public foo { public: - virtual bar *getFoo(); + virtual bar *getFoo(); }; bar x; // -class A -{ +class A { public: - virtual void release() = 0; - virtual void release(int count) = 0; - virtual void retain() = 0; + virtual void release() = 0; + virtual void release(int count) = 0; + virtual void retain() = 0; }; -class B : public A -{ +class B : public A { public: - virtual void release(); - virtual void release(int count); - virtual void retain(); + virtual void release(); + virtual void release(int count); + virtual void retain(); }; -void foo(void) -{ - B b; +void foo(void) { + B b; } struct K { Modified: cfe/trunk/test/SemaCXX/access-control-check.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/access-control-check.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/access-control-check.cpp (original) +++ cfe/trunk/test/SemaCXX/access-control-check.cpp Wed Sep 9 10:08:12 2009 @@ -11,6 +11,6 @@ class N : M,P { N() {} - // FIXME. No access violation is reported in method call or member access. + // FIXME. No access violation is reported in method call or member access. int PR() { return iP + PPR(); } }; Modified: cfe/trunk/test/SemaCXX/attr-format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-format.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/attr-format.cpp (original) +++ cfe/trunk/test/SemaCXX/attr-format.cpp Wed Sep 9 10:08:12 2009 @@ -1,8 +1,8 @@ // RUN: clang-cc -fsyntax-only -verify %s struct S { - static void f(const char*, ...) __attribute__((format(printf, 1, 2))); - - // GCC has a hidden 'this' argument in member functions which is why - // the format argument is argument 2 here. - void g(const char*, ...) __attribute__((format(printf, 2, 3))); -}; \ No newline at end of file + static void f(const char*, ...) __attribute__((format(printf, 1, 2))); + + // GCC has a hidden 'this' argument in member functions which is why + // the format argument is argument 2 here. + void g(const char*, ...) __attribute__((format(printf, 2, 3))); +}; Modified: cfe/trunk/test/SemaCXX/class-base-member-init.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class-base-member-init.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/class-base-member-init.cpp (original) +++ cfe/trunk/test/SemaCXX/class-base-member-init.cpp Wed Sep 9 10:08:12 2009 @@ -7,9 +7,9 @@ struct D : S { D() : b1(0), b2(1), b1(0), S(), S() {} // expected-error {{multiple initializations given for non-static member 'b1'}} \ - // expected-note {{previous initialization is here}} \ - // expected-error {{multiple initializations given for base 'class S'}} \ - // expected-note {{previous initialization is here}} + // expected-note {{previous initialization is here}} \ + // expected-error {{multiple initializations given for base 'class S'}} \ + // expected-note {{previous initialization is here}} int b1; int b2; Modified: cfe/trunk/test/SemaCXX/constructor-initializer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constructor-initializer.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/constructor-initializer.cpp (original) +++ cfe/trunk/test/SemaCXX/constructor-initializer.cpp Wed Sep 9 10:08:12 2009 @@ -94,18 +94,18 @@ Derived::V(), // expected-note {{base 'Derived::V'}} ::NonExisting(), // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}} INT::NonExisting() {} // expected-error {{expected a class or namespace}} \ - // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}} + // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}} }; // FIXME. This is bad message! -struct M { // expected-note {{candidate function}} \ - // expected-note {{candidate function}} - M(int i, int j); // expected-note {{candidate function}} \ - // // expected-note {{candidate function}} +struct M { // expected-note {{candidate function}} \ + // expected-note {{candidate function}} + M(int i, int j); // expected-note {{candidate function}} \ + // // expected-note {{candidate function}} }; struct N : M { - N() : M(1), // expected-error {{no matching constructor for initialization of 'M'}} + N() : M(1), // expected-error {{no matching constructor for initialization of 'M'}} m1(100) { } // expected-error {{no matching constructor for initialization of 'm1'}} M m1; }; @@ -116,7 +116,7 @@ }; struct Q { - Q() : f1(1,2), // expected-error {{Too many arguments for member initializer 'f1'}} + Q() : f1(1,2), // expected-error {{Too many arguments for member initializer 'f1'}} pf(0.0) { } // expected-error {{incompatible type passing 'double', expected 'float *'}} float f1; Modified: cfe/trunk/test/SemaCXX/copy-constructor-error.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/copy-constructor-error.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/copy-constructor-error.cpp (original) +++ cfe/trunk/test/SemaCXX/copy-constructor-error.cpp Wed Sep 9 10:08:12 2009 @@ -1,8 +1,8 @@ // RUN: clang-cc -fsyntax-only -verify %s -struct S { // expected-note {{candidate function}} - S (S); // expected-error {{copy constructor must pass its first argument by reference}} \\ - // expected-note {{candidate function}} +struct S { // expected-note {{candidate function}} + S (S); // expected-error {{copy constructor must pass its first argument by reference}} \\ + // expected-note {{candidate function}} }; S f(); Modified: cfe/trunk/test/SemaCXX/default-assignment-operator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default-assignment-operator.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/default-assignment-operator.cpp (original) +++ cfe/trunk/test/SemaCXX/default-assignment-operator.cpp Wed Sep 9 10:08:12 2009 @@ -26,7 +26,7 @@ // Test1 void f(X x, const X cx) { - x = cx; // expected-note {{synthesized method is first required here}} + x = cx; // expected-note {{synthesized method is first required here}} x = cx; z1 = z2; } @@ -36,8 +36,7 @@ T t1; T t2; -void g() -{ +void g() { t1 = t2; } @@ -51,8 +50,7 @@ class W : V {}; W w1, w2; -void h() -{ +void h() { w1 = w2; } @@ -67,9 +65,8 @@ class D1 : B1 {}; D1 d1, d2; -void i() -{ - d1 = d2; +void i() { + d1 = d2; } // Test5 @@ -83,8 +80,7 @@ E1 e1, e2; -void j() -{ +void j() { e1 = e2; // expected-note{{synthesized method is first required here}} } Modified: cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp (original) +++ cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp Wed Sep 9 10:08:12 2009 @@ -46,9 +46,9 @@ struct Z1 { - int& z; // expected-note {{declared at}} - const int c1; // expected-note {{declared at}} - volatile int v1; + int& z; // expected-note {{declared at}} + const int c1; // expected-note {{declared at}} + volatile int v1; }; Z1 z1; // expected-error {{cannot define the implicit default constructor for 'struct Z1', because reference member 'z' cannot be default-initialized}} \ Modified: cfe/trunk/test/SemaCXX/enum.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/enum.cpp (original) +++ cfe/trunk/test/SemaCXX/enum.cpp Wed Sep 9 10:08:12 2009 @@ -14,14 +14,13 @@ // typedef enum Foo { - A = 0, - B = 1 + A = 0, + B = 1 } Foo; - - + void bar() { - Foo myvar = A; - myvar = B; + Foo myvar = A; + myvar = B; } /// PR3688 Modified: cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp (original) +++ cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp Wed Sep 9 10:08:12 2009 @@ -3,7 +3,7 @@ struct A { A() : value(), cvalue() { } // expected-error {{cannot initialize the member to null in default constructor because reference member 'value' cannot be null-initialized}} \ // expected-error {{constructor for 'struct A' must explicitly initialize the reference member 'value'}} - int &value; // expected-note{{declared at}} {{expected-note{{declared at}} + int &value; // expected-note{{declared at}} {{expected-note{{declared at}} const int cvalue; }; @@ -11,10 +11,10 @@ }; struct X { - X() { } // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'value'}} \ - // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cvalue'}} \ - // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'b'}} \ - // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cb'}} + X() { } // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'value'}} \ + // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cvalue'}} \ + // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'b'}} \ + // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cb'}} int &value; // expected-note{{declared at}} const int cvalue; // expected-note{{declared at}} B& b; // expected-note{{declared at}} Modified: cfe/trunk/test/SemaCXX/inherit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/inherit.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/inherit.cpp (original) +++ cfe/trunk/test/SemaCXX/inherit.cpp Wed Sep 9 10:08:12 2009 @@ -10,7 +10,7 @@ class C : public B1, private B2 { }; -class D; // expected-note {{forward declaration of 'class D'}} +class D; // expected-note {{forward declaration of 'class D'}} class E : public D { }; // expected-error{{base class has incomplete type}} Modified: cfe/trunk/test/SemaCXX/member-expr-static.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr-static.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/member-expr-static.cpp (original) +++ cfe/trunk/test/SemaCXX/member-expr-static.cpp Wed Sep 9 10:08:12 2009 @@ -2,20 +2,18 @@ typedef void (*thread_continue_t)(); extern "C" { -extern void kernel_thread_start(thread_continue_t continuation); -extern void pure_c(void); + extern void kernel_thread_start(thread_continue_t continuation); + extern void pure_c(void); } -class _IOConfigThread -{ +class _IOConfigThread { public: - static void main( void ); + static void main( void ); }; -void foo( void ) -{ - kernel_thread_start(&_IOConfigThread::main); - kernel_thread_start((thread_continue_t)&_IOConfigThread::main); - kernel_thread_start(&pure_c); +void foo( void ) { + kernel_thread_start(&_IOConfigThread::main); + kernel_thread_start((thread_continue_t)&_IOConfigThread::main); + kernel_thread_start(&pure_c); } Modified: cfe/trunk/test/SemaCXX/static-initializers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-initializers.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/static-initializers.cpp (original) +++ cfe/trunk/test/SemaCXX/static-initializers.cpp Wed Sep 9 10:08:12 2009 @@ -1,12 +1,10 @@ // RUN: clang-cc -fsyntax-only -verify %s -int f() -{ - return 10; +int f() { + return 10; } -void g() -{ - static int a = f(); +void g() { + static int a = f(); } static int b = f(); Modified: cfe/trunk/test/SemaCXX/warn-reorder-ctor-initialization.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-reorder-ctor-initialization.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/warn-reorder-ctor-initialization.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-reorder-ctor-initialization.cpp Wed Sep 9 10:08:12 2009 @@ -64,13 +64,13 @@ }; struct F : public A1, public B1, private virtual V { - F() : A1(), V() { } // expected-warning {{base class 'struct A1' will be initialized after}} \ - // expected-note {{base 'struct V'}} + F() : A1(), V() { } // expected-warning {{base class 'struct A1' will be initialized after}} \ + // expected-note {{base 'struct V'}} }; struct X : public virtual A, virtual V, public virtual B { - X(): A(), V(), B() {} // expected-warning {{base class 'struct A' will be initialized after}} \ - // expected-note {{base 'struct V'}} + X(): A(), V(), B() {} // expected-warning {{base class 'struct A' will be initialized after}} \ + // expected-note {{base 'struct V'}} }; class Anon { Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/tools/clang-cc/clang-cc.cpp (original) +++ cfe/trunk/tools/clang-cc/clang-cc.cpp Wed Sep 9 10:08:12 2009 @@ -109,14 +109,14 @@ static llvm::cl::opt Verbose("v", llvm::cl::desc("Enable verbose output")); static llvm::cl::opt -Stats("print-stats", +Stats("print-stats", llvm::cl::desc("Print performance metrics and statistics")); static llvm::cl::opt DisableFree("disable-free", llvm::cl::desc("Disable freeing of memory on exit"), llvm::cl::init(false)); static llvm::cl::opt -EmptyInputOnly("empty-input-only", +EmptyInputOnly("empty-input-only", llvm::cl::desc("Force running on an empty input file")); enum ProgActions { @@ -129,7 +129,7 @@ EmitAssembly, // Emit a .s file. EmitLLVM, // Emit a .ll file. EmitBC, // Emit a .bc file. - EmitLLVMOnly, // Generate LLVM IR, but do not + EmitLLVMOnly, // Generate LLVM IR, but do not EmitHTML, // Translate input source into HTML. ASTPrint, // Parse ASTs and print them. ASTPrintXML, // Parse ASTs and print them in XML. @@ -143,13 +143,13 @@ PrintPreprocessedInput, // -E mode. DumpTokens, // Dump out preprocessed tokens. DumpRawTokens, // Dump out raw tokens. - RunAnalysis, // Run one or more source code analyses. + RunAnalysis, // Run one or more source code analyses. GeneratePTH, // Generate pre-tokenized header. GeneratePCH, // Generate pre-compiled header. InheritanceView // View C++ inheritance for a specified class. }; -static llvm::cl::opt +static llvm::cl::opt ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore, llvm::cl::init(ParseSyntaxOnly), llvm::cl::values( @@ -262,13 +262,13 @@ static llvm::cl::opt MessageLength("fmessage-length", - llvm::cl::desc("Format message diagnostics so that they fit " - "within N columns or fewer, when possible."), - llvm::cl::value_desc("N")); + llvm::cl::desc("Format message diagnostics so that they fit " + "within N columns or fewer, when possible."), + llvm::cl::value_desc("N")); static llvm::cl::opt NoColorDiagnostic("fno-color-diagnostics", - llvm::cl::desc("Don't use colors when showing diagnostics " + llvm::cl::desc("Don't use colors when showing diagnostics " "(automatically turned off if output is not a " "terminal).")); //===----------------------------------------------------------------------===// @@ -402,8 +402,9 @@ static llvm::cl::opt ObjCSenderDispatch("fobjc-sender-dependent-dispatch", - llvm::cl::desc("Enable sender-dependent dispatch for" - "Objective-C messages"), llvm::cl::init(false)); + llvm::cl::desc("Enable sender-dependent dispatch for" + "Objective-C messages"), + llvm::cl::init(false)); /// InitializeBaseLanguage - Handle the -x foo options. static void InitializeBaseLanguage() { @@ -416,14 +417,14 @@ static LangKind GetLanguage(const std::string &Filename) { if (BaseLang != langkind_unspecified) return BaseLang; - + std::string::size_type DotPos = Filename.rfind('.'); if (DotPos == std::string::npos) { BaseLang = langkind_c; // Default to C if no extension. return langkind_c; } - + std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end()); // C header: .h // C++ header: .hh or .H; @@ -464,12 +465,12 @@ static void InitializeObjCOptions(LangOptions &Options) { Options.ObjC1 = Options.ObjC2 = 1; } - + static void InitializeLangOptions(LangOptions &Options, LangKind LK){ // FIXME: implement -fpreprocessed mode. bool NoPreprocess = false; - + switch (LK) { default: assert(0 && "Unknown language kind!"); case langkind_asm_cpp: @@ -507,28 +508,28 @@ Options.LaxVectorConversions = 1; break; } - + if (ObjCExclusiveGC) Options.setGCMode(LangOptions::GCOnly); else if (ObjCEnableGC) Options.setGCMode(LangOptions::HybridGC); - + if (ObjCEnableGCBitmapPrint) Options.ObjCGCBitmapPrint = 1; - + if (AltiVec) Options.AltiVec = 1; if (PThread) Options.POSIXThreads = 1; - + Options.setVisibilityMode(SymbolVisibility); Options.OverflowChecking = OverflowChecking; } /// LangStds - Language standards we support. enum LangStds { - lang_unspecified, + lang_unspecified, lang_c89, lang_c94, lang_c99, lang_gnu_START, lang_gnu89 = lang_gnu_START, lang_gnu99, @@ -575,7 +576,7 @@ PascalStrings("fpascal-strings", llvm::cl::desc("Recognize and construct Pascal-style " "string literals")); - + static llvm::cl::opt MSExtensions("fms-extensions", llvm::cl::desc("Accept some non-standard constructs used in " @@ -647,7 +648,7 @@ OptSize("Os", llvm::cl::desc("Optimize for size")); static llvm::cl::opt -DisableLLVMOptimizations("disable-llvm-optzns", +DisableLLVMOptimizations("disable-llvm-optzns", llvm::cl::desc("Don't run LLVM optimization passes")); static llvm::cl::opt @@ -661,7 +662,7 @@ // FIXME: Also add an "-fno-access-control" option. static llvm::cl::opt -AccessControl("faccess-control", +AccessControl("faccess-control", llvm::cl::desc("Enable C++ access control")); static llvm::cl::opt @@ -705,7 +706,7 @@ // Pass the map of target features to the target for validation and // processing. Target->HandleTargetFeatures(Features); - + if (LangStd == lang_unspecified) { // Based on the base language, pick one. switch (LK) { @@ -728,7 +729,7 @@ break; } } - + switch (LangStd) { default: assert(0 && "Unknown language standard!"); @@ -760,17 +761,17 @@ // GNUMode - Set if we're in gnu99, gnu89, gnucxx98, etc. Options.GNUMode = LangStd >= lang_gnu_START; - + if (Options.CPlusPlus) { Options.C99 = 0; Options.HexFloats = 0; } - + if (LangStd == lang_c89 || LangStd == lang_c94 || LangStd == lang_gnu89) Options.ImplicitInt = 1; else Options.ImplicitInt = 0; - + // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs // is specified, or -std is set to a conforming mode. Options.Trigraphs = !Options.GNUMode; @@ -783,14 +784,14 @@ // However, blocks are not turned off when compiling Obj-C or Obj-C++ code. if (!Options.ObjC1 && !Options.GNUMode) Options.Blocks = 0; - + // Default to not accepting '$' in identifiers when preprocessing assembler, // but do accept when preprocessing C. FIXME: these defaults are right for // darwin, are they right everywhere? Options.DollarIdents = LK != langkind_asm_cpp; if (DollarsInIdents.getPosition()) // Explicit setting overrides default. Options.DollarIdents = DollarsInIdents; - + if (PascalStrings.getPosition()) Options.PascalStrings = PascalStrings; if (MSExtensions.getPosition()) @@ -809,18 +810,18 @@ Options.NoBuiltin = 1; if (Freestanding) Options.Freestanding = Options.NoBuiltin = 1; - + if (EnableHeinousExtensions) Options.HeinousExtensions = 1; if (AccessControl) Options.AccessControl = 1; - + Options.ElideConstructors = !NoElideConstructors; - + // OpenCL and C++ both have bool, true, false keywords. Options.Bool = Options.OpenCL | Options.CPlusPlus; - + Options.MathErrno = MathErrno; Options.InstantiationDepth = TemplateDepth; @@ -838,14 +839,14 @@ Options.ObjCNonFragileABI = 1; Options.ObjCSenderDispatch = ObjCSenderDispatch; - + if (EmitAllDecls) Options.EmitAllDecls = 1; // The __OPTIMIZE_SIZE__ define is tied to -Oz, which we don't // support. Options.OptimizeSize = 0; - + // -Os implies -O2 if (OptSize || OptLevel) Options.Optimize = 1; @@ -854,7 +855,7 @@ Options.PICLevel = PICLevel; Options.GNUInline = !Options.C99; - // FIXME: This is affected by other options (-fno-inline). + // FIXME: This is affected by other options (-fno-inline). Options.NoInline = !OptSize && !OptLevel; Options.Static = StaticDefine; @@ -881,7 +882,7 @@ llvm::cl::desc("Specify target triple (e.g. i686-apple-darwin9)")); static llvm::cl::opt -MacOSVersionMin("mmacosx-version-min", +MacOSVersionMin("mmacosx-version-min", llvm::cl::desc("Specify target Mac OS X version (e.g. 10.5)")); // If -mmacosx-version-min=10.3.9 is specified, change the triple from being @@ -891,12 +892,12 @@ static void HandleMacOSVersionMin(std::string &Triple) { std::string::size_type DarwinDashIdx = Triple.find("-darwin"); if (DarwinDashIdx == std::string::npos) { - fprintf(stderr, + fprintf(stderr, "-mmacosx-version-min only valid for darwin (Mac OS X) targets\n"); exit(1); } unsigned DarwinNumIdx = DarwinDashIdx + strlen("-darwin"); - + // Remove the number. Triple.resize(DarwinNumIdx); @@ -914,10 +915,10 @@ // The version number must be in the range 0-9. MacOSVersionMinIsInvalid = (unsigned)VersionNum > 9; - + // Turn MacOSVersionMin into a darwin number: e.g. 10.3.9 is 3 -> 7. Triple += llvm::itostr(VersionNum+4); - + if (End[0] == '.' && isdigit(End[1]) && End[2] == '\0') { // 10.4.7 is ok. // Add the period piece (.7) to the end of the triple. This gives us // something like ...-darwin8.7 @@ -926,16 +927,16 @@ MacOSVersionMinIsInvalid = true; } } - + if (MacOSVersionMinIsInvalid) { - fprintf(stderr, + fprintf(stderr, "-mmacosx-version-min=%s is invalid, expected something like '10.4'.\n", MacOSVersionMin.c_str()); exit(1); } - else if (VersionNum <= 4 && + else if (VersionNum <= 4 && !strncmp(Triple.c_str(), "x86_64", strlen("x86_64"))) { - fprintf(stderr, + fprintf(stderr, "-mmacosx-version-min=%s is invalid with -arch x86_64.\n", MacOSVersionMin.c_str()); exit(1); @@ -944,7 +945,7 @@ } static llvm::cl::opt -IPhoneOSVersionMin("miphoneos-version-min", +IPhoneOSVersionMin("miphoneos-version-min", llvm::cl::desc("Specify target iPhone OS version (e.g. 2.0)")); // If -miphoneos-version-min=2.2 is specified, change the triple from being @@ -956,15 +957,15 @@ static void HandleIPhoneOSVersionMin(std::string &Triple) { std::string::size_type DarwinDashIdx = Triple.find("-darwin"); if (DarwinDashIdx == std::string::npos) { - fprintf(stderr, + fprintf(stderr, "-miphoneos-version-min only valid for darwin (Mac OS X) targets\n"); exit(1); } unsigned DarwinNumIdx = DarwinDashIdx + strlen("-darwin"); - + // Remove the number. Triple.resize(DarwinNumIdx); - + // Validate that IPhoneOSVersionMin is a 'version number', starting with [2-9].[0-9] bool IPhoneOSVersionMinIsInvalid = false; int VersionNum = 0; @@ -975,13 +976,13 @@ const char *Start = IPhoneOSVersionMin.c_str(); char *End = 0; VersionNum = (int)strtol(Start, &End, 10); - + // The version number must be in the range 0-9. IPhoneOSVersionMinIsInvalid = (unsigned)VersionNum > 9; - + // Turn IPhoneOSVersionMin into a darwin number: e.g. 2.0 is 2 -> 9.2. Triple += "9." + llvm::itostr(VersionNum); - + if (End[0] == '.' && isdigit(End[1]) && End[2] == '\0') { // 2.2 is ok. // Add the period piece (.2) to the end of the triple. This gives us // something like ...-darwin9.2.2 @@ -990,9 +991,9 @@ IPhoneOSVersionMinIsInvalid = true; } } - + if (IPhoneOSVersionMinIsInvalid) { - fprintf(stderr, + fprintf(stderr, "-miphoneos-version-min=%s is invalid, expected something like '2.0'.\n", IPhoneOSVersionMin.c_str()); exit(1); @@ -1014,7 +1015,7 @@ HandleMacOSVersionMin(Triple); else if (!IPhoneOSVersionMin.empty()) HandleIPhoneOSVersionMin(Triple);; - + return Triple; } @@ -1030,14 +1031,14 @@ if (EmptyInputOnly) { const char *EmptyStr = ""; - llvm::MemoryBuffer *SB = + llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, ""); SourceMgr.createMainFileIDForMemBuffer(SB); } else if (InFile != "-") { const FileEntry *File = FileMgr.getFile(InFile); if (File) SourceMgr.createMainFileID(File, SourceLocation()); if (SourceMgr.getMainFileID().isInvalid()) { - PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading) + PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading) << InFile.c_str(); return true; } @@ -1053,7 +1054,7 @@ SourceMgr.createMainFileIDForMemBuffer(SB); if (SourceMgr.getMainFileID().isInvalid()) { - PP.getDiagnostics().Report(FullSourceLoc(), + PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading_stdin); return true; } @@ -1094,7 +1095,7 @@ llvm::cl::desc("Include file before parsing")); static llvm::cl::opt -RelocatablePCH("relocatable-pch", +RelocatablePCH("relocatable-pch", llvm::cl::desc("Whether to build a relocatable precompiled " "header")); @@ -1105,7 +1106,7 @@ // This tool exports a large number of command line options to control how the // preprocessor searches for header files. At root, however, the Preprocessor // object takes a very simple interface: a list of directories to search for -// +// // FIXME: -nostdinc++ // FIXME: -imultilib // @@ -1165,22 +1166,22 @@ ++Fidx; } } - + // Consume what's left from whatever list was longer. for (; Iidx != I_dirs.size(); ++Iidx) Init.AddPath(I_dirs[Iidx], InitHeaderSearch::Angled, false, true, false); for (; Fidx != F_dirs.size(); ++Fidx) Init.AddPath(F_dirs[Fidx], InitHeaderSearch::Angled, false, true, true); - + // Handle -idirafter... options. for (unsigned i = 0, e = idirafter_dirs.size(); i != e; ++i) Init.AddPath(idirafter_dirs[i], InitHeaderSearch::After, false, true, false); - + // Handle -iquote... options. for (unsigned i = 0, e = iquote_dirs.size(); i != e; ++i) Init.AddPath(iquote_dirs[i], InitHeaderSearch::Quoted, false, true, false); - + // Handle -isystem... options. for (unsigned i = 0, e = isystem_dirs.size(); i != e; ++i) Init.AddPath(isystem_dirs[i], InitHeaderSearch::System, false, true, false); @@ -1198,28 +1199,28 @@ bool iwithprefixbefore_done = iwithprefixbefore_vals.empty(); while (!iprefix_done || !iwithprefix_done || !iwithprefixbefore_done) { if (!iprefix_done && - (iwithprefix_done || - iprefix_vals.getPosition(iprefix_idx) < + (iwithprefix_done || + iprefix_vals.getPosition(iprefix_idx) < iwithprefix_vals.getPosition(iwithprefix_idx)) && - (iwithprefixbefore_done || - iprefix_vals.getPosition(iprefix_idx) < + (iwithprefixbefore_done || + iprefix_vals.getPosition(iprefix_idx) < iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) { Prefix = iprefix_vals[iprefix_idx]; ++iprefix_idx; iprefix_done = iprefix_idx == iprefix_vals.size(); } else if (!iwithprefix_done && - (iwithprefixbefore_done || - iwithprefix_vals.getPosition(iwithprefix_idx) < + (iwithprefixbefore_done || + iwithprefix_vals.getPosition(iwithprefix_idx) < iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) { - Init.AddPath(Prefix+iwithprefix_vals[iwithprefix_idx], + Init.AddPath(Prefix+iwithprefix_vals[iwithprefix_idx], InitHeaderSearch::System, false, false, false); ++iwithprefix_idx; iwithprefix_done = iwithprefix_idx == iwithprefix_vals.size(); } else { - Init.AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx], + Init.AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx], InitHeaderSearch::Angled, false, false, false); ++iwithprefixbefore_idx; - iwithprefixbefore_done = + iwithprefixbefore_done = iwithprefixbefore_idx == iwithprefixbefore_vals.size(); } } @@ -1228,36 +1229,35 @@ Init.AddDefaultEnvVarPaths(Lang); // Add the clang headers, which are relative to the clang binary. - llvm::sys::Path MainExecutablePath = + llvm::sys::Path MainExecutablePath = llvm::sys::Path::GetMainExecutable(Argv0, (void*)(intptr_t)InitializeIncludePaths); if (!MainExecutablePath.isEmpty()) { MainExecutablePath.eraseComponent(); // Remove /clang from foo/bin/clang MainExecutablePath.eraseComponent(); // Remove /bin from foo/bin - // Get foo/lib/clang//include + // Get foo/lib/clang//include MainExecutablePath.appendComponent("lib"); MainExecutablePath.appendComponent("clang"); MainExecutablePath.appendComponent(CLANG_VERSION_STRING); MainExecutablePath.appendComponent("include"); - + // We pass true to ignore sysroot so that we *always* look for clang headers // relative to our executable, never relative to -isysroot. Init.AddPath(MainExecutablePath.c_str(), InitHeaderSearch::System, false, false, false, true /*ignore sysroot*/); } - - if (!nostdinc) + + if (!nostdinc) Init.AddDefaultSystemIncludePaths(Lang); // Now that we have collected all of the include paths, merge them all // together and tell the preprocessor about them. - + Init.Realize(); } -void InitializePreprocessorInitOptions(PreprocessorInitOptions &InitOpts) -{ +void InitializePreprocessorInitOptions(PreprocessorInitOptions &InitOpts) { // Add macros from the command line. unsigned d = 0, D = D_macros.size(); unsigned u = 0, U = U_macros.size(); @@ -1326,17 +1326,17 @@ TargetInfo &Target; SourceManager &SourceMgr; HeaderSearch &HeaderInfo; - + public: DriverPreprocessorFactory(Diagnostic &diags, const LangOptions &opts, TargetInfo &target, SourceManager &SM, - HeaderSearch &Headers) + HeaderSearch &Headers) : Diags(diags), LangInfo(opts), Target(target), SourceMgr(SM), HeaderInfo(Headers) {} - - + + virtual ~DriverPreprocessorFactory() {} - + virtual Preprocessor* CreatePreprocessor() { llvm::OwningPtr PTHMgr; @@ -1345,23 +1345,23 @@ "options\n"); exit(1); } - + // Use PTH? if (!TokenCache.empty() || !ImplicitIncludePTH.empty()) { const std::string& x = TokenCache.empty() ? ImplicitIncludePTH:TokenCache; - PTHMgr.reset(PTHManager::Create(x, &Diags, + PTHMgr.reset(PTHManager::Create(x, &Diags, TokenCache.empty() ? Diagnostic::Error : Diagnostic::Warning)); } - + if (Diags.hasErrorOccurred()) exit(1); - + // Create the Preprocessor. llvm::OwningPtr PP(new Preprocessor(Diags, LangInfo, Target, SourceMgr, HeaderInfo, PTHMgr.get())); - + // Note that this is different then passing PTHMgr to Preprocessor's ctor. // That argument is used as the IdentifierInfoLookup argument to // IdentifierTable's ctor. @@ -1387,7 +1387,7 @@ static void ParseFile(Preprocessor &PP, MinimalAction *PA) { Parser P(PP, *PA); PP.EnterMainSourceFile(); - + // Parsing the specified input file. P.ParseTranslationUnit(); delete PA; @@ -1424,24 +1424,24 @@ /// and feature list. static void ComputeFeatureMap(TargetInfo *Target, llvm::StringMap &Features) { - assert(Features.empty() && "invalid map"); + assert(Features.empty() && "invalid map"); // Initialize the feature map based on the target. Target->getDefaultFeatures(TargetCPU, Features); // Apply the user specified deltas. - for (llvm::cl::list::iterator it = TargetFeatures.begin(), + for (llvm::cl::list::iterator it = TargetFeatures.begin(), ie = TargetFeatures.end(); it != ie; ++it) { const char *Name = it->c_str(); - + // FIXME: Don't handle errors like this. if (Name[0] != '-' && Name[0] != '+') { - fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n", + fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n", Name); exit(1); } if (!Target->setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) { - fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n", + fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n", Name + 1); exit(1); } @@ -1482,7 +1482,7 @@ Opts.CPU = TargetCPU; Opts.Features.clear(); - for (llvm::StringMap::const_iterator it = Features.begin(), + for (llvm::StringMap::const_iterator it = Features.begin(), ie = Features.end(); it != ie; ++it) { // FIXME: If we are completely confident that we have the right // set, we only need to pass the minuses. @@ -1490,9 +1490,9 @@ Name += it->first(); Opts.Features.push_back(Name); } - + Opts.NoCommon = NoCommon | LangOpts.CPlusPlus; - + // Handle -ftime-report. Opts.TimePasses = TimeReport; @@ -1579,7 +1579,7 @@ #include "clang/Frontend/Analyses.def" clEnumValEnd)); -static llvm::cl::opt +static llvm::cl::opt AnalysisStoreOpt("analyzer-store", llvm::cl::desc("Source Code Analysis - Abstract Memory Store Models"), llvm::cl::init(BasicStoreModel), @@ -1589,7 +1589,7 @@ #include "clang/Frontend/Analyses.def" clEnumValEnd)); -static llvm::cl::opt +static llvm::cl::opt AnalysisConstraintsOpt("analyzer-constraints", llvm::cl::desc("Source Code Analysis - Symbolic Constraint Engines"), llvm::cl::init(RangeConstraintsModel), @@ -1681,7 +1681,7 @@ llvm::OwningPtr Chain1; llvm::OwningPtr Chain2; public: - + LoggingDiagnosticClient(DiagnosticClient *Normal) { // Output diags both where requested... Chain1.reset(Normal); @@ -1695,12 +1695,12 @@ !NoDiagnosticsFixIt, MessageLength)); } - + virtual void setLangOptions(const LangOptions *LO) { Chain1->setLangOptions(LO); Chain2->setLangOptions(LO); } - + virtual bool IncludeInDiagnosticCounts() const { return Chain1->IncludeInDiagnosticCounts(); } @@ -1715,11 +1715,11 @@ static void SetUpBuildDumpLog(unsigned argc, char **argv, llvm::OwningPtr &DiagClient) { - + std::string ErrorInfo; BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), ErrorInfo); - + if (!ErrorInfo.empty()) { llvm::errs() << "error opening -dump-build-information file '" << DumpBuildInformation << "', option ignored!\n"; @@ -1733,7 +1733,7 @@ for (unsigned i = 0; i != argc; ++i) (*BuildLogFile) << argv[i] << ' '; (*BuildLogFile) << '\n'; - + // LoggingDiagnosticClient - Insert a new logging diagnostic client in between // the diagnostic producers and the normal receiver. DiagClient.reset(new LoggingDiagnosticClient(DiagClient.take())); @@ -1772,7 +1772,7 @@ llvm::errs() << "ERROR: " << Error << "\n"; ::exit(1); } - + if (OutFile != "-") OutPath = OutFile; @@ -1802,7 +1802,7 @@ OS.reset(ComputeOutFile(InFile, 0, false, OutPath)); Consumer.reset(CreateASTPrinter(OS.get())); break; - + case ASTPrintXML: OS.reset(ComputeOutFile(InFile, "xml", false, OutPath)); Consumer.reset(CreateASTPrinterXML(OS.get())); @@ -1831,7 +1831,7 @@ case EmitAssembly: case EmitLLVM: - case EmitBC: + case EmitBC: case EmitLLVMOnly: { BackendAction Act; if (ProgAction == EmitAssembly) { @@ -1860,7 +1860,7 @@ PP.Diag(SourceLocation(), diag::err_relocatable_without_without_isysroot); RelocatablePCH.setValue(false); } - + OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); if (RelocatablePCH.getValue()) Consumer.reset(CreatePCHGenerator(PP, OS.get(), isysroot.c_str())); @@ -1920,7 +1920,7 @@ } case RunPreprocessorOnly: break; - + case GeneratePTH: { llvm::TimeRegion Timer(ClangFrontendTimer); if (OutputFile.empty() || OutputFile == "-") { @@ -1933,15 +1933,15 @@ CacheTokens(PP, static_cast(OS.get())); ClearSourceMgr = true; break; - } + } case PrintPreprocessedInput: OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); break; - + case ParseNoop: break; - + case ParsePrintCallbacks: { llvm::TimeRegion Timer(ClangFrontendTimer); OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); @@ -1955,13 +1955,13 @@ Consumer.reset(new ASTConsumer()); break; } - + case RewriteMacros: OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); RewriteMacrosInInput(PP, OS.get()); ClearSourceMgr = true; break; - + case RewriteTest: OS.reset(ComputeOutFile(InFile, 0, true, OutPath)); DoRewriteTest(PP, OS.get()); @@ -1987,7 +1987,7 @@ PP.getLangOptions()); bool AddedFixitLocation = false; - for (unsigned Idx = 0, Last = FixItAtLocations.size(); + for (unsigned Idx = 0, Last = FixItAtLocations.size(); Idx != Last; ++Idx) { RequestedSourceLocation Requested; if (ResolveParsedLocation(FixItAtLocations[Idx], @@ -2017,19 +2017,19 @@ PP.getBuiltinInfo(), /* FreeMemory = */ !DisableFree, /* size_reserve = */0)); - + llvm::OwningPtr Reader; llvm::OwningPtr Source; - + if (!ImplicitIncludePCH.empty()) { // If the user specified -isysroot, it will be used for relocatable PCH // files. const char *isysrootPCH = 0; if (isysroot.getNumOccurrences() != 0) isysrootPCH = isysroot.c_str(); - + Reader.reset(new PCHReader(PP, ContextOwner.get(), isysrootPCH)); - + // The user has asked us to include a precompiled header. Load // the precompiled header into the AST context. switch (Reader->ReadPCH(ImplicitIncludePCH)) { @@ -2080,7 +2080,7 @@ // If we have an ASTConsumer, run the parser with it. if (Consumer) - ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats, + ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats, CompleteTranslationUnit); if (PA == RunPreprocessorOnly) { // Just lex as fast as we can, no output. @@ -2106,7 +2106,7 @@ DisableLineMarkers, DumpDefines); ClearSourceMgr = true; } - + if (FixItRewrite) FixItRewrite->WriteFixedFile(InFile, OutputFile); @@ -2116,7 +2116,7 @@ Consumer.take(); else Consumer.reset(); - + // If in -disable-free mode, don't deallocate ASTContext. if (DisableFree) ContextOwner.take(); @@ -2136,7 +2136,7 @@ fprintf(stderr, "\n"); } - // For a multi-file compilation, some things are ok with nuking the source + // For a multi-file compilation, some things are ok with nuking the source // manager tables, other require stable fileid/macroid's across multiple // files. if (ClearSourceMgr) @@ -2176,14 +2176,14 @@ llvm::cl::ParseCommandLineOptions(argc, argv, "LLVM 'Clang' Compiler: http://clang.llvm.org\n"); - + if (TimeReport) ClangFrontendTimer = new llvm::Timer("Clang front-end time"); - + if (Verbose) llvm::errs() << "clang-cc version 1.0 based upon " << PACKAGE_STRING << " hosted on " << llvm::sys::getHostTriple() << "\n"; - + // If no input was specified, read from stdin. if (InputFilenames.empty()) InputFilenames.push_back("-"); @@ -2227,17 +2227,17 @@ } else { DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag)); } - + if (!DumpBuildInformation.empty()) { if (!HTMLDiag.empty()) { fprintf(stderr, "-dump-build-information and -html-diags don't work together\n"); return 1; } - + SetUpBuildDumpLog(argc, argv, DiagClient); } - + // Configure our handling of diagnostics. Diagnostic Diags(DiagClient.get()); @@ -2253,7 +2253,7 @@ // -I- is a deprecated GCC feature, scan for it and reject it. for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) { if (I_dirs[i] == "-") { - Diags.Report(FullSourceLoc(), diag::err_pp_I_dash_not_supported); + Diags.Report(FullSourceLoc(), diag::err_pp_I_dash_not_supported); I_dirs.erase(I_dirs.begin()+i); --i; } @@ -2262,18 +2262,18 @@ // Get information about the target being compiled for. std::string Triple = CreateTargetTriple(); llvm::OwningPtr Target(TargetInfo::CreateTargetInfo(Triple)); - + if (Target == 0) { - Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple) + Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple) << Triple.c_str(); return 1; } - + if (!InheritanceViewCls.empty()) // C++ visualization? ProgAction = InheritanceView; - + llvm::OwningPtr SourceMgr; - + // Create a file manager object to provide access to and cache the filesystem. FileManager FileMgr; @@ -2283,35 +2283,35 @@ for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) { const std::string &InFile = InputFilenames[i]; - + /// Create a SourceManager object. This tracks and owns all the file /// buffers allocated to a translation unit. if (!SourceMgr) SourceMgr.reset(new SourceManager()); else SourceMgr->clearIDTables(); - + // Initialize language options, inferring file types from input filenames. LangOptions LangInfo; DiagClient->setLangOptions(&LangInfo); - + InitializeBaseLanguage(); LangKind LK = GetLanguage(InFile); InitializeLangOptions(LangInfo, LK); InitializeLanguageStandard(LangInfo, LK, Target.get(), Features); - + // Process the -I options and set them in the HeaderInfo. HeaderSearch HeaderInfo(FileMgr); - - + + InitializeIncludePaths(argv[0], HeaderInfo, FileMgr, LangInfo); - + // Set up the preprocessor with these options. DriverPreprocessorFactory PPFactory(Diags, LangInfo, *Target, *SourceMgr.get(), HeaderInfo); - + llvm::OwningPtr PP(PPFactory.CreatePreprocessor()); - + if (!PP) continue; @@ -2342,7 +2342,7 @@ if (ImplicitIncludePCH.empty()) { if (InitializeSourceManager(*PP.get(), InFile)) continue; - + // Initialize builtin info. PP->getBuiltinInfo().InitializeBuiltins(PP->getIdentifierTable(), PP->getLangOptions().NoBuiltin); @@ -2353,7 +2353,7 @@ // Process the source file. ProcessInputFile(*PP, PPFactory, InFile, ProgAction, Features, Context); - + HeaderInfo.ClearFileInfo(); DiagClient->setLangOptions(0); } @@ -2362,7 +2362,7 @@ if (unsigned NumDiagnostics = Diags.getNumDiagnostics()) fprintf(stderr, "%d diagnostic%s generated.\n", NumDiagnostics, (NumDiagnostics == 1 ? "" : "s")); - + if (Stats) { FileMgr.PrintStats(); fprintf(stderr, "\n"); @@ -2370,11 +2370,11 @@ delete ClangFrontendTimer; delete BuildLogFile; - + // If verifying diagnostics and we reached here, all is well. if (VerifyDiagnostics) return 0; - + // Managed static deconstruction. Useful for making things like // -time-passes usable. llvm::llvm_shutdown(); Modified: cfe/trunk/tools/index-test/index-test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/index-test/index-test.cpp?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/tools/index-test/index-test.cpp (original) +++ cfe/trunk/tools/index-test/index-test.cpp Wed Sep 9 10:08:12 2009 @@ -62,11 +62,11 @@ : AST(ast), Filename(filename), DeclRefMap(ast->getASTContext()), SelMap(ast->getASTContext()) { } - + virtual ASTContext &getASTContext() { return AST->getASTContext(); } virtual DeclReferenceMap &getDeclReferenceMap() { return DeclRefMap; } virtual SelectorMap &getSelectorMap() { return SelMap; } - + llvm::OwningPtr AST; std::string Filename; DeclReferenceMap DeclRefMap; @@ -85,7 +85,7 @@ PrintDecls // Print declarations of the point-at node }; -static llvm::cl::opt +static llvm::cl::opt ProgAction( llvm::cl::desc("Choose action to perform on the pointed-at AST node:"), llvm::cl::ZeroOrMore, @@ -119,7 +119,7 @@ llvm::errs() << "Error: Cannot -print-refs on a ObjC message expression\n"; HadErrors = true; return; - + case PrintDecls: { Analyz.FindObjCMethods(Msg, Results); for (ResultsTy::iterator @@ -144,7 +144,7 @@ static void ProcessASTLocation(ASTLocation ASTLoc, Indexer &Idxer) { assert(ASTLoc.isValid()); - + if (ObjCMessageExpr *Msg = dyn_cast_or_null(ASTLoc.getStmt())) return ProcessObjCMessage(Msg, Idxer); @@ -210,20 +210,20 @@ llvm::PrettyStackTraceProgram X(argc, argv); llvm::cl::ParseCommandLineOptions(argc, argv, "LLVM 'Clang' Indexing Test Bed: http://clang.llvm.org\n"); - + FileManager FileMgr; Program Prog; Indexer Idxer(Prog, FileMgr); llvm::SmallVector TUnits; - + // If no input was specified, read from stdin. if (InputFilenames.empty()) InputFilenames.push_back("-"); for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) { const std::string &InFile = InputFilenames[i]; - + std::string ErrMsg; llvm::OwningPtr AST; @@ -235,7 +235,7 @@ TUnit *TU = new TUnit(AST.take(), InFile); TUnits.push_back(TU); - + Idxer.IndexAST(TU); } @@ -272,7 +272,7 @@ "Couldn't resolve source location (invalid location)\n"; return 1; } - + ASTLoc = ResolveLocationInAST(FirstAST->getASTContext(), Loc); if (ASTLoc.isInvalid()) { llvm::errs() << "[" << FirstFile << "] Error: " << @@ -280,7 +280,7 @@ return 1; } } - + if (ASTLoc.isValid()) { if (ProgAction == PrintPoint) { llvm::raw_ostream &OS = llvm::outs(); @@ -292,7 +292,7 @@ ProcessASTLocation(ASTLoc, Idxer); } } - + if (HadErrors) return 1; @@ -304,6 +304,6 @@ // Managed static deconstruction. Useful for making things like // -time-passes usable. llvm::llvm_shutdown(); - + return 0; } From mrs at apple.com Wed Sep 9 10:08:16 2009 From: mrs at apple.com (Mike Stump) Date: Wed, 09 Sep 2009 15:08:16 -0000 Subject: [cfe-commits] r81346 [1/6] - in /cfe/trunk: include/clang/AST/ include/clang/Analysis/ include/clang/Analysis/Analyses/ include/clang/Analysis/FlowSensitive/ include/clang/Analysis/PathSensitive/ include/clang/Analysis/Support/ include/clang/Analysis/Visitors/ include/clang/Basic/ include/clang/CodeGen/ include/clang/Driver/ include/clang/Frontend/ include/clang/Index/ include/clang/Lex/ include/clang/Parse/ include/clang/Rewrite/ include/clang/Sema/ lib/AST/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Front... Message-ID: <200909091508.n89F8bJA008160@zion.cs.uiuc.edu> Author: mrs Date: Wed Sep 9 10:08:12 2009 New Revision: 81346 URL: http://llvm.org/viewvc/llvm-project?rev=81346&view=rev Log: Remove tabs, and whitespace cleanups. Modified: cfe/trunk/include/clang/AST/APValue.h cfe/trunk/include/clang/AST/ASTConsumer.h cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/ASTDiagnostic.h cfe/trunk/include/clang/AST/Attr.h cfe/trunk/include/clang/AST/CanonicalType.h cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclBase.h cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/include/clang/AST/DeclContextInternals.h cfe/trunk/include/clang/AST/DeclGroup.h cfe/trunk/include/clang/AST/DeclObjC.h cfe/trunk/include/clang/AST/DeclTemplate.h cfe/trunk/include/clang/AST/DeclarationName.h cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/ExprObjC.h cfe/trunk/include/clang/AST/ExternalASTSource.h cfe/trunk/include/clang/AST/NestedNameSpecifier.h cfe/trunk/include/clang/AST/ParentMap.h cfe/trunk/include/clang/AST/PrettyPrinter.h cfe/trunk/include/clang/AST/RecordLayout.h cfe/trunk/include/clang/AST/Redeclarable.h cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/include/clang/AST/StmtGraphTraits.h cfe/trunk/include/clang/AST/StmtIterator.h cfe/trunk/include/clang/AST/StmtObjC.h cfe/trunk/include/clang/AST/StmtVisitor.h cfe/trunk/include/clang/AST/TemplateName.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/AST/TypeLoc.h cfe/trunk/include/clang/AST/TypeOrdering.h cfe/trunk/include/clang/AST/TypeVisitor.h cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h cfe/trunk/include/clang/Analysis/CFG.h cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowValues.h cfe/trunk/include/clang/Analysis/LocalCheckers.h cfe/trunk/include/clang/Analysis/PathDiagnostic.h cfe/trunk/include/clang/Analysis/PathSensitive/AnalysisContext.h cfe/trunk/include/clang/Analysis/PathSensitive/AnalysisManager.h cfe/trunk/include/clang/Analysis/PathSensitive/BasicValueFactory.h cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h cfe/trunk/include/clang/Analysis/PathSensitive/Checker.h cfe/trunk/include/clang/Analysis/PathSensitive/CheckerVisitor.h cfe/trunk/include/clang/Analysis/PathSensitive/ConstraintManager.h cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h cfe/trunk/include/clang/Analysis/PathSensitive/ExplodedGraph.h cfe/trunk/include/clang/Analysis/PathSensitive/GRAuditor.h cfe/trunk/include/clang/Analysis/PathSensitive/GRBlockCounter.h cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h cfe/trunk/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h cfe/trunk/include/clang/Analysis/PathSensitive/GRStateTrait.h cfe/trunk/include/clang/Analysis/PathSensitive/GRSubEngine.h cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h cfe/trunk/include/clang/Analysis/PathSensitive/SValuator.h cfe/trunk/include/clang/Analysis/PathSensitive/Store.h cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h cfe/trunk/include/clang/Analysis/ProgramPoint.h cfe/trunk/include/clang/Analysis/Support/BlkExprDeclBitVector.h cfe/trunk/include/clang/Analysis/Support/Optional.h cfe/trunk/include/clang/Analysis/Support/SaveAndRestore.h cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h cfe/trunk/include/clang/Analysis/Visitors/CFGStmtVisitor.h cfe/trunk/include/clang/Analysis/Visitors/CFGVarDeclVisitor.h cfe/trunk/include/clang/Basic/Builtins.h cfe/trunk/include/clang/Basic/ConvertUTF.h cfe/trunk/include/clang/Basic/Diagnostic.h cfe/trunk/include/clang/Basic/FileManager.h cfe/trunk/include/clang/Basic/IdentifierTable.h cfe/trunk/include/clang/Basic/LangOptions.h cfe/trunk/include/clang/Basic/OnDiskHashTable.h cfe/trunk/include/clang/Basic/SourceLocation.h cfe/trunk/include/clang/Basic/SourceManager.h cfe/trunk/include/clang/Basic/SourceManagerInternals.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/TokenKinds.h cfe/trunk/include/clang/CodeGen/ModuleBuilder.h cfe/trunk/include/clang/Driver/Action.h cfe/trunk/include/clang/Driver/Arg.h cfe/trunk/include/clang/Driver/ArgList.h cfe/trunk/include/clang/Driver/Compilation.h cfe/trunk/include/clang/Driver/Driver.h cfe/trunk/include/clang/Driver/DriverDiagnostic.h cfe/trunk/include/clang/Driver/HostInfo.h cfe/trunk/include/clang/Driver/Job.h cfe/trunk/include/clang/Driver/Option.h cfe/trunk/include/clang/Driver/Options.h cfe/trunk/include/clang/Driver/Tool.h cfe/trunk/include/clang/Frontend/ASTConsumers.h cfe/trunk/include/clang/Frontend/ASTUnit.h cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h cfe/trunk/include/clang/Frontend/CompileOptions.h cfe/trunk/include/clang/Frontend/DocumentXML.h cfe/trunk/include/clang/Frontend/FixItRewriter.h cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h cfe/trunk/include/clang/Frontend/ManagerRegistry.h cfe/trunk/include/clang/Frontend/PCHBitCodes.h cfe/trunk/include/clang/Frontend/PCHReader.h cfe/trunk/include/clang/Frontend/PCHWriter.h cfe/trunk/include/clang/Frontend/PathDiagnosticClients.h cfe/trunk/include/clang/Frontend/TextDiagnosticPrinter.h cfe/trunk/include/clang/Frontend/Utils.h cfe/trunk/include/clang/Index/ASTLocation.h cfe/trunk/include/clang/Index/DeclReferenceMap.h cfe/trunk/include/clang/Index/Entity.h cfe/trunk/include/clang/Index/GlobalSelector.h cfe/trunk/include/clang/Index/Handlers.h cfe/trunk/include/clang/Index/Indexer.h cfe/trunk/include/clang/Index/Program.h cfe/trunk/include/clang/Index/STLExtras.h cfe/trunk/include/clang/Index/SelectorMap.h cfe/trunk/include/clang/Lex/DirectoryLookup.h cfe/trunk/include/clang/Lex/HeaderMap.h cfe/trunk/include/clang/Lex/HeaderSearch.h cfe/trunk/include/clang/Lex/LexDiagnostic.h cfe/trunk/include/clang/Lex/Lexer.h cfe/trunk/include/clang/Lex/LiteralSupport.h cfe/trunk/include/clang/Lex/MacroInfo.h cfe/trunk/include/clang/Lex/MultipleIncludeOpt.h cfe/trunk/include/clang/Lex/PPCallbacks.h cfe/trunk/include/clang/Lex/PTHLexer.h cfe/trunk/include/clang/Lex/PTHManager.h cfe/trunk/include/clang/Lex/Pragma.h cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/include/clang/Lex/PreprocessorLexer.h cfe/trunk/include/clang/Lex/ScratchBuffer.h cfe/trunk/include/clang/Lex/Token.h cfe/trunk/include/clang/Lex/TokenConcatenation.h cfe/trunk/include/clang/Lex/TokenLexer.h cfe/trunk/include/clang/Parse/Action.h cfe/trunk/include/clang/Parse/AttributeList.h cfe/trunk/include/clang/Parse/DeclSpec.h cfe/trunk/include/clang/Parse/Designator.h cfe/trunk/include/clang/Parse/Ownership.h cfe/trunk/include/clang/Parse/ParseDiagnostic.h cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Parse/Scope.h cfe/trunk/include/clang/Rewrite/DeltaTree.h cfe/trunk/include/clang/Rewrite/HTMLRewrite.h cfe/trunk/include/clang/Rewrite/RewriteRope.h cfe/trunk/include/clang/Rewrite/Rewriter.h cfe/trunk/include/clang/Rewrite/TokenRewriter.h cfe/trunk/include/clang/Sema/ExternalSemaSource.h cfe/trunk/include/clang/Sema/ParseAST.h cfe/trunk/include/clang/Sema/SemaConsumer.h cfe/trunk/include/clang/Sema/SemaDiagnostic.h cfe/trunk/lib/AST/APValue.cpp cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/AST/DeclBase.cpp cfe/trunk/lib/AST/DeclCXX.cpp cfe/trunk/lib/AST/DeclObjC.cpp cfe/trunk/lib/AST/DeclPrinter.cpp cfe/trunk/lib/AST/DeclTemplate.cpp cfe/trunk/lib/AST/DeclarationName.cpp cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprCXX.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/InheritViz.cpp cfe/trunk/lib/AST/NestedNameSpecifier.cpp cfe/trunk/lib/AST/ParentMap.cpp cfe/trunk/lib/AST/RecordLayoutBuilder.cpp cfe/trunk/lib/AST/RecordLayoutBuilder.h cfe/trunk/lib/AST/Stmt.cpp cfe/trunk/lib/AST/StmtDumper.cpp cfe/trunk/lib/AST/StmtIterator.cpp cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/AST/StmtViz.cpp cfe/trunk/lib/AST/TemplateName.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/AnalysisContext.cpp cfe/trunk/lib/Analysis/AnalysisManager.cpp cfe/trunk/lib/Analysis/BasicConstraintManager.cpp cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.h cfe/trunk/lib/Analysis/BasicStore.cpp cfe/trunk/lib/Analysis/BasicValueFactory.cpp cfe/trunk/lib/Analysis/BugReporter.cpp cfe/trunk/lib/Analysis/BugReporterVisitors.cpp cfe/trunk/lib/Analysis/CFG.cpp cfe/trunk/lib/Analysis/CFRefCount.cpp cfe/trunk/lib/Analysis/CallGraph.cpp cfe/trunk/lib/Analysis/CheckDeadStores.cpp cfe/trunk/lib/Analysis/CheckNSError.cpp cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp cfe/trunk/lib/Analysis/CheckSecuritySyntaxOnly.cpp cfe/trunk/lib/Analysis/Environment.cpp cfe/trunk/lib/Analysis/ExplodedGraph.cpp cfe/trunk/lib/Analysis/GRBlockCounter.cpp cfe/trunk/lib/Analysis/GRCoreEngine.cpp cfe/trunk/lib/Analysis/GRExprEngine.cpp cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp cfe/trunk/lib/Analysis/GRState.cpp cfe/trunk/lib/Analysis/LiveVariables.cpp cfe/trunk/lib/Analysis/MemRegion.cpp cfe/trunk/lib/Analysis/PathDiagnostic.cpp cfe/trunk/lib/Analysis/RangeConstraintManager.cpp cfe/trunk/lib/Analysis/RegionStore.cpp cfe/trunk/lib/Analysis/SVals.cpp cfe/trunk/lib/Analysis/SValuator.cpp cfe/trunk/lib/Analysis/SimpleConstraintManager.cpp cfe/trunk/lib/Analysis/SimpleConstraintManager.h cfe/trunk/lib/Analysis/SimpleSValuator.cpp cfe/trunk/lib/Analysis/Store.cpp cfe/trunk/lib/Analysis/SymbolManager.cpp cfe/trunk/lib/Analysis/UninitializedValues.cpp cfe/trunk/lib/Analysis/ValueManager.cpp cfe/trunk/lib/Basic/Builtins.cpp cfe/trunk/lib/Basic/ConvertUTF.c cfe/trunk/lib/Basic/Diagnostic.cpp cfe/trunk/lib/Basic/FileManager.cpp cfe/trunk/lib/Basic/IdentifierTable.cpp cfe/trunk/lib/Basic/SourceLocation.cpp cfe/trunk/lib/Basic/SourceManager.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGBlocks.h cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CGCXX.cpp cfe/trunk/lib/CodeGen/CGCXX.h cfe/trunk/lib/CodeGen/CGCXXTemp.cpp cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CGCall.h cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGObjCGNU.cpp cfe/trunk/lib/CodeGen/CGObjCMac.cpp cfe/trunk/lib/CodeGen/CGObjCRuntime.h cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.h cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.h cfe/trunk/lib/CodeGen/Mangle.cpp cfe/trunk/lib/CodeGen/Mangle.h cfe/trunk/lib/CodeGen/ModuleBuilder.cpp cfe/trunk/lib/CodeGen/TargetABIInfo.cpp cfe/trunk/lib/Driver/Action.cpp cfe/trunk/lib/Driver/Arg.cpp cfe/trunk/lib/Driver/ArgList.cpp cfe/trunk/lib/Driver/Compilation.cpp cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/HostInfo.cpp cfe/trunk/lib/Driver/Job.cpp cfe/trunk/lib/Driver/OptTable.cpp cfe/trunk/lib/Driver/Option.cpp cfe/trunk/lib/Driver/Tool.cpp cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/lib/Driver/ToolChains.h cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Driver/Tools.h cfe/trunk/lib/Driver/Types.cpp cfe/trunk/lib/Frontend/ASTConsumers.cpp cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/lib/Frontend/AnalysisConsumer.cpp cfe/trunk/lib/Frontend/Backend.cpp cfe/trunk/lib/Frontend/CacheTokens.cpp cfe/trunk/lib/Frontend/DeclXML.cpp cfe/trunk/lib/Frontend/DependencyFile.cpp cfe/trunk/lib/Frontend/DiagChecker.cpp cfe/trunk/lib/Frontend/DocumentXML.cpp cfe/trunk/lib/Frontend/FixItRewriter.cpp cfe/trunk/lib/Frontend/GeneratePCH.cpp cfe/trunk/lib/Frontend/HTMLDiagnostics.cpp cfe/trunk/lib/Frontend/HTMLPrint.cpp cfe/trunk/lib/Frontend/InitHeaderSearch.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/lib/Frontend/PCHReader.cpp cfe/trunk/lib/Frontend/PCHReaderDecl.cpp cfe/trunk/lib/Frontend/PCHReaderStmt.cpp cfe/trunk/lib/Frontend/PCHWriter.cpp cfe/trunk/lib/Frontend/PCHWriterDecl.cpp cfe/trunk/lib/Frontend/PCHWriterStmt.cpp cfe/trunk/lib/Frontend/PlistDiagnostics.cpp cfe/trunk/lib/Frontend/PrintParserCallbacks.cpp cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp cfe/trunk/lib/Frontend/RewriteBlocks.cpp cfe/trunk/lib/Frontend/RewriteMacros.cpp cfe/trunk/lib/Frontend/RewriteObjC.cpp cfe/trunk/lib/Frontend/RewriteTest.cpp cfe/trunk/lib/Frontend/StmtXML.cpp cfe/trunk/lib/Frontend/TextDiagnosticBuffer.cpp cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp cfe/trunk/lib/Frontend/TypeXML.cpp cfe/trunk/lib/Frontend/Warnings.cpp cfe/trunk/lib/Headers/stdarg.h cfe/trunk/lib/Index/ASTLocation.cpp cfe/trunk/lib/Index/Analyzer.cpp cfe/trunk/lib/Index/DeclReferenceMap.cpp cfe/trunk/lib/Index/Entity.cpp cfe/trunk/lib/Index/EntityImpl.h cfe/trunk/lib/Index/GlobalSelector.cpp cfe/trunk/lib/Index/Indexer.cpp cfe/trunk/lib/Index/ProgramImpl.h cfe/trunk/lib/Index/ResolveLocation.cpp cfe/trunk/lib/Lex/HeaderMap.cpp cfe/trunk/lib/Lex/HeaderSearch.cpp cfe/trunk/lib/Lex/Lexer.cpp cfe/trunk/lib/Lex/LiteralSupport.cpp cfe/trunk/lib/Lex/MacroArgs.cpp cfe/trunk/lib/Lex/MacroArgs.h cfe/trunk/lib/Lex/MacroInfo.cpp cfe/trunk/lib/Lex/PPCaching.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PPExpressions.cpp cfe/trunk/lib/Lex/PPLexerChange.cpp cfe/trunk/lib/Lex/PPMacroExpansion.cpp cfe/trunk/lib/Lex/PTHLexer.cpp cfe/trunk/lib/Lex/Pragma.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/lib/Lex/PreprocessorLexer.cpp cfe/trunk/lib/Lex/ScratchBuffer.cpp cfe/trunk/lib/Lex/TokenConcatenation.cpp cfe/trunk/lib/Lex/TokenLexer.cpp cfe/trunk/lib/Parse/AttributeList.cpp cfe/trunk/lib/Parse/DeclSpec.cpp cfe/trunk/lib/Parse/ExtensionRAIIObject.h cfe/trunk/lib/Parse/MinimalAction.cpp cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Parse/ParseInit.cpp cfe/trunk/lib/Parse/ParseObjc.cpp cfe/trunk/lib/Parse/ParsePragma.cpp cfe/trunk/lib/Parse/ParsePragma.h cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Parse/ParseTemplate.cpp cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/lib/Parse/Parser.cpp cfe/trunk/lib/Rewrite/DeltaTree.cpp cfe/trunk/lib/Rewrite/HTMLRewrite.cpp cfe/trunk/lib/Rewrite/RewriteRope.cpp cfe/trunk/lib/Rewrite/Rewriter.cpp cfe/trunk/lib/Rewrite/TokenRewriter.cpp cfe/trunk/lib/Sema/IdentifierResolver.cpp cfe/trunk/lib/Sema/IdentifierResolver.h cfe/trunk/lib/Sema/JumpDiagnostics.cpp cfe/trunk/lib/Sema/ParseAST.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/Sema.h cfe/trunk/lib/Sema/SemaAccess.cpp cfe/trunk/lib/Sema/SemaAttr.cpp cfe/trunk/lib/Sema/SemaCXXCast.cpp cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaExprObjC.cpp cfe/trunk/lib/Sema/SemaInherit.cpp cfe/trunk/lib/Sema/SemaInherit.h cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaLookup.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Sema/SemaOverload.h cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/Analysis/cfref_rdar6080742.c cfe/trunk/test/CodeGen/asm.c cfe/trunk/test/CodeGen/attr-cleanup.c cfe/trunk/test/CodeGen/conditional.c cfe/trunk/test/CodeGen/debug-info.c cfe/trunk/test/CodeGen/exprs.c cfe/trunk/test/CodeGen/functions.c cfe/trunk/test/CodeGen/global-with-initialiser.c cfe/trunk/test/CodeGen/globalinit.c cfe/trunk/test/CodeGen/init-with-member-expr.c cfe/trunk/test/CodeGen/regparm.c cfe/trunk/test/CodeGen/staticinit.c cfe/trunk/test/CodeGen/struct-init.c cfe/trunk/test/CodeGen/struct.c cfe/trunk/test/CodeGen/union-init.c cfe/trunk/test/CodeGen/vector.c cfe/trunk/test/CodeGenCXX/constructor-conversion.cpp cfe/trunk/test/CodeGenCXX/constructor-default-arg.cpp cfe/trunk/test/CodeGenCXX/constructor-for-array-members.cpp cfe/trunk/test/CodeGenCXX/constructor-init.cpp cfe/trunk/test/CodeGenCXX/constructor-template.cpp cfe/trunk/test/CodeGenCXX/conversion-function.cpp cfe/trunk/test/CodeGenCXX/copy-assign-synthesis-1.cpp cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis.cpp cfe/trunk/test/CodeGenCXX/default-constructor-for-members.cpp cfe/trunk/test/CodeGenCXX/default-destructor-synthesis.cpp cfe/trunk/test/CodeGenCXX/nested-base-member-access.cpp cfe/trunk/test/CodeGenCXX/virt.cpp cfe/trunk/test/Lexer/comment-escape.c cfe/trunk/test/Parser/MicrosoftExtensions.c cfe/trunk/test/Parser/cxx-friend.cpp cfe/trunk/test/Parser/cxx-template-decl.cpp cfe/trunk/test/Preprocessor/assembler-with-cpp.c cfe/trunk/test/Sema/array-init.c cfe/trunk/test/Sema/attr-deprecated.c cfe/trunk/test/Sema/block-call.c cfe/trunk/test/Sema/block-explicit-return-type.c cfe/trunk/test/Sema/block-literal.c cfe/trunk/test/Sema/block-misc.c cfe/trunk/test/Sema/block-printf-attribute-1.c cfe/trunk/test/Sema/block-return.c cfe/trunk/test/Sema/block-sentinel-attribute.c cfe/trunk/test/Sema/c89-2.c cfe/trunk/test/Sema/c89.c cfe/trunk/test/Sema/complex-int.c cfe/trunk/test/Sema/conditional.c cfe/trunk/test/Sema/darwin-align-cast.c cfe/trunk/test/Sema/floating-point-compare.c cfe/trunk/test/Sema/function-pointer-sentinel-attribute.c cfe/trunk/test/Sema/function-sentinel-attr.c cfe/trunk/test/Sema/implicit-int.c cfe/trunk/test/Sema/predefined-function.c cfe/trunk/test/Sema/static-init.c cfe/trunk/test/Sema/struct-decl.c cfe/trunk/test/Sema/transparent-union-pointer.c cfe/trunk/test/SemaCXX/abstract.cpp cfe/trunk/test/SemaCXX/access-control-check.cpp cfe/trunk/test/SemaCXX/attr-format.cpp cfe/trunk/test/SemaCXX/class-base-member-init.cpp cfe/trunk/test/SemaCXX/constructor-initializer.cpp cfe/trunk/test/SemaCXX/copy-constructor-error.cpp cfe/trunk/test/SemaCXX/default-assignment-operator.cpp cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp cfe/trunk/test/SemaCXX/enum.cpp cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp cfe/trunk/test/SemaCXX/inherit.cpp cfe/trunk/test/SemaCXX/member-expr-static.cpp cfe/trunk/test/SemaCXX/static-initializers.cpp cfe/trunk/test/SemaCXX/warn-reorder-ctor-initialization.cpp cfe/trunk/tools/clang-cc/clang-cc.cpp cfe/trunk/tools/index-test/index-test.cpp Modified: cfe/trunk/include/clang/AST/APValue.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/APValue.h (original) +++ cfe/trunk/include/clang/AST/APValue.h Wed Sep 9 10:08:12 2009 @@ -37,16 +37,16 @@ }; private: ValueKind Kind; - - struct ComplexAPSInt { - APSInt Real, Imag; + + struct ComplexAPSInt { + APSInt Real, Imag; ComplexAPSInt() : Real(1), Imag(1) {} }; struct ComplexAPFloat { APFloat Real, Imag; ComplexAPFloat() : Real(0.0), Imag(0.0) {} }; - + struct LV { Expr* Base; uint64_t Offset; @@ -57,9 +57,9 @@ Vec() : Elts(0), NumElts(0) {} ~Vec() { delete[] Elts; } }; - + enum { - MaxSize = (sizeof(ComplexAPSInt) > sizeof(ComplexAPFloat) ? + MaxSize = (sizeof(ComplexAPSInt) > sizeof(ComplexAPFloat) ? sizeof(ComplexAPSInt) : sizeof(ComplexAPFloat)) }; @@ -94,7 +94,7 @@ ~APValue() { MakeUninit(); } - + ValueKind getKind() const { return Kind; } bool isUninit() const { return Kind == Uninitialized; } bool isInt() const { return Kind == Int; } @@ -103,10 +103,10 @@ bool isComplexFloat() const { return Kind == ComplexFloat; } bool isLValue() const { return Kind == LValue; } bool isVector() const { return Kind == Vector; } - + void print(llvm::raw_ostream &OS) const; void dump() const; - + APSInt &getInt() { assert(isInt() && "Invalid accessor"); return *(APSInt*)(char*)Data; @@ -114,7 +114,7 @@ const APSInt &getInt() const { return const_cast(this)->getInt(); } - + APFloat &getFloat() { assert(isFloat() && "Invalid accessor"); return *(APFloat*)(char*)Data; @@ -122,7 +122,7 @@ const APFloat &getFloat() const { return const_cast(this)->getFloat(); } - + APValue &getVectorElt(unsigned i) const { assert(isVector() && "Invalid accessor"); return ((Vec*)(char*)Data)->Elts[i]; @@ -131,7 +131,7 @@ assert(isVector() && "Invalid accessor"); return ((Vec*)(void *)Data)->NumElts; } - + APSInt &getComplexIntReal() { assert(isComplexInt() && "Invalid accessor"); return ((ComplexAPSInt*)(char*)Data)->Real; @@ -139,7 +139,7 @@ const APSInt &getComplexIntReal() const { return const_cast(this)->getComplexIntReal(); } - + APSInt &getComplexIntImag() { assert(isComplexInt() && "Invalid accessor"); return ((ComplexAPSInt*)(char*)Data)->Imag; @@ -147,7 +147,7 @@ const APSInt &getComplexIntImag() const { return const_cast(this)->getComplexIntImag(); } - + APFloat &getComplexFloatReal() { assert(isComplexFloat() && "Invalid accessor"); return ((ComplexAPFloat*)(char*)Data)->Real; @@ -172,7 +172,7 @@ assert(isLValue() && "Invalid accessor"); return ((const LV*)(const void*)Data)->Offset; } - + void setInt(const APSInt &I) { assert(isInt() && "Invalid accessor"); *(APSInt*)(char*)Data = I; @@ -189,14 +189,14 @@ ((Vec*)(char*)Data)->Elts[i] = E[i]; } void setComplexInt(const APSInt &R, const APSInt &I) { - assert(R.getBitWidth() == I.getBitWidth() && + assert(R.getBitWidth() == I.getBitWidth() && "Invalid complex int (type mismatch)."); assert(isComplexInt() && "Invalid accessor"); ((ComplexAPSInt*)(char*)Data)->Real = R; ((ComplexAPSInt*)(char*)Data)->Imag = I; } void setComplexFloat(const APFloat &R, const APFloat &I) { - assert(&R.getSemantics() == &I.getSemantics() && + assert(&R.getSemantics() == &I.getSemantics() && "Invalid complex float (type mismatch)."); assert(isComplexFloat() && "Invalid accessor"); ((ComplexAPFloat*)(char*)Data)->Real = R; @@ -207,9 +207,9 @@ ((LV*)(char*)Data)->Base = B; ((LV*)(char*)Data)->Offset = O; } - + const APValue &operator=(const APValue &RHS); - + private: void MakeUninit(); void MakeInt() { @@ -248,7 +248,7 @@ V.print(OS); return OS; } - + } // end namespace clang. #endif Modified: cfe/trunk/include/clang/AST/ASTConsumer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ASTConsumer.h (original) +++ cfe/trunk/include/clang/AST/ASTConsumer.h Wed Sep 9 10:08:12 2009 @@ -36,27 +36,27 @@ ASTConsumer() : SemaConsumer(false) { } virtual ~ASTConsumer() {} - + /// Initialize - This is called to initialize the consumer, providing the /// ASTContext and the Action. virtual void Initialize(ASTContext &Context) {} - + /// HandleTopLevelDecl - Handle the specified top-level declaration. This is /// called by the parser to process every top-level Decl*. Note that D can /// be the head of a chain of Decls (e.g. for `int a, b` the chain will have /// two elements). Use Decl::getNextDeclarator() to walk the chain. virtual void HandleTopLevelDecl(DeclGroupRef D); - + /// HandleTranslationUnit - This method is called when the ASTs for entire /// translation unit have been parsed. - virtual void HandleTranslationUnit(ASTContext &Ctx) {} - + virtual void HandleTranslationUnit(ASTContext &Ctx) {} + /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl /// (e.g. struct, union, enum, class) is completed. This allows the client to /// hack on the type, which can occur at any point in the file (because these /// can be defined in declspecs). virtual void HandleTagDeclDefinition(TagDecl *D) {} - + /// \brief Callback invoked at the end of a translation unit to /// notify the consumer that the given tentative definition should /// be completed. Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Sep 9 10:08:12 2009 @@ -56,12 +56,12 @@ class TypedefDecl; class UnresolvedUsingDecl; class UsingDecl; - + namespace Builtin { class Context; } - + /// ASTContext - This class holds long-lived AST nodes (such as types and /// decls) that can be referred to throughout the semantic analysis of a file. -class ASTContext { +class ASTContext { std::vector Types; llvm::FoldingSet ExtQualTypes; llvm::FoldingSet ComplexTypes; @@ -87,7 +87,7 @@ llvm::FoldingSet ObjCInterfaceTypes; llvm::FoldingSet ObjCObjectPointerTypes; llvm::FoldingSet ElaboratedTypes; - + llvm::FoldingSet QualifiedTemplateNames; llvm::FoldingSet DependentTemplateNames; @@ -108,7 +108,7 @@ llvm::DenseMap SignedFixedWidthIntTypes; llvm::DenseMap UnsignedFixedWidthIntTypes; - + /// BuiltinVaListType - built-in va list type. /// This is initially null and set by Sema::LazilyCreateBuiltin when /// a builtin that takes a valist is encountered. @@ -116,33 +116,33 @@ /// ObjCIdType - a pseudo built-in typedef type (set by Sema). QualType ObjCIdTypedefType; - + /// ObjCSelType - another pseudo built-in typedef type (set by Sema). QualType ObjCSelType; const RecordType *SelStructType; - + /// ObjCProtoType - another pseudo built-in typedef type (set by Sema). QualType ObjCProtoType; const RecordType *ProtoStructType; /// ObjCClassType - another pseudo built-in typedef type (set by Sema). QualType ObjCClassTypedefType; - + QualType ObjCConstantStringType; RecordDecl *CFConstantStringTypeDecl; RecordDecl *ObjCFastEnumerationStateTypeDecl; - + /// \brief The type for the C FILE type. TypeDecl *FILEDecl; - + /// \brief The type for the C jmp_buf type. TypeDecl *jmp_bufDecl; - + /// \brief The type for the C sigjmp_buf type. TypeDecl *sigjmp_bufDecl; - - /// \brief Keeps track of all declaration attributes. + + /// \brief Keeps track of all declaration attributes. /// /// Since so few decls have attrs, we keep them in a hash map instead of /// wasting space in the Decl class. @@ -153,7 +153,7 @@ /// /// This data structure stores the mapping from instantiations of static /// data members to the static data member representations within the - /// class template from which they were instantiated. + /// class template from which they were instantiated. /// /// Given the following example: /// @@ -169,11 +169,11 @@ /// int *x = &X::value; /// \endcode /// - /// This mapping will contain an entry that maps from the VarDecl for + /// This mapping will contain an entry that maps from the VarDecl for /// X::value to the corresponding VarDecl for X::value (within the - /// class template X). + /// class template X). llvm::DenseMap InstantiatedFromStaticDataMember; - + /// \brief Keeps track of the UnresolvedUsingDecls from which UsingDecls /// where created during instantiation. /// @@ -196,14 +196,14 @@ /// B to the UnresolvedUsingDecl in B. llvm::DenseMap InstantiatedFromUnresolvedUsingDecl; - + llvm::DenseMap InstantiatedFromUnnamedFieldDecl; - + TranslationUnitDecl *TUDecl; /// SourceMgr - The associated SourceManager object. SourceManager &SourceMgr; - + /// LangOpts - The language options used to create the AST associated with /// this ASTContext object. LangOptions LangOpts; @@ -211,17 +211,17 @@ /// \brief Whether we have already loaded comment source ranges from an /// external source. bool LoadedExternalComments; - + /// MallocAlloc/BumpAlloc - The allocator objects used to create AST objects. bool FreeMemory; llvm::MallocAllocator MallocAlloc; llvm::BumpPtrAllocator BumpAlloc; - + /// \brief Mapping from declarations to their comments, once we have /// already looked up the comment associated with a given declaration. llvm::DenseMap DeclComments; - -public: + +public: TargetInfo &Target; IdentifierTable &Idents; SelectorTable &Selectors; @@ -238,38 +238,38 @@ /// \brief Source ranges for all of the comments in the source file, /// sorted in order of appearance in the translation unit. std::vector Comments; - + SourceManager& getSourceManager() { return SourceMgr; } const SourceManager& getSourceManager() const { return SourceMgr; } void *Allocate(unsigned Size, unsigned Align = 8) { return FreeMemory ? MallocAlloc.Allocate(Size, Align) : BumpAlloc.Allocate(Size, Align); } - void Deallocate(void *Ptr) { + void Deallocate(void *Ptr) { if (FreeMemory) - MallocAlloc.Deallocate(Ptr); + MallocAlloc.Deallocate(Ptr); } const LangOptions& getLangOptions() const { return LangOpts; } - - FullSourceLoc getFullLoc(SourceLocation Loc) const { + + FullSourceLoc getFullLoc(SourceLocation Loc) const { return FullSourceLoc(Loc,SourceMgr); } /// \brief Retrieve the attributes for the given declaration. Attr*& getDeclAttrs(const Decl *D) { return DeclAttrs[D]; } - + /// \brief Erase the attributes corresponding to the given declaration. void eraseDeclAttrs(const Decl *D) { DeclAttrs.erase(D); } /// \brief If this variable is an instantiated static data member of a - /// class template specialization, returns the templated static data member + /// class template specialization, returns the templated static data member /// from which it was instantiated. VarDecl *getInstantiatedFromStaticDataMember(VarDecl *Var); - + /// \brief Note that the static data member \p Inst is an instantiation of /// the static data member template \p Tmpl of a class template. - void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl); - + void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl); + /// \brief If this using decl is instantiated from an unresolved using decl, /// return it. UnresolvedUsingDecl *getInstantiatedFromUnresolvedUsingDecl(UsingDecl *UUD); @@ -278,17 +278,17 @@ /// the unresolved using decl \p Tmpl of a class template. void setInstantiatedFromUnresolvedUsingDecl(UsingDecl *Inst, UnresolvedUsingDecl *Tmpl); - - + + FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field); - + void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl); - + TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; } - + const char *getCommentForDecl(const Decl *D); - + // Builtin Types. QualType VoidTy; QualType BoolTy; @@ -331,27 +331,27 @@ //===--------------------------------------------------------------------===// // Type Constructors //===--------------------------------------------------------------------===// - - /// getAddSpaceQualType - Return the uniqued reference to the type for an - /// address space qualified type with the specified type and address space. - /// The resulting type has a union of the qualifiers from T and the address - /// space. If T already has an address space specifier, it is silently + + /// getAddSpaceQualType - Return the uniqued reference to the type for an + /// address space qualified type with the specified type and address space. + /// The resulting type has a union of the qualifiers from T and the address + /// space. If T already has an address space specifier, it is silently /// replaced. QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace); - + /// getObjCGCQualType - Returns the uniqued reference to the type for an /// objc gc qualified type. The retulting type has a union of the qualifiers /// from T and the gc attribute. QualType getObjCGCQualType(QualType T, QualType::GCAttrTypes gcAttr); - + /// getNoReturnType - Add the noreturn attribute to the given type which must /// be a FunctionType or a pointer to an allowable type or a BlockPointer. QualType getNoReturnType(QualType T); - + /// getComplexType - Return the uniqued reference to the type for a complex /// number with the specified element type. QualType getComplexType(QualType T); - + /// getPointerType - Return the uniqued reference to the type for a pointer to /// the specified type. QualType getPointerType(QualType T); @@ -379,7 +379,7 @@ ArrayType::ArraySizeModifier ASM, unsigned EltTypeQuals, SourceRange Brackets); - + /// getDependentSizedArrayType - Returns a non-unique reference to /// the type for a dependently-sized array of the specified element /// type. FIXME: We will need these to be uniqued, or at least @@ -430,7 +430,7 @@ /// the type for a dependently-sized vector of the specified element /// type. FIXME: We will need these to be uniqued, or at least /// comparable, at some point. - QualType getDependentSizedExtVectorType(QualType VectorType, + QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc); @@ -455,7 +455,7 @@ /// specified typename decl. QualType getTypedefType(TypedefDecl *Decl); - QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, + QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, IdentifierInfo *Name = 0); @@ -466,17 +466,17 @@ QualType getQualifiedNameType(NestedNameSpecifier *NNS, QualType NamedType); - QualType getTypenameType(NestedNameSpecifier *NNS, + QualType getTypenameType(NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon = QualType()); - QualType getTypenameType(NestedNameSpecifier *NNS, + QualType getTypenameType(NestedNameSpecifier *NNS, const TemplateSpecializationType *TemplateId, QualType Canon = QualType()); QualType getElaboratedType(QualType UnderlyingType, ElaboratedType::TagKind Tag); QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, - ObjCProtocolDecl **Protocols = 0, + ObjCProtocolDecl **Protocols = 0, unsigned NumProtocols = 0); /// getObjCObjectPointerType - Return a ObjCObjectPointerType type for the @@ -484,18 +484,18 @@ QualType getObjCObjectPointerType(QualType OIT, ObjCProtocolDecl **ProtocolList = 0, unsigned NumProtocols = 0); - + /// getTypeOfType - GCC extension. QualType getTypeOfExprType(Expr *e); QualType getTypeOfType(QualType t); - + /// getDecltypeType - C++0x decltype. QualType getDecltypeType(Expr *e); - + /// getTagDeclType - Return the unique reference to the type for the /// specified TagDecl (struct/union/class/enum) decl. QualType getTagDeclType(const TagDecl *Decl); - + /// getSizeType - Return the unique type for "size_t" (C99 7.17), defined /// in . The sizeof operator requires this (C99 6.5.3.4p4). QualType getSizeType() const; @@ -512,15 +512,15 @@ /// getUnsignedWCharType - Return the type of "unsigned wchar_t". /// Used when in C++, as a GCC extension. QualType getUnsignedWCharType() const; - + /// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?) /// defined in . Pointer - pointer requires this (C99 6.5.6p9). QualType getPointerDiffType() const; - + // getCFConstantStringType - Return the C structure type used to represent // constant CFStrings. - QualType getCFConstantStringType(); - + QualType getCFConstantStringType(); + /// Get the structure type used to representation CFStrings, or NULL /// if it hasn't yet been built. QualType getRawCFConstantStringType() { @@ -532,13 +532,13 @@ // This setter/getter represents the ObjC type for an NSConstantString. void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl); - QualType getObjCConstantStringInterface() const { - return ObjCConstantStringType; + QualType getObjCConstantStringInterface() const { + return ObjCConstantStringType; } //// This gets the struct used to keep track of fast enumerations. QualType getObjCFastEnumerationStateType(); - + /// Get the ObjCFastEnumerationState type, or NULL if it hasn't yet /// been built. QualType getRawObjCFastEnumerationStateType() { @@ -551,10 +551,10 @@ /// \brief Set the type for the C FILE type. void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; } - + /// \brief Retrieve the C FILE type. - QualType getFILEType() { - if (FILEDecl) + QualType getFILEType() { + if (FILEDecl) return getTypeDeclType(FILEDecl); return QualType(); } @@ -563,10 +563,10 @@ void setjmp_bufDecl(TypeDecl *jmp_bufDecl) { this->jmp_bufDecl = jmp_bufDecl; } - + /// \brief Retrieve the C jmp_buf type. - QualType getjmp_bufType() { - if (jmp_bufDecl) + QualType getjmp_bufType() { + if (jmp_bufDecl) return getTypeDeclType(jmp_bufDecl); return QualType(); } @@ -575,41 +575,41 @@ void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) { this->sigjmp_bufDecl = sigjmp_bufDecl; } - + /// \brief Retrieve the C sigjmp_buf type. - QualType getsigjmp_bufType() { - if (sigjmp_bufDecl) + QualType getsigjmp_bufType() { + if (sigjmp_bufDecl) return getTypeDeclType(sigjmp_bufDecl); return QualType(); } - + /// getObjCEncodingForType - Emit the ObjC type encoding for the /// given type into \arg S. If \arg NameFields is specified then /// record field names are also encoded. - void getObjCEncodingForType(QualType t, std::string &S, + void getObjCEncodingForType(QualType t, std::string &S, const FieldDecl *Field=0); void getLegacyIntegralTypeEncoding(QualType &t) const; - + // Put the string version of type qualifiers into S. - void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, + void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const; - + /// getObjCEncodingForMethodDecl - Return the encoded type for this method /// declaration. void getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S); - + /// getObjCEncodingForPropertyDecl - Return the encoded type for /// this method declaration. If non-NULL, Container must be either /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should /// only be NULL when getting encodings for protocol properties. - void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, + void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, const Decl *Container, std::string &S); - + bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto); - + /// getObjCEncodingTypeSize returns size of type for objective-c encoding /// purpose. int getObjCEncodingTypeSize(QualType t); @@ -618,32 +618,32 @@ /// Sema. id is always a (typedef for a) pointer type, a pointer to a struct. QualType getObjCIdType() const { return ObjCIdTypedefType; } void setObjCIdType(QualType T); - + void setObjCSelType(QualType T); QualType getObjCSelType() const { return ObjCSelType; } - + void setObjCProtoType(QualType QT); QualType getObjCProtoType() const { return ObjCProtoType; } - + /// This setter/getter repreents the ObjC 'Class' type. It is setup lazily, by /// Sema. 'Class' is always a (typedef for a) pointer type, a pointer to a /// struct. QualType getObjCClassType() const { return ObjCClassTypedefType; } void setObjCClassType(QualType T); - + void setBuiltinVaListType(QualType T); QualType getBuiltinVaListType() const { return BuiltinVaListType; } QualType getFixedWidthIntType(unsigned Width, bool Signed); - TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, + TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template); - TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, + TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, OverloadedFunctionDecl *Template); - - TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, + + TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name); enum GetBuiltinTypeError { @@ -651,42 +651,42 @@ GE_Missing_stdio, //< Missing a type from GE_Missing_setjmp //< Missing a type from }; - + /// GetBuiltinType - Return the type for the specified builtin. QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error); - + private: QualType getFromTargetType(unsigned Type) const; //===--------------------------------------------------------------------===// // Type Predicates. //===--------------------------------------------------------------------===// - + public: /// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's /// garbage collection attribute. /// QualType::GCAttrTypes getObjCGCAttrKind(const QualType &Ty) const; - + /// isObjCNSObjectType - Return true if this is an NSObject object with /// its NSObject attribute set. bool isObjCNSObjectType(QualType Ty) const; - + //===--------------------------------------------------------------------===// // Type Sizing and Analysis //===--------------------------------------------------------------------===// - + /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified /// scalar floating point type. const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const; - + /// getTypeInfo - Get the size and alignment of the specified complete type in /// bits. std::pair getTypeInfo(const Type *T); std::pair getTypeInfo(QualType T) { return getTypeInfo(T.getTypePtr()); } - + /// getTypeSize - Return the size of the specified type, in bits. This method /// does not work on incomplete types. uint64_t getTypeSize(QualType T) { @@ -695,7 +695,7 @@ uint64_t getTypeSize(const Type *T) { return getTypeInfo(T).first; } - + /// getTypeAlign - Return the ABI-specified alignment of a type, in bits. /// This method does not work on incomplete types. unsigned getTypeAlign(QualType T) { @@ -704,23 +704,23 @@ unsigned getTypeAlign(const Type *T) { return getTypeInfo(T).second; } - + /// getPreferredTypeAlign - Return the "preferred" alignment of the specified /// type for the current target in bits. This can be different than the ABI /// alignment in cases where it is beneficial for performance to overalign /// a data type. unsigned getPreferredTypeAlign(const Type *T); - + /// getDeclAlignInBytes - Return the alignment of the specified decl /// that should be returned by __alignof(). Note that bitfields do /// not have a valid alignment, so this method will assert on them. unsigned getDeclAlignInBytes(const Decl *D); - + /// getASTRecordLayout - Get or compute information about the layout of the /// specified record (struct/union/class), which indicates its size and field /// position information. const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D); - + /// getASTObjCInterfaceLayout - Get or compute information about the /// layout of the specified Objective-C interface. const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D); @@ -747,7 +747,7 @@ //===--------------------------------------------------------------------===// // Type Operators //===--------------------------------------------------------------------===// - + /// getCanonicalType - Return the canonical (structural) type corresponding to /// the specified potentially non-canonical type. The non-canonical version /// of a type may have many "decorated" versions of types. Decorators can @@ -763,7 +763,7 @@ bool hasSameType(QualType T1, QualType T2) { return getCanonicalType(T1) == getCanonicalType(T2); } - + /// \brief Determine whether the given types are equivalent after /// cvr-qualifiers have been removed. bool hasSameUnqualifiedType(QualType T1, QualType T2) { @@ -772,7 +772,7 @@ return T1.getUnqualifiedType() == T2.getUnqualifiedType(); } - /// \brief Retrieves the "canonical" declaration of + /// \brief Retrieves the "canonical" declaration of /// \brief Retrieves the "canonical" nested name specifier for a /// given nested name specifier. @@ -822,11 +822,11 @@ /// \brief Retrieve the "canonical" template argument. /// - /// The canonical template argument is the simplest template argument - /// (which may be a type, value, expression, or declaration) that + /// The canonical template argument is the simplest template argument + /// (which may be a type, value, expression, or declaration) that /// expresses the value of the argument. TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg); - + /// Type Query functions. If the type is an instance of the specified class, /// return the Type pointer for the underlying maximally pretty type. This /// is a member of ASTContext because this may need to do some amount of @@ -849,10 +849,10 @@ /// getBaseElementType - Returns the innermost element type of a type /// (which needn't actually be an array type). QualType getBaseElementType(QualType QT); - + /// getConstantArrayElementCount - Returns number of constant array elements. uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const; - + /// getArrayDecayedType - Return the properly qualified result of decaying the /// specified array type to a pointer. This operation is non-trivial when /// handling typedefs etc. The canonical type of "T" must be an array type, @@ -860,7 +860,7 @@ /// /// See C99 6.7.5.3p7 and C99 6.3.2.1p3. QualType getArrayDecayedType(QualType T); - + /// getPromotedIntegerType - Returns the type that Promotable will /// promote to: C99 6.3.1.1p2, assuming that Promotable is a promotable /// integer type. @@ -873,22 +873,22 @@ /// promotion occurs. QualType isPromotableBitField(Expr *E); - /// getIntegerTypeOrder - Returns the highest ranked integer type: + /// getIntegerTypeOrder - Returns the highest ranked integer type: /// C99 6.3.1.8p1. If LHS > RHS, return 1. If LHS == RHS, return 0. If - /// LHS < RHS, return -1. + /// LHS < RHS, return -1. int getIntegerTypeOrder(QualType LHS, QualType RHS); - + /// getFloatingTypeOrder - Compare the rank of the two specified floating /// point types, ignoring the domain of the type (i.e. 'double' == /// '_Complex double'). If LHS > RHS, return 1. If LHS == RHS, return 0. If - /// LHS < RHS, return -1. + /// LHS < RHS, return -1. int getFloatingTypeOrder(QualType LHS, QualType RHS); - /// getFloatingTypeOfSizeWithinDomain - Returns a real floating - /// point or a complex type (based on typeDomain/typeSize). + /// getFloatingTypeOfSizeWithinDomain - Returns a real floating + /// point or a complex type (based on typeDomain/typeSize). /// 'typeDomain' is a real floating point or complex type. /// 'typeSize' is a real floating point or complex type. - QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize, + QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize, QualType typeDomain) const; private: @@ -900,10 +900,10 @@ //===--------------------------------------------------------------------===// // Type Compatibility Predicates //===--------------------------------------------------------------------===// - + /// Compatibility predicates used to check assignment expressions. bool typesAreCompatible(QualType, QualType); // C99 6.2.7p1 - + bool isObjCIdType(QualType T) const { return T == ObjCIdTypedefType; } @@ -950,15 +950,15 @@ //===--------------------------------------------------------------------===// // Type Iterators. //===--------------------------------------------------------------------===// - + typedef std::vector::iterator type_iterator; typedef std::vector::const_iterator const_type_iterator; - + type_iterator types_begin() { return Types.begin(); } type_iterator types_end() { return Types.end(); } const_type_iterator types_begin() const { return Types.begin(); } - const_type_iterator types_end() const { return Types.end(); } - + const_type_iterator types_end() const { return Types.end(); } + //===--------------------------------------------------------------------===// // Integer Values //===--------------------------------------------------------------------===// @@ -996,12 +996,12 @@ private: ASTContext(const ASTContext&); // DO NOT IMPLEMENT void operator=(const ASTContext&); // DO NOT IMPLEMENT - + void InitBuiltinTypes(); void InitBuiltinType(QualType &R, BuiltinType::Kind K); - + // Return the ObjC type encoding for a given type. - void getObjCEncodingForTypeImpl(QualType t, std::string &S, + void getObjCEncodingForTypeImpl(QualType t, std::string &S, bool ExpandPointedToStructures, bool ExpandStructures, const FieldDecl *Field, @@ -1009,7 +1009,7 @@ bool EncodingProperty = false); const ASTRecordLayout &getObjCLayout(const ObjCInterfaceDecl *D, - const ObjCImplementationDecl *Impl); + const ObjCImplementationDecl *Impl); }; } // end namespace clang Modified: cfe/trunk/include/clang/AST/ASTDiagnostic.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDiagnostic.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ASTDiagnostic.h (original) +++ cfe/trunk/include/clang/AST/ASTDiagnostic.h Wed Sep 9 10:08:12 2009 @@ -13,7 +13,7 @@ #include "clang/Basic/Diagnostic.h" namespace clang { - namespace diag { + namespace diag { enum { #define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define ASTSTART Modified: cfe/trunk/include/clang/AST/Attr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Attr.h (original) +++ cfe/trunk/include/clang/AST/Attr.h Wed Sep 9 10:08:12 2009 @@ -57,7 +57,7 @@ DLLImport, Deprecated, Destructor, - FastCall, + FastCall, Format, FormatArg, GNUInline, @@ -83,14 +83,14 @@ StdCall, TransparentUnion, Unavailable, - Unused, + Unused, Used, Visibility, WarnUnusedResult, Weak, WeakImport }; - + private: Attr *Next; Kind AttrKind; @@ -104,16 +104,16 @@ void operator delete(void* data) throw() { assert(0 && "Attrs cannot be released with regular 'delete'."); } - + protected: Attr(Kind AK) : Next(0), AttrKind(AK), Inherited(false) {} virtual ~Attr() { assert(Next == 0 && "Destroy didn't work"); } public: - + void Destroy(ASTContext &C); - + /// \brief Whether this attribute should be merged to new /// declarations. virtual bool isMerged() const { return true; } @@ -130,18 +130,18 @@ return V; return 0; } - + bool isInherited() const { return Inherited; } void setInherited(bool value) { Inherited = value; } void addAttr(Attr *attr) { assert((attr != 0) && "addAttr(): attr is null"); - + // FIXME: This doesn't preserve the order in any way. attr->Next = Next; Next = attr; } - + // Clone this attribute. virtual Attr* clone(ASTContext &C) const = 0; @@ -169,8 +169,8 @@ /// getAlignment - The specified alignment in bits. unsigned getAlignment() const { return Alignment; } - virtual Attr* clone(ASTContext &C) const { - return ::new (C) PragmaPackAttr(Alignment); + virtual Attr* clone(ASTContext &C) const { + return ::new (C) PragmaPackAttr(Alignment); } // Implement isa/cast/dyncast/etc. @@ -179,7 +179,7 @@ } static bool classof(const PragmaPackAttr *A) { return true; } }; - + class AlignedAttr : public Attr { unsigned Alignment; public: @@ -189,7 +189,7 @@ unsigned getAlignment() const { return Alignment; } virtual Attr* clone(ASTContext &C) const { return ::new (C) AlignedAttr(Alignment); } - + // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Aligned; @@ -201,11 +201,11 @@ std::string Annotation; public: AnnotateAttr(const std::string &ann) : Attr(Annotate), Annotation(ann) {} - + const std::string& getAnnotation() const { return Annotation; } virtual Attr* clone(ASTContext &C) const { return ::new (C) AnnotateAttr(Annotation); } - + // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Annotate; @@ -217,11 +217,11 @@ std::string Label; public: AsmLabelAttr(const std::string &L) : Attr(AsmLabel), Label(L) {} - + const std::string& getLabel() const { return Label; } - + virtual Attr* clone(ASTContext &C) const { return ::new (C) AsmLabelAttr(Label); } - + // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == AsmLabel; @@ -251,28 +251,28 @@ ConstructorAttr(int p) : Attr(Constructor), priority(p) {} int getPriority() const { return priority; } - + virtual Attr *clone(ASTContext &C) const { return ::new (C) ConstructorAttr(priority); } // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Constructor; } + static bool classof(const Attr *A) { return A->getKind() == Constructor; } static bool classof(const ConstructorAttr *A) { return true; } -}; - +}; + class DestructorAttr : public Attr { int priority; public: DestructorAttr(int p) : Attr(Destructor), priority(p) {} int getPriority() const { return priority; } - + virtual Attr *clone(ASTContext &C) const { return ::new (C) DestructorAttr(priority); } // Implement isa/cast/dyncast/etc. - static bool classof(const Attr *A) { return A->getKind() == Destructor; } + static bool classof(const Attr *A) { return A->getKind() == Destructor; } static bool classof(const DestructorAttr *A) { return true; } -}; - +}; + class GNUInlineAttr : public Attr { public: GNUInlineAttr() : Attr(GNUInline) {} @@ -301,14 +301,14 @@ DEF_SIMPLE_ATTR(Malloc); DEF_SIMPLE_ATTR(NoReturn); -DEF_SIMPLE_ATTR(AnalyzerNoReturn); +DEF_SIMPLE_ATTR(AnalyzerNoReturn); DEF_SIMPLE_ATTR(Deprecated); class SectionAttr : public Attr { std::string Name; public: SectionAttr(const std::string &N) : Attr(Section), Name(N) {} - + const std::string& getName() const { return Name; } virtual Attr *clone(ASTContext &C) const { return ::new (C) SectionAttr(Name); } @@ -322,8 +322,8 @@ DEF_SIMPLE_ATTR(Unavailable); DEF_SIMPLE_ATTR(Unused); -DEF_SIMPLE_ATTR(Used); -DEF_SIMPLE_ATTR(Weak); +DEF_SIMPLE_ATTR(Used); +DEF_SIMPLE_ATTR(Weak); DEF_SIMPLE_ATTR(WeakImport); DEF_SIMPLE_ATTR(NoThrow); DEF_SIMPLE_ATTR(Const); @@ -335,14 +335,14 @@ public: NonNullAttr(unsigned* arg_nums = 0, unsigned size = 0) : Attr(NonNull), ArgNums(0), Size(0) { - + if (size == 0) return; assert(arg_nums); ArgNums = new unsigned[size]; Size = size; memcpy(ArgNums, arg_nums, sizeof(*ArgNums)*size); } - + virtual ~NonNullAttr() { delete [] ArgNums; } @@ -354,7 +354,7 @@ bool isNonNull(unsigned arg) const { return ArgNums ? std::binary_search(ArgNums, ArgNums+Size, arg) : true; - } + } virtual Attr *clone(ASTContext &C) const { return ::new (C) NonNullAttr(ArgNums, Size); } @@ -374,8 +374,8 @@ int getFormatIdx() const { return formatIdx; } int getFirstArg() const { return firstArg; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) FormatAttr(Type, formatIdx, firstArg); + virtual Attr *clone(ASTContext &C) const { + return ::new (C) FormatAttr(Type, formatIdx, firstArg); } // Implement isa/cast/dyncast/etc. @@ -452,8 +452,8 @@ virtual bool isMerged() const { return false; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) OverloadableAttr; + virtual Attr *clone(ASTContext &C) const { + return ::new (C) OverloadableAttr; } static bool classof(const Attr *A) { return A->getKind() == Overloadable; } @@ -480,15 +480,15 @@ }; class FunctionDecl; - + class CleanupAttr : public Attr { FunctionDecl *FD; - + public: CleanupAttr(FunctionDecl *fd) : Attr(Cleanup), FD(fd) {} const FunctionDecl *getFunctionDecl() const { return FD; } - + virtual Attr *clone(ASTContext &C) const { return ::new (C) CleanupAttr(FD); } // Implement isa/cast/dyncast/etc. @@ -497,7 +497,7 @@ }; DEF_SIMPLE_ATTR(NoDebug); -DEF_SIMPLE_ATTR(WarnUnusedResult); +DEF_SIMPLE_ATTR(WarnUnusedResult); DEF_SIMPLE_ATTR(NoInline); class RegparmAttr : public Attr { @@ -508,11 +508,11 @@ unsigned getNumParams() const { return NumParams; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) RegparmAttr(NumParams); + virtual Attr *clone(ASTContext &C) const { + return ::new (C) RegparmAttr(NumParams); } - // Implement isa/cast/dyncast/etc. + // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == Regparm; } static bool classof(const RegparmAttr *A) { return true; } }; @@ -527,23 +527,23 @@ unsigned getYDim() const { return Y; } unsigned getZDim() const { return Z; } - virtual Attr *clone(ASTContext &C) const { - return ::new (C) ReqdWorkGroupSizeAttr(X, Y, Z); + virtual Attr *clone(ASTContext &C) const { + return ::new (C) ReqdWorkGroupSizeAttr(X, Y, Z); } - + // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() == ReqdWorkGroupSize; } static bool classof(const ReqdWorkGroupSizeAttr *A) { return true; } }; - + // Checker-specific attributes. DEF_SIMPLE_ATTR(CFReturnsRetained); DEF_SIMPLE_ATTR(NSReturnsRetained); #undef DEF_SIMPLE_ATTR - + } // end namespace clang #endif Modified: cfe/trunk/include/clang/AST/CanonicalType.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/CanonicalType.h (original) +++ cfe/trunk/include/clang/AST/CanonicalType.h Wed Sep 9 10:08:12 2009 @@ -21,69 +21,69 @@ #include namespace clang { - + template class CanProxy; template struct CanProxyAdaptor; //----------------------------------------------------------------------------// // Canonical, qualified type template //----------------------------------------------------------------------------// - + /// \brief Represents a canonical, potentially-qualified type. /// /// The CanQual template is a lightweight smart pointer that provides access /// to the canonical representation of a type, where all typedefs and other -/// syntactic sugar has been eliminated. A CanQualType may also have various +/// syntactic sugar has been eliminated. A CanQualType may also have various /// qualifiers (const, volatile, restrict) attached to it. /// -/// The template type parameter @p T is one of the Type classes (PointerType, +/// The template type parameter @p T is one of the Type classes (PointerType, /// BuiltinType, etc.). The type stored within @c CanQual will be of that /// type (or some subclass of that type). The typedef @c CanQualType is just /// a shorthand for @c CanQual. /// -/// An instance of @c CanQual can be implicitly converted to a +/// An instance of @c CanQual can be implicitly converted to a /// @c CanQual when T is derived from U, which essentially provides an -/// implicit upcast. For example, @c CanQual can be -/// converted to @c CanQual. Note that any @c CanQual type can +/// implicit upcast. For example, @c CanQual can be +/// converted to @c CanQual. Note that any @c CanQual type can /// be implicitly converted to a QualType, but the reverse operation requires /// a call to ASTContext::getCanonicalType(). -/// -/// +/// +/// template class CanQual { - /// \brief The actual, canonical type. + /// \brief The actual, canonical type. QualType Stored; - + public: /// \brief Constructs a NULL canonical type. CanQual() : Stored() { } - + /// \brief Converting constructor that permits implicit upcasting of /// canonical type pointers. template - CanQual(const CanQual& Other, + CanQual(const CanQual& Other, typename llvm::enable_if, int>::type = 0); - + /// \brief Implicit conversion to the underlying pointer. /// /// Also provides the ability to use canonical types in a boolean context, - /// e.g., + /// e.g., /// @code /// if (CanQual Ptr = T->getAs()) { ... } /// @endcode operator const T*() const { return getTypePtr(); } - - /// \brief Retrieve the underlying type pointer, which refers to a + + /// \brief Retrieve the underlying type pointer, which refers to a /// canonical type. T *getTypePtr() const { return cast_or_null(Stored.getTypePtr()); } - + /// \brief Implicit conversion to a qualified type. operator QualType() const { return Stored; } - + /// \brief Retrieve a canonical type pointer with a different static type, /// upcasting or downcasting as needed. /// - /// The getAs() function is typically used to try to downcast to a + /// The getAs() function is typically used to try to downcast to a /// more specific (canonical) type in the type system. For example: /// /// @code @@ -98,17 +98,17 @@ /// static type (@p U). If the dynamic type is not the specified static type /// or a derived class thereof, a NULL canonical type. template CanProxy getAs() const; - + /// \brief Overloaded arrow operator that produces a canonical type /// proxy. CanProxy operator->() const; - + /// \brief Retrieve the const/volatile/restrict qualifiers. unsigned getCVRQualifiers() const { return Stored.getCVRQualifiers(); } - + /// \brief Set the const/volatile/restrict qualifiers void setCVRQualifiers(unsigned Quals) { Stored.setCVRQualifiers(Quals); } - + bool isConstQualified() const { return (getCVRQualifiers() & QualType::Const) ? true : false; } @@ -117,42 +117,42 @@ } bool isRestrictQualified() const { return (getCVRQualifiers() & QualType::Restrict) ? true : false; - } - + } + /// \brief Retrieve the unqualified form of this type. CanQual getUnqualifiedType() const; - + CanQual getQualifiedType(unsigned TQs) const { return CanQual::CreateUnsafe(QualType(getTypePtr(), TQs)); } - - /// \brief Determines whether this canonical type is more qualified than + + /// \brief Determines whether this canonical type is more qualified than /// the @p Other canonical type. bool isMoreQualifiedThan(CanQual Other) const { return Stored.isMoreQualifiedThan(Other.Stored); } - + /// \brief Determines whether this canonical type is at least as qualified as /// the @p Other canonical type. bool isAtLeastAsQualifiedAs(CanQual Other) const { return Stored.isAtLeastAsQualifiedAs(Other.Stored); } - + /// \brief If the canonical type is a reference type, returns the type that /// it refers to; otherwise, returns the type itself. CanQual getNonReferenceType() const; - + /// \brief Retrieve the internal representation of this canonical type. void *getAsOpaquePtr() const { return Stored.getAsOpaquePtr(); } - + /// \brief Construct a canonical type from its internal representation. static CanQual getFromOpaquePtr(void *Ptr); - + /// \brief Builds a canonical type from a QualType. /// - /// This routine is inherently unsafe, because it requires the user to - /// ensure that the given type is a canonical type with the correct - // (dynamic) type. + /// This routine is inherently unsafe, because it requires the user to + /// ensure that the given type is a canonical type with the correct + // (dynamic) type. static CanQual CreateUnsafe(QualType Other); }; @@ -172,7 +172,7 @@ //----------------------------------------------------------------------------// // Internal proxy classes used by canonical types //----------------------------------------------------------------------------// - + #define LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(Accessor) \ CanQualType Accessor() const { \ return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor()); \ @@ -183,32 +183,32 @@ /// \brief Base class of all canonical proxy types, which is responsible for /// storing the underlying canonical type and providing basic conversions. -template +template class CanProxyBase { protected: CanQual Stored; - + public: /// \brief Retrieve the pointer to the underlying Type T* getTypePtr() const { return Stored.getTypePtr(); } - + /// \brief Implicit conversion to the underlying pointer. /// /// Also provides the ability to use canonical type proxies in a Boolean - // context,e.g., + // context,e.g., /// @code /// if (CanQual Ptr = T->getAs()) { ... } /// @endcode operator const T*() const { return this->Stored.getTypePtr(); } - + /// \brief Try to convert the given canonical type to a specific structural /// type. - template CanProxy getAs() const { - return this->Stored.template getAs(); + template CanProxy getAs() const { + return this->Stored.template getAs(); } - + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type::TypeClass, getTypeClass) - + // Type predicates LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjectType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIncompleteType) @@ -271,44 +271,44 @@ /// that provide accessors returning canonical types (@c CanQualType) rather /// than the more typical @c QualType, to propagate the notion of "canonical" /// through the system. -template +template struct CanProxyAdaptor : CanProxyBase { }; /// \brief Canonical proxy type returned when retrieving the members of a -/// canonical type or as the result of the @c CanQual::getAs member +/// canonical type or as the result of the @c CanQual::getAs member /// function. /// /// The CanProxy type mainly exists as a proxy through which operator-> will -/// look to either map down to a raw T* (e.g., PointerType*) or to a proxy +/// look to either map down to a raw T* (e.g., PointerType*) or to a proxy /// type that provides canonical-type access to the fields of the type. template class CanProxy : public CanProxyAdaptor { public: /// \brief Build a NULL proxy. CanProxy() { } - + /// \brief Build a proxy to the given canonical type. CanProxy(CanQual Stored) { this->Stored = Stored; } - + /// \brief Implicit conversion to the stored canonical type. operator CanQual() const { return this->Stored; } }; - + } // end namespace clang namespace llvm { - -/// Implement simplify_type for CanQual, so that we can dyn_cast from + +/// Implement simplify_type for CanQual, so that we can dyn_cast from /// CanQual to a specific Type class. We're prefer isa/dyn_cast/cast/etc. /// to return smart pointer (proxies?). -template +template struct simplify_type > { typedef T* SimpleType; static SimpleType getSimplifiedValue(const ::clang::CanQual &Val) { return Val.getTypePtr(); } }; -template +template struct simplify_type< ::clang::CanQual > : public simplify_type > {}; @@ -325,21 +325,21 @@ // CVR qualifiers go in low bits. enum { NumLowBitsAvailable = 0 }; }; - + } // end namespace llvm namespace clang { - + //----------------------------------------------------------------------------// // Canonical proxy adaptors for canonical type nodes. //----------------------------------------------------------------------------// - -/// \brief Iterator adaptor that turns an iterator over canonical QualTypes + +/// \brief Iterator adaptor that turns an iterator over canonical QualTypes /// into an iterator over CanQualTypes. template class CanTypeIterator { InputIterator Iter; - + public: typedef CanQualType value_type; typedef value_type reference; @@ -348,62 +348,62 @@ difference_type; typedef typename std::iterator_traits::iterator_category iterator_category; - + CanTypeIterator() : Iter() { } explicit CanTypeIterator(InputIterator Iter) : Iter(Iter) { } - + // Input iterator reference operator*() const { return CanQualType::CreateUnsafe(*Iter); } - + pointer operator->() const; - + CanTypeIterator &operator++() { ++Iter; return *this; } - + CanTypeIterator operator++(int) { CanTypeIterator Tmp(*this); ++Iter; return Tmp; } - + friend bool operator==(const CanTypeIterator& X, const CanTypeIterator &Y) { return X.Iter == Y.Iter; } friend bool operator!=(const CanTypeIterator& X, const CanTypeIterator &Y) { return X.Iter != Y.Iter; } - + // Bidirectional iterator CanTypeIterator &operator--() { --Iter; return *this; } - + CanTypeIterator operator--(int) { CanTypeIterator Tmp(*this); --Iter; return Tmp; } - + // Random access iterator reference operator[](difference_type n) const { return CanQualType::CreateUnsafe(Iter[n]); } - + CanTypeIterator &operator+=(difference_type n) { Iter += n; return *this; } - + CanTypeIterator &operator-=(difference_type n) { Iter -= n; return *this; } - + friend CanTypeIterator operator+(CanTypeIterator X, difference_type n) { X += n; return X; @@ -413,15 +413,15 @@ X += n; return X; } - + friend CanTypeIterator operator-(CanTypeIterator X, difference_type n) { X -= n; return X; } - - friend difference_type operator-(const CanTypeIterator &X, + + friend difference_type operator-(const CanTypeIterator &X, const CanTypeIterator &Y) { - return X - Y; + return X - Y; } }; @@ -431,7 +431,7 @@ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(QualType::GCAttrTypes, getObjCGCAttr) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getAddressSpace) }; - + template<> struct CanProxyAdaptor : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) @@ -441,66 +441,60 @@ struct CanProxyAdaptor : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType) }; - + template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType) }; - + template<> struct CanProxyAdaptor : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType) }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType) }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType) }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Type *, getClass) }; - + template<> struct CanProxyAdaptor : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, getSizeModifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier) }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, getSizeModifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const llvm::APInt &, getSize) }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, getSizeModifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const llvm::APInt &, getSize) @@ -509,34 +503,31 @@ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getLBracketLoc) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getRBracketLoc) }; - + template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, getSizeModifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const llvm::APInt &, getSize) }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, getSizeModifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier) }; - + template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier, getSizeModifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Expr *, getSizeExpr) @@ -546,9 +537,8 @@ }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Expr *, getSizeExpr) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceRange, getBracketsRange) @@ -557,14 +547,13 @@ }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Expr *, getSizeExpr) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getAttributeLoc) + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getAttributeLoc) }; - + template<> struct CanProxyAdaptor : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType) @@ -583,28 +572,26 @@ }; template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getResultType) }; - + template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getResultType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumArgs); + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumArgs); CanQualType getArgType(unsigned i) const { return CanQualType::CreateUnsafe(this->getTypePtr()->getArgType(i)); } - + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariadic) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getTypeQuals) - - typedef CanTypeIterator + + typedef CanTypeIterator arg_type_iterator; - + arg_type_iterator arg_type_begin() const { return arg_type_iterator(this->getTypePtr()->arg_type_begin()); } @@ -612,10 +599,10 @@ arg_type_iterator arg_type_end() const { return arg_type_iterator(this->getTypePtr()->arg_type_end()); } - + // Note: canonical function types never have exception specifications }; - + template<> struct CanProxyAdaptor : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getUnderlyingType) @@ -638,44 +625,42 @@ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(RecordDecl *, getDecl) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBeingDefined) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasConstFields) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getAddressSpace) + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getAddressSpace) }; - + template<> struct CanProxyAdaptor : public CanProxyBase { LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(EnumDecl *, getDecl) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBeingDefined) }; - + template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getDepth) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndex) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isParameterPack) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(IdentifierInfo *, getName) + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(IdentifierInfo *, getName) }; - + template<> -struct CanProxyAdaptor - : public CanProxyBase -{ +struct CanProxyAdaptor + : public CanProxyBase { LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceType *, + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceType *, getInterfaceType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCIdType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCClassType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedIdType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClassType) - + typedef ObjCObjectPointerType::qual_iterator qual_iterator; LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumProtocols) }; - + //----------------------------------------------------------------------------// // Method and function definitions //----------------------------------------------------------------------------// @@ -698,12 +683,12 @@ CanQual CanQual::getFromOpaquePtr(void *Ptr) { CanQual Result; Result.Stored.setFromOpaqueValue(Ptr); - assert((!Result || Result.Stored.isCanonical()) + assert((!Result || Result.Stored.isCanonical()) && "Type is not canonical!"); return Result; } -template +template CanQual CanQual::CreateUnsafe(QualType Other) { assert((Other.isNull() || Other->isCanonical()) && "Type is not canonical!"); assert((Other.isNull() || isa(Other.getTypePtr())) && @@ -713,19 +698,19 @@ return Result; } -template -template +template +template CanProxy CanQual::getAs() const { if (Stored.isNull()) return CanProxy(); - + if (isa(Stored.getTypePtr())) return CanQual::CreateUnsafe(Stored); - + if (const ExtQualType *EQ = Stored->getAs()) return CanQual::CreateUnsafe(QualType(EQ->getBaseType(), 0)) .template getAs(); - + return CanProxy(); } @@ -733,13 +718,13 @@ CanProxy CanQual::operator->() const { return CanProxy(*this); } - + template -typename CanTypeIterator::pointer +typename CanTypeIterator::pointer CanTypeIterator::operator->() const { return CanProxy(*this); } - + } Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Wed Sep 9 10:08:12 2009 @@ -53,18 +53,18 @@ /// TranslationUnitDecl - The top declaration context. class TranslationUnitDecl : public Decl, public DeclContext { ASTContext &Ctx; - + explicit TranslationUnitDecl(ASTContext &ctx) : Decl(TranslationUnit, 0, SourceLocation()), DeclContext(TranslationUnit), Ctx(ctx) {} public: ASTContext &getASTContext() const { return Ctx; } - + static TranslationUnitDecl *Create(ASTContext &C); // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == TranslationUnit; } - static bool classof(const TranslationUnitDecl *D) { return true; } + static bool classof(const TranslationUnitDecl *D) { return true; } static DeclContext *castToDeclContext(const TranslationUnitDecl *D) { return static_cast(const_cast(D)); } @@ -113,7 +113,7 @@ /// manipulation, so it should be called only when performance doesn't matter. /// For simple declarations, getNameAsCString() should suffice. std::string getNameAsString() const { return Name.getAsString(); } - + /// getQualifiedNameAsString - Returns human-readable qualified name for /// declaration, like A::B::i, for i being member of namespace A::B. /// If declaration is not member of context which can be named (record, @@ -141,7 +141,7 @@ const NamedDecl *getUnderlyingDecl() const { return const_cast(this)->getUnderlyingDecl(); } - + static bool classof(const Decl *D) { return D->getKind() >= NamedFirst && D->getKind() <= NamedLast; } @@ -151,7 +151,7 @@ /// NamespaceDecl - Represent a C++ namespace. class NamespaceDecl : public NamedDecl, public DeclContext { SourceLocation LBracLoc, RBracLoc; - + // For extended namespace definitions: // // namespace A { int x; } @@ -162,7 +162,7 @@ // OrigNamespace points to the original namespace declaration. // OrigNamespace of the first namespace decl points to itself. NamespaceDecl *OrigNamespace, *NextNamespace; - + NamespaceDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id) : NamedDecl(Namespace, DC, L, Id), DeclContext(Namespace) { OrigNamespace = this; @@ -171,7 +171,7 @@ public: static NamespaceDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id); - + virtual void Destroy(ASTContext& C); NamespaceDecl *getNextNamespace() { return NextNamespace; } @@ -182,7 +182,7 @@ return OrigNamespace; } void setOriginalNamespace(NamespaceDecl *ND) { OrigNamespace = ND; } - + virtual SourceRange getSourceRange() const { return SourceRange(getLocation(), RBracLoc); } @@ -191,7 +191,7 @@ SourceLocation getRBracLoc() const { return RBracLoc; } void setLBracLoc(SourceLocation LBrace) { LBracLoc = LBrace; } void setRBracLoc(SourceLocation RBrace) { RBracLoc = RBrace; } - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == Namespace; } static bool classof(const NamespaceDecl *D) { return true; } @@ -203,20 +203,20 @@ } }; -/// ValueDecl - Represent the declaration of a variable (in which case it is +/// ValueDecl - Represent the declaration of a variable (in which case it is /// an lvalue) a function (in which case it is a function designator) or -/// an enum constant. +/// an enum constant. class ValueDecl : public NamedDecl { QualType DeclType; protected: ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, - DeclarationName N, QualType T) + DeclarationName N, QualType T) : NamedDecl(DK, DC, L, N), DeclType(T) {} public: QualType getType() const { return DeclType; } void setType(QualType newType) { DeclType = newType; } - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= ValueFirst && D->getKind() <= ValueLast; @@ -287,23 +287,23 @@ /// argument. struct UnparsedDefaultArgument; - /// \brief Placeholder type used in Init to denote an uninstantiated C++ + /// \brief Placeholder type used in Init to denote an uninstantiated C++ /// default argument. struct UninstantiatedDefaultArgument; - typedef llvm::PointerUnion4 InitType; - - /// \brief The initializer for this variable or, for a ParmVarDecl, the + + /// \brief The initializer for this variable or, for a ParmVarDecl, the /// C++ default argument. mutable InitType Init; - + private: // FIXME: This can be packed into the bitfields in Decl. unsigned SClass : 3; bool ThreadSpecified : 1; - bool HasCXXDirectInit : 1; + bool HasCXXDirectInit : 1; /// DeclaredInCondition - Whether this variable was declared in a /// condition, e.g., if (int x = foo()) { ... }. @@ -315,8 +315,8 @@ QualType T, DeclaratorInfo *DInfo, StorageClass SC) : DeclaratorDecl(DK, DC, L, Id, T, DInfo), Init(), ThreadSpecified(false), HasCXXDirectInit(false), - DeclaredInCondition(false) { - SClass = SC; + DeclaredInCondition(false) { + SClass = SC; } typedef Redeclarable redeclarable_base; @@ -326,7 +326,7 @@ typedef redeclarable_base::redecl_iterator redecl_iterator; redecl_iterator redecls_begin() const { return redeclarable_base::redecls_begin(); - } + } redecl_iterator redecls_end() const { return redeclarable_base::redecls_end(); } @@ -340,10 +340,10 @@ StorageClass getStorageClass() const { return (StorageClass)SClass; } void setStorageClass(StorageClass SC) { SClass = SC; } - + virtual SourceRange getSourceRange() const; - const Expr *getInit() const { + const Expr *getInit() const { if (Init.isNull()) return 0; @@ -352,9 +352,9 @@ if (EvaluatedStmt *ES = Init.dyn_cast()) S = ES->Value; } - return (const Expr*) S; + return (const Expr*) S; } - Expr *getInit() { + Expr *getInit() { if (Init.isNull()) return 0; @@ -364,26 +364,26 @@ S = ES->Value; } - return (Expr*) S; + return (Expr*) S; } /// \brief Retrieve the address of the initializer expression. Stmt **getInitAddress() { if (EvaluatedStmt *ES = Init.dyn_cast()) return &ES->Value; - + // This union hack tip-toes around strict-aliasing rules. union { InitType *InitPtr; Stmt **StmtPtr; }; - + InitPtr = &Init; return StmtPtr; } void setInit(ASTContext &C, Expr *I); - + /// \brief Note that constant evaluation has computed the given /// value for this variable's initializer. void setEvaluatedValue(ASTContext &C, const APValue &Value) const { @@ -398,7 +398,7 @@ Eval->WasEvaluated = true; Eval->Evaluated = Value; } - + /// \brief Return the already-evaluated value of this variable's /// initializer, or NULL if the value is not yet known. APValue *getEvaluatedValue() const { @@ -423,7 +423,7 @@ /// /// \pre isInitKnownICE() bool isInitICE() const { - assert(isInitKnownICE() && + assert(isInitKnownICE() && "Check whether we already know that the initializer is an ICE"); return Init.get()->IsICE; } @@ -465,7 +465,7 @@ bool hasCXXDirectInitializer() const { return HasCXXDirectInit; } - + /// isDeclaredInCondition - Whether this variable was declared as /// part of a condition in an if/switch/while statement, e.g., /// @code @@ -474,8 +474,8 @@ bool isDeclaredInCondition() const { return DeclaredInCondition; } - void setDeclaredInCondition(bool InCondition) { - DeclaredInCondition = InCondition; + void setDeclaredInCondition(bool InCondition) { + DeclaredInCondition = InCondition; } virtual VarDecl *getCanonicalDecl(); @@ -485,10 +485,10 @@ bool hasLocalStorage() const { if (getStorageClass() == None) return !isFileVarDecl(); - + // Return true for: Auto, Register. // Return false for: Extern, Static, PrivateExtern. - + return getStorageClass() <= Register; } @@ -515,7 +515,7 @@ return DC->getLookupContext()->isFunctionOrMethod(); return false; } - + /// \brief Determines whether this is a static data member. /// /// This will only be true in C++, and applies to, e.g., the @@ -530,10 +530,10 @@ } /// \brief If this variable is an instantiated static data member of a - /// class template specialization, returns the templated static data member + /// class template specialization, returns the templated static data member /// from which it was instantiated. - VarDecl *getInstantiatedFromStaticDataMember(); - + VarDecl *getInstantiatedFromStaticDataMember(); + /// isFileVarDecl - Returns true for file scoped variable declaration. bool isFileVarDecl() const { if (getKind() != Decl::Var) @@ -545,14 +545,14 @@ } if (isStaticDataMember()) return true; - + return false; } /// \brief Determine whether this is a tentative definition of a /// variable in C. bool isTentativeDefinition(ASTContext &Context) const; - + /// \brief Determines whether this variable is a variable with /// external, C linkage. bool isExternC(ASTContext &Context) const; @@ -567,7 +567,7 @@ class ImplicitParamDecl : public VarDecl { protected: ImplicitParamDecl(Kind DK, DeclContext *DC, SourceLocation L, - IdentifierInfo *Id, QualType Tw) + IdentifierInfo *Id, QualType Tw) : VarDecl(DK, DC, L, Id, Tw, /*DInfo=*/0, VarDecl::None) {} public: static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC, @@ -584,15 +584,15 @@ /// FIXME: Also can be paced into the bitfields in Decl. /// in, inout, etc. unsigned objcDeclQualifier : 6; - - /// \brief Retrieves the fake "value" of an unparsed + + /// \brief Retrieves the fake "value" of an unparsed static Expr *getUnparsedDefaultArgValue() { uintptr_t Value = (uintptr_t)-1; // Mask off the low bits Value &= ~(uintptr_t)0x07; return reinterpret_cast (Value); } - + protected: ParmVarDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, @@ -606,27 +606,27 @@ SourceLocation L,IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, StorageClass S, Expr *DefArg); - + ObjCDeclQualifier getObjCDeclQualifier() const { return ObjCDeclQualifier(objcDeclQualifier); } void setObjCDeclQualifier(ObjCDeclQualifier QTVal) { objcDeclQualifier = QTVal; } - - const Expr *getDefaultArg() const { + + const Expr *getDefaultArg() const { assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!"); - assert(!hasUninstantiatedDefaultArg() && + assert(!hasUninstantiatedDefaultArg() && "Default argument is not yet instantiated!"); return getInit(); } - Expr *getDefaultArg() { + Expr *getDefaultArg() { assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!"); - assert(!hasUninstantiatedDefaultArg() && + assert(!hasUninstantiatedDefaultArg() && "Default argument is not yet instantiated!"); return getInit(); } - void setDefaultArg(Expr *defarg) { + void setDefaultArg(Expr *defarg) { Init = reinterpret_cast(defarg); } @@ -636,14 +636,14 @@ Expr *getUninstantiatedDefaultArg() { return (Expr *)Init.get(); } - + /// hasDefaultArg - Determines whether this parameter has a default argument, /// either parsed or not. bool hasDefaultArg() const { - return getInit() || hasUnparsedDefaultArg() || + return getInit() || hasUnparsedDefaultArg() || hasUninstantiatedDefaultArg(); } - + /// hasUnparsedDefaultArg - Determines whether this parameter has a /// default argument that has not yet been parsed. This will occur /// during the processing of a C++ class whose member functions have @@ -661,18 +661,18 @@ bool hasUninstantiatedDefaultArg() const { return Init.is(); } - + /// setUnparsedDefaultArg - Specify that this parameter has an /// unparsed default argument. The argument will be replaced with a /// real default argument via setDefaultArg when the class /// definition enclosing the function declaration that owns this /// default argument is completed. - void setUnparsedDefaultArg() { + void setUnparsedDefaultArg() { Init = (UnparsedDefaultArgument *)0; } QualType getOriginalType() const; - + /// setOwningFunction - Sets the function declaration that owns this /// ParmVarDecl. Since ParmVarDecls are often created before the /// FunctionDecls that own them, this routine is required to update @@ -680,9 +680,9 @@ void setOwningFunction(DeclContext *FD) { setDeclContext(FD); } // Implement isa/cast/dyncast/etc. - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return (D->getKind() == ParmVar || - D->getKind() == OriginalParmVar); + D->getKind() == OriginalParmVar); } static bool classof(const ParmVarDecl *D) { return true; } }; @@ -698,7 +698,7 @@ private: OriginalParmVarDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, - DeclaratorInfo *DInfo, + DeclaratorInfo *DInfo, QualType OT, StorageClass S, Expr *DefArg) : ParmVarDecl(OriginalParmVar, DC, L, Id, T, DInfo, S, DefArg), @@ -715,7 +715,7 @@ static bool classof(const Decl *D) { return D->getKind() == OriginalParmVar; } static bool classof(const OriginalParmVarDecl *D) { return true; } }; - + // \brief Describes the kind of template specialization that a // particular template specialization declaration represents. enum TemplateSpecializationKind { @@ -730,17 +730,17 @@ /// specialization (C++ [temp.class.spec]). TSK_ExplicitSpecialization, /// This template specialization was instantiated from a template - /// due to an explicit instantiation declaration request + /// due to an explicit instantiation declaration request /// (C++0x [temp.explicit]). TSK_ExplicitInstantiationDeclaration, /// This template specialization was instantiated from a template - /// due to an explicit instantiation definition request + /// due to an explicit instantiation definition request /// (C++ [temp.explicit]). - TSK_ExplicitInstantiationDefinition + TSK_ExplicitInstantiationDefinition }; - + /// FunctionDecl - An instance of this class is created to represent a -/// function declaration or definition. +/// function declaration or definition. /// /// Since a given function can be declared several times in a program, /// there may be several FunctionDecls that correspond to that @@ -749,20 +749,20 @@ /// FunctionDecl (e.g., the translation unit); this FunctionDecl /// contains all of the information known about the function. Other, /// previous declarations of the function are available via the -/// getPreviousDeclaration() chain. +/// getPreviousDeclaration() chain. class FunctionDecl : public DeclaratorDecl, public DeclContext, public Redeclarable { public: enum StorageClass { None, Extern, Static, PrivateExtern }; - -private: + +private: /// ParamInfo - new[]'d array of pointers to VarDecls for the formal /// parameters of this function. This is null if a prototype or if there are /// no formals. ParmVarDecl **ParamInfo; - + LazyDeclStmtPtr Body; // FIXME: This can be packed into the bitfields in Decl. @@ -778,7 +778,7 @@ bool IsTrivial : 1; // sunk from CXXMethodDecl bool IsCopyAssignment : 1; // sunk from CXXMethodDecl bool HasImplicitReturnZero : 1; - + /// \brief End part of this FunctionDecl's source range. /// /// We could compute the full range in getSourceRange(). However, when we're @@ -790,15 +790,15 @@ /// \brief The template or declaration that this declaration /// describes or was instantiated from, respectively. - /// + /// /// For non-templates, this value will be NULL. For function /// declarations that describe a function template, this will be a /// pointer to a FunctionTemplateDecl. For member functions /// of class template specializations, this will be the /// FunctionDecl from which the member function was instantiated. - /// For function template specializations, this will be a + /// For function template specializations, this will be a /// FunctionTemplateSpecializationInfo, which contains information about - /// the template being specialized and the template arguments involved in + /// the template being specialized and the template arguments involved in /// that specialization. llvm::PointerUnion3 @@ -808,11 +808,11 @@ FunctionDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, DeclaratorInfo *DInfo, StorageClass S, bool isInline) - : DeclaratorDecl(DK, DC, L, N, T, DInfo), + : DeclaratorDecl(DK, DC, L, N, T, DInfo), DeclContext(DK), ParamInfo(0), Body(), - SClass(S), IsInline(isInline), C99InlineDefinition(false), - IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false), + SClass(S), IsInline(isInline), C99InlineDefinition(false), + IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false), HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false), IsCopyAssignment(false), HasImplicitReturnZero(false), @@ -828,7 +828,7 @@ typedef redeclarable_base::redecl_iterator redecl_iterator; redecl_iterator redecls_begin() const { return redeclarable_base::redecls_begin(); - } + } redecl_iterator redecls_end() const { return redeclarable_base::redecls_end(); } @@ -888,7 +888,7 @@ /// the class has been fully built by Sema. bool isTrivial() const { return IsTrivial; } void setTrivial(bool IT) { IsTrivial = IT; } - + bool isCopyAssignment() const { return IsCopyAssignment; } void setCopyAssignment(bool CA) { IsCopyAssignment = CA; } @@ -902,10 +902,10 @@ /// was explicitly written or because it was "inherited" by merging /// a declaration without a prototype with a declaration that has a /// prototype. - bool hasPrototype() const { - return HasWrittenPrototype || HasInheritedPrototype; + bool hasPrototype() const { + return HasWrittenPrototype || HasInheritedPrototype; } - + bool hasWrittenPrototype() const { return HasWrittenPrototype; } void setHasWrittenPrototype(bool P) { HasWrittenPrototype = P; } @@ -953,23 +953,23 @@ unsigned getBuiltinID(ASTContext &Context) const; unsigned getNumParmVarDeclsFromType() const; - + // Iterator access to formal parameters. unsigned param_size() const { return getNumParams(); } typedef ParmVarDecl **param_iterator; typedef ParmVarDecl * const *param_const_iterator; - + param_iterator param_begin() { return ParamInfo; } param_iterator param_end() { return ParamInfo+param_size(); } - + param_const_iterator param_begin() const { return ParamInfo; } param_const_iterator param_end() const { return ParamInfo+param_size(); } - + /// getNumParams - Return the number of parameters this function must have /// based on its functiontype. This is the length of the PararmInfo array /// after it has been created. unsigned getNumParams() const; - + const ParmVarDecl *getParamDecl(unsigned i) const { assert(i < getNumParams() && "Illegal param #"); return ParamInfo[i]; @@ -986,7 +986,7 @@ /// arguments (in C++). unsigned getMinRequiredArguments() const; - QualType getResultType() const { + QualType getResultType() const { return getType()->getAsFunctionType()->getResultType(); } StorageClass getStorageClass() const { return StorageClass(SClass); } @@ -1015,7 +1015,7 @@ /// isOverloadedOperator - Whether this function declaration /// represents an C++ overloaded operator, e.g., "operator+". - bool isOverloadedOperator() const { + bool isOverloadedOperator() const { return getOverloadedOperator() != OO_None; }; @@ -1048,7 +1048,7 @@ /// \brief Specify that this record is an instantiation of the /// member function RD. - void setInstantiationOfMemberFunction(FunctionDecl *RD) { + void setInstantiationOfMemberFunction(FunctionDecl *RD) { TemplateOrSpecialization = RD; } @@ -1078,14 +1078,14 @@ /// If this function declaration is not a function template specialization, /// returns NULL. FunctionTemplateDecl *getPrimaryTemplate() const; - + /// \brief Retrieve the template arguments used to produce this function /// template specialization from the primary template. /// /// If this function declaration is not a function template specialization, /// returns NULL. - const TemplateArgumentList *getTemplateSpecializationArgs() const; - + const TemplateArgumentList *getTemplateSpecializationArgs() const; + /// \brief Specify that this function declaration is actually a function /// template specialization. /// @@ -1108,7 +1108,7 @@ /// \brief Determine what kind of template instantiation this function /// represents. void setTemplateSpecializationKind(TemplateSpecializationKind TSK); - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= FunctionFirst && D->getKind() <= FunctionLast; @@ -1123,21 +1123,21 @@ }; -/// FieldDecl - An instance of this class is created by Sema::ActOnField to +/// FieldDecl - An instance of this class is created by Sema::ActOnField to /// represent a member of a struct/union/class. class FieldDecl : public DeclaratorDecl { // FIXME: This can be packed into the bitfields in Decl. bool Mutable : 1; Expr *BitWidth; protected: - FieldDecl(Kind DK, DeclContext *DC, SourceLocation L, + FieldDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, Expr *BW, bool Mutable) - : DeclaratorDecl(DK, DC, L, Id, T, DInfo), Mutable(Mutable), BitWidth(BW) - { } + : DeclaratorDecl(DK, DC, L, Id, T, DInfo), Mutable(Mutable), BitWidth(BW) { + } public: - static FieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, + static FieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, Expr *BW, bool Mutable); @@ -1189,7 +1189,7 @@ SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V); - + virtual void Destroy(ASTContext& C); const Expr *getInitExpr() const { return (const Expr*) Init; } @@ -1198,11 +1198,11 @@ void setInitExpr(Expr *E) { Init = (Stmt*) E; } void setInitVal(const llvm::APSInt &V) { Val = V; } - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == EnumConstant; } static bool classof(const EnumConstantDecl *D) { return true; } - + friend class StmtIteratorBase; }; @@ -1244,16 +1244,16 @@ /// UnderlyingType - This is the type the typedef is set to. QualType UnderlyingType; TypedefDecl(DeclContext *DC, SourceLocation L, - IdentifierInfo *Id, QualType T) + IdentifierInfo *Id, QualType T) : TypeDecl(Typedef, DC, L, Id), UnderlyingType(T) {} virtual ~TypedefDecl() {} public: - + static TypedefDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,IdentifierInfo *Id, QualType T); - + QualType getUnderlyingType() const { return UnderlyingType; } void setUnderlyingType(QualType newType) { UnderlyingType = newType; } @@ -1263,9 +1263,9 @@ }; class TypedefDecl; - + /// TagDecl - Represents the declaration of a struct/union/class/enum. -class TagDecl +class TagDecl : public TypeDecl, public DeclContext, public Redeclarable { public: // This is really ugly. @@ -1283,7 +1283,7 @@ /// IsDefinition - True if this is a definition ("struct foo {};"), false if /// it is a declaration ("struct foo;"). bool IsDefinition : 1; - + /// TypedefForAnonDecl - If a TagDecl is anonymous and part of a typedef, /// this points to the TypedefDecl. Used for mangling. TypedefDecl *TypedefForAnonDecl; @@ -1302,19 +1302,19 @@ IsDefinition = false; setPreviousDeclaration(PrevDecl); } - + typedef Redeclarable redeclarable_base; virtual TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); } - + public: typedef redeclarable_base::redecl_iterator redecl_iterator; redecl_iterator redecls_begin() const { return redeclarable_base::redecls_begin(); - } + } redecl_iterator redecls_end() const { return redeclarable_base::redecls_end(); } - + SourceLocation getRBraceLoc() const { return RBraceLoc; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } @@ -1322,7 +1322,7 @@ void setTagKeywordLoc(SourceLocation TKL) { TagKeywordLoc = TKL; } virtual SourceRange getSourceRange() const; - + virtual TagDecl* getCanonicalDecl(); /// isDefinition - Return true if this decl has its body specified. @@ -1336,7 +1336,7 @@ bool isDependentType() const { return isDependentContext(); } /// @brief Starts the definition of this tag declaration. - /// + /// /// This method should be invoked at the beginning of the definition /// of this tag declaration. It will set the tag type into a state /// where it is in the process of being defined. @@ -1345,7 +1345,7 @@ /// @brief Completes the definition of this tag declaration. void completeDefinition(); - /// getDefinition - Returns the TagDecl that actually defines this + /// getDefinition - Returns the TagDecl that actually defines this /// struct/union/class/enum. When determining whether or not a /// struct/union/class/enum is completely defined, one should use this method /// as opposed to 'isDefinition'. 'isDefinition' indicates whether or not a @@ -1353,7 +1353,7 @@ /// struct/union/class/enum type is defined. This method returns NULL if /// there is no TagDecl that defines the struct/union/class/enum. TagDecl* getDefinition(ASTContext& C) const; - + const char *getKindName() const { return ElaboratedType::getNameForTagKind(getTagKind()); } @@ -1373,10 +1373,10 @@ bool isClass() const { return getTagKind() == TK_class; } bool isUnion() const { return getTagKind() == TK_union; } bool isEnum() const { return getTagKind() == TK_enum; } - + TypedefDecl *getTypedefForAnonDecl() const { return TypedefForAnonDecl; } void setTypedefForAnonDecl(TypedefDecl *TDD) { TypedefForAnonDecl = TDD; } - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= TagFirst && D->getKind() <= TagLast; @@ -1419,7 +1419,7 @@ static EnumDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation TKL, EnumDecl *PrevDecl); - + virtual void Destroy(ASTContext& C); /// completeDefinition - When created, the EnumDecl corresponds to a @@ -1428,16 +1428,16 @@ /// added (via DeclContext::addDecl). NewType is the new underlying /// type of the enumeration type. void completeDefinition(ASTContext &C, QualType NewType); - + // enumerator_iterator - Iterates through the enumerators of this // enumeration. typedef specific_decl_iterator enumerator_iterator; - enumerator_iterator enumerator_begin() const { + enumerator_iterator enumerator_begin() const { return enumerator_iterator(this->decls_begin()); } - enumerator_iterator enumerator_end() const { + enumerator_iterator enumerator_end() const { return enumerator_iterator(this->decls_end()); } @@ -1477,14 +1477,14 @@ /// AnonymousStructOrUnion - Whether this is the type of an /// anonymous struct or union. bool AnonymousStructOrUnion : 1; - + /// HasObjectMember - This is true if this struct has at least one - /// member containing an object + /// member containing an object bool HasObjectMember : 1; protected: RecordDecl(Kind DK, TagKind TK, DeclContext *DC, - SourceLocation L, IdentifierInfo *Id, + SourceLocation L, IdentifierInfo *Id, RecordDecl *PrevDecl, SourceLocation TKL); virtual ~RecordDecl(); @@ -1495,7 +1495,7 @@ RecordDecl* PrevDecl = 0); virtual void Destroy(ASTContext& C); - + bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; } void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; } @@ -1505,7 +1505,7 @@ /// type declared, e.g., /// @code /// union { int i; float f; }; - /// @endcode + /// @endcode /// is an anonymous union but neither of the following are: /// @code /// union X { int i; float f; }; @@ -1518,7 +1518,7 @@ bool hasObjectMember() const { return HasObjectMember; } void setHasObjectMember (bool val) { HasObjectMember = val; } - + /// \brief Determines whether this declaration represents the /// injected class name. /// @@ -1534,7 +1534,7 @@ /// \endcode bool isInjectedClassName() const; - /// getDefinition - Returns the RecordDecl that actually defines this + /// getDefinition - Returns the RecordDecl that actually defines this /// struct/union/class. When determining whether or not a struct/union/class /// is completely defined, one should use this method as opposed to /// 'isDefinition'. 'isDefinition' indicates whether or not a specific @@ -1544,7 +1544,7 @@ RecordDecl* getDefinition(ASTContext& C) const { return cast_or_null(TagDecl::getDefinition(C)); } - + // Iterator access to field members. The field iterator only visits // the non-static data members of this class, ignoring any static // data members, functions, constructors, destructors, etc. @@ -1559,7 +1559,7 @@ // field_empty - Whether there are any fields (non-static data // members) in this record. - bool field_empty() const { + bool field_empty() const { return field_begin() == field_end(); } @@ -1588,7 +1588,7 @@ static bool classof(const Decl *D) { return D->getKind() == FileScopeAsm; } - static bool classof(const FileScopeAsmDecl *D) { return true; } + static bool classof(const FileScopeAsmDecl *D) { return true; } }; /// BlockDecl - This represents a block literal declaration, which is like an @@ -1603,12 +1603,12 @@ /// no formals. ParmVarDecl **ParamInfo; unsigned NumParams; - + Stmt *Body; - + protected: BlockDecl(DeclContext *DC, SourceLocation CaretLoc) - : Decl(Block, DC, CaretLoc), DeclContext(Block), + : Decl(Block, DC, CaretLoc), DeclContext(Block), isVariadic(false), ParamInfo(0), NumParams(0), Body(0) {} virtual ~BlockDecl(); @@ -1621,7 +1621,7 @@ bool IsVariadic() const { return isVariadic; } void setIsVariadic(bool value) { isVariadic = value; } - + CompoundStmt *getCompoundBody() const { return (CompoundStmt*) Body; } Stmt *getBody() const { return (Stmt*) Body; } void setBody(CompoundStmt *B) { Body = (Stmt*) B; } @@ -1630,14 +1630,14 @@ unsigned param_size() const { return getNumParams(); } typedef ParmVarDecl **param_iterator; typedef ParmVarDecl * const *param_const_iterator; - + bool param_empty() const { return NumParams == 0; } param_iterator param_begin() { return ParamInfo; } param_iterator param_end() { return ParamInfo+param_size(); } - + param_const_iterator param_begin() const { return ParamInfo; } param_const_iterator param_end() const { return ParamInfo+param_size(); } - + unsigned getNumParams() const; const ParmVarDecl *getParamDecl(unsigned i) const { assert(i < getNumParams() && "Illegal param #"); @@ -1648,10 +1648,10 @@ return ParamInfo[i]; } void setParams(ASTContext& C, ParmVarDecl **NewParamInfo, unsigned NumParams); - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == Block; } - static bool classof(const BlockDecl *D) { return true; } + static bool classof(const BlockDecl *D) { return true; } static DeclContext *castToDeclContext(const BlockDecl *D) { return static_cast(const_cast(D)); } Modified: cfe/trunk/include/clang/AST/DeclBase.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclBase.h (original) +++ cfe/trunk/include/clang/AST/DeclBase.h Wed Sep 9 10:08:12 2009 @@ -60,8 +60,8 @@ namespace clang { -/// Decl - This represents one declaration (or definition), e.g. a variable, -/// typedef, function, struct, etc. +/// Decl - This represents one declaration (or definition), e.g. a variable, +/// typedef, function, struct, etc. /// class Decl { public: @@ -69,7 +69,7 @@ enum Kind { #define DECL(Derived, Base) Derived, #define DECL_RANGE(CommonBase, Start, End) \ - CommonBase##First = Start, CommonBase##Last = End, + CommonBase##First = Start, CommonBase##Last = End, #define LAST_DECL_RANGE(CommonBase, Start, End) \ CommonBase##First = Start, CommonBase##Last = End #include "clang/AST/DeclNodes.def" @@ -93,7 +93,7 @@ IDNS_OrdinaryFriend = 0x80, IDNS_TagFriend = 0x100 }; - + /// ObjCDeclQualifier - Qualifier used on types in method declarations /// for remote messaging. They are meant for the arguments though and /// applied to the Decls (ObjCMethodDecl and ParmVarDecl). @@ -106,7 +106,7 @@ OBJC_TQ_Byref = 0x10, OBJC_TQ_Oneway = 0x20 }; - + private: /// NextDeclInContext - The next declaration within the same lexical /// DeclContext. These pointers form the linked list that is @@ -119,8 +119,8 @@ DeclContext *SemanticDC; DeclContext *LexicalDC; }; - - + + /// DeclCtx - Holds either a DeclContext* or a MultipleDC*. /// For declarations that don't contain C++ scope specifiers, it contains /// the DeclContext where the Decl was declared. @@ -144,16 +144,16 @@ inline DeclContext *getSemanticDC() const { return DeclCtx.get(); } - + /// Loc - The location that this decl. SourceLocation Loc; - + /// DeclKind - This indicates which class this is. Kind DeclKind : 8; - + /// InvalidDecl - This indicates a semantic error occurred. unsigned int InvalidDecl : 1; - + /// HasAttrs - This indicates whether the decl has attributes or not. unsigned int HasAttrs : 1; @@ -168,22 +168,22 @@ protected: /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in. unsigned IdentifierNamespace : 16; - + private: #ifndef NDEBUG void CheckAccessDeclContext() const; #else void CheckAccessDeclContext() const { } #endif - + protected: /// Access - Used by C++ decls for the access specifier. // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum unsigned Access : 2; friend class CXXClassMemberWrapper; - Decl(Kind DK, DeclContext *DC, SourceLocation L) - : NextDeclInContext(0), DeclCtx(DC), + Decl(Kind DK, DeclContext *DC, SourceLocation L) + : NextDeclInContext(0), DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false), IdentifierNamespace(getIdentifierNamespaceForKind(DK)), Access(AS_none) { @@ -206,7 +206,7 @@ Kind getKind() const { return DeclKind; } const char *getDeclKindName() const; - + Decl *getNextDeclInContext() { return NextDeclInContext; } const Decl *getNextDeclInContext() const { return NextDeclInContext; } @@ -225,15 +225,15 @@ } ASTContext &getASTContext() const; - + void setAccess(AccessSpecifier AS) { - Access = AS; + Access = AS; CheckAccessDeclContext(); } - - AccessSpecifier getAccess() const { + + AccessSpecifier getAccess() const { CheckAccessDeclContext(); - return AccessSpecifier(Access); + return AccessSpecifier(Access); } bool hasAttrs() const { return HasAttrs; } @@ -251,11 +251,11 @@ return V; return 0; } - + template bool hasAttr() const { return getAttr() != 0; } - + /// setInvalidDecl - Indicates the Decl had a semantic error. This /// allows for graceful error recovery. void setInvalidDecl(bool Invalid = true) { InvalidDecl = Invalid; } @@ -266,12 +266,12 @@ /// was written explicitly in the source code. bool isImplicit() const { return Implicit; } void setImplicit(bool I = true) { Implicit = I; } - + /// \brief Whether this declaration was used, meaning that a definition /// is required. bool isUsed() const { return Used; } void setUsed(bool U = true) { Used = U; } - + unsigned getIdentifierNamespace() const { return IdentifierNamespace; } @@ -280,7 +280,7 @@ } static unsigned getIdentifierNamespaceForKind(Kind DK); - + /// getLexicalDeclContext - The declaration context where this Decl was /// lexically declared (LexicalDC). May be different from /// getDeclContext() (SemanticDC). @@ -303,7 +303,7 @@ bool isOutOfLine() const { return getLexicalDeclContext() != getDeclContext(); } - + /// setDeclContext - Set both the semantic and lexical DeclContext /// to DC. void setDeclContext(DeclContext *DC); @@ -324,7 +324,7 @@ /// \brief Whether this particular Decl is a canonical one. bool isCanonicalDecl() const { return getCanonicalDecl() == this; } - + protected: /// \brief Returns the next redeclaration or itself if this is the only decl. /// @@ -367,10 +367,10 @@ return tmp; } - friend bool operator==(redecl_iterator x, redecl_iterator y) { + friend bool operator==(redecl_iterator x, redecl_iterator y) { return x.Current == y.Current; } - friend bool operator!=(redecl_iterator x, redecl_iterator y) { + friend bool operator!=(redecl_iterator x, redecl_iterator y) { return x.Current != y.Current; } }; @@ -398,11 +398,11 @@ static void addDeclKind(Kind k); static bool CollectingStats(bool Enable = false); static void PrintStats(); - + /// isTemplateParameter - Determines whether this declaration is a /// template parameter. bool isTemplateParameter() const; - + /// isTemplateParameter - Determines whether this declaration is a /// template parameter pack. bool isTemplateParameterPack() const; @@ -445,12 +445,12 @@ if (!mask) return FOK_None; return (mask & (IDNS_Tag | IDNS_Ordinary) ? FOK_Declared : FOK_Undeclared); } - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *) { return true; } static DeclContext *castToDeclContext(const Decl *); static Decl *castFromDeclContext(const DeclContext *); - + /// Destroy - Call destructors and release memory. virtual void Destroy(ASTContext& C); @@ -478,10 +478,10 @@ PrettyStackTraceDecl(Decl *theDecl, SourceLocation L, SourceManager &sm, const char *Msg) : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {} - + virtual void print(llvm::raw_ostream &OS) const; -}; - +}; + /// DeclContext - This is used only as base class of specific decl types that /// can act as declaration contexts. These decls are (only the top classes @@ -526,9 +526,9 @@ mutable Decl *LastDecl; protected: - DeclContext(Decl::Kind K) + DeclContext(Decl::Kind K) : DeclKind(K), ExternalLexicalStorage(false), - ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0), + ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0), LastDecl(0) { } void DestroyDecls(ASTContext &C); @@ -548,7 +548,7 @@ const DeclContext *getParent() const { return const_cast(this)->getParent(); } - + /// getLexicalParent - Returns the containing lexical DeclContext. May be /// different from getParent, e.g.: /// @@ -563,7 +563,7 @@ } const DeclContext *getLexicalParent() const { return const_cast(this)->getLexicalParent(); - } + } ASTContext &getParentASTContext() const { return cast(this)->getASTContext(); @@ -604,10 +604,10 @@ /// context are semantically declared in the nearest enclosing /// non-transparent (opaque) context but are lexically declared in /// this context. For example, consider the enumerators of an - /// enumeration type: + /// enumeration type: /// @code /// enum E { - /// Val1 + /// Val1 /// }; /// @endcode /// Here, E is a transparent context, so its enumerator (Val1) will @@ -622,7 +622,7 @@ bool Equals(DeclContext *DC) { return this->getPrimaryContext() == DC->getPrimaryContext(); } - + /// \brief Determine whether this declaration context encloses the /// declaration context DC. bool Encloses(DeclContext *DC); @@ -643,7 +643,7 @@ const DeclContext *getLookupContext() const { return const_cast(this)->getLookupContext(); } - + /// \brief Retrieve the nearest enclosing namespace context. DeclContext *getEnclosingNamespaceContext(); const DeclContext *getEnclosingNamespaceContext() const { @@ -699,16 +699,16 @@ return tmp; } - friend bool operator==(decl_iterator x, decl_iterator y) { + friend bool operator==(decl_iterator x, decl_iterator y) { return x.Current == y.Current; } - friend bool operator!=(decl_iterator x, decl_iterator y) { + friend bool operator!=(decl_iterator x, decl_iterator y) { return x.Current != y.Current; } }; /// decls_begin/decls_end - Iterate over the declarations stored in - /// this context. + /// this context. decl_iterator decls_begin() const; decl_iterator decls_end() const; bool decls_empty() const; @@ -724,7 +724,7 @@ /// will either be NULL or will point to a declaration of /// type SpecificDecl. DeclContext::decl_iterator Current; - + /// SkipToNextDecl - Advances the current position up to the next /// declaration of type SpecificDecl that also meets the criteria /// required by Acceptable. @@ -769,13 +769,13 @@ ++(*this); return tmp; } - + friend bool operator==(const specific_decl_iterator& x, const specific_decl_iterator& y) { return x.Current == y.Current; } - - friend bool + + friend bool operator!=(const specific_decl_iterator& x, const specific_decl_iterator& y) { return x.Current != y.Current; } @@ -796,7 +796,7 @@ /// will either be NULL or will point to a declaration of /// type SpecificDecl. DeclContext::decl_iterator Current; - + /// SkipToNextDecl - Advances the current position up to the next /// declaration of type SpecificDecl that also meets the criteria /// required by Acceptable. @@ -843,13 +843,13 @@ ++(*this); return tmp; } - + friend bool operator==(const filtered_decl_iterator& x, const filtered_decl_iterator& y) { return x.Current == y.Current; } - - friend bool + + friend bool operator!=(const filtered_decl_iterator& x, const filtered_decl_iterator& y) { return x.Current != y.Current; } @@ -920,7 +920,7 @@ /// udir_iterator - Iterates through the using-directives stored /// within this context. typedef UsingDirectiveDecl * const * udir_iterator; - + typedef std::pair udir_iterator_range; udir_iterator_range getUsingDirectives() const; @@ -944,8 +944,8 @@ /// \brief State whether this DeclContext has external storage for /// declarations lexically in this context. - void setHasExternalLexicalStorage(bool ES = true) { - ExternalLexicalStorage = ES; + void setHasExternalLexicalStorage(bool ES = true) { + ExternalLexicalStorage = ES; } /// \brief Whether this DeclContext has external storage containing @@ -954,8 +954,8 @@ /// \brief State whether this DeclContext has external storage for /// declarations visible in this context. - void setHasExternalVisibleStorage(bool ES = true) { - ExternalVisibleStorage = ES; + void setHasExternalVisibleStorage(bool ES = true) { + ExternalVisibleStorage = ES; } static bool classof(const Decl *D); Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Sep 9 10:08:12 2009 @@ -28,33 +28,33 @@ class CXXMethodDecl; class ClassTemplateSpecializationDecl; -/// \brief Represents any kind of function declaration, whether it is a +/// \brief Represents any kind of function declaration, whether it is a /// concrete function or a function template. class AnyFunctionDecl { NamedDecl *Function; - + AnyFunctionDecl(NamedDecl *ND) : Function(ND) { } - + public: AnyFunctionDecl(FunctionDecl *FD) : Function(FD) { } AnyFunctionDecl(FunctionTemplateDecl *FTD); - - /// \brief Implicily converts any function or function template into a + + /// \brief Implicily converts any function or function template into a /// named declaration. operator NamedDecl *() const { return Function; } - + /// \brief Retrieve the underlying function or function template. NamedDecl *get() const { return Function; } - - static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) { + + static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) { return AnyFunctionDecl(ND); } }; - + } // end namespace clang namespace llvm { - /// Implement simplify_type for AnyFunctionDecl, so that we can dyn_cast from + /// Implement simplify_type for AnyFunctionDecl, so that we can dyn_cast from /// AnyFunctionDecl to any function or function template declaration. template<> struct simplify_type { typedef ::clang::NamedDecl* SimpleType; @@ -64,26 +64,26 @@ }; template<> struct simplify_type< ::clang::AnyFunctionDecl> : public simplify_type {}; - + // Provide PointerLikeTypeTraits for non-cvr pointers. template<> class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> { public: static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) { - return F.get(); + return F.get(); } static inline ::clang::AnyFunctionDecl getFromVoidPointer(void *P) { return ::clang::AnyFunctionDecl::getFromNamedDecl( static_cast< ::clang::NamedDecl*>(P)); } - + enum { NumLowBitsAvailable = 2 }; }; - + } // end namespace llvm namespace clang { - + /// OverloadedFunctionDecl - An instance of this class represents a /// set of overloaded functions. All of the functions have the same /// name and occur within the same scope. @@ -128,56 +128,56 @@ unsigned size() const { return Functions.size(); } // Implement isa/cast/dyncast/etc. - static bool classof(const Decl *D) { - return D->getKind() == OverloadedFunction; + static bool classof(const Decl *D) { + return D->getKind() == OverloadedFunction; } static bool classof(const OverloadedFunctionDecl *D) { return true; } }; - -/// \brief Provides uniform iteration syntax for an overload set, function, + +/// \brief Provides uniform iteration syntax for an overload set, function, /// or function template. class OverloadIterator { /// \brief An overloaded function set, function declaration, or /// function template declaration. NamedDecl *D; - + /// \brief If the declaration is an overloaded function set, this is the /// iterator pointing to the current position within that overloaded /// function set. OverloadedFunctionDecl::function_iterator Iter; - + public: typedef AnyFunctionDecl value_type; typedef value_type reference; typedef NamedDecl *pointer; typedef int difference_type; typedef std::forward_iterator_tag iterator_category; - + OverloadIterator() : D(0) { } - + OverloadIterator(FunctionDecl *FD) : D(FD) { } - OverloadIterator(FunctionTemplateDecl *FTD) + OverloadIterator(FunctionTemplateDecl *FTD) : D(reinterpret_cast(FTD)) { } - OverloadIterator(OverloadedFunctionDecl *Ovl) + OverloadIterator(OverloadedFunctionDecl *Ovl) : D(Ovl), Iter(Ovl->function_begin()) { } - + OverloadIterator(NamedDecl *ND); - + reference operator*() const; - + pointer operator->() const { return (**this).get(); } - + OverloadIterator &operator++(); - + OverloadIterator operator++(int) { OverloadIterator Temp(*this); ++(*this); return Temp; } - + bool Equals(const OverloadIterator &Other) const; }; - + inline bool operator==(const OverloadIterator &X, const OverloadIterator &Y) { return X.Equals(Y); } @@ -215,7 +215,7 @@ /// struct (false). This determines the mapping from the access /// specifier as written in the source code to the access specifier /// used for semantic analysis. - bool BaseOfClass : 1; + bool BaseOfClass : 1; /// Access - Access specifier as written in the source code (which /// may be AS_none). The actual type of data stored here is an @@ -226,7 +226,7 @@ /// BaseType - The type of the base class. This will be a class or /// struct (or a typedef of such). QualType BaseType; - + public: CXXBaseSpecifier() { } @@ -236,7 +236,7 @@ /// getSourceRange - Retrieves the source range that contains the /// entire base specifier. SourceRange getSourceRange() const { return Range; } - + /// isVirtual - Determines whether the base class is a virtual base /// class (or not). bool isVirtual() const { return Virtual; } @@ -246,11 +246,11 @@ /// semantic analysis, so the result can never be AS_none. To /// retrieve the access specifier as written in the source code, use /// getAccessSpecifierAsWritten(). - AccessSpecifier getAccessSpecifier() const { + AccessSpecifier getAccessSpecifier() const { if ((AccessSpecifier)Access == AS_none) return BaseOfClass? AS_private : AS_public; else - return (AccessSpecifier)Access; + return (AccessSpecifier)Access; } /// getAccessSpecifierAsWritten - Retrieves the access specifier as @@ -271,7 +271,7 @@ /// to deal with C++-specific things. class CXXRecordDecl : public RecordDecl { /// UserDeclaredConstructor - True when this class has a - /// user-declared constructor. + /// user-declared constructor. bool UserDeclaredConstructor : 1; /// UserDeclaredCopyConstructor - True when this class has a @@ -315,7 +315,7 @@ /// * for all the nonstatic data members of its class that are of class type /// (or array thereof), each such class has a trivial constructor. bool HasTrivialConstructor : 1; - + /// HasTrivialCopyConstructor - True when this class has a trivial copy /// constructor. /// @@ -340,7 +340,7 @@ /// operator; /// otherwise the copy assignment operator is non-trivial. bool HasTrivialCopyAssignment : 1; - + /// HasTrivialDestructor - True when this class has a trivial destructor. /// /// C++ [class.dtor]p3. A destructor is trivial if it is an @@ -360,10 +360,10 @@ /// VBases - direct and indirect virtual base classes of this class. CXXBaseSpecifier *VBases; - + /// NumVBases - The number of virtual base class specifiers in VBases. unsigned NumVBases; - + /// Conversions - Overload set containing the conversion functions /// of this C++ class (but not its inherited conversion /// functions). Each of the entries in this overload set is a @@ -372,7 +372,7 @@ /// \brief The template or declaration that this declaration /// describes or was instantiated from, respectively. - /// + /// /// For non-templates, this value will be NULL. For record /// declarations that describe a class template, this will be a /// pointer to a ClassTemplateDecl. For member @@ -417,9 +417,9 @@ SourceLocation TKL = SourceLocation(), CXXRecordDecl* PrevDecl=0, bool DelayTypeCreation = false); - + virtual void Destroy(ASTContext& C); - + bool isDynamicClass() const { return Polymorphic || NumVBases!=0; } @@ -448,11 +448,11 @@ reverse_base_class_const_iterator bases_rend() const { return reverse_base_class_const_iterator(bases_begin()); } - + /// getNumVBases - Retrieves the number of virtual base classes of this /// class. unsigned getNumVBases() const { return NumVBases; } - + base_class_iterator vbases_begin() { return VBases; } base_class_const_iterator vbases_begin() const { return VBases; } base_class_iterator vbases_end() { return VBases + NumVBases; } @@ -474,7 +474,7 @@ /// all method members of the class, including non-instance methods, /// special methods, etc. typedef specific_decl_iterator method_iterator; - + /// method_begin - Method begin iterator. Iterates in the order the methods /// were declared. method_iterator method_begin() const { @@ -487,7 +487,7 @@ /// Iterator access to constructor members. typedef specific_decl_iterator ctor_iterator; - + ctor_iterator ctor_begin() const { return ctor_iterator(decls_begin()); } @@ -500,13 +500,13 @@ bool hasConstCopyConstructor(ASTContext &Context) const; /// getCopyConstructor - Returns the copy constructor for this class - CXXConstructorDecl *getCopyConstructor(ASTContext &Context, + CXXConstructorDecl *getCopyConstructor(ASTContext &Context, unsigned TypeQuals) const; /// hasConstCopyAssignment - Determines whether this class has a /// copy assignment operator that accepts a const-qualified argument. /// It returns its decl in MD if found. - bool hasConstCopyAssignment(ASTContext &Context, + bool hasConstCopyAssignment(ASTContext &Context, const CXXMethodDecl *&MD) const; /// addedConstructor - Notify the class that another constructor has @@ -517,9 +517,9 @@ /// hasUserDeclaredConstructor - Whether this class has any /// user-declared constructors. When true, a default constructor /// will not be implicitly declared. - bool hasUserDeclaredConstructor() const { + bool hasUserDeclaredConstructor() const { assert((isDefinition() || - cast(getTypeForDecl())->isBeingDefined()) && + cast(getTypeForDecl())->isBeingDefined()) && "Incomplete record decl!"); return UserDeclaredConstructor; } @@ -551,23 +551,23 @@ /// setUserDeclaredDestructor - Set whether this class has a /// user-declared destructor. If not set by the time the class is /// fully defined, a destructor will be implicitly declared. - void setUserDeclaredDestructor(bool UCD) { - UserDeclaredDestructor = UCD; + void setUserDeclaredDestructor(bool UCD) { + UserDeclaredDestructor = UCD; } /// getConversions - Retrieve the overload set containing all of the /// conversion functions in this class. - OverloadedFunctionDecl *getConversionFunctions() { - assert((this->isDefinition() || + OverloadedFunctionDecl *getConversionFunctions() { + assert((this->isDefinition() || cast(getTypeForDecl())->isBeingDefined()) && "getConversionFunctions() called on incomplete type"); - return &Conversions; + return &Conversions; } - const OverloadedFunctionDecl *getConversionFunctions() const { - assert((this->isDefinition() || + const OverloadedFunctionDecl *getConversionFunctions() const { + assert((this->isDefinition() || cast(getTypeForDecl())->isBeingDefined()) && "getConversionFunctions() called on incomplete type"); - return &Conversions; + return &Conversions; } /// addConversionFunction - Add a new conversion function to the @@ -576,7 +576,7 @@ /// \brief Add a new conversion function template to the list of conversion /// functions. - void addConversionFunction(ASTContext &Context, + void addConversionFunction(ASTContext &Context, FunctionTemplateDecl *ConvDecl); /// isAggregate - Whether this class is an aggregate (C++ @@ -618,22 +618,22 @@ /// isAbstract - Whether this class is abstract (C++ [class.abstract]), /// which means that the class contains or inherits a pure virtual function. bool isAbstract() const { return Abstract; } - + /// setAbstract - Set whether this class is abstract (C++ [class.abstract]) void setAbstract(bool Abs) { Abstract = Abs; } - + // hasTrivialConstructor - Whether this class has a trivial constructor // (C++ [class.ctor]p5) bool hasTrivialConstructor() const { return HasTrivialConstructor; } - + // setHasTrivialConstructor - Set whether this class has a trivial constructor // (C++ [class.ctor]p5) void setHasTrivialConstructor(bool TC) { HasTrivialConstructor = TC; } - + // hasTrivialCopyConstructor - Whether this class has a trivial copy // constructor (C++ [class.copy]p6) bool hasTrivialCopyConstructor() const { return HasTrivialCopyConstructor; } - + // setHasTrivialCopyConstructor - Set whether this class has a trivial // copy constructor (C++ [class.copy]p6) void setHasTrivialCopyConstructor(bool TC) { HasTrivialCopyConstructor = TC; } @@ -641,7 +641,7 @@ // hasTrivialCopyAssignment - Whether this class has a trivial copy // assignment operator (C++ [class.copy]p11) bool hasTrivialCopyAssignment() const { return HasTrivialCopyAssignment; } - + // setHasTrivialCopyAssignment - Set whether this class has a // trivial copy assignment operator (C++ [class.copy]p11) void setHasTrivialCopyAssignment(bool TC) { HasTrivialCopyAssignment = TC; } @@ -649,11 +649,11 @@ // hasTrivialDestructor - Whether this class has a trivial destructor // (C++ [class.dtor]p3) bool hasTrivialDestructor() const { return HasTrivialDestructor; } - + // setHasTrivialDestructor - Set whether this class has a trivial destructor // (C++ [class.dtor]p3) void setHasTrivialDestructor(bool TC) { HasTrivialDestructor = TC; } - + /// \brief If this record is an instantiation of a member class, /// retrieves the member class from which it was instantiated. /// @@ -679,7 +679,7 @@ /// \brief Specify that this record is an instantiation of the /// member class RD. - void setInstantiationOfMemberClass(CXXRecordDecl *RD) { + void setInstantiationOfMemberClass(CXXRecordDecl *RD) { TemplateOrInstantiation = RD; } @@ -704,16 +704,16 @@ /// getDefaultConstructor - Returns the default constructor for this class CXXConstructorDecl *getDefaultConstructor(ASTContext &Context); - + /// getDestructor - Returns the destructor decl for this class. const CXXDestructorDecl *getDestructor(ASTContext &Context); - + /// isLocalClass - If the class is a local class [class.local], returns /// the enclosing function declaration. const FunctionDecl *isLocalClass() const { if (const CXXRecordDecl *RD = dyn_cast(getDeclContext())) return RD->isLocalClass(); - + return dyn_cast(getDeclContext()); } @@ -722,14 +722,14 @@ /// GraphViz. void viewInheritance(ASTContext& Context) const; - static bool classof(const Decl *D) { - return D->getKind() == CXXRecord || + static bool classof(const Decl *D) { + return D->getKind() == CXXRecord || D->getKind() == ClassTemplateSpecialization || - D->getKind() == ClassTemplatePartialSpecialization; + D->getKind() == ClassTemplatePartialSpecialization; } static bool classof(const CXXRecordDecl *D) { return true; } - static bool classof(const ClassTemplateSpecializationDecl *D) { - return true; + static bool classof(const ClassTemplateSpecializationDecl *D) { + return true; } }; @@ -749,32 +749,32 @@ QualType T, DeclaratorInfo *DInfo, bool isStatic = false, bool isInline = false); - + bool isStatic() const { return getStorageClass() == Static; } bool isInstance() const { return !isStatic(); } - bool isVirtual() const { + bool isVirtual() const { return isVirtualAsWritten() || (begin_overridden_methods() != end_overridden_methods()); } - /// + /// void addOverriddenMethod(const CXXMethodDecl *MD); - + typedef const CXXMethodDecl ** method_iterator; - + method_iterator begin_overridden_methods() const; method_iterator end_overridden_methods() const; - + /// getParent - Returns the parent of this method declaration, which /// is the class in which this method is defined. - const CXXRecordDecl *getParent() const { - return cast(FunctionDecl::getParent()); + const CXXRecordDecl *getParent() const { + return cast(FunctionDecl::getParent()); } - + /// getParent - Returns the parent of this method declaration, which /// is the class in which this method is defined. - CXXRecordDecl *getParent() { + CXXRecordDecl *getParent() { return const_cast( cast(FunctionDecl::getParent())); } @@ -788,7 +788,7 @@ } // Implement isa/cast/dyncast/etc. - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion; } static bool classof(const CXXMethodDecl *D) { return true; } @@ -818,13 +818,13 @@ /// Args - The arguments used to initialize the base or member. Stmt **Args; unsigned NumArgs; - + /// \brief Stores either the constructor to call to initialize this base or /// member (a CXXConstructorDecl pointer), or stores the anonymous union of /// which the initialized value is a member. /// - /// When the value is a FieldDecl pointer, 'BaseOrMember' is class's - /// anonymous union data member, this field holds the FieldDecl for the + /// When the value is a FieldDecl pointer, 'BaseOrMember' is class's + /// anonymous union data member, this field holds the FieldDecl for the /// member of the anonymous union being initialized. /// @code /// struct X { @@ -838,7 +838,7 @@ /// In above example, BaseOrMember holds the field decl. for anonymous union /// and AnonUnionMember holds field decl for au_i1. llvm::PointerUnion CtorOrAnonUnion; - + /// IdLoc - Location of the id in ctor-initializer list. SourceLocation IdLoc; @@ -847,13 +847,13 @@ public: /// CXXBaseOrMemberInitializer - Creates a new base-class initializer. - explicit + explicit CXXBaseOrMemberInitializer(QualType BaseType, Expr **Args, unsigned NumArgs, CXXConstructorDecl *C, SourceLocation L, SourceLocation R); /// CXXBaseOrMemberInitializer - Creates a new member initializer. - explicit + explicit CXXBaseOrMemberInitializer(FieldDecl *Member, Expr **Args, unsigned NumArgs, CXXConstructorDecl *C, SourceLocation L, SourceLocation R); @@ -872,7 +872,7 @@ /// getBaseOrMember - get the generic 'member' representing either the field /// or a base class. void* getBaseOrMember() const { return reinterpret_cast(BaseOrMember); } - + /// isBaseInitializer - Returns true when this initializer is /// initializing a base class. bool isBaseInitializer() const { return (BaseOrMember & 0x1) != 0; } @@ -885,8 +885,8 @@ /// type used to specify the initializer. The resulting type will be /// a class type or a typedef of a class type. If this is not a base /// class initializer, returns NULL. - Type *getBaseClass() { - if (isBaseInitializer()) + Type *getBaseClass() { + if (isBaseInitializer()) return reinterpret_cast(BaseOrMember & ~0x01); else return 0; @@ -896,8 +896,8 @@ /// type used to specify the initializer. The resulting type will be /// a class type or a typedef of a class type. If this is not a base /// class initializer, returns NULL. - const Type *getBaseClass() const { - if (isBaseInitializer()) + const Type *getBaseClass() const { + if (isBaseInitializer()) return reinterpret_cast(BaseOrMember & ~0x01); else return 0; @@ -906,9 +906,9 @@ /// getMember - If this is a member initializer, returns the /// declaration of the non-static data member being /// initialized. Otherwise, returns NULL. - FieldDecl *getMember() { + FieldDecl *getMember() { if (isMemberInitializer()) - return reinterpret_cast(BaseOrMember); + return reinterpret_cast(BaseOrMember); else return 0; } @@ -916,21 +916,21 @@ void setMember(FieldDecl * anonUnionField) { BaseOrMember = reinterpret_cast(anonUnionField); } - + FieldDecl *getAnonUnionMember() const { return CtorOrAnonUnion.dyn_cast(); } void setAnonUnionMember(FieldDecl *anonMember) { CtorOrAnonUnion = anonMember; } - - const CXXConstructorDecl *getConstructor() const { + + const CXXConstructorDecl *getConstructor() const { return CtorOrAnonUnion.dyn_cast(); } - + SourceLocation getSourceLocation() const { return IdLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } - + /// arg_begin() - Retrieve an iterator to the first initializer argument. arg_iterator arg_begin() { return Args; } /// arg_begin() - Retrieve an iterator to the first initializer argument. @@ -948,7 +948,7 @@ /// CXXConstructorDecl - Represents a C++ constructor within a /// class. For example: -/// +/// /// @code /// class X { /// public: @@ -966,23 +966,23 @@ /// explicitly defaulted (i.e., defined with " = default") will have /// @c !Implicit && ImplicitlyDefined. bool ImplicitlyDefined : 1; - + /// Support for base and member initializers. - /// BaseOrMemberInitializers - The arguments used to initialize the base + /// BaseOrMemberInitializers - The arguments used to initialize the base /// or member. CXXBaseOrMemberInitializer **BaseOrMemberInitializers; unsigned NumBaseOrMemberInitializers; - + CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L, DeclarationName N, QualType T, DeclaratorInfo *DInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared) : CXXMethodDecl(CXXConstructor, RD, L, N, T, DInfo, false, isInline), Explicit(isExplicit), ImplicitlyDefined(false), - BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) { + BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) { setImplicit(isImplicitlyDeclared); } virtual void Destroy(ASTContext& C); - + public: static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation L, DeclarationName N, @@ -990,59 +990,59 @@ bool isExplicit, bool isInline, bool isImplicitlyDeclared); - /// isExplicit - Whether this constructor was marked "explicit" or not. + /// isExplicit - Whether this constructor was marked "explicit" or not. bool isExplicit() const { return Explicit; } /// isImplicitlyDefined - Whether this constructor was implicitly /// defined. If false, then this constructor was defined by the /// user. This operation can only be invoked if the constructor has /// already been defined. - bool isImplicitlyDefined(ASTContext &C) const { - assert(isThisDeclarationADefinition() && + bool isImplicitlyDefined(ASTContext &C) const { + assert(isThisDeclarationADefinition() && "Can only get the implicit-definition flag once the " "constructor has been defined"); - return ImplicitlyDefined; + return ImplicitlyDefined; } /// setImplicitlyDefined - Set whether this constructor was /// implicitly defined or not. - void setImplicitlyDefined(bool ID) { - assert(isThisDeclarationADefinition() && + void setImplicitlyDefined(bool ID) { + assert(isThisDeclarationADefinition() && "Can only set the implicit-definition flag once the constructor " "has been defined"); - ImplicitlyDefined = ID; + ImplicitlyDefined = ID; } - + /// init_iterator - Iterates through the member/base initializer list. typedef CXXBaseOrMemberInitializer **init_iterator; - + /// init_const_iterator - Iterates through the memberbase initializer list. typedef CXXBaseOrMemberInitializer * const * init_const_iterator; - + /// init_begin() - Retrieve an iterator to the first initializer. init_iterator init_begin() { return BaseOrMemberInitializers; } /// begin() - Retrieve an iterator to the first initializer. init_const_iterator init_begin() const { return BaseOrMemberInitializers; } - + /// init_end() - Retrieve an iterator past the last initializer. - init_iterator init_end() { - return BaseOrMemberInitializers + NumBaseOrMemberInitializers; + init_iterator init_end() { + return BaseOrMemberInitializers + NumBaseOrMemberInitializers; } /// end() - Retrieve an iterator past the last initializer. - init_const_iterator init_end() const { - return BaseOrMemberInitializers + NumBaseOrMemberInitializers; + init_const_iterator init_end() const { + return BaseOrMemberInitializers + NumBaseOrMemberInitializers; } - + /// getNumArgs - Determine the number of arguments used to /// initialize the member or base. - unsigned getNumBaseOrMemberInitializers() const { - return NumBaseOrMemberInitializers; + unsigned getNumBaseOrMemberInitializers() const { + return NumBaseOrMemberInitializers; } - + void setNumBaseOrMemberInitializers(unsigned numBaseOrMemberInitializers) { NumBaseOrMemberInitializers = numBaseOrMemberInitializers; } - + void setBaseOrMemberInitializers(CXXBaseOrMemberInitializer ** initializers) { BaseOrMemberInitializers = initializers; } @@ -1079,7 +1079,7 @@ bool isConvertingConstructor(bool AllowExplicit) const; // Implement isa/cast/dyncast/etc. - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return D->getKind() == CXXConstructor; } static bool classof(const CXXConstructorDecl *D) { return true; } @@ -1087,7 +1087,7 @@ /// CXXDestructorDecl - Represents a C++ destructor within a /// class. For example: -/// +/// /// @code /// class X { /// public: @@ -1109,97 +1109,97 @@ /// explicitly defaulted (i.e., defined with " = default") will have /// @c !Implicit && ImplicitlyDefined. bool ImplicitlyDefined : 1; - + /// Support for base and member destruction. - /// BaseOrMemberDestructions - The arguments used to destruct the base + /// BaseOrMemberDestructions - The arguments used to destruct the base /// or member. Each uintptr_t value represents one of base classes (either /// virtual or direct non-virtual base), or non-static data member /// to be destroyed. The low two bits encode the kind of object /// being destroyed. uintptr_t *BaseOrMemberDestructions; unsigned NumBaseOrMemberDestructions; - + CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation L, DeclarationName N, QualType T, bool isInline, bool isImplicitlyDeclared) : CXXMethodDecl(CXXDestructor, RD, L, N, T, /*DInfo=*/0, false, isInline), ImplicitlyDefined(false), - BaseOrMemberDestructions(0), NumBaseOrMemberDestructions(0) { + BaseOrMemberDestructions(0), NumBaseOrMemberDestructions(0) { setImplicit(isImplicitlyDeclared); } virtual void Destroy(ASTContext& C); - + public: static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation L, DeclarationName N, - QualType T, bool isInline, + QualType T, bool isInline, bool isImplicitlyDeclared); /// isImplicitlyDefined - Whether this destructor was implicitly /// defined. If false, then this destructor was defined by the /// user. This operation can only be invoked if the destructor has /// already been defined. - bool isImplicitlyDefined() const { - assert(isThisDeclarationADefinition() && + bool isImplicitlyDefined() const { + assert(isThisDeclarationADefinition() && "Can only get the implicit-definition flag once the destructor has been defined"); - return ImplicitlyDefined; + return ImplicitlyDefined; } /// setImplicitlyDefined - Set whether this destructor was /// implicitly defined or not. - void setImplicitlyDefined(bool ID) { - assert(isThisDeclarationADefinition() && + void setImplicitlyDefined(bool ID) { + assert(isThisDeclarationADefinition() && "Can only set the implicit-definition flag once the destructor has been defined"); - ImplicitlyDefined = ID; + ImplicitlyDefined = ID; } /// destr_iterator - Iterates through the member/base destruction list. - + /// destr_const_iterator - Iterates through the member/base destruction list. typedef uintptr_t const destr_const_iterator; - + /// destr_begin() - Retrieve an iterator to the first destructed member/base. - uintptr_t* destr_begin() { - return BaseOrMemberDestructions; + uintptr_t* destr_begin() { + return BaseOrMemberDestructions; } /// destr_begin() - Retrieve an iterator to the first destructed member/base. - uintptr_t* destr_begin() const { - return BaseOrMemberDestructions; + uintptr_t* destr_begin() const { + return BaseOrMemberDestructions; } - + /// destr_end() - Retrieve an iterator past the last destructed member/base. - uintptr_t* destr_end() { - return BaseOrMemberDestructions + NumBaseOrMemberDestructions; + uintptr_t* destr_end() { + return BaseOrMemberDestructions + NumBaseOrMemberDestructions; } /// destr_end() - Retrieve an iterator past the last destructed member/base. - uintptr_t* destr_end() const { - return BaseOrMemberDestructions + NumBaseOrMemberDestructions; + uintptr_t* destr_end() const { + return BaseOrMemberDestructions + NumBaseOrMemberDestructions; } - + /// getNumBaseOrMemberDestructions - Number of base and non-static members /// to destroy. - unsigned getNumBaseOrMemberDestructions() const { - return NumBaseOrMemberDestructions; + unsigned getNumBaseOrMemberDestructions() const { + return NumBaseOrMemberDestructions; } - + /// setNumBaseOrMemberDestructions - Set number of base and non-static members /// to destroy. void setNumBaseOrMemberDestructions(unsigned numBaseOrMemberDestructions) { NumBaseOrMemberDestructions = numBaseOrMemberDestructions; } - - /// getBaseOrMemberToDestroy - get the generic 'member' representing either + + /// getBaseOrMemberToDestroy - get the generic 'member' representing either /// the field or a base class. uintptr_t* getBaseOrMemberToDestroy() const { - return BaseOrMemberDestructions; + return BaseOrMemberDestructions; } - - /// setBaseOrMemberToDestroy - set the generic 'member' representing either + + /// setBaseOrMemberToDestroy - set the generic 'member' representing either /// the field or a base class. void setBaseOrMemberDestructions(uintptr_t* baseOrMemberDestructions) { BaseOrMemberDestructions = baseOrMemberDestructions; } - + /// isVbaseToDestroy - returns true, if object is virtual base. bool isVbaseToDestroy(uintptr_t Vbase) const { return (Vbase & VBASE) != 0; @@ -1209,7 +1209,7 @@ bool isDirectNonVBaseToDestroy(uintptr_t DrctNonVbase) const { return (DrctNonVbase & DRCTNONVBASE) != 0; } - /// isAnyBaseToDestroy - returns true, if object is any base (virtual or + /// isAnyBaseToDestroy - returns true, if object is any base (virtual or /// direct non-virtual) bool isAnyBaseToDestroy(uintptr_t AnyBase) const { return (AnyBase & ANYBASE) != 0; @@ -1225,9 +1225,9 @@ return 0; } /// getMemberToDestroy - Get the member for the given object. - FieldDecl *getMemberToDestroy(uintptr_t Member) const { + FieldDecl *getMemberToDestroy(uintptr_t Member) const { if (isMemberToDestroy(Member)) - return reinterpret_cast(Member); + return reinterpret_cast(Member); return 0; } /// getVbaseClassToDestroy - Get the virtual base. @@ -1242,9 +1242,9 @@ return reinterpret_cast(Base & ~0x02); return 0; } - + // Implement isa/cast/dyncast/etc. - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return D->getKind() == CXXDestructor; } static bool classof(const CXXDestructorDecl *D) { return true; } @@ -1252,7 +1252,7 @@ /// CXXConversionDecl - Represents a C++ conversion function within a /// class. For example: -/// +/// /// @code /// class X { /// public: @@ -1266,7 +1266,7 @@ bool Explicit : 1; CXXConversionDecl(CXXRecordDecl *RD, SourceLocation L, - DeclarationName N, QualType T, DeclaratorInfo *DInfo, + DeclarationName N, QualType T, DeclaratorInfo *DInfo, bool isInline, bool isExplicit) : CXXMethodDecl(CXXConversion, RD, L, N, T, DInfo, false, isInline), Explicit(isExplicit) { } @@ -1284,12 +1284,12 @@ /// getConversionType - Returns the type that this conversion /// function is converting to. - QualType getConversionType() const { - return getType()->getAsFunctionType()->getResultType(); + QualType getConversionType() const { + return getType()->getAsFunctionType()->getResultType(); } // Implement isa/cast/dyncast/etc. - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return D->getKind() == CXXConversion; } static bool classof(const CXXConversionDecl *D) { return true; } @@ -1325,8 +1325,8 @@ SourceLocation FriendL) : Decl(Decl::Friend, DC, L), Friend(Friend), - FriendLoc(FriendL) - {} + FriendLoc(FriendL) { + } public: static FriendDecl *Create(ASTContext &C, DeclContext *DC, @@ -1353,12 +1353,12 @@ } // Implement isa/cast/dyncast/etc. - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return D->getKind() == Decl::Friend; } static bool classof(const FriendDecl *D) { return true; } }; - + /// LinkageSpecDecl - This represents a linkage specification. For example: /// extern "C" void foo(); /// @@ -1378,14 +1378,14 @@ /// HadBraces - Whether this linkage specification had curly braces or not. bool HadBraces : 1; - LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang, + LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang, bool Braces) - : Decl(LinkageSpec, DC, L), + : Decl(LinkageSpec, DC, L), DeclContext(LinkageSpec), Language(lang), HadBraces(Braces) { } public: - static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation L, LanguageIDs Lang, + static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation L, LanguageIDs Lang, bool Braces); LanguageIDs getLanguage() const { return Language; } @@ -1452,8 +1452,8 @@ NamespaceDecl *Nominated, DeclContext *CommonAncestor) : NamedDecl(Decl::UsingDirective, DC, L, getName()), - NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange), - Qualifier(Qualifier), IdentLoc(IdentLoc), + NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange), + Qualifier(Qualifier), IdentLoc(IdentLoc), NominatedNamespace(Nominated? Nominated->getOriginalNamespace() : 0), CommonAncestor(CommonAncestor) { } @@ -1518,20 +1518,20 @@ /// \brief The nested-name-specifier that precedes the namespace /// name, if any. NestedNameSpecifier *Qualifier; - + /// IdentLoc - Location of namespace identifier. SourceLocation IdentLoc; - - /// Namespace - The Decl that this alias points to. Can either be a + + /// Namespace - The Decl that this alias points to. Can either be a /// NamespaceDecl or a NamespaceAliasDecl. NamedDecl *Namespace; - - NamespaceAliasDecl(DeclContext *DC, SourceLocation L, - SourceLocation AliasLoc, IdentifierInfo *Alias, + + NamespaceAliasDecl(DeclContext *DC, SourceLocation L, + SourceLocation AliasLoc, IdentifierInfo *Alias, SourceRange QualifierRange, NestedNameSpecifier *Qualifier, SourceLocation IdentLoc, NamedDecl *Namespace) - : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc), + : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc), QualifierRange(QualifierRange), Qualifier(Qualifier), IdentLoc(IdentLoc), Namespace(Namespace) { } @@ -1550,7 +1550,7 @@ return cast(Namespace); } - + const NamespaceDecl *getNamespace() const { return const_cast(this)->getNamespace(); } @@ -1559,14 +1559,14 @@ /// may either be a NamespaceDecl or a NamespaceAliasDecl. NamedDecl *getAliasedNamespace() const { return Namespace; } - static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation L, SourceLocation AliasLoc, - IdentifierInfo *Alias, + static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation L, SourceLocation AliasLoc, + IdentifierInfo *Alias, SourceRange QualifierRange, NestedNameSpecifier *Qualifier, - SourceLocation IdentLoc, + SourceLocation IdentLoc, NamedDecl *Namespace); - + static bool classof(const Decl *D) { return D->getKind() == Decl::NamespaceAlias; } @@ -1579,16 +1579,16 @@ /// \brief The source range that covers the nested-name-specifier /// preceding the declaration name. SourceRange NestedNameRange; - + /// \brief The source location of the target declaration name. SourceLocation TargetNameLocation; - + /// \brief The source location of the "using" location itself. SourceLocation UsingLocation; - + /// \brief Target declaration. NamedDecl* TargetDecl; - + /// \brief Target nested name specifier. NestedNameSpecifier* TargetNestedNameDecl; @@ -1601,7 +1601,7 @@ : NamedDecl(Decl::Using, DC, L, Target->getDeclName()), NestedNameRange(NNR), TargetNameLocation(TargetNL), UsingLocation(UL), TargetDecl(Target), - TargetNestedNameDecl(TargetNNS), IsTypeName(IsTypeNameArg) { + TargetNestedNameDecl(TargetNNS), IsTypeName(IsTypeNameArg) { this->IdentifierNamespace = TargetDecl->getIdentifierNamespace(); } @@ -1609,22 +1609,22 @@ /// \brief Returns the source range that covers the nested-name-specifier /// preceding the namespace name. SourceRange getNestedNameRange() { return NestedNameRange; } - + /// \brief Returns the source location of the target declaration name. SourceLocation getTargetNameLocation() { return TargetNameLocation; } - + /// \brief Returns the source location of the "using" location itself. SourceLocation getUsingLocation() { return UsingLocation; } - + /// \brief getTargetDecl - Returns target specified by using-decl. NamedDecl *getTargetDecl() { return TargetDecl; } const NamedDecl *getTargetDecl() const { return TargetDecl; } - + /// \brief Get target nested name declaration. - NestedNameSpecifier* getTargetNestedNameDecl() { - return TargetNestedNameDecl; + NestedNameSpecifier* getTargetNestedNameDecl() { + return TargetNestedNameDecl; } - + /// isTypeName - Return true if using decl has 'typename'. bool isTypeName() const { return IsTypeName; } @@ -1645,39 +1645,39 @@ /// \brief The source range that covers the nested-name-specifier /// preceding the declaration name. SourceRange TargetNestedNameRange; - + /// \brief The source location of the target declaration name. SourceLocation TargetNameLocation; - + NestedNameSpecifier *TargetNestedNameSpecifier; - + DeclarationName TargetName; - + // \brief Has 'typename' keyword. bool IsTypeName; - + UnresolvedUsingDecl(DeclContext *DC, SourceLocation UsingLoc, SourceRange TargetNNR, NestedNameSpecifier *TargetNNS, SourceLocation TargetNameLoc, DeclarationName TargetName, bool IsTypeNameArg) : NamedDecl(Decl::UnresolvedUsing, DC, UsingLoc, TargetName), - TargetNestedNameRange(TargetNNR), TargetNameLocation(TargetNameLoc), - TargetNestedNameSpecifier(TargetNNS), TargetName(TargetName), + TargetNestedNameRange(TargetNNR), TargetNameLocation(TargetNameLoc), + TargetNestedNameSpecifier(TargetNNS), TargetName(TargetName), IsTypeName(IsTypeNameArg) { } public: /// \brief Returns the source range that covers the nested-name-specifier /// preceding the namespace name. SourceRange getTargetNestedNameRange() const { return TargetNestedNameRange; } - + /// \brief Get target nested name declaration. - NestedNameSpecifier* getTargetNestedNameSpecifier() { - return TargetNestedNameSpecifier; + NestedNameSpecifier* getTargetNestedNameSpecifier() { + return TargetNestedNameSpecifier; } - + /// \brief Returns the source location of the target declaration name. SourceLocation getTargetNameLocation() const { return TargetNameLocation; } - + /// \brief Returns the source location of the target declaration name. DeclarationName getTargetName() const { return TargetName; } @@ -1690,33 +1690,33 @@ SourceLocation TargetNameLoc, DeclarationName TargetName, bool IsTypeNameArg); - + static bool classof(const Decl *D) { return D->getKind() == Decl::UnresolvedUsing; } static bool classof(const UnresolvedUsingDecl *D) { return true; } }; - + /// StaticAssertDecl - Represents a C++0x static_assert declaration. class StaticAssertDecl : public Decl { Expr *AssertExpr; StringLiteral *Message; - StaticAssertDecl(DeclContext *DC, SourceLocation L, + StaticAssertDecl(DeclContext *DC, SourceLocation L, Expr *assertexpr, StringLiteral *message) : Decl(StaticAssert, DC, L), AssertExpr(assertexpr), Message(message) { } - + public: static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, Expr *AssertExpr, StringLiteral *Message); - + Expr *getAssertExpr() { return AssertExpr; } const Expr *getAssertExpr() const { return AssertExpr; } - + StringLiteral *getMessage() { return Message; } const StringLiteral *getMessage() const { return Message; } - + virtual ~StaticAssertDecl(); virtual void Destroy(ASTContext& C); @@ -1730,7 +1730,7 @@ /// into a diagnostic with <<. const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, AccessSpecifier AS); - + } // end namespace clang #endif Modified: cfe/trunk/include/clang/AST/DeclContextInternals.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclContextInternals.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclContextInternals.h (original) +++ cfe/trunk/include/clang/AST/DeclContextInternals.h Wed Sep 9 10:08:12 2009 @@ -57,13 +57,13 @@ Data = reinterpret_cast(New) | (Data & 0x03); } } - + ~StoredDeclsList() { // If this is a vector-form, free the vector. if (VectorTy *Vector = getAsVector()) delete Vector; } - + StoredDeclsList &operator=(const StoredDeclsList &RHS) { if (VectorTy *Vector = getAsVector()) delete Vector; @@ -74,9 +74,9 @@ } return *this; } - + bool isNull() const { return (Data & ~0x03) == 0; } - + NamedDecl *getAsDecl() const { if ((Data & 0x03) != DK_Decl) return 0; @@ -135,27 +135,27 @@ DeclContext::lookup_result getLookupResult(ASTContext &Context) { if (isNull()) return DeclContext::lookup_result(0, 0); - + if (hasDeclarationIDs()) materializeDecls(Context); // If we have a single NamedDecl, return it. if (getAsDecl()) { assert(!isNull() && "Empty list isn't allowed"); - + // Data is a raw pointer to a NamedDecl*, return it. void *Ptr = &Data; return DeclContext::lookup_result((NamedDecl**)Ptr, (NamedDecl**)Ptr+1); } - + assert(getAsVector() && "Must have a vector at this point"); VectorTy &Vector = *getAsVector(); - + // Otherwise, we have a range result. - return DeclContext::lookup_result((NamedDecl **)&Vector[0], + return DeclContext::lookup_result((NamedDecl **)&Vector[0], (NamedDecl **)&Vector[0]+Vector.size()); } - + /// HandleRedeclaration - If this is a redeclaration of an existing decl, /// replace the old one with D and return true. Otherwise return false. bool HandleRedeclaration(ASTContext &Context, NamedDecl *D) { @@ -169,7 +169,7 @@ setOnlyValue(D); return true; } - + // Determine if this declaration is actually a redeclaration. VectorTy &Vec = *getAsVector(); for (VectorTy::iterator OD = Vec.begin(), ODEnd = Vec.end(); @@ -183,10 +183,10 @@ return false; } - + /// AddSubsequentDecl - This is called on the second and later decl when it is /// not a redeclaration to merge it into the appropriate place in our list. - /// + /// void AddSubsequentDecl(NamedDecl *D) { assert(!hasDeclarationIDs() && "Must materialize before adding decls"); @@ -197,7 +197,7 @@ VT->push_back(reinterpret_cast(OldD)); Data = reinterpret_cast(VT) | DK_Decl_Vector; } - + VectorTy &Vec = *getAsVector(); if (isa(D) || D->getIdentifierNamespace() == Decl::IDNS_Tag) @@ -217,4 +217,4 @@ } // end namespace clang -#endif +#endif Modified: cfe/trunk/include/clang/AST/DeclGroup.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclGroup.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclGroup.h (original) +++ cfe/trunk/include/clang/AST/DeclGroup.h Wed Sep 9 10:08:12 2009 @@ -18,7 +18,7 @@ #include namespace clang { - + class ASTContext; class Decl; class DeclGroup; @@ -27,7 +27,7 @@ class DeclGroup { // FIXME: Include a TypeSpecifier object. unsigned NumDecls; - + private: DeclGroup() : NumDecls(0) {} DeclGroup(unsigned numdecls, Decl** decls); @@ -38,34 +38,34 @@ unsigned size() const { return NumDecls; } - Decl*& operator[](unsigned i) { + Decl*& operator[](unsigned i) { assert (i < NumDecls && "Out-of-bounds access."); return *((Decl**) (this+1)); } - - Decl* const& operator[](unsigned i) const { + + Decl* const& operator[](unsigned i) const { assert (i < NumDecls && "Out-of-bounds access."); return *((Decl* const*) (this+1)); } }; - + class DeclGroupRef { // Note this is not a PointerIntPair because we need the address of the // non-group case to be valid as a Decl** for iteration. - enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 }; + enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 }; Decl* D; Kind getKind() const { return (Kind) (reinterpret_cast(D) & Mask); - } - -public: + } + +public: DeclGroupRef() : D(0) {} - + explicit DeclGroupRef(Decl* d) : D(d) {} explicit DeclGroupRef(DeclGroup* dg) : D((Decl*) (reinterpret_cast(dg) | DeclGroupKind)) {} - + static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls) { if (NumDecls == 0) return DeclGroupRef(); @@ -73,10 +73,10 @@ return DeclGroupRef(Decls[0]); return DeclGroupRef(DeclGroup::Create(C, Decls, NumDecls)); } - + typedef Decl** iterator; typedef Decl* const * const_iterator; - + bool isNull() const { return D == 0; } bool isSingleDecl() const { return getKind() == SingleDeclKind; } bool isDeclGroup() const { return getKind() == DeclGroupKind; } @@ -88,7 +88,7 @@ const Decl *getSingleDecl() const { return const_cast(this)->getSingleDecl(); } - + DeclGroup &getDeclGroup() { assert(isDeclGroup() && "Isn't a declgroup"); return *((DeclGroup*)(reinterpret_cast(D) & ~Mask)); @@ -96,7 +96,7 @@ const DeclGroup &getDeclGroup() const { return const_cast(this)->getDeclGroup(); } - + iterator begin() { if (isSingleDecl()) return D ? &D : 0; @@ -109,13 +109,13 @@ DeclGroup &G = getDeclGroup(); return &G[0] + G.size(); } - + const_iterator begin() const { if (isSingleDecl()) return D ? &D : 0; return &getDeclGroup()[0]; } - + const_iterator end() const { if (isSingleDecl()) return D ? &D+1 : 0; @@ -130,7 +130,7 @@ return X; } }; - + } // end clang namespace namespace llvm { Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Sep 9 10:08:12 2009 @@ -43,17 +43,17 @@ ~ObjCListBase() { assert(List == 0 && "Destroy should have been called before dtor"); } - + void Destroy(ASTContext &Ctx); - + unsigned size() const { return NumElts; } bool empty() const { return NumElts == 0; } - + protected: void set(void *const* InList, unsigned Elts, ASTContext &Ctx); }; - - + + /// ObjCList - This is a simple template class used to hold various lists of /// decls etc, which is heavily used by the ObjC front-end. This only use case /// this supports is setting the list all at once and then reading elements out @@ -64,30 +64,30 @@ void set(T* const* InList, unsigned Elts, ASTContext &Ctx) { ObjCListBase::set(reinterpret_cast(InList), Elts, Ctx); } - + typedef T* const * iterator; iterator begin() const { return (iterator)List; } iterator end() const { return (iterator)List+NumElts; } - + T* operator[](unsigned Idx) const { assert(Idx < NumElts && "Invalid access"); return (T*)List[Idx]; } }; - + /// ObjCMethodDecl - Represents an instance or class method declaration. /// ObjC methods can be declared within 4 contexts: class interfaces, /// categories, protocols, and class implementations. While C++ member -/// functions leverage C syntax, Objective-C method syntax is modeled after -/// Smalltalk (using colons to specify argument types/expressions). +/// functions leverage C syntax, Objective-C method syntax is modeled after +/// Smalltalk (using colons to specify argument types/expressions). /// Here are some brief examples: /// /// Setter/getter instance methods: /// - (void)setMenu:(NSMenu *)menu; -/// - (NSMenu *)menu; -/// +/// - (NSMenu *)menu; +/// /// Instance method that takes 2 NSView arguments: /// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView; /// @@ -106,27 +106,27 @@ /// instance (true) or class (false) method. bool IsInstance : 1; bool IsVariadic : 1; - + // Synthesized declaration method for a property setter/getter bool IsSynthesized : 1; - + // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum /// @required/@optional unsigned DeclImplementation : 2; - + // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum /// in, inout, etc. unsigned objcDeclQualifier : 6; - + // Type of this method. QualType MethodDeclType; /// ParamInfo - List of pointers to VarDecls for the formal parameters of this /// Method. ObjCList ParamInfo; - + /// List of attributes for this method declaration. SourceLocation EndLoc; // the location of the ';' or '}'. - + // The following are only used for method definitions, null otherwise. // FIXME: space savings opportunity, consider a sub-class. Stmt *Body; @@ -137,7 +137,7 @@ /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily /// constructed by createImplicitParams. ImplicitParamDecl *CmdDecl; - + ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, DeclContext *contextDecl, @@ -150,7 +150,7 @@ IsInstance(isInstance), IsVariadic(isVariadic), IsSynthesized(isSynthesized), DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None), - MethodDeclType(T), + MethodDeclType(T), EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {} virtual ~ObjCMethodDecl() {} @@ -161,12 +161,12 @@ virtual ObjCMethodDecl *getNextRedeclaration(); public: - + /// Destroy - Call destructors and release memory. virtual void Destroy(ASTContext& C); static ObjCMethodDecl *Create(ASTContext &C, - SourceLocation beginLoc, + SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, DeclContext *contextDecl, bool isInstance = true, @@ -180,25 +180,25 @@ return ObjCDeclQualifier(objcDeclQualifier); } void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; } - + // Location information, modeled after the Stmt API. SourceLocation getLocStart() const { return getLocation(); } SourceLocation getLocEnd() const { return EndLoc; } void setEndLoc(SourceLocation Loc) { EndLoc = Loc; } - virtual SourceRange getSourceRange() const { - return SourceRange(getLocation(), EndLoc); + virtual SourceRange getSourceRange() const { + return SourceRange(getLocation(), EndLoc); } - + ObjCInterfaceDecl *getClassInterface(); const ObjCInterfaceDecl *getClassInterface() const { return const_cast(this)->getClassInterface(); } - + Selector getSelector() const { return getDeclName().getObjCSelector(); } QualType getResultType() const { return MethodDeclType; } void setResultType(QualType T) { MethodDeclType = T; } - + // Iterator access to formal parameters. unsigned param_size() const { return ParamInfo.size(); } typedef ObjCList::iterator param_iterator; @@ -219,7 +219,7 @@ arg_type_iterator arg_type_end() const { return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType)); } - + /// createImplicitParams - Used to lazily create the self and cmd /// implict parameters. This must be called prior to using getSelfDecl() /// or getCmdDecl(). The call is ignored if the implicit paramters @@ -230,27 +230,27 @@ void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; } ImplicitParamDecl * getCmdDecl() const { return CmdDecl; } void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; } - + bool isInstanceMethod() const { return IsInstance; } void setInstanceMethod(bool isInst) { IsInstance = isInst; } bool isVariadic() const { return IsVariadic; } void setVariadic(bool isVar) { IsVariadic = isVar; } - + bool isClassMethod() const { return !IsInstance; } bool isSynthesized() const { return IsSynthesized; } void setSynthesized(bool isSynth) { IsSynthesized = isSynth; } - + // Related to protocols declared in @protocol - void setDeclImplementation(ImplementationControl ic) { - DeclImplementation = ic; + void setDeclImplementation(ImplementationControl ic) { + DeclImplementation = ic; } - ImplementationControl getImplementationControl() const { - return ImplementationControl(DeclImplementation); + ImplementationControl getImplementationControl() const { + return ImplementationControl(DeclImplementation); } - virtual Stmt *getBody() const { - return (Stmt*) Body; + virtual Stmt *getBody() const { + return (Stmt*) Body; } CompoundStmt *getCompoundBody() { return (CompoundStmt*)Body; } void setBody(Stmt *B) { Body = B; } @@ -273,9 +273,9 @@ struct ObjCMethodList { ObjCMethodDecl *Method; ObjCMethodList *Next; - + ObjCMethodList() { - Method = 0; + Method = 0; Next = 0; } ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) { @@ -286,13 +286,13 @@ /// ObjCContainerDecl - Represents a container for method declarations. /// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, -/// ObjCProtocolDecl, and ObjCImplDecl. +/// ObjCProtocolDecl, and ObjCImplDecl. /// class ObjCContainerDecl : public NamedDecl, public DeclContext { SourceLocation AtEndLoc; // marks the end of the method container. public: - ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L, + ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id) : NamedDecl(DK, DC, L, Id), DeclContext(DK) {} @@ -300,24 +300,24 @@ // Iterator access to properties. typedef specific_decl_iterator prop_iterator; - prop_iterator prop_begin() const { + prop_iterator prop_begin() const { return prop_iterator(decls_begin()); } - prop_iterator prop_end() const { + prop_iterator prop_end() const { return prop_iterator(decls_end()); } - + // Iterator access to instance/class methods. typedef specific_decl_iterator method_iterator; - method_iterator meth_begin() const { + method_iterator meth_begin() const { return method_iterator(decls_begin()); } - method_iterator meth_end() const { + method_iterator meth_end() const { return method_iterator(decls_end()); } - typedef filtered_decl_iterator + typedef filtered_decl_iterator instmeth_iterator; instmeth_iterator instmeth_begin() const { return instmeth_iterator(decls_begin()); @@ -326,8 +326,8 @@ return instmeth_iterator(decls_end()); } - typedef filtered_decl_iterator + typedef filtered_decl_iterator classmeth_iterator; classmeth_iterator classmeth_begin() const { return classmeth_iterator(decls_begin()); @@ -345,7 +345,7 @@ return getMethod(Sel, false/*isInstance*/); } ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const; - + ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const; // Marks the end of the container. @@ -355,10 +355,10 @@ virtual SourceRange getSourceRange() const { return SourceRange(getLocation(), getAtEndLoc()); } - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { - return D->getKind() >= ObjCContainerFirst && + return D->getKind() >= ObjCContainerFirst && D->getKind() <= ObjCContainerLast; } static bool classof(const ObjCContainerDecl *D) { return true; } @@ -374,11 +374,11 @@ /// ObjCInterfaceDecl - Represents an ObjC class declaration. For example: /// /// // MostPrimitive declares no super class (not particularly useful). -/// @interface MostPrimitive +/// @interface MostPrimitive /// // no instance variables or methods. /// @end /// -/// // NSResponder inherits from NSObject & implements NSCoding (a protocol). +/// // NSResponder inherits from NSObject & implements NSCoding (a protocol). /// @interface NSResponder : NSObject /// { // instance variables are represented by ObjCIvarDecl. /// id nextResponder; // nextResponder instance variable. @@ -397,32 +397,32 @@ /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType mutable Type *TypeForDecl; friend class ASTContext; - + /// Class's super class. ObjCInterfaceDecl *SuperClass; - + /// Protocols referenced in interface header declaration ObjCList ReferencedProtocols; - + /// Instance variables in the interface. ObjCList IVars; - + /// List of categories defined for this class. /// FIXME: Why is this a linked list?? ObjCCategoryDecl *CategoryList; - + bool ForwardDecl:1; // declared with @class. bool InternalInterface:1; // true - no @interface for @implementation - + SourceLocation ClassLoc; // location of the class identifier. SourceLocation SuperClassLoc; // location of the super class identifier. SourceLocation EndLoc; // marks the '>', '}', or identifier. ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, SourceLocation CLoc, bool FD, bool isInternal); - + virtual ~ObjCInterfaceDecl() {} - + public: /// Destroy - Call destructors and release memory. @@ -430,24 +430,24 @@ static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, - IdentifierInfo *Id, + IdentifierInfo *Id, SourceLocation ClassLoc = SourceLocation(), bool ForwardDecl = false, bool isInternal = false); - const ObjCList &getReferencedProtocols() const { - return ReferencedProtocols; + const ObjCList &getReferencedProtocols() const { + return ReferencedProtocols; } ObjCImplementationDecl *getImplementation() const; void setImplementation(ObjCImplementationDecl *ImplD); ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const; - + // Get the local instance/class method declared in a category. ObjCMethodDecl *getCategoryInstanceMethod(Selector Sel) const; ObjCMethodDecl *getCategoryClassMethod(Selector Sel) const; ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const { - return isInstance ? getInstanceMethod(Sel) + return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel); } @@ -461,29 +461,29 @@ ivar_iterator ivar_end() const { return IVars.end(); } unsigned ivar_size() const { return IVars.size(); } bool ivar_empty() const { return IVars.empty(); } - + /// setProtocolList - Set the list of protocols that this interface /// implements. void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num, ASTContext &C) { ReferencedProtocols.set(List, Num, C); } - + void setIVarList(ObjCIvarDecl * const *List, unsigned Num, ASTContext &C) { IVars.set(List, Num, C); } bool isForwardDecl() const { return ForwardDecl; } void setForwardDecl(bool val) { ForwardDecl = val; } - + ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } - + ObjCCategoryDecl* getCategoryList() const { return CategoryList; } - void setCategoryList(ObjCCategoryDecl *category) { + void setCategoryList(ObjCCategoryDecl *category) { CategoryList = category; } - + /// isSuperClassOf - Return true if this class is the specified class or is a /// super class of the specified interface class. bool isSuperClassOf(const ObjCInterfaceDecl *I) const { @@ -495,7 +495,7 @@ } return false; } - + ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared); ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) { @@ -518,25 +518,25 @@ SourceLocation getLocStart() const { return getLocation(); } // '@'interface SourceLocation getLocEnd() const { return EndLoc; } void setLocEnd(SourceLocation LE) { EndLoc = LE; }; - + void setClassLoc(SourceLocation Loc) { ClassLoc = Loc; } SourceLocation getClassLoc() const { return ClassLoc; } void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; } SourceLocation getSuperClassLoc() const { return SuperClassLoc; } - + /// isImplicitInterfaceDecl - check that this is an implicitly declared /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation /// declaration without an @interface declaration. bool isImplicitInterfaceDecl() const { return InternalInterface; } void setImplicitInterfaceDecl(bool val) { InternalInterface = val; } - + /// ClassImplementsProtocol - Checks that 'lProto' protocol /// has been implemented in IDecl class, its super class or categories (if /// lookupCategory is true). bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID = false); - + // Low-level accessor Type *getTypeForDecl() const { return TypeForDecl; } void setTypeForDecl(Type *TD) const { TypeForDecl = TD; } @@ -565,19 +565,19 @@ enum AccessControl { None, Private, Protected, Public, Package }; - + private: ObjCIvarDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, AccessControl ac, Expr *BW) - : FieldDecl(ObjCIvar, DC, L, Id, T, DInfo, BW, /*Mutable=*/false), + : FieldDecl(ObjCIvar, DC, L, Id, T, DInfo, BW, /*Mutable=*/false), DeclAccess(ac) {} - + public: static ObjCIvarDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo, AccessControl ac, Expr *BW = NULL); - + void setAccessControl(AccessControl ac) { DeclAccess = ac; } AccessControl getAccessControl() const { return AccessControl(DeclAccess); } @@ -585,7 +585,7 @@ AccessControl getCanonicalAccessControl() const { return DeclAccess == None ? Protected : AccessControl(DeclAccess); } - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == ObjCIvar; } static bool classof(const ObjCIvarDecl *D) { return true; } @@ -594,7 +594,7 @@ unsigned DeclAccess : 3; }; - + /// ObjCAtDefsFieldDecl - Represents a field declaration created by an /// @defs(...). class ObjCAtDefsFieldDecl : public FieldDecl { @@ -604,13 +604,13 @@ : FieldDecl(ObjCAtDefsField, DC, L, Id, T, /*DInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ? BW, /*Mutable=*/false) {} - + public: static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *BW); - + virtual void Destroy(ASTContext& C); // Implement isa/cast/dyncast/etc. @@ -619,8 +619,8 @@ }; /// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols -/// declare a pure abstract type (i.e no instance variables are permitted). -/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++ +/// declare a pure abstract type (i.e no instance variables are permitted). +/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++ /// feature with nice semantics and lousy syntax:-). Here is an example: /// /// @protocol NSDraggingInfo @@ -637,7 +637,7 @@ /// /// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and /// protocols are in distinct namespaces. For example, Cocoa defines both -/// an NSObject protocol and class (which isn't allowed in Java). As a result, +/// an NSObject protocol and class (which isn't allowed in Java). As a result, /// protocols are referenced using angle brackets as follows: /// /// id anyObjectThatImplementsNSDraggingInfo; @@ -645,42 +645,42 @@ class ObjCProtocolDecl : public ObjCContainerDecl { /// Referenced protocols ObjCList ReferencedProtocols; - + bool isForwardProtoDecl; // declared with @protocol. - + SourceLocation EndLoc; // marks the '>' or identifier. - + ObjCProtocolDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id) - : ObjCContainerDecl(ObjCProtocol, DC, L, Id), + : ObjCContainerDecl(ObjCProtocol, DC, L, Id), isForwardProtoDecl(true) { } - + virtual ~ObjCProtocolDecl() {} - + public: - static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, + static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id); /// Destroy - Call destructors and release memory. virtual void Destroy(ASTContext& C); - - const ObjCList &getReferencedProtocols() const { + + const ObjCList &getReferencedProtocols() const { return ReferencedProtocols; } typedef ObjCList::iterator protocol_iterator; protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } unsigned protocol_size() const { return ReferencedProtocols.size(); } - + /// setProtocolList - Set the list of protocols that this interface /// implements. void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, ASTContext &C) { ReferencedProtocols.set(List, Num, C); } - + ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName); - + // Lookup a method. First, we search locally. If a method isn't // found, we search referenced protocols and class categories. ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const; @@ -694,34 +694,34 @@ bool isForwardDecl() const { return isForwardProtoDecl; } void setForwardDecl(bool val) { isForwardProtoDecl = val; } - // Location information, modeled after the Stmt API. + // Location information, modeled after the Stmt API. SourceLocation getLocStart() const { return getLocation(); } // '@'protocol SourceLocation getLocEnd() const { return EndLoc; } void setLocEnd(SourceLocation LE) { EndLoc = LE; }; - + static bool classof(const Decl *D) { return D->getKind() == ObjCProtocol; } static bool classof(const ObjCProtocolDecl *D) { return true; } }; - + /// ObjCClassDecl - Specifies a list of forward class declarations. For example: /// /// @class NSCursor, NSImage, NSPasteboard, NSWindow; /// class ObjCClassDecl : public Decl { ObjCList ForwardDecls; - - ObjCClassDecl(DeclContext *DC, SourceLocation L, + + ObjCClassDecl(DeclContext *DC, SourceLocation L, ObjCInterfaceDecl *const *Elts, unsigned nElts, ASTContext &C); virtual ~ObjCClassDecl() {} public: - + /// Destroy - Call destructors and release memory. virtual void Destroy(ASTContext& C); - + static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, - ObjCInterfaceDecl *const *Elts = 0, + ObjCInterfaceDecl *const *Elts = 0, unsigned nElts = 0); - + typedef ObjCList::iterator iterator; iterator begin() const { return ForwardDecls.begin(); } iterator end() const { return ForwardDecls.end(); } @@ -731,33 +731,33 @@ void setClassList(ASTContext &C, ObjCInterfaceDecl*const*List, unsigned Num) { ForwardDecls.set(List, Num, C); } - + static bool classof(const Decl *D) { return D->getKind() == ObjCClass; } static bool classof(const ObjCClassDecl *D) { return true; } }; /// ObjCForwardProtocolDecl - Specifies a list of forward protocol declarations. /// For example: -/// +/// /// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo; -/// +/// class ObjCForwardProtocolDecl : public Decl { ObjCList ReferencedProtocols; - + ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, ObjCProtocolDecl *const *Elts, unsigned nElts, - ASTContext &C); + ASTContext &C); virtual ~ObjCForwardProtocolDecl() {} - + public: static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation L, + SourceLocation L, ObjCProtocolDecl *const *Elts = 0, unsigned Num = 0); /// Destroy - Call destructors and release memory. virtual void Destroy(ASTContext& C); - + typedef ObjCList::iterator protocol_iterator; protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } @@ -776,7 +776,7 @@ /// ObjCCategoryDecl - Represents a category declaration. A category allows /// you to add methods to an existing class (without subclassing or modifying -/// the original class interface or implementation:-). Categories don't allow +/// the original class interface or implementation:-). Categories don't allow /// you to add instance data. The following example adds "myMethod" to all /// NSView's within a process: /// @@ -788,31 +788,31 @@ /// several files (a feature more naturally supported in C++). /// /// Categories were originally inspired by dynamic languages such as Common -/// Lisp and Smalltalk. More traditional class-based languages (C++, Java) +/// Lisp and Smalltalk. More traditional class-based languages (C++, Java) /// don't support this level of dynamism, which is both powerful and dangerous. /// class ObjCCategoryDecl : public ObjCContainerDecl { /// Interface belonging to this category ObjCInterfaceDecl *ClassInterface; - + /// referenced protocols in this category. ObjCList ReferencedProtocols; - + /// Next category belonging to this class. /// FIXME: this should not be a singly-linked list. Move storage elsewhere. ObjCCategoryDecl *NextClassCategory; - + SourceLocation EndLoc; // marks the '>' or identifier. - + ObjCCategoryDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id) : ObjCContainerDecl(ObjCCategory, DC, L, Id), ClassInterface(0), NextClassCategory(0){ } public: - + static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id); - + ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; } @@ -826,16 +826,16 @@ ASTContext &C) { ReferencedProtocols.set(List, Num, C); } - - const ObjCList &getReferencedProtocols() const { + + const ObjCList &getReferencedProtocols() const { return ReferencedProtocols; } - + typedef ObjCList::iterator protocol_iterator; protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } unsigned protocol_size() const { return ReferencedProtocols.size(); } - + ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; } void setNextClassCategory(ObjCCategoryDecl *Cat) { NextClassCategory = Cat; @@ -844,11 +844,11 @@ NextClassCategory = ClassInterface->getCategoryList(); ClassInterface->setCategoryList(this); } - // Location information, modeled after the Stmt API. + // Location information, modeled after the Stmt API. SourceLocation getLocStart() const { return getLocation(); } // '@'interface SourceLocation getLocEnd() const { return EndLoc; } void setLocEnd(SourceLocation LE) { EndLoc = LE; }; - + static bool classof(const Decl *D) { return D->getKind() == ObjCCategory; } static bool classof(const ObjCCategoryDecl *D) { return true; } }; @@ -856,43 +856,43 @@ class ObjCImplDecl : public ObjCContainerDecl { /// Class interface for this category implementation ObjCInterfaceDecl *ClassInterface; - + protected: ObjCImplDecl(Kind DK, DeclContext *DC, SourceLocation L, ObjCInterfaceDecl *classInterface) - : ObjCContainerDecl(DK, DC, L, - classInterface? classInterface->getIdentifier() : 0), + : ObjCContainerDecl(DK, DC, L, + classInterface? classInterface->getIdentifier() : 0), ClassInterface(classInterface) {} - + public: virtual ~ObjCImplDecl() {} - + const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } void setClassInterface(ObjCInterfaceDecl *IFace); - void addInstanceMethod(ObjCMethodDecl *method) { + void addInstanceMethod(ObjCMethodDecl *method) { // FIXME: Context should be set correctly before we get here. method->setLexicalDeclContext(this); - addDecl(method); + addDecl(method); } - void addClassMethod(ObjCMethodDecl *method) { + void addClassMethod(ObjCMethodDecl *method) { // FIXME: Context should be set correctly before we get here. method->setLexicalDeclContext(this); - addDecl(method); + addDecl(method); } - + void addPropertyImplementation(ObjCPropertyImplDecl *property); - + ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const; ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const; // Iterator access to properties. typedef specific_decl_iterator propimpl_iterator; - propimpl_iterator propimpl_begin() const { + propimpl_iterator propimpl_begin() const { return propimpl_iterator(decls_begin()); } - propimpl_iterator propimpl_end() const { + propimpl_iterator propimpl_end() const { return propimpl_iterator(decls_end()); } @@ -901,10 +901,10 @@ } static bool classof(const ObjCImplDecl *D) { return true; } }; - -/// ObjCCategoryImplDecl - An object of this class encapsulates a category -/// @implementation declaration. If a category class has declaration of a -/// property, its implementation must be specified in the category's + +/// ObjCCategoryImplDecl - An object of this class encapsulates a category +/// @implementation declaration. If a category class has declaration of a +/// property, its implementation must be specified in the category's /// @implementation declaration. Example: /// @interface I @end /// @interface I(CATEGORY) @@ -926,14 +926,14 @@ static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface); - + /// getIdentifier - Get the identifier that names the class /// interface associated with this implementation. - IdentifierInfo *getIdentifier() const { - return Id; + IdentifierInfo *getIdentifier() const { + return Id; } void setIdentifier(IdentifierInfo *II) { Id = II; } - + ObjCCategoryDecl *getCategoryClass() const; /// getNameAsCString - Get the name of identifier for the class @@ -942,12 +942,12 @@ const char *getNameAsCString() const { return Id ? Id->getName() : ""; } - + /// @brief Get the name of the class associated with this interface. std::string getNameAsString() const { return Id ? Id->getName() : ""; } - + static bool classof(const Decl *D) { return D->getKind() == ObjCCategoryImpl;} static bool classof(const ObjCCategoryImplDecl *D) { return true; } }; @@ -961,30 +961,30 @@ /// @end /// @endcode /// -/// Typically, instance variables are specified in the class interface, +/// Typically, instance variables are specified in the class interface, /// *not* in the implementation. Nevertheless (for legacy reasons), we /// allow instance variables to be specified in the implementation. When /// specified, they need to be *identical* to the interface. /// -class ObjCImplementationDecl : public ObjCImplDecl { +class ObjCImplementationDecl : public ObjCImplDecl { /// Implementation Class's super class. ObjCInterfaceDecl *SuperClass; - - ObjCImplementationDecl(DeclContext *DC, SourceLocation L, + + ObjCImplementationDecl(DeclContext *DC, SourceLocation L, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl) - : ObjCImplDecl(ObjCImplementation, DC, L, classInterface), + : ObjCImplDecl(ObjCImplementation, DC, L, classInterface), SuperClass(superDecl){} -public: - static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation L, +public: + static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation L, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl); - + /// getIdentifier - Get the identifier that names the class /// interface associated with this implementation. - IdentifierInfo *getIdentifier() const { - return getClassInterface()->getIdentifier(); + IdentifierInfo *getIdentifier() const { + return getClassInterface()->getIdentifier(); } /// getNameAsCString - Get the name of identifier for the class @@ -1002,35 +1002,35 @@ const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } ObjCInterfaceDecl *getSuperClass() { return SuperClass; } - + void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } - + typedef specific_decl_iterator ivar_iterator; - ivar_iterator ivar_begin() const { - return ivar_iterator(decls_begin()); + ivar_iterator ivar_begin() const { + return ivar_iterator(decls_begin()); } - ivar_iterator ivar_end() const { + ivar_iterator ivar_end() const { return ivar_iterator(decls_end()); } - unsigned ivar_size() const { + unsigned ivar_size() const { return std::distance(ivar_begin(), ivar_end()); } - bool ivar_empty() const { + bool ivar_empty() const { return ivar_begin() == ivar_end(); } - + static bool classof(const Decl *D) { return D->getKind() == ObjCImplementation; } static bool classof(const ObjCImplementationDecl *D) { return true; } }; -/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is +/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is /// declared as @compatibility_alias alias class. class ObjCCompatibleAliasDecl : public NamedDecl { /// Class that this is an alias of. ObjCInterfaceDecl *AliasedClass; - + ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl* aliasedClass) : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {} @@ -1042,12 +1042,12 @@ const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } - + static bool classof(const Decl *D) { return D->getKind() == ObjCCompatibleAlias; } static bool classof(const ObjCCompatibleAliasDecl *D) { return true; } - + }; /// ObjCPropertyDecl - Represents one property declaration in an interface. @@ -1057,13 +1057,13 @@ class ObjCPropertyDecl : public NamedDecl { public: enum PropertyAttributeKind { - OBJC_PR_noattr = 0x00, - OBJC_PR_readonly = 0x01, + OBJC_PR_noattr = 0x00, + OBJC_PR_readonly = 0x01, OBJC_PR_getter = 0x02, - OBJC_PR_assign = 0x04, - OBJC_PR_readwrite = 0x08, + OBJC_PR_assign = 0x04, + OBJC_PR_readwrite = 0x08, OBJC_PR_retain = 0x10, - OBJC_PR_copy = 0x20, + OBJC_PR_copy = 0x20, OBJC_PR_nonatomic = 0x40, OBJC_PR_setter = 0x80 }; @@ -1073,27 +1073,27 @@ private: QualType DeclType; unsigned PropertyAttributes : 8; - + // @required/@optional unsigned PropertyImplementation : 2; - + Selector GetterName; // getter name of NULL if no getter Selector SetterName; // setter name of NULL if no setter - + ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property - ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, + ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T) : NamedDecl(ObjCProperty, DC, L, Id), DeclType(T), PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None), - GetterName(Selector()), + GetterName(Selector()), SetterName(Selector()), GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {} public: - static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation L, + static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation L, IdentifierInfo *Id, QualType T, PropertyControl propControl = None); QualType getType() const { return DeclType; } @@ -1102,14 +1102,14 @@ PropertyAttributeKind getPropertyAttributes() const { return PropertyAttributeKind(PropertyAttributes); } - void setPropertyAttributes(PropertyAttributeKind PRVal) { + void setPropertyAttributes(PropertyAttributeKind PRVal) { PropertyAttributes |= PRVal; } void makeitReadWriteAttribute(void) { PropertyAttributes &= ~OBJC_PR_readonly; PropertyAttributes |= OBJC_PR_readwrite; - } + } // Helper methods for accessing attributes. @@ -1131,38 +1131,38 @@ Selector getGetterName() const { return GetterName; } void setGetterName(Selector Sel) { GetterName = Sel; } - + Selector getSetterName() const { return SetterName; } void setSetterName(Selector Sel) { SetterName = Sel; } - + ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; } void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; } ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; } void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; } - + // Related to @optional/@required declared in @protocol void setPropertyImplementation(PropertyControl pc) { PropertyImplementation = pc; } PropertyControl getPropertyImplementation() const { return PropertyControl(PropertyImplementation); - } - + } + void setPropertyIvarDecl(ObjCIvarDecl *Ivar) { PropertyIvarDecl = Ivar; } ObjCIvarDecl *getPropertyIvarDecl() const { return PropertyIvarDecl; } - + static bool classof(const Decl *D) { return D->getKind() == ObjCProperty; } static bool classof(const ObjCPropertyDecl *D) { return true; } }; -/// ObjCPropertyImplDecl - Represents implementation declaration of a property +/// ObjCPropertyImplDecl - Represents implementation declaration of a property /// in a class or category implementation block. For example: /// @synthesize prop1 = ivar1; /// @@ -1181,23 +1181,23 @@ ObjCIvarDecl *PropertyIvarDecl; ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L, - ObjCPropertyDecl *property, - Kind PK, + ObjCPropertyDecl *property, + Kind PK, ObjCIvarDecl *ivarDecl) - : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc), + : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl) { assert (PK == Dynamic || PropertyIvarDecl); } - + public: static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation atLoc, SourceLocation L, - ObjCPropertyDecl *property, - Kind PK, + SourceLocation atLoc, SourceLocation L, + ObjCPropertyDecl *property, + Kind PK, ObjCIvarDecl *ivarDecl); - virtual SourceRange getSourceRange() const { - return SourceRange(AtLoc, getLocation()); + virtual SourceRange getSourceRange() const { + return SourceRange(AtLoc, getLocation()); } SourceLocation getLocStart() const { return AtLoc; } void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } @@ -1210,7 +1210,7 @@ Kind getPropertyImplementation() const { return PropertyIvarDecl ? Synthesize : Dynamic; } - + ObjCIvarDecl *getPropertyIvarDecl() const { return PropertyIvarDecl; } @@ -1219,7 +1219,7 @@ static bool classof(const Decl *D) { return D->getKind() == ObjCPropertyImpl; } - static bool classof(const ObjCPropertyImplDecl *D) { return true; } + static bool classof(const ObjCPropertyImplDecl *D) { return true; } }; } // end namespace clang Modified: cfe/trunk/include/clang/AST/DeclTemplate.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclTemplate.h (original) +++ cfe/trunk/include/clang/AST/DeclTemplate.h Wed Sep 9 10:08:12 2009 @@ -53,7 +53,7 @@ SourceLocation RAngleLoc); public: - static TemplateParameterList *Create(ASTContext &C, + static TemplateParameterList *Create(ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, Decl **Params, @@ -115,10 +115,10 @@ bool CopyArgs; } Args; }; - + /// \brief Location of the beginning of this template argument. SourceLocation StartLoc; - + public: /// \brief The type of template argument we're storing. enum ArgKind { @@ -133,21 +133,21 @@ /// The template argument is a value- or type-dependent expression /// stored in an Expr*. Expression = 4, - + /// The template argument is actually a parameter pack. Arguments are stored /// in the Args struct. Pack = 5 } Kind; - + /// \brief Construct an empty, invalid template argument. TemplateArgument() : TypeOrValue(0), StartLoc(), Kind(Null) { } - + /// \brief Construct a template type argument. TemplateArgument(SourceLocation Loc, QualType T) : Kind(Type) { TypeOrValue = reinterpret_cast(T.getAsOpaquePtr()); StartLoc = Loc; } - + /// \brief Construct a template argument that refers to a /// declaration, which is either an external declaration or a /// template declaration. @@ -156,7 +156,7 @@ TypeOrValue = reinterpret_cast(D); StartLoc = Loc; } - + /// \brief Construct an integral constant template argument. TemplateArgument(SourceLocation Loc, const llvm::APSInt &Value, QualType Type) @@ -165,14 +165,14 @@ Integer.Type = Type.getAsOpaquePtr(); StartLoc = Loc; } - - /// \brief Construct a template argument that is an expression. + + /// \brief Construct a template argument that is an expression. /// /// This form of template argument only occurs in template argument /// lists used for dependent types and for expression; it will not /// occur in a non-dependent, canonical template argument list. TemplateArgument(Expr *E); - + /// \brief Copy constructor for a template argument. TemplateArgument(const TemplateArgument &Other) : Kind(Other.Kind) { if (Kind == Integral) { @@ -188,27 +188,27 @@ TypeOrValue = Other.TypeOrValue; StartLoc = Other.StartLoc; } - + TemplateArgument& operator=(const TemplateArgument& Other) { // FIXME: Does not provide the strong guarantee for exception // safety. using llvm::APSInt; - + // FIXME: Handle Packs assert(Kind != Pack && "FIXME: Handle packs"); assert(Other.Kind != Pack && "FIXME: Handle packs"); - + if (Kind == Other.Kind && Kind == Integral) { // Copy integral values. *this->getAsIntegral() = *Other.getAsIntegral(); - Integer.Type = Other.Integer.Type; + Integer.Type = Other.Integer.Type; } else { // Destroy the current integral value, if that's what we're holding. if (Kind == Integral) getAsIntegral()->~APSInt(); - + Kind = Other.Kind; - + if (Other.Kind == Integral) { new (Integer.Value) llvm::APSInt(*Other.getAsIntegral()); Integer.Type = Other.Integer.Type; @@ -216,127 +216,127 @@ TypeOrValue = Other.TypeOrValue; } StartLoc = Other.StartLoc; - + return *this; } - + ~TemplateArgument() { using llvm::APSInt; - + if (Kind == Integral) getAsIntegral()->~APSInt(); else if (Kind == Pack && Args.CopyArgs) delete[] Args.Args; } - + /// \brief Return the kind of stored template argument. ArgKind getKind() const { return Kind; } - + /// \brief Determine whether this template argument has no value. bool isNull() const { return Kind == Null; } - + /// \brief Retrieve the template argument as a type. QualType getAsType() const { if (Kind != Type) return QualType(); - + return QualType::getFromOpaquePtr(reinterpret_cast(TypeOrValue)); } - + /// \brief Retrieve the template argument as a declaration. Decl *getAsDecl() const { if (Kind != Declaration) return 0; return reinterpret_cast(TypeOrValue); } - + /// \brief Retrieve the template argument as an integral value. llvm::APSInt *getAsIntegral() { if (Kind != Integral) return 0; return reinterpret_cast(&Integer.Value[0]); } - + const llvm::APSInt *getAsIntegral() const { return const_cast(this)->getAsIntegral(); } - + /// \brief Retrieve the type of the integral value. QualType getIntegralType() const { if (Kind != Integral) return QualType(); - + return QualType::getFromOpaquePtr(Integer.Type); } - + void setIntegralType(QualType T) { - assert(Kind == Integral && + assert(Kind == Integral && "Cannot set the integral type of a non-integral template argument"); Integer.Type = T.getAsOpaquePtr(); }; - + /// \brief Retrieve the template argument as an expression. Expr *getAsExpr() const { if (Kind != Expression) return 0; - + return reinterpret_cast(TypeOrValue); } - + /// \brief Iterator that traverses the elements of a template argument pack. typedef const TemplateArgument * pack_iterator; - - /// \brief Iterator referencing the first argument of a template argument + + /// \brief Iterator referencing the first argument of a template argument /// pack. pack_iterator pack_begin() const { assert(Kind == Pack); return Args.Args; } - + /// \brief Iterator referencing one past the last argument of a template /// argument pack. pack_iterator pack_end() const { assert(Kind == Pack); return Args.Args + Args.NumArgs; } - + /// \brief The number of template arguments in the given template argument /// pack. unsigned pack_size() const { assert(Kind == Pack); return Args.NumArgs; } - + /// \brief Retrieve the location where the template argument starts. SourceLocation getLocation() const { return StartLoc; } - + /// \brief Construct a template argument pack. void setArgumentPack(TemplateArgument *Args, unsigned NumArgs, bool CopyArgs); - + /// \brief Used to insert TemplateArguments into FoldingSets. void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context) const { ID.AddInteger(Kind); switch (Kind) { case Null: break; - + case Type: getAsType().Profile(ID); break; - + case Declaration: ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : 0); break; - + case Integral: getAsIntegral()->Profile(ID); getIntegralType().Profile(ID); break; - + case Expression: getAsExpr()->Profile(ID, Context, true); break; - + case Pack: ID.AddInteger(Args.NumArgs); for (unsigned I = 0; I != Args.NumArgs; ++I) @@ -350,47 +350,47 @@ TemplateArgument *StructuredArgs; unsigned MaxStructuredArgs; unsigned NumStructuredArgs; - + TemplateArgument *FlatArgs; unsigned MaxFlatArgs; unsigned NumFlatArgs; - + bool AddingToPack; unsigned PackBeginIndex; - + public: TemplateArgumentListBuilder(const TemplateParameterList *Parameters, unsigned NumTemplateArgs) - : StructuredArgs(0), MaxStructuredArgs(Parameters->size()), - NumStructuredArgs(0), FlatArgs(0), + : StructuredArgs(0), MaxStructuredArgs(Parameters->size()), + NumStructuredArgs(0), FlatArgs(0), MaxFlatArgs(std::max(MaxStructuredArgs, NumTemplateArgs)), NumFlatArgs(0), AddingToPack(false), PackBeginIndex(0) { } - + void Append(const TemplateArgument& Arg); void BeginPack(); void EndPack(); - + void ReleaseArgs(); - - unsigned flatSize() const { + + unsigned flatSize() const { return NumFlatArgs; } const TemplateArgument *getFlatArguments() const { return FlatArgs; } - + unsigned structuredSize() const { // If we don't have any structured args, just reuse the flat size. if (!StructuredArgs) return flatSize(); - + return NumStructuredArgs; } const TemplateArgument *getStructuredArguments() const { // If we don't have any structured args, just reuse the flat args. if (!StructuredArgs) return getFlatArguments(); - + return StructuredArgs; } }; @@ -406,44 +406,44 @@ /// The integer value will be non-zero to indicate that this /// template argument list does not own the pointer. llvm::PointerIntPair FlatArguments; - + /// \brief The number of template arguments in this template /// argument list. unsigned NumFlatArguments; - + llvm::PointerIntPair StructuredArguments; unsigned NumStructuredArguments; - + public: TemplateArgumentList(ASTContext &Context, TemplateArgumentListBuilder &Builder, bool TakeArgs); - + ~TemplateArgumentList(); - + /// \brief Retrieve the template argument at a given index. - const TemplateArgument &get(unsigned Idx) const { + const TemplateArgument &get(unsigned Idx) const { assert(Idx < NumFlatArguments && "Invalid template argument index"); return getFlatArgumentList()[Idx]; } - + /// \brief Retrieve the template argument at a given index. const TemplateArgument &operator[](unsigned Idx) const { return get(Idx); } - + /// \brief Retrieve the number of template arguments in this /// template argument list. unsigned size() const { return NumFlatArguments; } - + /// \brief Retrieve the number of template arguments in the /// flattened template argument list. unsigned flat_size() const { return NumFlatArguments; } - + /// \brief Retrieve the flattened template argument list. - const TemplateArgument *getFlatArgumentList() const { + const TemplateArgument *getFlatArgumentList() const { return FlatArguments.getPointer(); } }; - + //===----------------------------------------------------------------------===// // Kinds of Templates //===----------------------------------------------------------------------===// @@ -457,15 +457,13 @@ // This is probably never used. TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name) - : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(0) - { } + : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(0) { } // Construct a template decl with the given name and parameters. // Used when there is not templated element (tt-params, alias?). TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params) - : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(Params) - { } + : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(Params) { } // Construct a template decl with name, parameters, and templated element. TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, @@ -497,26 +495,26 @@ NamedDecl *TemplatedDecl; TemplateParameterList* TemplateParams; }; - -/// \brief Provides information about a function template specialization, + +/// \brief Provides information about a function template specialization, /// which is a FunctionDecl that has been explicitly specialization or /// instantiated from a function template. class FunctionTemplateSpecializationInfo : public llvm::FoldingSetNode { public: - /// \brief The function template specialization that this structure + /// \brief The function template specialization that this structure /// describes. FunctionDecl *Function; - - /// \brief The function template from which this function template + + /// \brief The function template from which this function template /// specialization was generated. /// /// The two bits are contain the top 4 values of TemplateSpecializationKind. llvm::PointerIntPair Template; - + /// \brief The template arguments used to produce the function template /// specialization from the function template. const TemplateArgumentList *TemplateArguments; - + /// \brief Retrieve the template from which this function was specialized. FunctionTemplateDecl *getTemplate() const { return Template.getPointer(); } @@ -527,61 +525,61 @@ /// \brief Set the template specialization kind. void setTemplateSpecializationKind(TemplateSpecializationKind TSK) { - assert(TSK != TSK_Undeclared && + assert(TSK != TSK_Undeclared && "Cannot encode TSK_Undeclared for a function template specialization"); Template.setInt(TSK - 1); } - + void Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, TemplateArguments->getFlatArgumentList(), + Profile(ID, TemplateArguments->getFlatArgumentList(), TemplateArguments->flat_size(), - Function->getASTContext()); + Function->getASTContext()); } - - static void - Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs, + + static void + Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, ASTContext &Context) { ID.AddInteger(NumTemplateArgs); for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg) TemplateArgs[Arg].Profile(ID, Context); - } + } }; - + /// Declaration of a template function. -class FunctionTemplateDecl : public TemplateDecl { +class FunctionTemplateDecl : public TemplateDecl { protected: /// \brief Data that is common to all of the declarations of a given /// function template. struct Common { Common() : InstantiatedFromMember(0) { } - + /// \brief The function template specializations for this function /// template, including explicit specializations and instantiations. llvm::FoldingSet Specializations; - + /// \brief The member function template from which this was most /// directly instantiated (or null). - FunctionTemplateDecl *InstantiatedFromMember; + FunctionTemplateDecl *InstantiatedFromMember; }; - + /// \brief A pointer to the previous declaration (if this is a redeclaration) /// or to the data that is common to all declarations of this function /// template. llvm::PointerUnion CommonOrPrev; - - /// \brief Retrieves the "common" pointer shared by all + + /// \brief Retrieves the "common" pointer shared by all /// (re-)declarations of the same function template. Calling this routine /// may implicitly allocate memory for the common pointer. Common *getCommonPtr(); - + FunctionTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl) : TemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl), CommonOrPrev((Common*)0) { } - + public: void Destroy(ASTContext &C); - + /// Get the underlying function declaration of the template. FunctionDecl *getTemplatedDecl() const { return static_cast(TemplatedDecl); @@ -592,7 +590,7 @@ llvm::FoldingSet &getSpecializations() { return getCommonPtr()->Specializations; } - + /// \brief Retrieve the previous declaration of this function template, or /// NULL if no such declaration exists. const FunctionTemplateDecl *getPreviousDeclaration() const { @@ -604,16 +602,16 @@ FunctionTemplateDecl *getPreviousDeclaration() { return CommonOrPrev.dyn_cast(); } - + /// \brief Set the previous declaration of this function template. void setPreviousDeclaration(FunctionTemplateDecl *Prev) { if (Prev) CommonOrPrev = Prev; } - + virtual FunctionTemplateDecl *getCanonicalDecl(); - - /// \brief Retrieve the member function template that this function template + + /// \brief Retrieve the member function template that this function template /// was instantiated from. /// /// This routine will return non-NULL for member function templates of @@ -627,23 +625,23 @@ /// \endcode /// /// X::A is a CXXMethodDecl (whose parent is X, a - /// ClassTemplateSpecializationDecl) for which getPrimaryTemplate() will + /// ClassTemplateSpecializationDecl) for which getPrimaryTemplate() will /// return X::f, a FunctionTemplateDecl (whose parent is again /// X) for which getInstantiatedFromMemberTemplate() will return - /// X::f, a FunctionTemplateDecl (whose parent is X, a + /// X::f, a FunctionTemplateDecl (whose parent is X, a /// ClassTemplateDecl). /// - /// \returns NULL if this is not an instantiation of a member function + /// \returns NULL if this is not an instantiation of a member function /// template. FunctionTemplateDecl *getInstantiatedFromMemberTemplate() { return getCommonPtr()->InstantiatedFromMember; } - + void setInstantiatedFromMemberTemplate(FunctionTemplateDecl *FTD) { assert(!getCommonPtr()->InstantiatedFromMember); getCommonPtr()->InstantiatedFromMember = FTD; } - + /// Create a template function node. static FunctionTemplateDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, @@ -669,8 +667,7 @@ /// the occurrence within the parameter list. /// This class is inheritedly privately by different kinds of template /// parameters and is not part of the Decl hierarchy. Just a facility. -class TemplateParmPosition -{ +class TemplateParmPosition { protected: // FIXME: This should probably never be called, but it's here as TemplateParmPosition() @@ -692,7 +689,7 @@ /// Get the position of the template parameter within its parameter list. unsigned getPosition() const { return Position; } - + /// Get the index of the template parameter within its parameter list. unsigned getIndex() const { return Position; } }; @@ -721,10 +718,10 @@ /// \brief The default template argument, if any. QualType DefaultArgument; - TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, + TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, bool Typename, QualType Type, bool ParameterPack) : TypeDecl(TemplateTypeParm, DC, L, Id), Typename(Typename), - InheritedDefault(false), ParameterPack(ParameterPack), DefaultArgument() { + InheritedDefault(false), ParameterPack(ParameterPack), DefaultArgument() { TypeForDecl = Type.getTypePtr(); } @@ -787,7 +784,7 @@ unsigned P, IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo) : VarDecl(NonTypeTemplateParm, DC, L, Id, T, DInfo, VarDecl::None), - TemplateParmPosition(D, P), DefaultArgument(0) + TemplateParmPosition(D, P), DefaultArgument(0) { } public: @@ -798,7 +795,7 @@ using TemplateParmPosition::getDepth; using TemplateParmPosition::getPosition; using TemplateParmPosition::getIndex; - + /// \brief Determine whether this template parameter has a default /// argument. bool hasDefaultArgument() const { return DefaultArgument; } @@ -850,7 +847,7 @@ using TemplateParmPosition::getDepth; using TemplateParmPosition::getPosition; using TemplateParmPosition::getIndex; - + /// \brief Determine whether this template parameter has a default /// argument. bool hasDefaultArgument() const { return DefaultArgument; } @@ -882,26 +879,26 @@ /// /// \code /// template class array; -/// -/// template<> +/// +/// template<> /// class array { }; // class template specialization array /// \endcode -class ClassTemplateSpecializationDecl +class ClassTemplateSpecializationDecl : public CXXRecordDecl, public llvm::FoldingSetNode { - - /// \brief Structure that stores information about a class template + + /// \brief Structure that stores information about a class template /// specialization that was instantiated from a class template partial /// specialization. struct SpecializedPartialSpecialization { /// \brief The class template partial specialization from which this /// class template specialization was instantiated. ClassTemplatePartialSpecializationDecl *PartialSpecialization; - + /// \brief The template argument list deduced for the class template /// partial specialization itself. TemplateArgumentList *TemplateArgs; }; - + /// \brief The template that this specialization specializes llvm::PointerUnion SpecializedTemplate; @@ -919,7 +916,7 @@ ClassTemplateDecl *SpecializedTemplate, TemplateArgumentListBuilder &Builder, ClassTemplateSpecializationDecl *PrevDecl); - + public: static ClassTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation L, @@ -932,9 +929,9 @@ /// \brief Retrieve the template that this specialization specializes. ClassTemplateDecl *getSpecializedTemplate() const; - /// \brief Retrieve the template arguments of the class template + /// \brief Retrieve the template arguments of the class template /// specialization. - const TemplateArgumentList &getTemplateArgs() const { + const TemplateArgumentList &getTemplateArgs() const { return TemplateArgs; } @@ -952,22 +949,22 @@ /// a template (rather than an explicit specialization), return the /// class template or class template partial specialization from which it /// was instantiated. - llvm::PointerUnion getInstantiatedFrom() const { if (getSpecializationKind() != TSK_ImplicitInstantiation && getSpecializationKind() != TSK_ExplicitInstantiationDefinition && getSpecializationKind() != TSK_ExplicitInstantiationDeclaration) return (ClassTemplateDecl*)0; - - if (SpecializedPartialSpecialization *PartialSpec + + if (SpecializedPartialSpecialization *PartialSpec = SpecializedTemplate.dyn_cast()) return PartialSpec->PartialSpecialization; - + return const_cast( SpecializedTemplate.get()); } - + /// \brief Retrieve the set of template arguments that should be used /// to instantiate members of the class template or class template partial /// specialization from which this class template specialization was @@ -980,25 +977,25 @@ /// deduced template arguments for the class template partial specialization /// itself. const TemplateArgumentList &getTemplateInstantiationArgs() const { - if (SpecializedPartialSpecialization *PartialSpec + if (SpecializedPartialSpecialization *PartialSpec = SpecializedTemplate.dyn_cast()) return *PartialSpec->TemplateArgs; - + return getTemplateArgs(); } - + /// \brief Note that this class template specialization is actually an /// instantiation of the given class template partial specialization whose /// template arguments have been deduced. void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, TemplateArgumentList *TemplateArgs) { - SpecializedPartialSpecialization *PS + SpecializedPartialSpecialization *PS = new (getASTContext()) SpecializedPartialSpecialization(); PS->PartialSpecialization = PartialSpec; PS->TemplateArgs = TemplateArgs; SpecializedTemplate = PS; } - + /// \brief Sets the type of this specialization as it was written by /// the user. This will be a class template specialization type. void setTypeAsWritten(QualType T) { @@ -1010,15 +1007,15 @@ getASTContext()); } - static void - Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs, + static void + Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, ASTContext &Context) { ID.AddInteger(NumTemplateArgs); for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg) TemplateArgs[Arg].Profile(ID, Context); } - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return D->getKind() == ClassTemplateSpecialization || D->getKind() == ClassTemplatePartialSpecialization; } @@ -1032,10 +1029,9 @@ } }; -class ClassTemplatePartialSpecializationDecl - : public ClassTemplateSpecializationDecl -{ - /// \brief The list of template parameters +class ClassTemplatePartialSpecializationDecl + : public ClassTemplateSpecializationDecl { + /// \brief The list of template parameters TemplateParameterList* TemplateParams; ClassTemplatePartialSpecializationDecl(ASTContext &Context, @@ -1044,7 +1040,7 @@ ClassTemplateDecl *SpecializedTemplate, TemplateArgumentListBuilder &Builder, ClassTemplatePartialSpecializationDecl *PrevDecl) - : ClassTemplateSpecializationDecl(Context, + : ClassTemplateSpecializationDecl(Context, ClassTemplatePartialSpecialization, DC, L, SpecializedTemplate, Builder, PrevDecl), @@ -1065,7 +1061,7 @@ // FIXME: Add Profile support! - static bool classof(const Decl *D) { + static bool classof(const Decl *D) { return D->getKind() == ClassTemplatePartialSpecialization; } @@ -1088,7 +1084,7 @@ /// \brief The class template partial specializations for this class /// template. - llvm::FoldingSet + llvm::FoldingSet PartialSpecializations; /// \brief The injected-class-name type for this class template. @@ -1104,11 +1100,11 @@ /// \brief Pointer to the data that is common to all of the /// declarations of this class template. - /// + /// /// The first declaration of a class template (e.g., the declaration /// with no "previous declaration") owns this pointer. Common *CommonPtr; - + ClassTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, ClassTemplateDecl *PrevDecl, Common *CommonPtr) @@ -1127,7 +1123,7 @@ ClassTemplateDecl *getPreviousDeclaration() const { return PreviousDeclaration; } - + virtual ClassTemplateDecl *getCanonicalDecl(); /// Create a class template node. @@ -1159,7 +1155,7 @@ /// \returns the class template partial specialization that exactly matches /// the type \p T, or NULL if no such partial specialization exists. ClassTemplatePartialSpecializationDecl *findPartialSpecialization(QualType T); - + /// \brief Retrieve the type of the injected-class-name for this /// class template. /// @@ -1215,7 +1211,7 @@ }; /// Implementation of inline functions that require the template declarations -inline AnyFunctionDecl::AnyFunctionDecl(FunctionTemplateDecl *FTD) +inline AnyFunctionDecl::AnyFunctionDecl(FunctionTemplateDecl *FTD) : Function(FTD) { } } /* end of namespace clang */ Modified: cfe/trunk/include/clang/AST/DeclarationName.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclarationName.h (original) +++ cfe/trunk/include/clang/AST/DeclarationName.h Wed Sep 9 10:08:12 2009 @@ -101,7 +101,7 @@ /// CXXSpecialName, returns a pointer to it. Otherwise, returns /// a NULL pointer. CXXSpecialName *getAsCXXSpecialName() const { - if (getNameKind() >= CXXConstructorName && + if (getNameKind() >= CXXConstructorName && getNameKind() <= CXXConversionFunctionName) return reinterpret_cast(Ptr & ~PtrMask); return 0; @@ -116,16 +116,16 @@ // Construct a declaration name from the name of a C++ constructor, // destructor, or conversion function. - DeclarationName(CXXSpecialName *Name) - : Ptr(reinterpret_cast(Name)) { + DeclarationName(CXXSpecialName *Name) + : Ptr(reinterpret_cast(Name)) { assert((Ptr & PtrMask) == 0 && "Improperly aligned CXXSpecialName"); Ptr |= StoredDeclarationNameExtra; } // Construct a declaration name from the name of a C++ overloaded // operator. - DeclarationName(CXXOperatorIdName *Name) - : Ptr(reinterpret_cast(Name)) { + DeclarationName(CXXOperatorIdName *Name) + : Ptr(reinterpret_cast(Name)) { assert((Ptr & PtrMask) == 0 && "Improperly aligned CXXOperatorId"); Ptr |= StoredDeclarationNameExtra; } @@ -145,8 +145,8 @@ DeclarationName() : Ptr(0) { } // Construct a declaration name from an IdentifierInfo *. - DeclarationName(const IdentifierInfo *II) - : Ptr(reinterpret_cast(II)) { + DeclarationName(const IdentifierInfo *II) + : Ptr(reinterpret_cast(II)) { assert((Ptr & PtrMask) == 0 && "Improperly aligned IdentifierInfo"); } @@ -158,8 +158,8 @@ // operator bool() - Evaluates true when this declaration name is // non-empty. - operator bool() const { - return ((Ptr & PtrMask) != 0) || + operator bool() const { + return ((Ptr & PtrMask) != 0) || (reinterpret_cast(Ptr & ~PtrMask)); } @@ -171,10 +171,10 @@ bool isObjCOneArgSelector() const { return getStoredNameKind() == StoredObjCOneArgSelector; } - + /// getNameKind - Determine what kind of name this is. NameKind getNameKind() const; - + /// getName - Retrieve the human-readable string for this name. std::string getAsString() const; @@ -182,7 +182,7 @@ /// getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in /// this declaration name, or NULL if this declaration name isn't a /// simple identifier. - IdentifierInfo *getAsIdentifierInfo() const { + IdentifierInfo *getAsIdentifierInfo() const { if (isIdentifier()) return reinterpret_cast(Ptr); return 0; @@ -201,7 +201,7 @@ N.Ptr = P; return N; } - + /// getCXXNameType - If this name is one of the C++ names (of a /// constructor, destructor, or conversion function), return the /// type associated with that name. @@ -310,13 +310,13 @@ /// getCXXSpecialName - Returns a declaration name for special kind /// of C++ name, e.g., for a constructor, destructor, or conversion /// function. - DeclarationName getCXXSpecialName(DeclarationName::NameKind Kind, + DeclarationName getCXXSpecialName(DeclarationName::NameKind Kind, CanQualType Ty); /// getCXXOperatorName - Get the name of the overloadable C++ /// operator corresponding to Op. DeclarationName getCXXOperatorName(OverloadedOperatorKind Op); -}; +}; /// Insertion operator for diagnostics. This allows sending DeclarationName's /// into a diagnostic with <<. @@ -326,8 +326,8 @@ Diagnostic::ak_declarationname); return DB; } - - + + } // end namespace clang namespace llvm { @@ -345,7 +345,7 @@ static unsigned getHashValue(clang::DeclarationName); - static inline bool + static inline bool isEqual(clang::DeclarationName LHS, clang::DeclarationName RHS) { return LHS == RHS; } Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Wed Sep 9 10:08:12 2009 @@ -42,20 +42,20 @@ QualType TR; protected: - /// TypeDependent - Whether this expression is type-dependent + /// TypeDependent - Whether this expression is type-dependent /// (C++ [temp.dep.expr]). bool TypeDependent : 1; - /// ValueDependent - Whether this expression is value-dependent + /// ValueDependent - Whether this expression is value-dependent /// (C++ [temp.dep.constexpr]). bool ValueDependent : 1; // FIXME: Eventually, this constructor should go away and we should // require every subclass to provide type/value-dependence // information. - Expr(StmtClass SC, QualType T) + Expr(StmtClass SC, QualType T) : Stmt(SC), TypeDependent(false), ValueDependent(false) { - setType(T); + setType(T); } Expr(StmtClass SC, QualType T, bool TD, bool VD) @@ -66,7 +66,7 @@ /// \brief Construct an empty expression. explicit Expr(StmtClass SC, EmptyShell) : Stmt(SC) { } -public: +public: /// \brief Increases the reference count for this expression. /// /// Invoke the Retain() operation when this expression @@ -75,9 +75,9 @@ Stmt::Retain(); return this; } - + QualType getType() const { return TR; } - void setType(QualType t) { + void setType(QualType t) { // In C++, the type of an expression is always adjusted so that it // will not have reference type an expression will never have // reference type (C++ [expr]p6). Use @@ -85,16 +85,16 @@ // type. Additionally, inspect Expr::isLvalue to determine whether // an expression that is adjusted in this manner should be // considered an lvalue. - assert((TR.isNull() || !TR->isReferenceType()) && + assert((TR.isNull() || !TR->isReferenceType()) && "Expressions can't have reference type"); - TR = t; + TR = t; } /// isValueDependent - Determines whether this expression is /// value-dependent (C++ [temp.dep.constexpr]). For example, the /// array bound of "Chars" in the following example is - /// value-dependent. + /// value-dependent. /// @code /// template struct meta_string; /// @endcode @@ -109,7 +109,7 @@ /// example, the expressions "x" and "x + y" are type-dependent in /// the following code, but "y" is not type-dependent: /// @code - /// template + /// template /// void add(T x, int y) { /// x + y; /// } @@ -127,14 +127,14 @@ /// getExprLoc - Return the preferred location for the arrow when diagnosing /// a problem with a generic expression. virtual SourceLocation getExprLoc() const { return getLocStart(); } - + /// isUnusedResultAWarning - Return true if this immediate expression should /// be warned about if the result is unused. If so, fill in Loc and Ranges /// with location to warn on and the source range[s] to report with the /// warning. bool isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, SourceRange &R2) const; - + /// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or /// incomplete type other than void. Nonarray expressions that can be lvalues: /// - name, where name must be a variable @@ -159,10 +159,10 @@ // Same as above, but excluding checks for non-object and void types in C isLvalueResult isLvalueInternal(ASTContext &Ctx) const; - + /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, /// does not have an incomplete type, does not have a const-qualified type, - /// and if it is a structure or union, does not have any member (including, + /// and if it is a structure or union, does not have any member (including, /// recursively, any member or element of all contained aggregates or unions) /// with a const-qualified type. /// @@ -186,7 +186,7 @@ }; isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc = 0) const; - + /// \brief If this expression refers to a bit-field, retrieve the /// declaration of that bit-field. FieldDecl *getBitField(); @@ -194,7 +194,7 @@ const FieldDecl *getBitField() const { return const_cast(this)->getBitField(); } - + /// isIntegerConstantExpr - Return true if this expression is a valid integer /// constant expression, and, if so, return its value in Result. If not a /// valid i-c-e, return false and fill in Loc (if specified) with the location @@ -209,16 +209,16 @@ /// isConstantInitializer - Returns true if this expression is a constant /// initializer, which can be emitted at compile-time. bool isConstantInitializer(ASTContext &Ctx) const; - + /// EvalResult is a struct with detailed info about an evaluated expression. struct EvalResult { /// Val - This is the value the expression can be folded to. APValue Val; - + /// HasSideEffects - Whether the evaluated expression has side effects. /// For example, (f() && 0) can be folded, but it still has side effects. bool HasSideEffects; - + /// Diag - If the expression is unfoldable, then Diag contains a note /// diagnostic indicating why it's not foldable. DiagLoc indicates a caret /// position for the error, and DiagExpr is the expression that caused @@ -230,7 +230,7 @@ unsigned Diag; const Expr *DiagExpr; SourceLocation DiagLoc; - + EvalResult() : HasSideEffects(false), Diag(0), DiagExpr(0) {} }; @@ -257,11 +257,11 @@ bool isNullPointerConstant(ASTContext &Ctx) const; /// isOBJCGCCandidate - Return true if this expression may be used in a read/ - /// write barrier. + /// write barrier. bool isOBJCGCCandidate(ASTContext &Ctx) const; - + /// IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return - /// its subexpression. If that subexpression is also a ParenExpr, + /// its subexpression. If that subexpression is also a ParenExpr, /// then this method recursively returns its subexpression, and so forth. /// Otherwise, the method returns the current Expr. Expr* IgnoreParens(); @@ -269,12 +269,12 @@ /// IgnoreParenCasts - Ignore parentheses and casts. Strip off any ParenExpr /// or CastExprs, returning their operand. Expr *IgnoreParenCasts(); - + /// IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the /// value (including ptr->int casts of the same size). Strip off any /// ParenExpr or CastExprs, returning their operand. Expr *IgnoreParenNoopCasts(ASTContext &Ctx); - + const Expr* IgnoreParens() const { return const_cast(this)->IgnoreParens(); } @@ -284,18 +284,18 @@ const Expr *IgnoreParenNoopCasts(ASTContext &Ctx) const { return const_cast(this)->IgnoreParenNoopCasts(Ctx); } - + static bool hasAnyTypeDependentArguments(Expr** Exprs, unsigned NumExprs); static bool hasAnyValueDependentArguments(Expr** Exprs, unsigned NumExprs); - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() >= firstExprConstant && - T->getStmtClass() <= lastExprConstant; + T->getStmtClass() <= lastExprConstant; } static bool classof(const Expr *) { return true; } }; - + //===----------------------------------------------------------------------===// // Primary Expressions. //===----------------------------------------------------------------------===// @@ -303,7 +303,7 @@ /// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function, /// enum, etc. class DeclRefExpr : public Expr { - NamedDecl *D; + NamedDecl *D; SourceLocation Loc; protected: @@ -319,14 +319,14 @@ public: // FIXME: Eventually, this constructor will go away and all clients // will have to provide the type- and value-dependent flags. - DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l) : + DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l) : Expr(DeclRefExprClass, t), D(d), Loc(l) {} - DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, bool VD) : + DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, bool VD) : Expr(DeclRefExprClass, t, TD, VD), D(d), Loc(l) {} - + /// \brief Construct an empty declaration reference expression. - explicit DeclRefExpr(EmptyShell Empty) + explicit DeclRefExpr(EmptyShell Empty) : Expr(DeclRefExprClass, Empty) { } NamedDecl *getDecl() { return D; } @@ -336,14 +336,14 @@ SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == DeclRefExprClass || T->getStmtClass() == CXXConditionDeclExprClass || - T->getStmtClass() == QualifiedDeclRefExprClass; + T->getStmtClass() == QualifiedDeclRefExprClass; } static bool classof(const DeclRefExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -357,16 +357,16 @@ Function, PrettyFunction }; - + private: SourceLocation Loc; IdentType Type; public: - PredefinedExpr(SourceLocation l, QualType type, IdentType IT) + PredefinedExpr(SourceLocation l, QualType type, IdentType IT) : Expr(PredefinedExprClass, type), Loc(l), Type(IT) {} - + /// \brief Construct an empty predefined expression. - explicit PredefinedExpr(EmptyShell Empty) + explicit PredefinedExpr(EmptyShell Empty) : Expr(PredefinedExprClass, Empty) { } IdentType getIdentType() const { return Type; } @@ -380,11 +380,11 @@ virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == PredefinedExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == PredefinedExprClass; } static bool classof(const PredefinedExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -394,7 +394,7 @@ llvm::APInt Value; SourceLocation Loc; public: - // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy, + // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy, // or UnsignedLongLongTy IntegerLiteral(const llvm::APInt &V, QualType type, SourceLocation l) : Expr(IntegerLiteralClass, type), Value(V), Loc(l) { @@ -402,7 +402,7 @@ } /// \brief Construct an empty integer literal. - explicit IntegerLiteral(EmptyShell Empty) + explicit IntegerLiteral(EmptyShell Empty) : Expr(IntegerLiteralClass, Empty) { } const llvm::APInt &getValue() const { return Value; } @@ -414,11 +414,11 @@ void setValue(const llvm::APInt &Val) { Value = Val; } void setLocation(SourceLocation Location) { Loc = Location; } - static bool classof(const Stmt *T) { - return T->getStmtClass() == IntegerLiteralClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == IntegerLiteralClass; } static bool classof(const IntegerLiteral *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -439,17 +439,17 @@ SourceLocation getLocation() const { return Loc; } bool isWide() const { return IsWide; } - + virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - + unsigned getValue() const { return Value; } void setLocation(SourceLocation Location) { Loc = Location; } void setWide(bool W) { IsWide = W; } void setValue(unsigned Val) { Value = Val; } - static bool classof(const Stmt *T) { - return T->getStmtClass() == CharacterLiteralClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == CharacterLiteralClass; } static bool classof(const CharacterLiteral *) { return true; } @@ -463,12 +463,12 @@ bool IsExact : 1; SourceLocation Loc; public: - FloatingLiteral(const llvm::APFloat &V, bool isexact, + FloatingLiteral(const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L) - : Expr(FloatingLiteralClass, Type), Value(V), IsExact(isexact), Loc(L) {} + : Expr(FloatingLiteralClass, Type), Value(V), IsExact(isexact), Loc(L) {} /// \brief Construct an empty floating-point literal. - explicit FloatingLiteral(EmptyShell Empty) + explicit FloatingLiteral(EmptyShell Empty) : Expr(FloatingLiteralClass, Empty), Value(0.0) { } const llvm::APFloat &getValue() const { return Value; } @@ -481,7 +481,7 @@ /// double. Note that this may cause loss of precision, but is useful for /// debugging dumps, etc. double getValueAsApproximateDouble() const; - + SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } @@ -489,14 +489,14 @@ // into a method here that takes the inner-most code decl (a block, function // or objc method) that the expr lives in. This would allow sema and codegen // to be consistent for things like sizeof(__func__) etc. - + virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == FloatingLiteralClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == FloatingLiteralClass; } static bool classof(const FloatingLiteral *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -512,9 +512,9 @@ public: ImaginaryLiteral(Expr *val, QualType Ty) : Expr(ImaginaryLiteralClass, Ty), Val(val) {} - + /// \brief Build an empty imaginary literal. - explicit ImaginaryLiteral(EmptyShell Empty) + explicit ImaginaryLiteral(EmptyShell Empty) : Expr(ImaginaryLiteralClass, Empty) { } const Expr *getSubExpr() const { return cast(Val); } @@ -522,11 +522,11 @@ void setSubExpr(Expr *E) { Val = E; } virtual SourceRange getSourceRange() const { return Val->getSourceRange(); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ImaginaryLiteralClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ImaginaryLiteralClass; } static bool classof(const ImaginaryLiteral *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -556,7 +556,7 @@ SourceLocation TokLocs[1]; StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty) {} - + protected: virtual void DoDestroy(ASTContext &C); @@ -568,7 +568,7 @@ const SourceLocation *Loc, unsigned NumStrs); /// Simple constructor for string literals made from one token. - static StringLiteral *Create(ASTContext &C, const char *StrData, + static StringLiteral *Create(ASTContext &C, const char *StrData, unsigned ByteLength, bool Wide, QualType Ty, SourceLocation Loc) { return Create(C, StrData, ByteLength, Wide, Ty, &Loc, 1); @@ -595,12 +595,12 @@ /// getNumConcatenated - Get the number of string literal tokens that were /// concatenated in translation phase #6 to form this string literal. unsigned getNumConcatenated() const { return NumConcatenated; } - + SourceLocation getStrTokenLoc(unsigned TokNum) const { assert(TokNum < NumConcatenated && "Invalid tok number"); return TokLocs[TokNum]; } - void setStrTokenLoc(unsigned TokNum, SourceLocation L) { + void setStrTokenLoc(unsigned TokNum, SourceLocation L) { assert(TokNum < NumConcatenated && "Invalid tok number"); TokLocs[TokNum] = L; } @@ -609,14 +609,14 @@ tokloc_iterator tokloc_begin() const { return TokLocs; } tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; } - virtual SourceRange getSourceRange() const { - return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]); + virtual SourceRange getSourceRange() const { + return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == StringLiteralClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == StringLiteralClass; } static bool classof(const StringLiteral *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -630,11 +630,11 @@ public: ParenExpr(SourceLocation l, SourceLocation r, Expr *val) : Expr(ParenExprClass, val->getType(), - val->isTypeDependent(), val->isValueDependent()), + val->isTypeDependent(), val->isValueDependent()), L(l), R(r), Val(val) {} - + /// \brief Construct an empty parenthesized expression. - explicit ParenExpr(EmptyShell Empty) + explicit ParenExpr(EmptyShell Empty) : Expr(ParenExprClass, Empty) { } const Expr *getSubExpr() const { return cast(Val); } @@ -651,11 +651,11 @@ SourceLocation getRParen() const { return R; } void setRParen(SourceLocation Loc) { R = Loc; } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ParenExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ParenExprClass; } static bool classof(const ParenExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -673,7 +673,7 @@ /// later returns zero in the type of the operand. /// /// __builtin_offsetof(type, a.b[10]) is represented as a unary operator whose -/// subexpression is a compound literal with the various MemberExpr and +/// subexpression is a compound literal with the various MemberExpr and /// ArraySubscriptExpr's applied to it. /// class UnaryOperator : public Expr { @@ -693,16 +693,16 @@ Stmt *Val; Opcode Opc; SourceLocation Loc; -public: +public: UnaryOperator(Expr *input, Opcode opc, QualType type, SourceLocation l) : Expr(UnaryOperatorClass, type, input->isTypeDependent() && opc != OffsetOf, - input->isValueDependent()), + input->isValueDependent()), Val(input), Opc(opc), Loc(l) {} /// \brief Build an empty unary operator. - explicit UnaryOperator(EmptyShell Empty) + explicit UnaryOperator(EmptyShell Empty) : Expr(UnaryOperatorClass, Empty), Opc(AddrOf) { } Opcode getOpcode() const { return Opc; } @@ -731,8 +731,8 @@ bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; } bool isOffsetOfOp() const { return Opc == OffsetOf; } static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; } - bool isArithmeticOp() const { return isArithmeticOp(Opc); } - + bool isArithmeticOp() const { return isArithmeticOp(Opc); } + /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "sizeof" or "[pre]++" static const char *getOpcodeStr(Opcode Op); @@ -752,12 +752,12 @@ return SourceRange(Loc, Val->getLocEnd()); } virtual SourceLocation getExprLoc() const { return Loc; } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == UnaryOperatorClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == UnaryOperatorClass; } static bool classof(const UnaryOperator *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -778,7 +778,7 @@ virtual void DoDestroy(ASTContext& C); public: - SizeOfAlignOfExpr(bool issizeof, QualType T, + SizeOfAlignOfExpr(bool issizeof, QualType T, QualType resultType, SourceLocation op, SourceLocation rp) : Expr(SizeOfAlignOfExprClass, resultType, @@ -789,7 +789,7 @@ Argument.Ty = T.getAsOpaquePtr(); } - SizeOfAlignOfExpr(bool issizeof, Expr *E, + SizeOfAlignOfExpr(bool issizeof, Expr *E, QualType resultType, SourceLocation op, SourceLocation rp) : Expr(SizeOfAlignOfExprClass, resultType, @@ -821,9 +821,9 @@ } void setArgument(Expr *E) { Argument.Ex = E; isType = false; } - void setArgument(QualType T) { - Argument.Ty = T.getAsOpaquePtr(); - isType = true; + void setArgument(QualType T) { + Argument.Ty = T.getAsOpaquePtr(); + isType = true; } /// Gets the argument type, or the type of the argument expression, whichever @@ -842,11 +842,11 @@ return SourceRange(OpLoc, RParenLoc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == SizeOfAlignOfExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == SizeOfAlignOfExprClass; } static bool classof(const SizeOfAlignOfExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -859,7 +859,7 @@ /// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting. class ArraySubscriptExpr : public Expr { enum { LHS, RHS, END_EXPR=2 }; - Stmt* SubExprs[END_EXPR]; + Stmt* SubExprs[END_EXPR]; SourceLocation RBracketLoc; public: ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t, @@ -871,7 +871,7 @@ SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; } - + /// \brief Create an empty array subscript expression. explicit ArraySubscriptExpr(EmptyShell Shell) : Expr(ArraySubscriptExprClass, Shell) { } @@ -892,37 +892,37 @@ Expr *getRHS() { return cast(SubExprs[RHS]); } const Expr *getRHS() const { return cast(SubExprs[RHS]); } void setRHS(Expr *E) { SubExprs[RHS] = E; } - - Expr *getBase() { + + Expr *getBase() { return cast(getRHS()->getType()->isIntegerType() ? getLHS():getRHS()); } - - const Expr *getBase() const { + + const Expr *getBase() const { return cast(getRHS()->getType()->isIntegerType() ? getLHS():getRHS()); } - - Expr *getIdx() { + + Expr *getIdx() { return cast(getRHS()->getType()->isIntegerType() ? getRHS():getLHS()); } - + const Expr *getIdx() const { return cast(getRHS()->getType()->isIntegerType() ? getRHS():getLHS()); - } - - virtual SourceRange getSourceRange() const { + } + + virtual SourceRange getSourceRange() const { return SourceRange(getLHS()->getLocStart(), RBracketLoc); } - + SourceLocation getRBracketLoc() const { return RBracketLoc; } void setRBracketLoc(SourceLocation L) { RBracketLoc = L; } virtual SourceLocation getExprLoc() const { return getBase()->getExprLoc(); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ArraySubscriptExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ArraySubscriptExprClass; } static bool classof(const ArraySubscriptExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -930,9 +930,9 @@ /// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]). -/// CallExpr itself represents a normal function call, e.g., "f(x, 2)", +/// CallExpr itself represents a normal function call, e.g., "f(x, 2)", /// while its subclasses may represent alternative syntax that (semantically) -/// results in a function call. For example, CXXOperatorCallExpr is +/// results in a function call. For example, CXXOperatorCallExpr is /// a subclass for overloaded operator calls that use operator syntax, e.g., /// "str1 + str2" to resolve to a function call. class CallExpr : public Expr { @@ -940,23 +940,23 @@ Stmt **SubExprs; unsigned NumArgs; SourceLocation RParenLoc; - + protected: // This version of the constructor is for derived classes. CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args, unsigned numargs, QualType t, SourceLocation rparenloc); virtual void DoDestroy(ASTContext& C); - + public: - CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t, + CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t, SourceLocation rparenloc); - + /// \brief Build an empty call expression. CallExpr(ASTContext &C, StmtClass SC, EmptyShell Empty); ~CallExpr() {} - + const Expr *getCallee() const { return cast(SubExprs[FN]); } Expr *getCallee() { return cast(SubExprs[FN]); } void setCallee(Expr *F) { SubExprs[FN] = F; } @@ -967,7 +967,7 @@ /// getNumArgs - Return the number of actual arguments to this call. /// unsigned getNumArgs() const { return NumArgs; } - + /// getArg - Return the specified argument. Expr *getArg(unsigned Arg) { assert(Arg < NumArgs && "Arg access out of range!"); @@ -977,26 +977,26 @@ assert(Arg < NumArgs && "Arg access out of range!"); return cast(SubExprs[Arg+ARGS_START]); } - + /// setArg - Set the specified argument. void setArg(unsigned Arg, Expr *ArgExpr) { assert(Arg < NumArgs && "Arg access out of range!"); SubExprs[Arg+ARGS_START] = ArgExpr; } - + /// setNumArgs - This changes the number of arguments present in this call. /// Any orphaned expressions are deleted by this, and any new operands are set /// to null. void setNumArgs(ASTContext& C, unsigned NumArgs); - + typedef ExprIterator arg_iterator; typedef ConstExprIterator const_arg_iterator; - + arg_iterator arg_begin() { return SubExprs+ARGS_START; } arg_iterator arg_end() { return SubExprs+ARGS_START+getNumArgs(); } const_arg_iterator arg_begin() const { return SubExprs+ARGS_START; } const_arg_iterator arg_end() const { return SubExprs+ARGS_START+getNumArgs();} - + /// getNumCommas - Return the number of commas that must have been present in /// this function call. unsigned getNumCommas() const { return NumArgs ? NumArgs - 1 : 0; } @@ -1004,23 +1004,23 @@ /// isBuiltinCall - If this is a call to a builtin, return the builtin ID. If /// not, return 0. unsigned isBuiltinCall(ASTContext &Context) const; - - /// getCallReturnType - Get the return type of the call expr. This is not - /// always the type of the expr itself, if the return type is a reference + + /// getCallReturnType - Get the return type of the call expr. This is not + /// always the type of the expr itself, if the return type is a reference /// type. QualType getCallReturnType() const; - + SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const { return SourceRange(getCallee()->getLocStart(), RParenLoc); } - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == CallExprClass || T->getStmtClass() == CXXOperatorCallExprClass || - T->getStmtClass() == CXXMemberCallExprClass; + T->getStmtClass() == CXXMemberCallExprClass; } static bool classof(const CallExpr *) { return true; } static bool classof(const CXXOperatorCallExpr *) { return true; } @@ -1031,75 +1031,75 @@ virtual child_iterator child_end(); }; -/// \brief Represents the qualifier that may precede a C++ name, e.g., the +/// \brief Represents the qualifier that may precede a C++ name, e.g., the /// "std::" in "std::sort". struct NameQualifier { /// \brief The nested name specifier. NestedNameSpecifier *NNS; - + /// \brief The source range covered by the nested name specifier. SourceRange Range; }; /// \brief Represents an explicit template argument list in C++, e.g., -/// the "" in "sort". +/// the "" in "sort". struct ExplicitTemplateArgumentList { /// \brief The source location of the left angle bracket ('<'); SourceLocation LAngleLoc; - + /// \brief The source location of the right angle bracket ('>'); SourceLocation RAngleLoc; - + /// \brief The number of template arguments in TemplateArgs. - /// The actual template arguments (if any) are stored after the + /// The actual template arguments (if any) are stored after the /// ExplicitTemplateArgumentList structure. unsigned NumTemplateArgs; - + /// \brief Retrieve the template arguments - TemplateArgument *getTemplateArgs() { - return reinterpret_cast (this + 1); + TemplateArgument *getTemplateArgs() { + return reinterpret_cast (this + 1); } /// \brief Retrieve the template arguments const TemplateArgument *getTemplateArgs() const { - return reinterpret_cast (this + 1); + return reinterpret_cast (this + 1); } }; - + /// MemberExpr - [C99 6.5.2.3] Structure and Union Members. X->F and X.F. /// class MemberExpr : public Expr { /// Base - the expression for the base pointer or structure references. In /// X.F, this is "X". Stmt *Base; - + /// MemberDecl - This is the decl being referenced by the field/member name. /// In X.F, this is the decl referenced by F. NamedDecl *MemberDecl; - + /// MemberLoc - This is the location of the member name. SourceLocation MemberLoc; - + /// IsArrow - True if this is "X->F", false if this is "X.F". bool IsArrow : 1; - + /// \brief True if this member expression used a nested-name-specifier to - /// refer to the member, e.g., "x->Base::f". When true, a NameQualifier + /// refer to the member, e.g., "x->Base::f". When true, a NameQualifier /// structure is allocated immediately after the MemberExpr. bool HasQualifier : 1; - + /// \brief True if this member expression specified a template argument list /// explicitly, e.g., x->f. When true, an ExplicitTemplateArgumentList /// structure (and its TemplateArguments) are allocated immediately after /// the MemberExpr or, if the member expression also has a qualifier, after /// the NameQualifier structure. bool HasExplicitTemplateArgumentList : 1; - + /// \brief Retrieve the qualifier that preceded the member name, if any. NameQualifier *getMemberQualifier() { if (!HasQualifier) return 0; - + return reinterpret_cast (this + 1); } @@ -1107,48 +1107,48 @@ const NameQualifier *getMemberQualifier() const { return const_cast(this)->getMemberQualifier(); } - + /// \brief Retrieve the explicit template argument list that followed the /// member template name, if any. ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { if (!HasExplicitTemplateArgumentList) return 0; - + if (!HasQualifier) return reinterpret_cast(this + 1); - + return reinterpret_cast( getMemberQualifier() + 1); } - + /// \brief Retrieve the explicit template argument list that followed the /// member template name, if any. const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { return const_cast(this)->getExplicitTemplateArgumentList(); } - - MemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *qual, + + MemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *qual, SourceRange qualrange, NamedDecl *memberdecl, SourceLocation l, - bool has_explicit, SourceLocation langle, - const TemplateArgument *targs, unsigned numtargs, - SourceLocation rangle, QualType ty); + bool has_explicit, SourceLocation langle, + const TemplateArgument *targs, unsigned numtargs, + SourceLocation rangle, QualType ty); public: MemberExpr(Expr *base, bool isarrow, NamedDecl *memberdecl, SourceLocation l, - QualType ty) - : Expr(MemberExprClass, ty, + QualType ty) + : Expr(MemberExprClass, ty, base->isTypeDependent(), base->isValueDependent()), Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow), HasQualifier(false), HasExplicitTemplateArgumentList(false) {} /// \brief Build an empty member reference expression. - explicit MemberExpr(EmptyShell Empty) - : Expr(MemberExprClass, Empty), HasQualifier(false), + explicit MemberExpr(EmptyShell Empty) + : Expr(MemberExprClass, Empty), HasQualifier(false), HasExplicitTemplateArgumentList(false) { } - static MemberExpr *Create(ASTContext &C, Expr *base, bool isarrow, + static MemberExpr *Create(ASTContext &C, Expr *base, bool isarrow, NestedNameSpecifier *qual, SourceRange qualrange, - NamedDecl *memberdecl, + NamedDecl *memberdecl, SourceLocation l, bool has_explicit, SourceLocation langle, @@ -1156,7 +1156,7 @@ unsigned numtargs, SourceLocation rangle, QualType ty); - + void setBase(Expr *E) { Base = E; } Expr *getBase() const { return cast(Base); } @@ -1167,73 +1167,73 @@ NamedDecl *getMemberDecl() const { return MemberDecl; } void setMemberDecl(NamedDecl *D) { MemberDecl = D; } - /// \brief Determines whether this member expression actually had + /// \brief Determines whether this member expression actually had /// a C++ nested-name-specifier prior to the name of the member, e.g., /// x->Base::foo. bool hasQualifier() const { return HasQualifier; } - + /// \brief If the member name was qualified, retrieves the source range of /// the nested-name-specifier that precedes the member name. Otherwise, /// returns an empty source range. - SourceRange getQualifierRange() const { + SourceRange getQualifierRange() const { if (!HasQualifier) return SourceRange(); - + return getMemberQualifier()->Range; } - - /// \brief If the member name was qualified, retrieves the + + /// \brief If the member name was qualified, retrieves the /// nested-name-specifier that precedes the member name. Otherwise, returns /// NULL. - NestedNameSpecifier *getQualifier() const { + NestedNameSpecifier *getQualifier() const { if (!HasQualifier) return 0; - + return getMemberQualifier()->NNS; } /// \brief Determines whether this member expression actually had a C++ /// template argument list explicitly specified, e.g., x.f. - bool hasExplicitTemplateArgumentList() { - return HasExplicitTemplateArgumentList; + bool hasExplicitTemplateArgumentList() { + return HasExplicitTemplateArgumentList; } - - /// \brief Retrieve the location of the left angle bracket following the + + /// \brief Retrieve the location of the left angle bracket following the /// member name ('<'), if any. - SourceLocation getLAngleLoc() const { + SourceLocation getLAngleLoc() const { if (!HasExplicitTemplateArgumentList) return SourceLocation(); - + return getExplicitTemplateArgumentList()->LAngleLoc; } - + /// \brief Retrieve the template arguments provided as part of this /// template-id. - const TemplateArgument *getTemplateArgs() const { + const TemplateArgument *getTemplateArgs() const { if (!HasExplicitTemplateArgumentList) - return 0; - + return 0; + return getExplicitTemplateArgumentList()->getTemplateArgs(); } - + /// \brief Retrieve the number of template arguments provided as part of this /// template-id. - unsigned getNumTemplateArgs() const { + unsigned getNumTemplateArgs() const { if (!HasExplicitTemplateArgumentList) - return 0; - + return 0; + return getExplicitTemplateArgumentList()->NumTemplateArgs; } - - /// \brief Retrieve the location of the right angle bracket following the + + /// \brief Retrieve the location of the right angle bracket following the /// template arguments ('>'). - SourceLocation getRAngleLoc() const { + SourceLocation getRAngleLoc() const { if (!HasExplicitTemplateArgumentList) return SourceLocation(); - + return getExplicitTemplateArgumentList()->RAngleLoc; } - + bool isArrow() const { return IsArrow; } void setArrow(bool A) { IsArrow = A; } @@ -1248,26 +1248,26 @@ SourceLocation EndLoc = MemberLoc; if (HasExplicitTemplateArgumentList) EndLoc = getRAngleLoc(); - + SourceLocation BaseLoc = getBase()->getLocStart(); if (BaseLoc.isInvalid()) return SourceRange(MemberLoc, EndLoc); return SourceRange(BaseLoc, EndLoc); } - + virtual SourceLocation getExprLoc() const { return MemberLoc; } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == MemberExprClass; } static bool classof(const MemberExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; -/// CompoundLiteralExpr - [C99 6.5.2.5] +/// CompoundLiteralExpr - [C99 6.5.2.5] /// class CompoundLiteralExpr : public Expr { /// LParenLoc - If non-null, this is the location of the left paren in a @@ -1281,7 +1281,7 @@ bool fileScope) : Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init), FileScope(fileScope) {} - + /// \brief Construct an empty compound literal. explicit CompoundLiteralExpr(EmptyShell Empty) : Expr(CompoundLiteralExprClass, Empty) { } @@ -1305,11 +1305,11 @@ return SourceRange(LParenLoc, Init->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == CompoundLiteralExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == CompoundLiteralExprClass; } static bool classof(const CompoundLiteralExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1324,74 +1324,74 @@ /// CastKind - the kind of cast this represents. enum CastKind { /// CK_Unknown - Unknown cast kind. - /// FIXME: The goal is to get rid of this and make all casts have a + /// FIXME: The goal is to get rid of this and make all casts have a /// kind so that the AST client doesn't have to try to figure out what's /// going on. CK_Unknown, - + /// CK_BitCast - Used for reinterpret_cast. CK_BitCast, - + /// CK_NoOp - Used for const_cast. CK_NoOp, - + /// CK_DerivedToBase - Derived to base class casts. CK_DerivedToBase, - + /// CK_Dynamic - Dynamic cast. CK_Dynamic, - + /// CK_ToUnion - Cast to union (GCC extension). CK_ToUnion, - + /// CK_ArrayToPointerDecay - Array to pointer decay. CK_ArrayToPointerDecay, - + // CK_FunctionToPointerDecay - Function to pointer decay. CK_FunctionToPointerDecay, - + /// CK_NullToMemberPointer - Null pointer to member pointer. CK_NullToMemberPointer, - + /// CK_BaseToDerivedMemberPointer - Member pointer in base class to /// member pointer in derived class. CK_BaseToDerivedMemberPointer, - /// CK_UserDefinedConversion - Conversion using a user defined type + /// CK_UserDefinedConversion - Conversion using a user defined type /// conversion function. CK_UserDefinedConversion, /// CK_ConstructorConversion - Conversion by constructor CK_ConstructorConversion }; - + struct CastInfo { const CastKind Kind; - + // FIXME: This should assert that the CastKind does not require extra // information. CastInfo(CastKind Kind) : Kind(Kind) { } }; - + private: CastKind Kind; Stmt *Op; protected: - CastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op) : + CastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op) : Expr(SC, ty, // Cast expressions are type-dependent if the type is // dependent (C++ [temp.dep.expr]p3). ty->isDependentType(), // Cast expressions are value-dependent if the type is // dependent or if the subexpression is value-dependent. - ty->isDependentType() || (op && op->isValueDependent())), + ty->isDependentType() || (op && op->isValueDependent())), Kind(info.Kind), Op(op) {} - + /// \brief Construct an empty cast. - CastExpr(StmtClass SC, EmptyShell Empty) + CastExpr(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) { } - + public: CastKind getCastKind() const { return Kind; } void setCastKind(CastKind K) { Kind = K; } @@ -1401,7 +1401,7 @@ const Expr *getSubExpr() const { return cast(Op); } void setSubExpr(Expr *E) { Op = E; } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { StmtClass SC = T->getStmtClass(); if (SC >= CXXNamedCastExprClass && SC <= CXXFunctionalCastExprClass) return true; @@ -1412,7 +1412,7 @@ return false; } static bool classof(const CastExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1430,7 +1430,7 @@ /// @code /// class Base { }; /// class Derived : public Base { }; -/// void f(Derived d) { +/// void f(Derived d) { /// Base& b = d; // initializer is an ImplicitCastExpr to an lvalue of type Base /// } /// @endcode @@ -1439,11 +1439,11 @@ bool LvalueCast; public: - ImplicitCastExpr(QualType ty, const CastInfo &info, Expr *op, bool Lvalue) : + ImplicitCastExpr(QualType ty, const CastInfo &info, Expr *op, bool Lvalue) : CastExpr(ImplicitCastExprClass, ty, info, op), LvalueCast(Lvalue) { } /// \brief Construct an empty implicit cast. - explicit ImplicitCastExpr(EmptyShell Shell) + explicit ImplicitCastExpr(EmptyShell Shell) : CastExpr(ImplicitCastExprClass, Shell) { } @@ -1457,14 +1457,14 @@ /// setLvalueCast - Set whether this cast produces an lvalue. void setLvalueCast(bool Lvalue) { LvalueCast = Lvalue; } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ImplicitCastExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ImplicitCastExprClass; } static bool classof(const ImplicitCastExpr *) { return true; } }; /// ExplicitCastExpr - An explicit cast written in the source -/// code. +/// code. /// /// This class is effectively an abstract class, because it provides /// the basic representation of an explicitly-written cast without @@ -1486,11 +1486,11 @@ protected: ExplicitCastExpr(StmtClass SC, QualType exprTy, const CastInfo &info, - Expr *op, QualType writtenTy) + Expr *op, QualType writtenTy) : CastExpr(SC, exprTy, info, op), TypeAsWritten(writtenTy) {} /// \brief Construct an empty explicit cast. - ExplicitCastExpr(StmtClass SC, EmptyShell Shell) + ExplicitCastExpr(StmtClass SC, EmptyShell Shell) : CastExpr(SC, Shell) { } public: @@ -1499,7 +1499,7 @@ QualType getTypeAsWritten() const { return TypeAsWritten; } void setTypeAsWritten(QualType T) { TypeAsWritten = T; } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { StmtClass SC = T->getStmtClass(); if (SC >= ExplicitCastExprClass && SC <= CStyleCastExprClass) return true; @@ -1518,13 +1518,13 @@ SourceLocation LPLoc; // the location of the left paren SourceLocation RPLoc; // the location of the right paren public: - CStyleCastExpr(QualType exprTy, CastKind kind, Expr *op, QualType writtenTy, - SourceLocation l, SourceLocation r) : - ExplicitCastExpr(CStyleCastExprClass, exprTy, kind, op, writtenTy), + CStyleCastExpr(QualType exprTy, CastKind kind, Expr *op, QualType writtenTy, + SourceLocation l, SourceLocation r) : + ExplicitCastExpr(CStyleCastExprClass, exprTy, kind, op, writtenTy), LPLoc(l), RPLoc(r) {} /// \brief Construct an empty C-style explicit cast. - explicit CStyleCastExpr(EmptyShell Shell) + explicit CStyleCastExpr(EmptyShell Shell) : ExplicitCastExpr(CStyleCastExprClass, Shell) { } SourceLocation getLParenLoc() const { return LPLoc; } @@ -1536,8 +1536,8 @@ virtual SourceRange getSourceRange() const { return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == CStyleCastExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == CStyleCastExprClass; } static bool classof(const CStyleCastExpr *) { return true; } }; @@ -1589,22 +1589,22 @@ Stmt* SubExprs[END_EXPR]; Opcode Opc; SourceLocation OpLoc; -public: - +public: + BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, SourceLocation opLoc) : Expr(BinaryOperatorClass, ResTy, lhs->isTypeDependent() || rhs->isTypeDependent(), - lhs->isValueDependent() || rhs->isValueDependent()), + lhs->isValueDependent() || rhs->isValueDependent()), Opc(opc), OpLoc(opLoc) { SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; - assert(!isCompoundAssignmentOp() && + assert(!isCompoundAssignmentOp() && "Use ArithAssignBinaryOperator for compound assignments"); } /// \brief Construct an empty binary operator. - explicit BinaryOperator(EmptyShell Empty) + explicit BinaryOperator(EmptyShell Empty) : Expr(BinaryOperatorClass, Empty), Opc(Comma) { } SourceLocation getOperatorLoc() const { return OpLoc; } @@ -1621,7 +1621,7 @@ virtual SourceRange getSourceRange() const { return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd()); } - + /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "<<=". static const char *getOpcodeStr(Opcode Op); @@ -1643,19 +1643,19 @@ static bool isRelationalOp(Opcode Opc) { return Opc >= LT && Opc <= GE; } bool isRelationalOp() const { return isRelationalOp(Opc); } - static bool isEqualityOp(Opcode Opc) { return Opc == EQ || Opc == NE; } + static bool isEqualityOp(Opcode Opc) { return Opc == EQ || Opc == NE; } bool isEqualityOp() const { return isEqualityOp(Opc); } - + static bool isLogicalOp(Opcode Opc) { return Opc == LAnd || Opc == LOr; } bool isLogicalOp() const { return isLogicalOp(Opc); } bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; } bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;} bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; } - - static bool classof(const Stmt *S) { + + static bool classof(const Stmt *S) { return S->getStmtClass() == BinaryOperatorClass || - S->getStmtClass() == CompoundAssignOperatorClass; + S->getStmtClass() == CompoundAssignOperatorClass; } static bool classof(const BinaryOperator *) { return true; } @@ -1671,7 +1671,7 @@ SubExprs[RHS] = rhs; } - BinaryOperator(StmtClass SC, EmptyShell Empty) + BinaryOperator(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty), Opc(MulAssign) { } }; @@ -1692,7 +1692,7 @@ : BinaryOperator(lhs, rhs, opc, ResType, OpLoc, true), ComputationLHSType(CompLHSType), ComputationResultType(CompResultType) { - assert(isCompoundAssignmentOp() && + assert(isCompoundAssignmentOp() && "Only should be used for compound assignments"); } @@ -1710,8 +1710,8 @@ void setComputationResultType(QualType T) { ComputationResultType = T; } static bool classof(const CompoundAssignOperator *) { return true; } - static bool classof(const Stmt *S) { - return S->getStmtClass() == CompoundAssignOperatorClass; + static bool classof(const Stmt *S) { + return S->getStmtClass() == CompoundAssignOperatorClass; } }; @@ -1730,7 +1730,7 @@ // depend on the type of the conditional, but the standard // seems to imply that it could. File a bug! ((lhs && lhs->isTypeDependent()) || (rhs && rhs->isTypeDependent())), - (cond->isValueDependent() || + (cond->isValueDependent() || (lhs && lhs->isValueDependent()) || (rhs && rhs->isValueDependent()))), QuestionLoc(QLoc), @@ -1754,15 +1754,15 @@ // will be the same as getLHS() except a GCC extension allows the left // subexpression to be omitted, and instead of the condition be returned. // e.g: x ?: y is shorthand for x ? x : y, except that the expression "x" - // is only evaluated once. + // is only evaluated once. Expr *getTrueExpr() const { return cast(SubExprs[LHS] ? SubExprs[LHS] : SubExprs[COND]); } - + // getTrueExpr - Return the subexpression representing the value of the ?: // expression if the condition evaluates to false. This is the same as getRHS. Expr *getFalseExpr() const { return cast(SubExprs[RHS]); } - + Expr *getLHS() const { return cast_or_null(SubExprs[LHS]); } void setLHS(Expr *E) { SubExprs[LHS] = E; } @@ -1778,11 +1778,11 @@ virtual SourceRange getSourceRange() const { return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ConditionalOperatorClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ConditionalOperatorClass; } static bool classof(const ConditionalOperator *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1796,9 +1796,9 @@ AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L, QualType t) : Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {} - + /// \brief Build an empty address of a label expression. - explicit AddrLabelExpr(EmptyShell Empty) + explicit AddrLabelExpr(EmptyShell Empty) : Expr(AddrLabelExprClass, Empty) { } SourceLocation getAmpAmpLoc() const { return AmpAmpLoc; } @@ -1809,15 +1809,15 @@ virtual SourceRange getSourceRange() const { return SourceRange(AmpAmpLoc, LabelLoc); } - + LabelStmt *getLabel() const { return Label; } void setLabel(LabelStmt *S) { Label = S; } static bool classof(const Stmt *T) { - return T->getStmtClass() == AddrLabelExprClass; + return T->getStmtClass() == AddrLabelExprClass; } static bool classof(const AddrLabelExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1833,7 +1833,7 @@ StmtExpr(CompoundStmt *substmt, QualType T, SourceLocation lp, SourceLocation rp) : Expr(StmtExprClass, T), SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { } - + /// \brief Build an empty statement expression. explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { } @@ -1844,17 +1844,17 @@ virtual SourceRange getSourceRange() const { return SourceRange(LParenLoc, RParenLoc); } - + SourceLocation getLParenLoc() const { return LParenLoc; } void setLParenLoc(SourceLocation L) { LParenLoc = L; } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - + static bool classof(const Stmt *T) { - return T->getStmtClass() == StmtExprClass; + return T->getStmtClass() == StmtExprClass; } static bool classof(const StmtExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1869,8 +1869,8 @@ QualType Type2; SourceLocation BuiltinLoc, RParenLoc; public: - TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc, - QualType t1, QualType t2, SourceLocation RP) : + TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc, + QualType t1, QualType t2, SourceLocation RP) : Expr(TypesCompatibleExprClass, ReturnType), Type1(t1), Type2(t2), BuiltinLoc(BLoc), RParenLoc(RP) {} @@ -1882,21 +1882,21 @@ void setArgType1(QualType T) { Type1 = T; } QualType getArgType2() const { return Type2; } void setArgType2(QualType T) { Type2 = T; } - + SourceLocation getBuiltinLoc() const { return BuiltinLoc; } void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; } - + SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - + virtual SourceRange getSourceRange() const { return SourceRange(BuiltinLoc, RParenLoc); } static bool classof(const Stmt *T) { - return T->getStmtClass() == TypesCompatibleExprClass; + return T->getStmtClass() == TypesCompatibleExprClass; } static bool classof(const TypesCompatibleExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1919,27 +1919,27 @@ unsigned NumExprs; protected: - virtual void DoDestroy(ASTContext &C); + virtual void DoDestroy(ASTContext &C); public: ShuffleVectorExpr(ASTContext &C, Expr **args, unsigned nexpr, - QualType Type, SourceLocation BLoc, - SourceLocation RP) : + QualType Type, SourceLocation BLoc, + SourceLocation RP) : Expr(ShuffleVectorExprClass, Type), BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(nexpr) { - + SubExprs = new (C) Stmt*[nexpr]; for (unsigned i = 0; i < nexpr; i++) SubExprs[i] = args[i]; } /// \brief Build an empty vector-shuffle expression. - explicit ShuffleVectorExpr(EmptyShell Empty) + explicit ShuffleVectorExpr(EmptyShell Empty) : Expr(ShuffleVectorExprClass, Empty), SubExprs(0) { } SourceLocation getBuiltinLoc() const { return BuiltinLoc; } void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; } - + SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } @@ -1947,17 +1947,17 @@ return SourceRange(BuiltinLoc, RParenLoc); } static bool classof(const Stmt *T) { - return T->getStmtClass() == ShuffleVectorExprClass; + return T->getStmtClass() == ShuffleVectorExprClass; } static bool classof(const ShuffleVectorExpr *) { return true; } - + ~ShuffleVectorExpr() {} - + /// getNumSubExprs - Return the size of the SubExprs array. This includes the /// constant expression, the actual arguments passed in, and the function /// pointers. unsigned getNumSubExprs() const { return NumExprs; } - + /// getExpr - Return the Expr at the specified index. Expr *getExpr(unsigned Index) { assert((Index < NumExprs) && "Arg access out of range!"); @@ -1967,21 +1967,21 @@ assert((Index < NumExprs) && "Arg access out of range!"); return cast(SubExprs[Index]); } - + void setExprs(ASTContext &C, Expr ** Exprs, unsigned NumExprs); unsigned getShuffleMaskIdx(ASTContext &Ctx, unsigned N) { assert((N < NumExprs - 2) && "Shuffle idx out of range!"); return getExpr(N+2)->EvaluateAsInt(Ctx).getZExtValue(); } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; /// ChooseExpr - GNU builtin-in function __builtin_choose_expr. -/// This AST node is similar to the conditional operator (?:) in C, with +/// This AST node is similar to the conditional operator (?:) in C, with /// the following exceptions: /// - the test expression must be a integer constant expression. /// - the expression returned acts like the chosen subexpression in every @@ -1996,12 +1996,12 @@ public: ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t, SourceLocation RP) - : Expr(ChooseExprClass, t), + : Expr(ChooseExprClass, t), BuiltinLoc(BLoc), RParenLoc(RP) { SubExprs[COND] = cond; SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; - } + } /// \brief Build an empty __builtin_choose_expr. explicit ChooseExpr(EmptyShell Empty) : Expr(ChooseExprClass, Empty) { } @@ -2025,7 +2025,7 @@ SourceLocation getBuiltinLoc() const { return BuiltinLoc; } void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; } - + SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } @@ -2033,10 +2033,10 @@ return SourceRange(BuiltinLoc, RParenLoc); } static bool classof(const Stmt *T) { - return T->getStmtClass() == ChooseExprClass; + return T->getStmtClass() == ChooseExprClass; } static bool classof(const ChooseExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -2053,7 +2053,7 @@ SourceLocation TokenLoc; public: - GNUNullExpr(QualType Ty, SourceLocation Loc) + GNUNullExpr(QualType Ty, SourceLocation Loc) : Expr(GNUNullExprClass, Ty), TokenLoc(Loc) { } /// \brief Build an empty GNU __null expression. @@ -2067,10 +2067,10 @@ return SourceRange(TokenLoc); } static bool classof(const Stmt *T) { - return T->getStmtClass() == GNUNullExprClass; + return T->getStmtClass() == GNUNullExprClass; } static bool classof(const GNUNullExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -2086,7 +2086,7 @@ Val(e), BuiltinLoc(BLoc), RParenLoc(RPLoc) { } - + /// \brief Create an empty __builtin_va_start expression. explicit VAArgExpr(EmptyShell Empty) : Expr(VAArgExprClass, Empty) { } @@ -2096,23 +2096,23 @@ SourceLocation getBuiltinLoc() const { return BuiltinLoc; } void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; } - + SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } virtual SourceRange getSourceRange() const { return SourceRange(BuiltinLoc, RParenLoc); - } + } static bool classof(const Stmt *T) { return T->getStmtClass() == VAArgExprClass; } static bool classof(const VAArgExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); - virtual child_iterator child_end(); + virtual child_iterator child_end(); }; - + /// @brief Describes an C or C++ initializer list. /// /// InitListExpr describes an initializer list, which can be used to @@ -2154,7 +2154,7 @@ // FIXME: Eliminate this vector in favor of ASTContext allocation std::vector InitExprs; SourceLocation LBraceLoc, RBraceLoc; - + /// Contains the initializer list that describes the syntactic form /// written in the source code. InitListExpr *SyntacticForm; @@ -2173,27 +2173,27 @@ /// \brief Build an empty initializer list. explicit InitListExpr(EmptyShell Empty) : Expr(InitListExprClass, Empty) { } - + unsigned getNumInits() const { return InitExprs.size(); } - - const Expr* getInit(unsigned Init) const { + + const Expr* getInit(unsigned Init) const { assert(Init < getNumInits() && "Initializer access out of range!"); return cast_or_null(InitExprs[Init]); } - - Expr* getInit(unsigned Init) { + + Expr* getInit(unsigned Init) { assert(Init < getNumInits() && "Initializer access out of range!"); return cast_or_null(InitExprs[Init]); } - - void setInit(unsigned Init, Expr *expr) { + + void setInit(unsigned Init, Expr *expr) { assert(Init < getNumInits() && "Initializer access out of range!"); InitExprs[Init] = expr; } /// \brief Reserve space for some number of initializers. void reserveInits(unsigned NumInits); - + /// @brief Specify the number of initializers /// /// If there are more than @p NumInits initializers, the remaining @@ -2225,7 +2225,7 @@ bool isExplicit() { return LBraceLoc.isValid() && RBraceLoc.isValid(); } - + SourceLocation getLBraceLoc() const { return LBraceLoc; } void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; } SourceLocation getRBraceLoc() const { return RBraceLoc; } @@ -2234,30 +2234,30 @@ /// @brief Retrieve the initializer list that describes the /// syntactic form of the initializer. /// - /// + /// InitListExpr *getSyntacticForm() const { return SyntacticForm; } void setSyntacticForm(InitListExpr *Init) { SyntacticForm = Init; } bool hadArrayRangeDesignator() const { return HadArrayRangeDesignator; } - void sawArrayRangeDesignator(bool ARD = true) { + void sawArrayRangeDesignator(bool ARD = true) { HadArrayRangeDesignator = ARD; } virtual SourceRange getSourceRange() const { return SourceRange(LBraceLoc, RBraceLoc); - } + } static bool classof(const Stmt *T) { - return T->getStmtClass() == InitListExprClass; + return T->getStmtClass() == InitListExprClass; } static bool classof(const InitListExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); - + typedef std::vector::iterator iterator; typedef std::vector::reverse_iterator reverse_iterator; - + iterator begin() { return InitExprs.begin(); } iterator end() { return InitExprs.end(); } reverse_iterator rbegin() { return InitExprs.rbegin(); } @@ -2271,7 +2271,7 @@ /// designators, or GNU array-range designators) followed by an /// expression that initializes the field or element(s) that the /// designators refer to. For example, given: -/// +/// /// @code /// struct point { /// double x; @@ -2311,7 +2311,7 @@ unsigned NumSubExprs : 16; - DesignatedInitExpr(QualType Ty, unsigned NumDesignators, + DesignatedInitExpr(QualType Ty, unsigned NumDesignators, const Designator *Designators, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr **IndexExprs, unsigned NumIndexExprs, @@ -2322,7 +2322,7 @@ NumDesignators(0), Designators(0), NumSubExprs(NumSubExprs) { } protected: - virtual void DoDestroy(ASTContext &C); + virtual void DoDestroy(ASTContext &C); public: /// A field designator, e.g., ".x". @@ -2334,10 +2334,10 @@ /// IdentifierInfo*. After semantic analysis has resolved that /// name, the field designator will instead store a FieldDecl*. uintptr_t NameOrField; - + /// The location of the '.' in the designated initializer. unsigned DotLoc; - + /// The location of the field name in the designated initializer. unsigned FieldLoc; }; @@ -2353,7 +2353,7 @@ /// indices. Only valid for GNU array-range designators. unsigned EllipsisLoc; /// The location of the ']' terminating the array range designator. - unsigned RBracketLoc; + unsigned RBracketLoc; }; /// @brief Represents a single C99 designator. @@ -2382,8 +2382,8 @@ Designator() {} /// @brief Initializes a field designator. - Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc, - SourceLocation FieldLoc) + Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc, + SourceLocation FieldLoc) : Kind(FieldDesignator) { Field.NameOrField = reinterpret_cast(FieldName) | 0x01; Field.DotLoc = DotLoc.getRawEncoding(); @@ -2391,7 +2391,7 @@ } /// @brief Initializes an array designator. - Designator(unsigned Index, SourceLocation LBracketLoc, + Designator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc) : Kind(ArrayDesignator) { ArrayOrRange.Index = Index; @@ -2401,7 +2401,7 @@ } /// @brief Initializes a GNU array-range designator. - Designator(unsigned Index, SourceLocation LBracketLoc, + Designator(unsigned Index, SourceLocation LBracketLoc, SourceLocation EllipsisLoc, SourceLocation RBracketLoc) : Kind(ArrayRangeDesignator) { ArrayOrRange.Index = Index; @@ -2471,7 +2471,7 @@ } }; - static DesignatedInitExpr *Create(ASTContext &C, Designator *Designators, + static DesignatedInitExpr *Create(ASTContext &C, Designator *Designators, unsigned NumDesignators, Expr **IndexExprs, unsigned NumIndexExprs, SourceLocation EqualOrColonLoc, @@ -2485,8 +2485,8 @@ // Iterator access to the designators. typedef Designator* designators_iterator; designators_iterator designators_begin() { return Designators; } - designators_iterator designators_end() { - return Designators + NumDesignators; + designators_iterator designators_end() { + return Designators + NumDesignators; } Designator *getDesignator(unsigned Idx) { return &designators_begin()[Idx]; } @@ -2508,7 +2508,7 @@ void setGNUSyntax(bool GNU) { GNUSyntax = GNU; } /// @brief Retrieve the initializer value. - Expr *getInit() const { + Expr *getInit() const { return cast(*const_cast(this)->child_begin()); } @@ -2538,19 +2538,19 @@ /// \brief Replaces the designator at index @p Idx with the series /// of designators in [First, Last). - void ExpandDesignator(unsigned Idx, const Designator *First, + void ExpandDesignator(unsigned Idx, const Designator *First, const Designator *Last); virtual SourceRange getSourceRange() const; static bool classof(const Stmt *T) { - return T->getStmtClass() == DesignatedInitExprClass; + return T->getStmtClass() == DesignatedInitExprClass; } static bool classof(const DesignatedInitExpr *) { return true; } // Iterators virtual child_iterator child_begin(); - virtual child_iterator child_end(); + virtual child_iterator child_end(); }; /// \brief Represents an implicitly-generated value initialization of @@ -2561,16 +2561,16 @@ /// initializations not explicitly specified by the user. /// /// \see InitListExpr -class ImplicitValueInitExpr : public Expr { +class ImplicitValueInitExpr : public Expr { public: - explicit ImplicitValueInitExpr(QualType ty) + explicit ImplicitValueInitExpr(QualType ty) : Expr(ImplicitValueInitExprClass, ty) { } /// \brief Construct an empty implicit value initialization. explicit ImplicitValueInitExpr(EmptyShell Empty) : Expr(ImplicitValueInitExprClass, Empty) { } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == ImplicitValueInitExprClass; } static bool classof(const ImplicitValueInitExpr *) { return true; } @@ -2581,7 +2581,7 @@ // Iterators virtual child_iterator child_begin(); - virtual child_iterator child_end(); + virtual child_iterator child_end(); }; @@ -2590,49 +2590,49 @@ unsigned NumExprs; SourceLocation LParenLoc, RParenLoc; -protected: +protected: virtual void DoDestroy(ASTContext& C); - + public: - ParenListExpr(ASTContext& C, SourceLocation lparenloc, Expr **exprs, + ParenListExpr(ASTContext& C, SourceLocation lparenloc, Expr **exprs, unsigned numexprs, SourceLocation rparenloc); ~ParenListExpr() {} /// \brief Build an empty paren list. //explicit ParenListExpr(EmptyShell Empty) : Expr(ParenListExprClass, Empty) { } - + unsigned getNumExprs() const { return NumExprs; } - - const Expr* getExpr(unsigned Init) const { + + const Expr* getExpr(unsigned Init) const { assert(Init < getNumExprs() && "Initializer access out of range!"); return cast_or_null(Exprs[Init]); } - - Expr* getExpr(unsigned Init) { + + Expr* getExpr(unsigned Init) { assert(Init < getNumExprs() && "Initializer access out of range!"); return cast_or_null(Exprs[Init]); } Expr **getExprs() { return reinterpret_cast(Exprs); } - + SourceLocation getLParenLoc() const { return LParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } virtual SourceRange getSourceRange() const { return SourceRange(LParenLoc, RParenLoc); - } + } static bool classof(const Stmt *T) { - return T->getStmtClass() == ParenListExprClass; + return T->getStmtClass() == ParenListExprClass; } static bool classof(const ParenListExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + //===----------------------------------------------------------------------===// // Clang Extensions //===----------------------------------------------------------------------===// @@ -2652,9 +2652,9 @@ public: ExtVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor, SourceLocation loc) - : Expr(ExtVectorElementExprClass, ty), + : Expr(ExtVectorElementExprClass, ty), Base(base), Accessor(&accessor), AccessorLoc(loc) {} - + /// \brief Build an empty vector element expression. explicit ExtVectorElementExpr(EmptyShell Empty) : Expr(ExtVectorElementExprClass, Empty) { } @@ -2671,28 +2671,28 @@ /// getNumElements - Get the number of components being selected. unsigned getNumElements() const; - + /// containsDuplicateElements - Return true if any element access is /// repeated. bool containsDuplicateElements() const; - + /// getEncodedElementAccess - Encode the elements accessed into an llvm /// aggregate Constant of ConstantInt(s). void getEncodedElementAccess(llvm::SmallVectorImpl &Elts) const; - + virtual SourceRange getSourceRange() const { return SourceRange(getBase()->getLocStart(), AccessorLoc); } - + /// isArrow - Return true if the base expression is a pointer to vector, /// return false if the base expression is a vector. bool isArrow() const; - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ExtVectorElementExprClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ExtVectorElementExprClass; } static bool classof(const ExtVectorElementExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -2707,7 +2707,7 @@ bool HasBlockDeclRefExprs; public: BlockExpr(BlockDecl *BD, QualType ty, bool hasBlockDeclRefExprs) - : Expr(BlockExprClass, ty), + : Expr(BlockExprClass, ty), TheBlock(BD), HasBlockDeclRefExprs(hasBlockDeclRefExprs) {} /// \brief Build an empty block expression. @@ -2734,25 +2734,25 @@ bool hasBlockDeclRefExprs() const { return HasBlockDeclRefExprs; } void setHasBlockDeclRefExprs(bool BDRE) { HasBlockDeclRefExprs = BDRE; } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == BlockExprClass; } static bool classof(const BlockExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + /// BlockDeclRefExpr - A reference to a declared variable, function, /// enum, etc. class BlockDeclRefExpr : public Expr { - ValueDecl *D; + ValueDecl *D; SourceLocation Loc; bool IsByRef : 1; bool ConstQualAdded : 1; public: - BlockDeclRefExpr(ValueDecl *d, QualType t, SourceLocation l, bool ByRef, + BlockDeclRefExpr(ValueDecl *d, QualType t, SourceLocation l, bool ByRef, bool constAdded = false) : Expr(BlockDeclRefExprClass, t), D(d), Loc(l), IsByRef(ByRef), ConstQualAdded(constAdded) {} @@ -2761,7 +2761,7 @@ // block. explicit BlockDeclRefExpr(EmptyShell Empty) : Expr(BlockDeclRefExprClass, Empty) { } - + ValueDecl *getDecl() { return D; } const ValueDecl *getDecl() const { return D; } void setDecl(ValueDecl *VD) { D = VD; } @@ -2770,18 +2770,18 @@ void setLocation(SourceLocation L) { Loc = L; } virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - + bool isByRef() const { return IsByRef; } void setByRef(bool BR) { IsByRef = BR; } - + bool isConstQualAdded() const { return ConstQualAdded; } void setConstQualAdded(bool C) { ConstQualAdded = C; } - static bool classof(const Stmt *T) { - return T->getStmtClass() == BlockDeclRefExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == BlockDeclRefExprClass; } static bool classof(const BlockDeclRefExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Sep 9 10:08:12 2009 @@ -47,14 +47,14 @@ OverloadedOperatorKind Operator; public: - CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, - Expr **args, unsigned numargs, QualType t, + CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, + Expr **args, unsigned numargs, QualType t, SourceLocation operatorloc) : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), Operator(Op) {} - explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : + explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : CallExpr(C, CXXOperatorCallExprClass, Empty) { } - + /// getOperator - Returns the kind of overloaded operator that this /// expression refers to. @@ -69,9 +69,9 @@ SourceLocation getOperatorLoc() const { return getRParenLoc(); } virtual SourceRange getSourceRange() const; - - static bool classof(const Stmt *T) { - return T->getStmtClass() == CXXOperatorCallExprClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == CXXOperatorCallExprClass; } static bool classof(const CXXOperatorCallExpr *) { return true; } }; @@ -95,7 +95,7 @@ /// operation would return "x". Expr *getImplicitObjectArgument(); - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXMemberCallExprClass; } static bool classof(const CXXMemberCallExpr *) { return true; } @@ -113,7 +113,7 @@ SourceLocation Loc; // the location of the casting op protected: - CXXNamedCastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op, + CXXNamedCastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op, QualType writtenTy, SourceLocation l) : ExplicitCastExpr(SC, ty, info, op, writtenTy), Loc(l) {} @@ -128,7 +128,7 @@ virtual SourceRange getSourceRange() const { return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { switch (T->getStmtClass()) { case CXXNamedCastExprClass: case CXXStaticCastExprClass: @@ -144,34 +144,34 @@ }; /// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). -/// +/// /// This expression node represents a C++ static cast, e.g., /// @c static_cast(1.0). class CXXStaticCastExpr : public CXXNamedCastExpr { public: - CXXStaticCastExpr(QualType ty, const CastInfo &info, Expr *op, + CXXStaticCastExpr(QualType ty, const CastInfo &info, Expr *op, QualType writtenTy, SourceLocation l) : CXXNamedCastExpr(CXXStaticCastExprClass, ty, info, op, writtenTy, l) {} - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXStaticCastExprClass; } static bool classof(const CXXStaticCastExpr *) { return true; } }; /// CXXDynamicCastExpr - A C++ @c dynamic_cast expression -/// (C++ [expr.dynamic.cast]), which may perform a run-time check to +/// (C++ [expr.dynamic.cast]), which may perform a run-time check to /// determine how to perform the type cast. -/// +/// /// This expression node represents a dynamic cast, e.g., /// @c dynamic_cast(BasePtr). class CXXDynamicCastExpr : public CXXNamedCastExpr { public: - CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy, + CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy, SourceLocation l) : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {} - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXDynamicCastExprClass; } static bool classof(const CXXDynamicCastExpr *) { return true; } @@ -180,17 +180,17 @@ /// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ /// [expr.reinterpret.cast]), which provides a differently-typed view /// of a value but performs no actual work at run time. -/// +/// /// This expression node represents a reinterpret cast, e.g., /// @c reinterpret_cast(VoidPtr). class CXXReinterpretCastExpr : public CXXNamedCastExpr { public: - CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy, + CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) - : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, CK_BitCast, op, + : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, CK_BitCast, op, writtenTy, l) {} - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXReinterpretCastExprClass; } static bool classof(const CXXReinterpretCastExpr *) { return true; } @@ -198,39 +198,39 @@ /// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), /// which can remove type qualifiers but does not change the underlying value. -/// +/// /// This expression node represents a const cast, e.g., /// @c const_cast(PtrToConstChar). class CXXConstCastExpr : public CXXNamedCastExpr { public: - CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, + CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {} - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXConstCastExprClass; } static bool classof(const CXXConstCastExpr *) { return true; } }; /// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. -/// +/// class CXXBoolLiteralExpr : public Expr { bool Value; SourceLocation Loc; public: - CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : + CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} bool getValue() const { return Value; } virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXBoolLiteralExprClass; } static bool classof(const CXXBoolLiteralExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -322,7 +322,7 @@ SourceLocation Loc; public: - CXXThisExpr(SourceLocation L, QualType Type) + CXXThisExpr(SourceLocation L, QualType Type) : Expr(CXXThisExprClass, Type, // 'this' is type-dependent if the class type of the enclosing // member function is dependent (C++ [temp.dep.expr]p2) @@ -331,7 +331,7 @@ virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXThisExprClass; } static bool classof(const CXXThisExpr *) { return true; } @@ -383,14 +383,14 @@ /// supply arguments for all of the parameters. class CXXDefaultArgExpr : public Expr { ParmVarDecl *Param; - + protected: - CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param) - : Expr(SC, param->hasUnparsedDefaultArg() ? + CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param) + : Expr(SC, param->hasUnparsedDefaultArg() ? param->getType().getNonReferenceType() : param->getDefaultArg()->getType()), Param(param) { } - + public: // Param is the parameter whose default argument is used by this // expression. @@ -426,39 +426,39 @@ class CXXTemporary { /// Destructor - The destructor that needs to be called. const CXXDestructorDecl *Destructor; - + CXXTemporary(const CXXDestructorDecl *destructor) : Destructor(destructor) { } ~CXXTemporary() { } public: - static CXXTemporary *Create(ASTContext &C, + static CXXTemporary *Create(ASTContext &C, const CXXDestructorDecl *Destructor); - + void Destroy(ASTContext &Ctx); - + const CXXDestructorDecl *getDestructor() const { return Destructor; } }; -/// CXXBindTemporaryExpr - Represents binding an expression to a temporary, +/// CXXBindTemporaryExpr - Represents binding an expression to a temporary, /// so its destructor can be called later. class CXXBindTemporaryExpr : public Expr { CXXTemporary *Temp; - + Stmt *SubExpr; - CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) + CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) : Expr(CXXBindTemporaryExprClass, subexpr->getType()), Temp(temp), SubExpr(subexpr) { } - ~CXXBindTemporaryExpr() { } + ~CXXBindTemporaryExpr() { } protected: virtual void DoDestroy(ASTContext &C); public: - static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, + static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, Expr* SubExpr); - + CXXTemporary *getTemporary() { return Temp; } const CXXTemporary *getTemporary() const { return Temp; } @@ -484,24 +484,24 @@ CXXConstructorDecl *Constructor; bool Elidable; - + Stmt **Args; unsigned NumArgs; - + protected: - CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, + CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, CXXConstructorDecl *d, bool elidable, Expr **args, unsigned numargs); - ~CXXConstructExpr() { } + ~CXXConstructExpr() { } virtual void DoDestroy(ASTContext &C); public: static CXXConstructExpr *Create(ASTContext &C, QualType T, - CXXConstructorDecl *D, bool Elidable, + CXXConstructorDecl *D, bool Elidable, Expr **Args, unsigned NumArgs); - - + + CXXConstructorDecl* getConstructor() const { return Constructor; } /// \brief Whether this construction is elidable. @@ -509,7 +509,7 @@ typedef ExprIterator arg_iterator; typedef ConstExprIterator const_arg_iterator; - + arg_iterator arg_begin() { return Args; } arg_iterator arg_end() { return Args + NumArgs; } const_arg_iterator arg_begin() const { return Args; } @@ -526,7 +526,7 @@ assert(Arg < NumArgs && "Arg access out of range!"); return cast(Args[Arg]); } - + /// setArg - Set the specified argument. void setArg(unsigned Arg, Expr *ArgExpr) { assert(Arg < NumArgs && "Arg access out of range!"); @@ -535,12 +535,12 @@ virtual SourceRange getSourceRange() const { return SourceRange(); } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXConstructExprClass || T->getStmtClass() == CXXTemporaryObjectExprClass; } static bool classof(const CXXConstructExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -554,24 +554,24 @@ SourceLocation TyBeginLoc; SourceLocation RParenLoc; public: - CXXFunctionalCastExpr(QualType ty, QualType writtenTy, - SourceLocation tyBeginLoc, CastKind kind, + CXXFunctionalCastExpr(QualType ty, QualType writtenTy, + SourceLocation tyBeginLoc, CastKind kind, Expr *castExpr, CXXMethodDecl *typeConversionMethod, - SourceLocation rParenLoc) : + SourceLocation rParenLoc) : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, writtenTy), TypeConversionMethod(typeConversionMethod), TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} - CXXMethodDecl *getTypeConversionMethod() const + CXXMethodDecl *getTypeConversionMethod() const { return TypeConversionMethod; } SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } - + virtual SourceRange getSourceRange() const { return SourceRange(TyBeginLoc, RParenLoc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == CXXFunctionalCastExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == CXXFunctionalCastExprClass; } static bool classof(const CXXFunctionalCastExpr *) { return true; } }; @@ -579,7 +579,7 @@ /// @brief Represents a C++ functional cast expression that builds a /// temporary object. /// -/// This expression type represents a C++ "functional" cast +/// This expression type represents a C++ "functional" cast /// (C++[expr.type.conv]) with N != 1 arguments that invokes a /// constructor to build a temporary object. If N == 0 but no /// constructor will be called (because the functional cast is @@ -600,12 +600,12 @@ SourceLocation RParenLoc; public: - CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, - QualType writtenTy, SourceLocation tyBeginLoc, - Expr **Args,unsigned NumArgs, + CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, + QualType writtenTy, SourceLocation tyBeginLoc, + Expr **Args,unsigned NumArgs, SourceLocation rParenLoc); - ~CXXTemporaryObjectExpr() { } + ~CXXTemporaryObjectExpr() { } SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } @@ -613,7 +613,7 @@ virtual SourceRange getSourceRange() const { return SourceRange(TyBeginLoc, RParenLoc); } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXTemporaryObjectExprClass; } static bool classof(const CXXTemporaryObjectExpr *) { return true; } @@ -630,28 +630,28 @@ public: CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, - SourceLocation rParenLoc ) : + SourceLocation rParenLoc ) : Expr(CXXZeroInitValueExprClass, ty, false, false), TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} - + SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } /// @brief Whether this initialization expression was /// implicitly-generated. - bool isImplicit() const { - return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); + bool isImplicit() const { + return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); } virtual SourceRange getSourceRange() const { return SourceRange(TyBeginLoc, RParenLoc); } - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXZeroInitValueExprClass; } static bool classof(const CXXZeroInitValueExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -666,26 +666,26 @@ public: CXXConditionDeclExpr(SourceLocation startLoc, SourceLocation eqLoc, VarDecl *var) - : DeclRefExpr(CXXConditionDeclExprClass, var, + : DeclRefExpr(CXXConditionDeclExprClass, var, var->getType().getNonReferenceType(), startLoc, var->getType()->isDependentType(), /*FIXME:integral constant?*/ var->getType()->isDependentType()) {} SourceLocation getStartLoc() const { return getLocation(); } - + VarDecl *getVarDecl() { return cast(getDecl()); } const VarDecl *getVarDecl() const { return cast(getDecl()); } virtual SourceRange getSourceRange() const { return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); } - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXConditionDeclExprClass; } static bool classof(const CXXConditionDeclExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -866,7 +866,7 @@ /// Example: /// /// \code -/// template +/// template /// void destroy(T* ptr) { /// ptr->~T(); /// } @@ -874,67 +874,67 @@ /// /// When the template is parsed, the expression \c ptr->~T will be stored as /// a member reference expression. If it then instantiated with a scalar type -/// as a template argument for T, the resulting expression will be a +/// as a template argument for T, the resulting expression will be a /// pseudo-destructor expression. class CXXPseudoDestructorExpr : public Expr { /// \brief The base expression (that is being destroyed). Stmt *Base; - + /// \brief Whether the operator was an arrow ('->'); otherwise, it was a /// period ('.'). bool IsArrow : 1; - + /// \brief The location of the '.' or '->' operator. SourceLocation OperatorLoc; - + /// \brief The nested-name-specifier that follows the operator, if present. NestedNameSpecifier *Qualifier; - - /// \brief The source range that covers the nested-name-specifier, if + + /// \brief The source range that covers the nested-name-specifier, if /// present. SourceRange QualifierRange; - + /// \brief The type being destroyed. QualType DestroyedType; - + /// \brief The location of the type after the '~'. SourceLocation DestroyedTypeLoc; - + public: CXXPseudoDestructorExpr(ASTContext &Context, Expr *Base, bool isArrow, SourceLocation OperatorLoc, NestedNameSpecifier *Qualifier, SourceRange QualifierRange, - QualType DestroyedType, + QualType DestroyedType, SourceLocation DestroyedTypeLoc) - : Expr(CXXPseudoDestructorExprClass, + : Expr(CXXPseudoDestructorExprClass, Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, false, 0)), /*isTypeDependent=*/false, /*isValueDependent=*/Base->isValueDependent()), - Base(static_cast(Base)), IsArrow(isArrow), + Base(static_cast(Base)), IsArrow(isArrow), OperatorLoc(OperatorLoc), Qualifier(Qualifier), QualifierRange(QualifierRange), DestroyedType(DestroyedType), DestroyedTypeLoc(DestroyedTypeLoc) { } - + void setBase(Expr *E) { Base = E; } Expr *getBase() const { return cast(Base); } - - /// \brief Determines whether this member expression actually had + + /// \brief Determines whether this member expression actually had /// a C++ nested-name-specifier prior to the name of the member, e.g., /// x->Base::foo. bool hasQualifier() const { return Qualifier != 0; } - + /// \brief If the member name was qualified, retrieves the source range of /// the nested-name-specifier that precedes the member name. Otherwise, /// returns an empty source range. SourceRange getQualifierRange() const { return QualifierRange; } - - /// \brief If the member name was qualified, retrieves the + + /// \brief If the member name was qualified, retrieves the /// nested-name-specifier that precedes the member name. Otherwise, returns /// NULL. NestedNameSpecifier *getQualifier() const { return Qualifier; } - + /// \brief Determine whether this pseudo-destructor expression was written /// using an '->' (otherwise, it used a '.'). bool isArrow() const { return IsArrow; } @@ -942,27 +942,27 @@ /// \brief Retrieve the location of the '.' or '->' operator. SourceLocation getOperatorLoc() const { return OperatorLoc; } - + /// \brief Retrieve the type that is being destroyed. QualType getDestroyedType() const { return DestroyedType; } - + /// \brief Retrieve the location of the type being destroyed. SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; } - + virtual SourceRange getSourceRange() const { return SourceRange(Base->getLocStart(), DestroyedTypeLoc); } - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXPseudoDestructorExprClass; } static bool classof(const CXXPseudoDestructorExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); - virtual child_iterator child_end(); + virtual child_iterator child_end(); }; - + /// \brief Represents the name of a function that has not been /// resolved to any declaration. /// @@ -980,7 +980,7 @@ /// } /// @endcode class UnresolvedFunctionNameExpr : public Expr { - /// The name that was present in the source + /// The name that was present in the source DeclarationName Name; /// The location of this name in the source code @@ -999,7 +999,7 @@ virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == UnresolvedFunctionNameExprClass; } static bool classof(const UnresolvedFunctionNameExpr *) { return true; } @@ -1064,9 +1064,9 @@ NestedNameSpecifier *NNS; public: - QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, + QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, bool VD, SourceRange R, NestedNameSpecifier *NNS) - : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD), + : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD), QualifierRange(R), NNS(NNS) { } /// \brief Retrieve the source range of the nested-name-specifier. @@ -1076,8 +1076,8 @@ /// declaration. NestedNameSpecifier *getQualifier() const { return NNS; } - virtual SourceRange getSourceRange() const { - return SourceRange(QualifierRange.getBegin(), getLocation()); + virtual SourceRange getSourceRange() const { + return SourceRange(QualifierRange.getBegin(), getLocation()); } static bool classof(const Stmt *T) { @@ -1117,13 +1117,13 @@ /// \brief Whether this expr is an address of (&) operand. bool IsAddressOfOperand; - + public: UnresolvedDeclRefExpr(DeclarationName N, QualType T, SourceLocation L, - SourceRange R, NestedNameSpecifier *NNS, + SourceRange R, NestedNameSpecifier *NNS, bool IsAddressOfOperand) - : Expr(UnresolvedDeclRefExprClass, T, true, true), - Name(N), Loc(L), QualifierRange(R), NNS(NNS), + : Expr(UnresolvedDeclRefExprClass, T, true, true), + Name(N), Loc(L), QualifierRange(R), NNS(NNS), IsAddressOfOperand(IsAddressOfOperand) { } /// \brief Retrieve the name that this expression refers to. @@ -1140,10 +1140,10 @@ NestedNameSpecifier *getQualifier() const { return NNS; } /// \brief Retrieve whether this is an address of (&) operand. - + bool isAddressOfOperand() const { return IsAddressOfOperand; } - virtual SourceRange getSourceRange() const { - return SourceRange(QualifierRange.getBegin(), getLocation()); + virtual SourceRange getSourceRange() const { + return SourceRange(QualifierRange.getBegin(), getLocation()); } static bool classof(const Stmt *T) { @@ -1155,42 +1155,42 @@ virtual StmtIterator child_end(); }; -/// \brief An expression that refers to a C++ template-id, such as -/// @c isa. +/// \brief An expression that refers to a C++ template-id, such as +/// @c isa. class TemplateIdRefExpr : public Expr { /// \brief If this template-id was qualified-id, e.g., @c std::sort, /// this nested name specifier contains the @c std::. NestedNameSpecifier *Qualifier; - + /// \brief If this template-id was a qualified-id, e.g., @c std::sort, /// this covers the source code range of the @c std::. SourceRange QualifierRange; - + /// \brief The actual template to which this template-id refers. TemplateName Template; - + /// \brief The source location of the template name. SourceLocation TemplateNameLoc; /// \brief The source location of the left angle bracket ('<'); SourceLocation LAngleLoc; - + /// \brief The source location of the right angle bracket ('>'); SourceLocation RAngleLoc; - + /// \brief The number of template arguments in TemplateArgs. unsigned NumTemplateArgs; - + TemplateIdRefExpr(QualType T, NestedNameSpecifier *Qualifier, SourceRange QualifierRange, TemplateName Template, SourceLocation TemplateNameLoc, - SourceLocation LAngleLoc, + SourceLocation LAngleLoc, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, SourceLocation RAngleLoc); - + virtual void DoDestroy(ASTContext &Context); - + public: static TemplateIdRefExpr * Create(ASTContext &Context, QualType T, @@ -1198,66 +1198,66 @@ TemplateName Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, SourceLocation RAngleLoc); - + /// \brief Retrieve the nested name specifier used to qualify the name of /// this template-id, e.g., the "std::sort" in @c std::sort, or NULL /// if this template-id was an unqualified-id. NestedNameSpecifier *getQualifier() const { return Qualifier; } - + /// \brief Retrieve the source range describing the nested name specifier /// used to qualified the name of this template-id, if the name was qualified. SourceRange getQualifierRange() const { return QualifierRange; } - + /// \brief Retrieve the name of the template referenced, e.g., "sort" in /// @c std::sort; TemplateName getTemplateName() const { return Template; } - + /// \brief Retrieve the location of the name of the template referenced, e.g., /// the location of "sort" in @c std::sort. SourceLocation getTemplateNameLoc() const { return TemplateNameLoc; } - - /// \brief Retrieve the location of the left angle bracket following the + + /// \brief Retrieve the location of the left angle bracket following the /// template name ('<'). SourceLocation getLAngleLoc() const { return LAngleLoc; } - + /// \brief Retrieve the template arguments provided as part of this /// template-id. - const TemplateArgument *getTemplateArgs() const { + const TemplateArgument *getTemplateArgs() const { return reinterpret_cast(this + 1); } - + /// \brief Retrieve the number of template arguments provided as part of this /// template-id. unsigned getNumTemplateArgs() const { return NumTemplateArgs; } - - /// \brief Retrieve the location of the right angle bracket following the + + /// \brief Retrieve the location of the right angle bracket following the /// template arguments ('>'). SourceLocation getRAngleLoc() const { return RAngleLoc; } - + virtual SourceRange getSourceRange() const { return SourceRange(Qualifier? QualifierRange.getBegin() : TemplateNameLoc, RAngleLoc); } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == TemplateIdRefExprClass; } static bool classof(const TemplateIdRefExpr *) { return true; } }; - + class CXXExprWithTemporaries : public Expr { Stmt *SubExpr; - + CXXTemporary **Temps; unsigned NumTemps; bool ShouldDestroyTemps; - - CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps, + + CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps, unsigned NumTemps, bool ShouldDestroyTemps); ~CXXExprWithTemporaries(); @@ -1268,7 +1268,7 @@ static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps, unsigned NumTemps, bool ShouldDestroyTemporaries); - + unsigned getNumTemporaries() const { return NumTemps; } CXXTemporary *getTemporary(unsigned i) { assert(i < NumTemps && "Index out of range"); @@ -1278,11 +1278,11 @@ assert(i < NumTemps && "Index out of range"); return Temps[i]; } - + bool shouldDestroyTemporaries() const { return ShouldDestroyTemps; } - + void removeLastTemporary() { NumTemps--; } - + Expr *getSubExpr() { return cast(SubExpr); } const Expr *getSubExpr() const { return cast(SubExpr); } void setSubExpr(Expr *E) { SubExpr = E; } @@ -1336,7 +1336,7 @@ /// \brief The number of arguments used to construct the type. unsigned NumArgs; - + CXXUnresolvedConstructExpr(SourceLocation TyBegin, QualType T, SourceLocation LParenLoc, @@ -1345,7 +1345,7 @@ SourceLocation RParenLoc); public: - static CXXUnresolvedConstructExpr *Create(ASTContext &C, + static CXXUnresolvedConstructExpr *Create(ASTContext &C, SourceLocation TyBegin, QualType T, SourceLocation LParenLoc, @@ -1387,7 +1387,7 @@ virtual SourceRange getSourceRange() const { return SourceRange(TyBeginLoc, RParenLoc); } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXUnresolvedConstructExprClass; } static bool classof(const CXXUnresolvedConstructExpr *) { return true; } @@ -1404,7 +1404,7 @@ /// \brief The expression for the base pointer or class reference, /// e.g., the \c x in x.f. Stmt *Base; - + /// \brief Whether this member expression used the '->' operator or /// the '.' operator. bool IsArrow : 1; @@ -1412,25 +1412,25 @@ /// \brief Whether this member expression has explicitly-specified template /// arguments. bool HasExplicitTemplateArgumentList : 1; - + /// \brief The location of the '->' or '.' operator. SourceLocation OperatorLoc; /// \brief The nested-name-specifier that precedes the member name, if any. NestedNameSpecifier *Qualifier; - + /// \brief The source range covering the nested name specifier. SourceRange QualifierRange; - + /// \brief In a qualified member access expression such as t->Base::f, this - /// member stores the resolves of name lookup in the context of the member + /// member stores the resolves of name lookup in the context of the member /// access expression, to be used at instantiation time. /// /// FIXME: This member, along with the Qualifier and QualifierRange, could /// be stuck into a structure that is optionally allocated at the end of /// the CXXUnresolvedMemberExpr, to save space in the common case. NamedDecl *FirstQualifierFoundInScope; - + /// \brief The member to which this member expression refers, which /// can be name, overloaded operator, or destructor. /// FIXME: could also be a template-id @@ -1438,25 +1438,25 @@ /// \brief The location of the member name. SourceLocation MemberLoc; - + /// \brief Retrieve the explicit template argument list that followed the /// member template name, if any. ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { if (!HasExplicitTemplateArgumentList) return 0; - + return reinterpret_cast(this + 1); } - + /// \brief Retrieve the explicit template argument list that followed the /// member template name, if any. const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { return const_cast(this) ->getExplicitTemplateArgumentList(); } - - CXXUnresolvedMemberExpr(ASTContext &C, - Expr *Base, bool IsArrow, + + CXXUnresolvedMemberExpr(ASTContext &C, + Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifier *Qualifier, SourceRange QualifierRange, @@ -1468,10 +1468,10 @@ const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, SourceLocation RAngleLoc); - + public: - CXXUnresolvedMemberExpr(ASTContext &C, - Expr *Base, bool IsArrow, + CXXUnresolvedMemberExpr(ASTContext &C, + Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifier *Qualifier, SourceRange QualifierRange, @@ -1484,10 +1484,10 @@ Qualifier(Qualifier), QualifierRange(QualifierRange), FirstQualifierFoundInScope(FirstQualifierFoundInScope), Member(Member), MemberLoc(MemberLoc) { } - + static CXXUnresolvedMemberExpr * - Create(ASTContext &C, - Expr *Base, bool IsArrow, + Create(ASTContext &C, + Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifier *Qualifier, SourceRange QualifierRange, @@ -1499,7 +1499,7 @@ const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, SourceLocation RAngleLoc); - + /// \brief Retrieve the base object of this member expressions, /// e.g., the \c x in \c x.m. Expr *getBase() { return cast(Base); } @@ -1517,26 +1517,26 @@ /// \brief Retrieve the nested-name-specifier that qualifies the member /// name. NestedNameSpecifier *getQualifier() const { return Qualifier; } - + /// \brief Retrieve the source range covering the nested-name-specifier /// that qualifies the member name. SourceRange getQualifierRange() const { return QualifierRange; } - + /// \brief Retrieve the first part of the nested-name-specifier that was /// found in the scope of the member access expression when the member access /// was initially parsed. /// /// This function only returns a useful result when member access expression - /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration - /// returned by this function describes what was found by unqualified name + /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration + /// returned by this function describes what was found by unqualified name /// lookup for the identifier "Base" within the scope of the member access /// expression itself. At template instantiation time, this information is /// combined with the results of name lookup into the type of the object /// expression itself (the class type of x). - NamedDecl *getFirstQualifierFoundInScope() const { + NamedDecl *getFirstQualifierFoundInScope() const { return FirstQualifierFoundInScope; } - + /// \brief Retrieve the name of the member that this expression /// refers to. DeclarationName getMember() const { return Member; } @@ -1549,56 +1549,56 @@ /// \brief Determines whether this member expression actually had a C++ /// template argument list explicitly specified, e.g., x.f. - bool hasExplicitTemplateArgumentList() { - return HasExplicitTemplateArgumentList; + bool hasExplicitTemplateArgumentList() { + return HasExplicitTemplateArgumentList; } - - /// \brief Retrieve the location of the left angle bracket following the + + /// \brief Retrieve the location of the left angle bracket following the /// member name ('<'), if any. - SourceLocation getLAngleLoc() const { + SourceLocation getLAngleLoc() const { if (!HasExplicitTemplateArgumentList) return SourceLocation(); - + return getExplicitTemplateArgumentList()->LAngleLoc; } - + /// \brief Retrieve the template arguments provided as part of this /// template-id. - const TemplateArgument *getTemplateArgs() const { + const TemplateArgument *getTemplateArgs() const { if (!HasExplicitTemplateArgumentList) - return 0; - + return 0; + return getExplicitTemplateArgumentList()->getTemplateArgs(); } - + /// \brief Retrieve the number of template arguments provided as part of this /// template-id. - unsigned getNumTemplateArgs() const { + unsigned getNumTemplateArgs() const { if (!HasExplicitTemplateArgumentList) - return 0; - + return 0; + return getExplicitTemplateArgumentList()->NumTemplateArgs; } - - /// \brief Retrieve the location of the right angle bracket following the + + /// \brief Retrieve the location of the right angle bracket following the /// template arguments ('>'). - SourceLocation getRAngleLoc() const { + SourceLocation getRAngleLoc() const { if (!HasExplicitTemplateArgumentList) return SourceLocation(); - + return getExplicitTemplateArgumentList()->RAngleLoc; } - + virtual SourceRange getSourceRange() const { if (HasExplicitTemplateArgumentList) return SourceRange(Base->getSourceRange().getBegin(), getRAngleLoc()); - + return SourceRange(Base->getSourceRange().getBegin(), MemberLoc); } - - static bool classof(const Stmt *T) { + + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXUnresolvedMemberExprClass; } static bool classof(const CXXUnresolvedMemberExpr *) { return true; } Modified: cfe/trunk/include/clang/AST/ExprObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ExprObjC.h (original) +++ cfe/trunk/include/clang/AST/ExprObjC.h Wed Sep 9 10:08:12 2009 @@ -22,7 +22,7 @@ class ASTContext; class ObjCMethodDecl; class ObjCPropertyDecl; - + /// ObjCStringLiteral, used for Objective-C string literals /// i.e. @"foo". class ObjCStringLiteral : public Expr { @@ -41,20 +41,20 @@ SourceLocation getAtLoc() const { return AtLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const { return SourceRange(AtLoc, String->getLocEnd()); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCStringLiteralClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCStringLiteralClass; } - static bool classof(const ObjCStringLiteral *) { return true; } - + static bool classof(const ObjCStringLiteral *) { return true; } + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + /// ObjCEncodeExpr, used for @encode in Objective-C. @encode has the same type /// and behavior as StringLiteral except that the string initializer is obtained /// from ASTContext with the encoding type as an argument. @@ -62,32 +62,32 @@ QualType EncType; SourceLocation AtLoc, RParenLoc; public: - ObjCEncodeExpr(QualType T, QualType ET, + ObjCEncodeExpr(QualType T, QualType ET, SourceLocation at, SourceLocation rp) - : Expr(ObjCEncodeExprClass, T, ET->isDependentType(), + : Expr(ObjCEncodeExprClass, T, ET->isDependentType(), ET->isDependentType()), EncType(ET), AtLoc(at), RParenLoc(rp) {} - + explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){} - + SourceLocation getAtLoc() const { return AtLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - + QualType getEncodedType() const { return EncType; } void setEncodedType(QualType T) { EncType = T; } - + virtual SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCEncodeExprClass; } static bool classof(const ObjCEncodeExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -106,7 +106,7 @@ Selector getSelector() const { return SelName; } void setSelector(Selector S) { SelName = S; } - + SourceLocation getAtLoc() const { return AtLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } @@ -115,26 +115,26 @@ virtual SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); } - + /// getNumArgs - Return the number of actual arguments to this call. unsigned getNumArgs() const { return SelName.getNumArgs(); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCSelectorExprClass; } static bool classof(const ObjCSelectorExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + /// ObjCProtocolExpr used for protocol expression in Objective-C. This is used /// as: @protocol(foo), as in: /// obj conformsToProtocol:@protocol(foo)] /// The return type is "Protocol*". -class ObjCProtocolExpr : public Expr { - ObjCProtocolDecl *TheProtocol; +class ObjCProtocolExpr : public Expr { + ObjCProtocolDecl *TheProtocol; SourceLocation AtLoc, RParenLoc; public: ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, @@ -146,7 +146,7 @@ ObjCProtocolDecl *getProtocol() const { return TheProtocol; } void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; } - + SourceLocation getAtLoc() const { return AtLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } @@ -155,12 +155,12 @@ virtual SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCProtocolExprClass; } static bool classof(const ObjCProtocolExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -173,44 +173,44 @@ Stmt *Base; bool IsArrow:1; // True if this is "X->F", false if this is "X.F". bool IsFreeIvar:1; // True if ivar reference has no base (self assumed). - + public: ObjCIvarRefExpr(ObjCIvarDecl *d, - QualType t, SourceLocation l, Expr *base=0, - bool arrow = false, bool freeIvar = false) : + QualType t, SourceLocation l, Expr *base=0, + bool arrow = false, bool freeIvar = false) : Expr(ObjCIvarRefExprClass, t), D(d), Loc(l), Base(base), IsArrow(arrow), IsFreeIvar(freeIvar) {} - + explicit ObjCIvarRefExpr(EmptyShell Empty) : Expr(ObjCIvarRefExprClass, Empty) {} ObjCIvarDecl *getDecl() { return D; } const ObjCIvarDecl *getDecl() const { return D; } void setDecl(ObjCIvarDecl *d) { D = d; } - + const Expr *getBase() const { return cast(Base); } Expr *getBase() { return cast(Base); } void setBase(Expr * base) { Base = base; } - + bool isArrow() const { return IsArrow; } bool isFreeIvar() const { return IsFreeIvar; } void setIsArrow(bool A) { IsArrow = A; } void setIsFreeIvar(bool A) { IsFreeIvar = A; } - + SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const { return isFreeIvar() ? SourceRange(Loc) - : SourceRange(getBase()->getLocStart(), Loc); + : SourceRange(getBase()->getLocStart(), Loc); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCIvarRefExprClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCIvarRefExprClass; } static bool classof(const ObjCIvarRefExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -225,48 +225,48 @@ SourceLocation IdLoc; Stmt *Base; public: - ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, + ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, SourceLocation l, Expr *base) : Expr(ObjCPropertyRefExprClass, t), AsProperty(PD), IdLoc(l), Base(base) { } - + explicit ObjCPropertyRefExpr(EmptyShell Empty) : Expr(ObjCPropertyRefExprClass, Empty) {} ObjCPropertyDecl *getProperty() const { return AsProperty; } void setProperty(ObjCPropertyDecl *D) { AsProperty = D; } - + const Expr *getBase() const { return cast(Base); } Expr *getBase() { return cast(Base); } void setBase(Expr *base) { Base = base; } - + SourceLocation getLocation() const { return IdLoc; } void setLocation(SourceLocation L) { IdLoc = L; } virtual SourceRange getSourceRange() const { return SourceRange(getBase()->getLocStart(), IdLoc); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCPropertyRefExprClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCPropertyRefExprClass; } static bool classof(const ObjCPropertyRefExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; -/// ObjCImplicitSetterGetterRefExpr - A dot-syntax expression to access two -/// methods; one to set a value to an 'ivar' (Setter) and the other to access -/// an 'ivar' (Setter). +/// ObjCImplicitSetterGetterRefExpr - A dot-syntax expression to access two +/// methods; one to set a value to an 'ivar' (Setter) and the other to access +/// an 'ivar' (Setter). /// An example for use of this AST is: /// @code /// @interface Test { } /// - (Test *)crash; /// - (void)setCrash: (Test*)value; /// @end -/// void foo(Test *p1, Test *p2) +/// void foo(Test *p1, Test *p2) /// { /// p2.crash = p1.crash; // Uses ObjCImplicitSetterGetterRefExpr AST /// } @@ -285,10 +285,10 @@ /// Location of the receiver class in the dot syntax notation /// used to call a class method setter/getter. SourceLocation ClassLoc; - + public: ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter, - QualType t, + QualType t, ObjCMethodDecl *setter, SourceLocation l, Expr *base) : Expr(ObjCImplicitSetterGetterRefExprClass, t), Setter(setter), @@ -296,13 +296,13 @@ ClassLoc(SourceLocation()) { } ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter, - QualType t, + QualType t, ObjCMethodDecl *setter, SourceLocation l, ObjCInterfaceDecl *C, SourceLocation CL) : Expr(ObjCImplicitSetterGetterRefExprClass, t), Setter(setter), Getter(getter), MemberLoc(l), Base(0), InterfaceDecl(C), ClassLoc(CL) { } - explicit ObjCImplicitSetterGetterRefExpr(EmptyShell Empty) + explicit ObjCImplicitSetterGetterRefExpr(EmptyShell Empty) : Expr(ObjCImplicitSetterGetterRefExprClass, Empty){} ObjCMethodDecl *getGetterMethod() const { return Getter; } @@ -311,7 +311,7 @@ void setGetterMethod(ObjCMethodDecl *D) { Getter = D; } void setSetterMethod(ObjCMethodDecl *D) { Setter = D; } void setInterfaceDecl(ObjCInterfaceDecl *D) { InterfaceDecl = D; } - + virtual SourceRange getSourceRange() const { if (Base) return SourceRange(getBase()->getLocStart(), MemberLoc); @@ -320,34 +320,34 @@ const Expr *getBase() const { return cast_or_null(Base); } Expr *getBase() { return cast_or_null(Base); } void setBase(Expr *base) { Base = base; } - + SourceLocation getLocation() const { return MemberLoc; } void setLocation(SourceLocation L) { MemberLoc = L; } SourceLocation getClassLoc() const { return ClassLoc; } void setClassLoc(SourceLocation L) { ClassLoc = L; } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCImplicitSetterGetterRefExprClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCImplicitSetterGetterRefExprClass; } static bool classof(const ObjCImplicitSetterGetterRefExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + class ObjCMessageExpr : public Expr { // SubExprs - The receiver and arguments of the message expression. Stmt **SubExprs; - + // NumArgs - The number of arguments (not including the receiver) to the // message expression. unsigned NumArgs; - + // A unigue name for this message. Selector SelName; - - // A method prototype for this message (optional). + + // A method prototype for this message (optional). // FIXME: Since method decls contain the selector, and most messages have a // prototype, consider devising a scheme for unifying SelName/MethodProto. ObjCMethodDecl *MethodProto; @@ -360,7 +360,7 @@ // Bit-swizzling flags. enum { IsInstMeth=0, IsClsMethDeclUnknown, IsClsMethDeclKnown, Flags=0x3 }; unsigned getFlag() const { return (uintptr_t) SubExprs[RECEIVER] & Flags; } - + public: /// This constructor is used to represent class messages where the /// ObjCInterfaceDecl* of the receiver is not known. @@ -376,28 +376,28 @@ QualType retType, ObjCMethodDecl *methDecl, SourceLocation LBrac, SourceLocation RBrac, Expr **ArgExprs, unsigned NumArgs); - + // constructor for instance messages. ObjCMessageExpr(Expr *receiver, Selector selInfo, QualType retType, ObjCMethodDecl *methDecl, SourceLocation LBrac, SourceLocation RBrac, Expr **ArgExprs, unsigned NumArgs); - + explicit ObjCMessageExpr(EmptyShell Empty) : Expr(ObjCMessageExprClass, Empty), SubExprs(0), NumArgs(0) {} - + ~ObjCMessageExpr() { delete [] SubExprs; } - + /// getReceiver - Returns the receiver of the message expression. /// This can be NULL if the message is for class methods. For /// class methods, use getClassName. /// FIXME: need to handle/detect 'super' usage within a class method. - Expr *getReceiver() { + Expr *getReceiver() { uintptr_t x = (uintptr_t) SubExprs[RECEIVER]; return (x & Flags) == IsInstMeth ? (Expr*) x : 0; - } + } const Expr *getReceiver() const { return const_cast(this)->getReceiver(); } @@ -405,36 +405,36 @@ void setReceiver(Expr *rec) { SubExprs[RECEIVER] = rec; } Selector getSelector() const { return SelName; } void setSelector(Selector S) { SelName = S; } - + const ObjCMethodDecl *getMethodDecl() const { return MethodProto; } ObjCMethodDecl *getMethodDecl() { return MethodProto; } void setMethodDecl(ObjCMethodDecl *MD) { MethodProto = MD; } - + typedef std::pair ClassInfo; - + /// getClassInfo - For class methods, this returns both the ObjCInterfaceDecl* /// and IdentifierInfo* of the invoked class. Both can be NULL if this /// is an instance message, and the ObjCInterfaceDecl* can be NULL if none - /// was available when this ObjCMessageExpr object was constructed. - ClassInfo getClassInfo() const; + /// was available when this ObjCMessageExpr object was constructed. + ClassInfo getClassInfo() const; void setClassInfo(const ClassInfo &C); - + /// getClassName - For class methods, this returns the invoked class, - /// and returns NULL otherwise. For instance methods, use getReceiver. + /// and returns NULL otherwise. For instance methods, use getReceiver. IdentifierInfo *getClassName() const { return getClassInfo().second; } - + /// getNumArgs - Return the number of actual arguments to this call. unsigned getNumArgs() const { return NumArgs; } - void setNumArgs(unsigned nArgs) { - NumArgs = nArgs; + void setNumArgs(unsigned nArgs) { + NumArgs = nArgs; // FIXME: should always allocate SubExprs via the ASTContext's // allocator. if (!SubExprs) SubExprs = new Stmt* [NumArgs + 1]; } - + /// getArg - Return the specified argument. Expr *getArg(unsigned Arg) { assert(Arg < NumArgs && "Arg access out of range!"); @@ -449,13 +449,13 @@ assert(Arg < NumArgs && "Arg access out of range!"); SubExprs[Arg+ARGS_START] = ArgExpr; } - + SourceLocation getLeftLoc() const { return LBracloc; } SourceLocation getRightLoc() const { return RBracloc; } void setLeftLoc(SourceLocation L) { LBracloc = L; } void setRightLoc(SourceLocation L) { RBracloc = L; } - + void setSourceRange(SourceRange R) { LBracloc = R.getBegin(); RBracloc = R.getEnd(); @@ -468,14 +468,14 @@ return T->getStmtClass() == ObjCMessageExprClass; } static bool classof(const ObjCMessageExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); - + typedef ExprIterator arg_iterator; typedef ConstExprIterator const_arg_iterator; - + arg_iterator arg_begin() { return &SubExprs[ARGS_START]; } arg_iterator arg_end() { return &SubExprs[ARGS_START] + NumArgs; } const_arg_iterator arg_begin() const { return &SubExprs[ARGS_START]; } @@ -487,16 +487,16 @@ class ObjCSuperExpr : public Expr { SourceLocation Loc; public: - ObjCSuperExpr(SourceLocation L, QualType Type) + ObjCSuperExpr(SourceLocation L, QualType Type) : Expr(ObjCSuperExprClass, Type), Loc(L) { } explicit ObjCSuperExpr(EmptyShell Empty) : Expr(ObjCSuperExprClass, Empty) {} SourceLocation getLoc() const { return Loc; } void setLoc(SourceLocation L) { Loc = L; } - + virtual SourceRange getSourceRange() const { return SourceRange(Loc); } - static bool classof(const Stmt *T) { + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCSuperExprClass; } static bool classof(const ObjCSuperExpr *) { return true; } @@ -511,23 +511,23 @@ class ObjCIsaExpr : public Expr { /// Base - the expression for the base object pointer. Stmt *Base; - + /// IsaMemberLoc - This is the location of the 'isa'. SourceLocation IsaMemberLoc; - + /// IsArrow - True if this is "X->F", false if this is "X.F". bool IsArrow; public: - ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, QualType ty) + ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, QualType ty) : Expr(ObjCIsaExprClass, ty), Base(base), IsaMemberLoc(l), IsArrow(isarrow) {} - + /// \brief Build an empty expression. explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) { } - + void setBase(Expr *E) { Base = E; } Expr *getBase() const { return cast(Base); } - + bool isArrow() const { return IsArrow; } void setArrow(bool A) { IsArrow = A; } @@ -539,14 +539,14 @@ virtual SourceRange getSourceRange() const { return SourceRange(getBase()->getLocStart(), IsaMemberLoc); } - + virtual SourceLocation getExprLoc() const { return IsaMemberLoc; } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCIsaExprClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCIsaExprClass; } static bool classof(const ObjCIsaExpr *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ExternalASTSource.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTSource.h Wed Sep 9 10:08:12 2009 @@ -33,7 +33,7 @@ /// \brief The name of the declarations. DeclarationName Name; - /// \brief The ID numbers of all of the declarations with this name. + /// \brief The ID numbers of all of the declarations with this name. /// /// These declarations have not necessarily been de-serialized. llvm::SmallVector Declarations; @@ -65,7 +65,7 @@ /// replaced with the sorted set of source ranges corresponding to /// comments in the source code. virtual void ReadComments(std::vector &Comments) = 0; - + /// \brief Resolve a type ID into a type, potentially building a new /// type. virtual QualType GetType(uint32_t ID) = 0; @@ -151,7 +151,7 @@ this->Ptr = reinterpret_cast(Ptr); return *this; } - + LazyOffsetPtr &operator=(uint64_t Offset) { assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits"); if (Offset == 0) @@ -177,7 +177,7 @@ /// \returns a pointer to the AST node. T* get(ExternalASTSource *Source) const { if (isOffset()) { - assert(Source && + assert(Source && "Cannot deserialize a lazy pointer without an AST source"); Ptr = reinterpret_cast((Source->*Get)(Ptr >> 1)); } Modified: cfe/trunk/include/clang/AST/NestedNameSpecifier.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/NestedNameSpecifier.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/NestedNameSpecifier.h (original) +++ cfe/trunk/include/clang/AST/NestedNameSpecifier.h Wed Sep 9 10:08:12 2009 @@ -81,8 +81,8 @@ /// \brief Copy constructor used internally to clone nested name /// specifiers. - NestedNameSpecifier(const NestedNameSpecifier &Other) - : llvm::FoldingSetNode(Other), Prefix(Other.Prefix), + NestedNameSpecifier(const NestedNameSpecifier &Other) + : llvm::FoldingSetNode(Other), Prefix(Other.Prefix), Specifier(Other.Specifier) { } @@ -90,7 +90,7 @@ /// \brief Either find or insert the given nested name specifier /// mockup in the given context. - static NestedNameSpecifier *FindOrInsert(ASTContext &Context, + static NestedNameSpecifier *FindOrInsert(ASTContext &Context, const NestedNameSpecifier &Mockup); public: @@ -99,18 +99,18 @@ /// The prefix must be dependent, since nested name specifiers /// referencing an identifier are only permitted when the identifier /// cannot be resolved. - static NestedNameSpecifier *Create(ASTContext &Context, - NestedNameSpecifier *Prefix, + static NestedNameSpecifier *Create(ASTContext &Context, + NestedNameSpecifier *Prefix, IdentifierInfo *II); /// \brief Builds a nested name specifier that names a namespace. - static NestedNameSpecifier *Create(ASTContext &Context, - NestedNameSpecifier *Prefix, + static NestedNameSpecifier *Create(ASTContext &Context, + NestedNameSpecifier *Prefix, NamespaceDecl *NS); /// \brief Builds a nested name specifier that names a type. - static NestedNameSpecifier *Create(ASTContext &Context, - NestedNameSpecifier *Prefix, + static NestedNameSpecifier *Create(ASTContext &Context, + NestedNameSpecifier *Prefix, bool Template, Type *T); /// \brief Builds a specifier that consists of just an identifier. @@ -120,7 +120,7 @@ /// nested name specifier, e.g., in "x->Base::f", the "x" has a dependent /// type. static NestedNameSpecifier *Create(ASTContext &Context, IdentifierInfo *II); - + /// \brief Returns the nested name specifier representing the global /// scope. static NestedNameSpecifier *GlobalSpecifier(ASTContext &Context); @@ -135,10 +135,10 @@ NestedNameSpecifier *getPrefix() const { return Prefix.getPointer(); } /// \brief Determine what kind of nested name specifier is stored. - SpecifierKind getKind() const { + SpecifierKind getKind() const { if (Specifier == 0) return Global; - return (SpecifierKind)Prefix.getInt(); + return (SpecifierKind)Prefix.getInt(); } /// \brief Retrieve the identifier stored in this nested name @@ -149,7 +149,7 @@ return 0; } - + /// \brief Retrieve the namespace stored in this nested name /// specifier. NamespaceDecl *getAsNamespace() const { @@ -161,7 +161,7 @@ /// \brief Retrieve the type stored in this nested name specifier. Type *getAsType() const { - if (Prefix.getInt() == TypeSpec || + if (Prefix.getInt() == TypeSpec || Prefix.getInt() == TypeSpecWithTemplate) return (Type *)Specifier; @@ -192,11 +192,11 @@ /// into a diagnostic with <<. inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, NestedNameSpecifier *NNS) { - DB.AddTaggedVal(reinterpret_cast(NNS), + DB.AddTaggedVal(reinterpret_cast(NNS), Diagnostic::ak_nestednamespec); return DB; } - + } #endif Modified: cfe/trunk/include/clang/AST/ParentMap.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ParentMap.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ParentMap.h (original) +++ cfe/trunk/include/clang/AST/ParentMap.h Wed Sep 9 10:08:12 2009 @@ -17,7 +17,7 @@ namespace clang { class Stmt; class Expr; - + class ParentMap { void* Impl; public: @@ -30,7 +30,7 @@ const Stmt *getParent(const Stmt* S) const { return getParent(const_cast(S)); } - + const Stmt *getParentIgnoreParens(const Stmt *S) const { return getParentIgnoreParens(const_cast(S)); } @@ -38,13 +38,13 @@ bool hasParent(Stmt* S) const { return getParent(S) != 0; } - + bool isConsumedExpr(Expr *E) const; - + bool isConsumedExpr(const Expr *E) const { return isConsumedExpr(const_cast(E)); } }; - + } // end clang namespace #endif Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/PrettyPrinter.h (original) +++ cfe/trunk/include/clang/AST/PrettyPrinter.h Wed Sep 9 10:08:12 2009 @@ -34,7 +34,7 @@ /// declarations should be printed. struct PrintingPolicy { /// \brief Create a default printing policy for C. - PrintingPolicy(const LangOptions &LO) + PrintingPolicy(const LangOptions &LO) : Indentation(2), LangOpts(LO), SuppressSpecifiers(false), SuppressTag(false), SuppressTagKind(false), SuppressScope(false), Dump(false), ConstantArraySizeAsWritten(false) { } Modified: cfe/trunk/include/clang/AST/RecordLayout.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/RecordLayout.h (original) +++ cfe/trunk/include/clang/AST/RecordLayout.h Wed Sep 9 10:08:12 2009 @@ -22,38 +22,38 @@ class RecordDecl; class CXXRecordDecl; -/// ASTRecordLayout - +/// ASTRecordLayout - /// This class contains layout information for one RecordDecl, /// which is a struct/union/class. The decl represented must be a definition, -/// not a forward declaration. -/// This class is also used to contain layout information for one +/// not a forward declaration. +/// This class is also used to contain layout information for one /// ObjCInterfaceDecl. FIXME - Find appropriate name. /// These objects are managed by ASTContext. class ASTRecordLayout { /// Size - Size of record in bits. uint64_t Size; - + /// DataSize - Size of record in bits without tail padding. uint64_t DataSize; - + /// FieldOffsets - Array of field offsets in bits. uint64_t *FieldOffsets; - + // Alignment - Alignment of record in bits. - unsigned Alignment; - + unsigned Alignment; + // FieldCount - Number of fields. unsigned FieldCount; struct CXXRecordLayoutInfo { - /// NonVirtualSize - The non-virtual size (in bits) of an object, which is + /// NonVirtualSize - The non-virtual size (in bits) of an object, which is /// the size of the object without virtual bases. uint64_t NonVirtualSize; - + /// NonVirtualAlign - The non-virtual alignment (in bits) of an object, /// which is the alignment of the object without virtual bases. uint64_t NonVirtualAlign; - + /// PrimaryBase - The primary base for our vtable. const CXXRecordDecl *PrimaryBase; /// PrimaryBase - Wether or not the primary base was a virtual base. @@ -67,16 +67,16 @@ /// FIXME: This should really use a SmallPtrMap, once we have one in LLVM :) llvm::DenseMap VBaseOffsets; }; - - /// CXXInfo - If the record layout is for a C++ record, this will have + + /// CXXInfo - If the record layout is for a C++ record, this will have /// C++ specific information about the record. CXXRecordLayoutInfo *CXXInfo; - + friend class ASTContext; friend class ASTRecordLayoutBuilder; ASTRecordLayout(uint64_t size, unsigned alignment, unsigned datasize, - const uint64_t *fieldoffsets, unsigned fieldcount) + const uint64_t *fieldoffsets, unsigned fieldcount) : Size(size), DataSize(datasize), FieldOffsets(0), Alignment(alignment), FieldCount(fieldcount), CXXInfo(0) { if (FieldCount > 0) { @@ -85,7 +85,7 @@ FieldOffsets[i] = fieldoffsets[i]; } } - + // Constructor for C++ records. ASTRecordLayout(uint64_t size, unsigned alignment, uint64_t datasize, const uint64_t *fieldoffsets, unsigned fieldcount, @@ -101,7 +101,7 @@ for (unsigned i = 0; i < FieldCount; ++i) FieldOffsets[i] = fieldoffsets[i]; } - + CXXInfo->PrimaryBase = PB; CXXInfo->PrimaryBaseWasVirtual = PBVirtual; CXXInfo->NonVirtualSize = nonvirtualsize; @@ -111,7 +111,7 @@ for (unsigned i = 0; i != vbasecount; ++i) CXXInfo->VBaseOffsets[vbases[i]] = vbaseoffsets[i]; } - + ~ASTRecordLayout() { delete [] FieldOffsets; delete CXXInfo; @@ -120,55 +120,55 @@ ASTRecordLayout(const ASTRecordLayout&); // DO NOT IMPLEMENT void operator=(const ASTRecordLayout&); // DO NOT IMPLEMENT public: - + /// getAlignment - Get the record alignment in bits. unsigned getAlignment() const { return Alignment; } /// getSize - Get the record size in bits. uint64_t getSize() const { return Size; } - + /// getFieldCount - Get the number of fields in the layout. unsigned getFieldCount() const { return FieldCount; } - + /// getFieldOffset - Get the offset of the given field index, in /// bits. uint64_t getFieldOffset(unsigned FieldNo) const { assert (FieldNo < FieldCount && "Invalid Field No"); return FieldOffsets[FieldNo]; } - + /// getDataSize() - Get the record data size, which is the record size /// without tail padding, in bits. uint64_t getDataSize() const { return DataSize; } - - /// getNonVirtualSize - Get the non-virtual size (in bits) of an object, + + /// getNonVirtualSize - Get the non-virtual size (in bits) of an object, /// which is the size of the object without virtual bases. - uint64_t getNonVirtualSize() const { + uint64_t getNonVirtualSize() const { assert(CXXInfo && "Record layout does not have C++ specific info!"); - + return CXXInfo->NonVirtualSize; } - + /// getNonVirtualSize - Get the non-virtual alignment (in bits) of an object, /// which is the alignment of the object without virtual bases. unsigned getNonVirtualAlign() const { assert(CXXInfo && "Record layout does not have C++ specific info!"); - + return CXXInfo->NonVirtualAlign; } - + /// getPrimaryBase - Get the primary base. const CXXRecordDecl *getPrimaryBase() const { assert(CXXInfo && "Record layout does not have C++ specific info!"); - + return CXXInfo->PrimaryBase; } /// getPrimaryBaseWasVirtual - Indicates if the primary base was virtual. bool getPrimaryBaseWasVirtual() const { assert(CXXInfo && "Record layout does not have C++ specific info!"); - + return CXXInfo->PrimaryBaseWasVirtual; } @@ -176,7 +176,7 @@ uint64_t getBaseClassOffset(const CXXRecordDecl *Base) const { assert(CXXInfo && "Record layout does not have C++ specific info!"); assert(CXXInfo->BaseOffsets.count(Base) && "Did not find base!"); - + return CXXInfo->BaseOffsets[Base]; } @@ -184,7 +184,7 @@ uint64_t getVBaseClassOffset(const CXXRecordDecl *VBase) const { assert(CXXInfo && "Record layout does not have C++ specific info!"); assert(CXXInfo->VBaseOffsets.count(VBase) && "Did not find base!"); - + return CXXInfo->VBaseOffsets[VBase]; } }; Modified: cfe/trunk/include/clang/AST/Redeclarable.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Redeclarable.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Redeclarable.h (original) +++ cfe/trunk/include/clang/AST/Redeclarable.h Wed Sep 9 10:08:12 2009 @@ -26,10 +26,10 @@ struct DeclLink : public llvm::PointerIntPair { DeclLink(decl_type *D, bool isLatest) : llvm::PointerIntPair(D, isLatest) { } - + typedef llvm::PointerIntPair base_type; - bool NextIsPrevious() const { return base_type::getInt() == false; } + bool NextIsPrevious() const { return base_type::getInt() == false; } bool NextIsLatest() const { return base_type::getInt() == true; } decl_type *getNext() const { return base_type::getPointer(); } }; @@ -69,7 +69,7 @@ return const_cast( static_cast(this))->getPreviousDeclaration(); } - + /// \brief Return the first declaration of this declaration or itself if this /// is the only declaration. decl_type *getFirstDeclaration() { @@ -91,7 +91,7 @@ assert(First->RedeclLink.NextIsLatest() && "Expected first"); } else { // Make this first. - First = static_cast(this); + First = static_cast(this); } // First one will point to this one as latest. @@ -131,10 +131,10 @@ return tmp; } - friend bool operator==(redecl_iterator x, redecl_iterator y) { + friend bool operator==(redecl_iterator x, redecl_iterator y) { return x.Current == y.Current; } - friend bool operator!=(redecl_iterator x, redecl_iterator y) { + friend bool operator!=(redecl_iterator x, redecl_iterator y) { return x.Current != y.Current; } }; Modified: cfe/trunk/include/clang/AST/Stmt.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Stmt.h (original) +++ cfe/trunk/include/clang/AST/Stmt.h Wed Sep 9 10:08:12 2009 @@ -39,21 +39,21 @@ class SourceManager; class StringLiteral; class SwitchStmt; - + //===----------------------------------------------------------------------===// // ExprIterator - Iterators for iterating over Stmt* arrays that contain // only Expr*. This is needed because AST nodes use Stmt* arrays to store // references to children (to be compatible with StmtIterator). //===----------------------------------------------------------------------===// - + class Stmt; class Expr; - + class ExprIterator { Stmt** I; public: ExprIterator(Stmt** i) : I(i) {} - ExprIterator() : I(0) {} + ExprIterator() : I(0) {} ExprIterator& operator++() { ++I; return *this; } ExprIterator operator-(size_t i) { return I-i; } ExprIterator operator+(size_t i) { return I+i; } @@ -67,12 +67,12 @@ bool operator>(const ExprIterator& R) const { return I > R.I; } bool operator>=(const ExprIterator& R) const { return I >= R.I; } }; - + class ConstExprIterator { Stmt* const * I; public: ConstExprIterator(Stmt* const* i) : I(i) {} - ConstExprIterator() : I(0) {} + ConstExprIterator() : I(0) {} ConstExprIterator& operator++() { ++I; return *this; } ConstExprIterator operator+(size_t i) { return I+i; } ConstExprIterator operator-(size_t i) { return I-i; } @@ -84,12 +84,12 @@ bool operator!=(const ConstExprIterator& R) const { return I != R.I; } bool operator>(const ConstExprIterator& R) const { return I > R.I; } bool operator>=(const ConstExprIterator& R) const { return I >= R.I; } - }; - + }; + //===----------------------------------------------------------------------===// // AST classes for statements. //===----------------------------------------------------------------------===// - + /// Stmt - This represents one statement. /// class Stmt { @@ -106,7 +106,7 @@ private: /// \brief The statement class. const unsigned sClass : 8; - + /// \brief The reference count for this statement. unsigned RefCount : 24; @@ -119,20 +119,20 @@ void operator delete(void* data) throw() { assert(0 && "Stmts cannot be released with regular 'delete'."); } - + public: // Only allow allocation of Stmts using the allocator in ASTContext - // or by doing a placement new. + // or by doing a placement new. void* operator new(size_t bytes, ASTContext& C, unsigned alignment = 16) throw() { return ::operator new(bytes, C, alignment); } - + void* operator new(size_t bytes, ASTContext* C, unsigned alignment = 16) throw() { return ::operator new(bytes, *C, alignment); } - + void* operator new(size_t bytes, void* mem) throw() { return mem; } @@ -152,9 +152,9 @@ /// DestroyChildren - Invoked by destructors of subclasses of Stmt to /// recursively release child AST nodes. void DestroyChildren(ASTContext& Ctx); - + /// \brief Construct an empty statement. - explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) { + explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) { if (Stmt::CollectingStats()) Stmt::addStmtClass(SC); } @@ -164,18 +164,18 @@ /// Subclasses should override this method (not Destroy()) to /// provide class-specific destruction. virtual void DoDestroy(ASTContext &Ctx); - + public: - Stmt(StmtClass SC) : sClass(SC), RefCount(1) { + Stmt(StmtClass SC) : sClass(SC), RefCount(1) { if (Stmt::CollectingStats()) Stmt::addStmtClass(SC); } virtual ~Stmt() {} - + /// \brief Destroy the current statement and its children. - void Destroy(ASTContext &Ctx) { + void Destroy(ASTContext &Ctx) { assert(RefCount >= 1); if (--RefCount == 0) - DoDestroy(Ctx); + DoDestroy(Ctx); } /// \brief Increases the reference count for this statement. @@ -187,10 +187,10 @@ ++RefCount; return this; } - + StmtClass getStmtClass() const { return (StmtClass)sClass; } const char *getStmtClassName() const; - + /// SourceLocation tokens are not useful in isolation - they are low level /// value objects created/interpreted by SourceManager. We assume AST /// clients will have a pointer to the respective SourceManager. @@ -216,23 +216,23 @@ /// 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 printPretty(llvm::raw_ostream &OS, PrinterHelper *Helper, + void printPretty(llvm::raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation = 0) const { printPretty(OS, *(ASTContext*)0, Helper, Policy, Indentation); } void printPretty(llvm::raw_ostream &OS, ASTContext &Context, - PrinterHelper *Helper, + PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation = 0) const; - + /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only /// works on systems with GraphViz (Mac OS X) or dot+gv installed. void viewAST() const; - + // Implement isa support. - static bool classof(const Stmt *) { return true; } - + static bool classof(const Stmt *) { return true; } + /// hasImplicitControlFlow - Some statements (e.g. short circuited operations) /// contain implicit control-flow in the order their subexpressions /// are evaluated. This predicate returns true if this statement has @@ -245,14 +245,14 @@ /// AST node. This permits easy iteration over all nodes in the AST. typedef StmtIterator child_iterator; typedef ConstStmtIterator const_child_iterator; - + virtual child_iterator child_begin() = 0; virtual child_iterator child_end() = 0; - + const_child_iterator child_begin() const { return const_child_iterator(const_cast(this)->child_begin()); } - + const_child_iterator child_end() const { return const_child_iterator(const_cast(this)->child_end()); } @@ -266,7 +266,7 @@ /// /// \brief Canonical whether the profile should be based on the canonical /// representation of this statement (e.g., where non-type template - /// parameters are identified by index/level rather than their + /// parameters are identified by index/level rather than their /// declaration pointers) or the exact representation of the statement as /// written in the source. void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, @@ -275,18 +275,18 @@ /// DeclStmt - Adaptor class for mixing declarations with statements and /// expressions. For example, CompoundStmt mixes statements, expressions -/// and declarations (variables, types). Another example is ForStmt, where +/// and declarations (variables, types). Another example is ForStmt, where /// the first statement can be an expression or a declaration. /// class DeclStmt : public Stmt { DeclGroupRef DG; SourceLocation StartLoc, EndLoc; - + public: - DeclStmt(DeclGroupRef dg, SourceLocation startLoc, + DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {} - + /// \brief Build an empty declaration statement. explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { } @@ -295,10 +295,10 @@ bool isSingleDecl() const { return DG.isSingleDecl(); } - + const Decl *getSingleDecl() const { return DG.getSingleDecl(); } - Decl *getSingleDecl() { return DG.getSingleDecl(); } - + Decl *getSingleDecl() { return DG.getSingleDecl(); } + const DeclGroupRef getDeclGroup() const { return DG; } DeclGroupRef getDeclGroup() { return DG; } void setDeclGroup(DeclGroupRef DGR) { DG = DGR; } @@ -311,19 +311,19 @@ SourceRange getSourceRange() const { return SourceRange(StartLoc, EndLoc); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == DeclStmtClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == DeclStmtClass; } static bool classof(const DeclStmt *) { return true; } - + // Iterators over subexpressions. virtual child_iterator child_begin(); virtual child_iterator child_end(); - + typedef DeclGroupRef::iterator decl_iterator; typedef DeclGroupRef::const_iterator const_decl_iterator; - + decl_iterator decl_begin() { return DG.begin(); } decl_iterator decl_end() { return DG.end(); } const_decl_iterator decl_begin() const { return DG.begin(); } @@ -344,12 +344,12 @@ void setSemiLoc(SourceLocation L) { SemiLoc = L; } virtual SourceRange getSourceRange() const { return SourceRange(SemiLoc); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == NullStmtClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == NullStmtClass; } static bool classof(const NullStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -362,24 +362,24 @@ unsigned NumStmts; SourceLocation LBracLoc, RBracLoc; public: - CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned numStmts, + CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned numStmts, SourceLocation LB, SourceLocation RB) : Stmt(CompoundStmtClass), NumStmts(numStmts), LBracLoc(LB), RBracLoc(RB) { if (NumStmts == 0) { Body = 0; return; } - + Body = new (C) Stmt*[NumStmts]; memcpy(Body, StmtStart, numStmts * sizeof(*Body)); - } + } // \brief Build an empty compound statement. explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty), Body(0), NumStmts(0) { } void setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts); - + bool body_empty() const { return NumStmts == 0; } unsigned size() const { return NumStmts; } @@ -407,25 +407,25 @@ const_reverse_body_iterator body_rbegin() const { return const_reverse_body_iterator(body_end()); } - + const_reverse_body_iterator body_rend() const { return const_reverse_body_iterator(body_begin()); } - - virtual SourceRange getSourceRange() const { - return SourceRange(LBracLoc, RBracLoc); + + virtual SourceRange getSourceRange() const { + return SourceRange(LBracLoc, RBracLoc); } - + SourceLocation getLBracLoc() const { return LBracLoc; } void setLBracLoc(SourceLocation L) { LBracLoc = L; } SourceLocation getRBracLoc() const { return RBracLoc; } void setRBracLoc(SourceLocation L) { RBracLoc = L; } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == CompoundStmtClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == CompoundStmtClass; } static bool classof(const CompoundStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -439,7 +439,7 @@ SwitchCase *NextSwitchCase; SwitchCase(StmtClass SC) : Stmt(SC), NextSwitchCase(0) {} - + public: const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; } @@ -450,19 +450,19 @@ Stmt *getSubStmt() { return v_getSubStmt(); } virtual SourceRange getSourceRange() const { return SourceRange(); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == CaseStmtClass || + + static bool classof(const Stmt *T) { + return T->getStmtClass() == CaseStmtClass || T->getStmtClass() == DefaultStmtClass; } static bool classof(const SwitchCase *) { return true; } protected: - virtual Stmt* v_getSubStmt() = 0; + virtual Stmt* v_getSubStmt() = 0; }; class CaseStmt : public SwitchCase { enum { SUBSTMT, LHS, RHS, END_EXPR }; - Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for + Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for // GNU "case 1 ... 4" extension SourceLocation CaseLoc; SourceLocation EllipsisLoc; @@ -471,7 +471,7 @@ virtual Stmt* v_getSubStmt() { return getSubStmt(); } public: CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc, - SourceLocation ellipsisLoc, SourceLocation colonLoc) + SourceLocation ellipsisLoc, SourceLocation colonLoc) : SwitchCase(CaseStmtClass) { SubExprs[SUBSTMT] = 0; SubExprs[LHS] = reinterpret_cast(lhs); @@ -495,32 +495,32 @@ Expr *getRHS() { return reinterpret_cast(SubExprs[RHS]); } Stmt *getSubStmt() { return SubExprs[SUBSTMT]; } - const Expr *getLHS() const { - return reinterpret_cast(SubExprs[LHS]); + const Expr *getLHS() const { + return reinterpret_cast(SubExprs[LHS]); } - const Expr *getRHS() const { - return reinterpret_cast(SubExprs[RHS]); + const Expr *getRHS() const { + return reinterpret_cast(SubExprs[RHS]); } const Stmt *getSubStmt() const { return SubExprs[SUBSTMT]; } void setSubStmt(Stmt *S) { SubExprs[SUBSTMT] = S; } void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast(Val); } void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast(Val); } - - + + virtual SourceRange getSourceRange() const { // Handle deeply nested case statements with iteration instead of recursion. const CaseStmt *CS = this; while (const CaseStmt *CS2 = dyn_cast(CS->getSubStmt())) CS = CS2; - - return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd()); + + return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == CaseStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == CaseStmtClass; } static bool classof(const CaseStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -532,7 +532,7 @@ SourceLocation ColonLoc; virtual Stmt* v_getSubStmt() { return getSubStmt(); } public: - DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) : + DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) : SwitchCase(DefaultStmtClass), SubStmt(substmt), DefaultLoc(DL), ColonLoc(CL) {} @@ -548,14 +548,14 @@ SourceLocation getColonLoc() const { return ColonLoc; } void setColonLoc(SourceLocation L) { ColonLoc = L; } - virtual SourceRange getSourceRange() const { - return SourceRange(DefaultLoc, SubStmt->getLocEnd()); + virtual SourceRange getSourceRange() const { + return SourceRange(DefaultLoc, SubStmt->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == DefaultStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == DefaultStmtClass; } static bool classof(const DefaultStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -566,13 +566,13 @@ Stmt *SubStmt; SourceLocation IdentLoc; public: - LabelStmt(SourceLocation IL, IdentifierInfo *label, Stmt *substmt) - : Stmt(LabelStmtClass), Label(label), + LabelStmt(SourceLocation IL, IdentifierInfo *label, Stmt *substmt) + : Stmt(LabelStmtClass), Label(label), SubStmt(substmt), IdentLoc(IL) {} // \brief Build an empty label statement. explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) { } - + SourceLocation getIdentLoc() const { return IdentLoc; } IdentifierInfo *getID() const { return Label; } void setID(IdentifierInfo *II) { Label = II; } @@ -582,14 +582,14 @@ void setIdentLoc(SourceLocation L) { IdentLoc = L; } void setSubStmt(Stmt *SS) { SubStmt = SS; } - virtual SourceRange getSourceRange() const { - return SourceRange(IdentLoc, SubStmt->getLocEnd()); - } - static bool classof(const Stmt *T) { - return T->getStmtClass() == LabelStmtClass; + virtual SourceRange getSourceRange() const { + return SourceRange(IdentLoc, SubStmt->getLocEnd()); + } + static bool classof(const Stmt *T) { + return T->getStmtClass() == LabelStmtClass; } static bool classof(const LabelStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -604,8 +604,8 @@ SourceLocation IfLoc; SourceLocation ElseLoc; public: - IfStmt(SourceLocation IL, Expr *cond, Stmt *then, - SourceLocation EL = SourceLocation(), Stmt *elsev = 0) + IfStmt(SourceLocation IL, Expr *cond, Stmt *then, + SourceLocation EL = SourceLocation(), Stmt *elsev = 0) : Stmt(IfStmtClass) { SubExprs[COND] = reinterpret_cast(cond); SubExprs[THEN] = then; @@ -613,14 +613,14 @@ IfLoc = IL; ElseLoc = EL; } - + /// \brief Build an empty if/then/else statement explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { } const Expr *getCond() const { return reinterpret_cast(SubExprs[COND]);} void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast(E); } const Stmt *getThen() const { return SubExprs[THEN]; } - void setThen(Stmt *S) { SubExprs[THEN] = S; } + void setThen(Stmt *S) { SubExprs[THEN] = S; } const Stmt *getElse() const { return SubExprs[ELSE]; } void setElse(Stmt *S) { SubExprs[ELSE] = S; } @@ -633,18 +633,18 @@ SourceLocation getElseLoc() const { return ElseLoc; } void setElseLoc(SourceLocation L) { ElseLoc = L; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const { if (SubExprs[ELSE]) return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd()); else return SourceRange(IfLoc, SubExprs[THEN]->getLocEnd()); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == IfStmtClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == IfStmtClass; } static bool classof(const IfStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -654,20 +654,20 @@ /// class SwitchStmt : public Stmt { enum { COND, BODY, END_EXPR }; - Stmt* SubExprs[END_EXPR]; + Stmt* SubExprs[END_EXPR]; // This points to a linked list of case and default statements. SwitchCase *FirstCase; SourceLocation SwitchLoc; - + protected: virtual void DoDestroy(ASTContext &Ctx); - + public: SwitchStmt(Expr *cond) : Stmt(SwitchStmtClass), FirstCase(0) { SubExprs[COND] = reinterpret_cast(cond); SubExprs[BODY] = NULL; } - + /// \brief Build a empty switch statement. explicit SwitchStmt(EmptyShell Empty) : Stmt(SwitchStmtClass, Empty) { } @@ -680,7 +680,7 @@ Stmt *getBody() { return SubExprs[BODY]; } void setBody(Stmt *S) { SubExprs[BODY] = S; } SwitchCase *getSwitchCaseList() { return FirstCase; } - + /// \brief Set the case list for this switch statement. /// /// The caller is responsible for incrementing the retain counts on @@ -690,24 +690,24 @@ SourceLocation getSwitchLoc() const { return SwitchLoc; } void setSwitchLoc(SourceLocation L) { SwitchLoc = L; } - void setBody(Stmt *S, SourceLocation SL) { - SubExprs[BODY] = S; + void setBody(Stmt *S, SourceLocation SL) { + SubExprs[BODY] = S; SwitchLoc = SL; - } + } void addSwitchCase(SwitchCase *SC) { assert(!SC->getNextSwitchCase() && "case/default already added to a switch"); SC->Retain(); SC->setNextSwitchCase(FirstCase); FirstCase = SC; } - virtual SourceRange getSourceRange() const { - return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd()); + virtual SourceRange getSourceRange() const { + return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == SwitchStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == SwitchStmtClass; } static bool classof(const SwitchStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -726,7 +726,7 @@ SubExprs[BODY] = body; WhileLoc = WL; } - + /// \brief Build an empty while statement. explicit WhileStmt(EmptyShell Empty) : Stmt(WhileStmtClass, Empty) { } @@ -740,14 +740,14 @@ SourceLocation getWhileLoc() const { return WhileLoc; } void setWhileLoc(SourceLocation L) { WhileLoc = L; } - virtual SourceRange getSourceRange() const { - return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd()); + virtual SourceRange getSourceRange() const { + return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == WhileStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == WhileStmtClass; } static bool classof(const WhileStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -768,16 +768,16 @@ : Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) { SubExprs[COND] = reinterpret_cast(cond); SubExprs[BODY] = body; - } + } /// \brief Build an empty do-while statement. explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) { } - + Expr *getCond() { return reinterpret_cast(SubExprs[COND]); } const Expr *getCond() const { return reinterpret_cast(SubExprs[COND]);} void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast(E); } Stmt *getBody() { return SubExprs[BODY]; } - const Stmt *getBody() const { return SubExprs[BODY]; } + const Stmt *getBody() const { return SubExprs[BODY]; } void setBody(Stmt *S) { SubExprs[BODY] = S; } SourceLocation getDoLoc() const { return DoLoc; } @@ -788,11 +788,11 @@ SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - virtual SourceRange getSourceRange() const { - return SourceRange(DoLoc, RParenLoc); + virtual SourceRange getSourceRange() const { + return SourceRange(DoLoc, RParenLoc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == DoStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == DoStmtClass; } static bool classof(const DoStmt *) { return true; } @@ -814,7 +814,7 @@ public: ForStmt(Stmt *Init, Expr *Cond, Expr *Inc, Stmt *Body, SourceLocation FL, - SourceLocation LP, SourceLocation RP) + SourceLocation LP, SourceLocation RP) : Stmt(ForStmtClass) { SubExprs[INIT] = Init; SubExprs[COND] = reinterpret_cast(Cond); @@ -824,7 +824,7 @@ LParenLoc = LP; RParenLoc = RP; } - + /// \brief Build an empty for statement. explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { } @@ -850,19 +850,19 @@ SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - virtual SourceRange getSourceRange() const { - return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); + virtual SourceRange getSourceRange() const { + return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ForStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ForStmtClass; } static bool classof(const ForStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + /// GotoStmt - This represents a direct goto. /// class GotoStmt : public Stmt { @@ -870,9 +870,9 @@ SourceLocation GotoLoc; SourceLocation LabelLoc; public: - GotoStmt(LabelStmt *label, SourceLocation GL, SourceLocation LL) + GotoStmt(LabelStmt *label, SourceLocation GL, SourceLocation LL) : Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {} - + /// \brief Build an empty goto statement. explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) { } @@ -884,14 +884,14 @@ SourceLocation getLabelLoc() const { return LabelLoc; } void setLabelLoc(SourceLocation L) { LabelLoc = L; } - virtual SourceRange getSourceRange() const { - return SourceRange(GotoLoc, LabelLoc); + virtual SourceRange getSourceRange() const { + return SourceRange(GotoLoc, LabelLoc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == GotoStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == GotoStmtClass; } static bool classof(const GotoStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -904,20 +904,20 @@ SourceLocation StarLoc; Stmt *Target; public: - IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, + IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, Expr *target) : Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), StarLoc(starLoc), Target((Stmt*)target) {} /// \brief Build an empty indirect goto statement. - explicit IndirectGotoStmt(EmptyShell Empty) + explicit IndirectGotoStmt(EmptyShell Empty) : Stmt(IndirectGotoStmtClass, Empty) { } - + void setGotoLoc(SourceLocation L) { GotoLoc = L; } SourceLocation getGotoLoc() const { return GotoLoc; } void setStarLoc(SourceLocation L) { StarLoc = L; } SourceLocation getStarLoc() const { return StarLoc; } - + Expr *getTarget(); const Expr *getTarget() const; void setTarget(Expr *E) { Target = reinterpret_cast(E); } @@ -925,12 +925,12 @@ virtual SourceRange getSourceRange() const { return SourceRange(GotoLoc, Target->getLocEnd()); } - - static bool classof(const Stmt *T) { - return T->getStmtClass() == IndirectGotoStmtClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == IndirectGotoStmtClass; } static bool classof(const IndirectGotoStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -943,22 +943,22 @@ SourceLocation ContinueLoc; public: ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {} - + /// \brief Build an empty continue statement. explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) { } SourceLocation getContinueLoc() const { return ContinueLoc; } void setContinueLoc(SourceLocation L) { ContinueLoc = L; } - virtual SourceRange getSourceRange() const { - return SourceRange(ContinueLoc); + virtual SourceRange getSourceRange() const { + return SourceRange(ContinueLoc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ContinueStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ContinueStmtClass; } static bool classof(const ContinueStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -970,7 +970,7 @@ SourceLocation BreakLoc; public: BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {} - + /// \brief Build an empty break statement. explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) { } @@ -979,11 +979,11 @@ virtual SourceRange getSourceRange() const { return SourceRange(BreakLoc); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == BreakStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == BreakStmtClass; } static bool classof(const BreakStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1003,7 +1003,7 @@ Stmt *RetExpr; SourceLocation RetLoc; public: - ReturnStmt(SourceLocation RL, Expr *E = 0) : Stmt(ReturnStmtClass), + ReturnStmt(SourceLocation RL, Expr *E = 0) : Stmt(ReturnStmtClass), RetExpr((Stmt*) E), RetLoc(RL) {} /// \brief Build an empty return expression. @@ -1017,12 +1017,12 @@ void setReturnLoc(SourceLocation L) { RetLoc = L; } virtual SourceRange getSourceRange() const; - - static bool classof(const Stmt *T) { - return T->getStmtClass() == ReturnStmtClass; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == ReturnStmtClass; } static bool classof(const ReturnStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -1036,18 +1036,18 @@ bool IsSimple; bool IsVolatile; - + unsigned NumOutputs; unsigned NumInputs; - + llvm::SmallVector Names; llvm::SmallVector Constraints; llvm::SmallVector Exprs; llvm::SmallVector Clobbers; public: - AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, - unsigned numoutputs, unsigned numinputs, + AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, + unsigned numoutputs, unsigned numinputs, std::string *names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, StringLiteral **clobbers, SourceLocation rparenloc); @@ -1090,10 +1090,10 @@ : MyKind(Operand), Str(), OperandNo(OpNo) { Str += Modifier; } - + bool isString() const { return MyKind == String; } bool isOperand() const { return MyKind == Operand; } - + const std::string &getString() const { assert(isString()); return Str; @@ -1103,7 +1103,7 @@ assert(isOperand()); return OperandNo; } - + /// getModifier - Get the modifier for this operand, if present. This /// returns '\0' if there was no modifier. char getModifier() const { @@ -1111,16 +1111,16 @@ return Str[0]; } }; - + /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing /// it into pieces. If the asm string is erroneous, emit errors and return /// true, otherwise return false. This handles canonicalization and /// translation of strings from GCC syntax to LLVM IR syntax, and handles - //// flattening of named references like %[foo] to Operand AsmStringPiece's. + //// flattening of named references like %[foo] to Operand AsmStringPiece's. unsigned AnalyzeAsmString(llvm::SmallVectorImpl &Pieces, ASTContext &C, unsigned &DiagOffs) const; - - + + //===--- Output operands ---===// unsigned getNumOutputs() const { return NumOutputs; } @@ -1133,72 +1133,72 @@ /// output operand. All output constraints are known to be non-empty (either /// '=' or '+'). std::string getOutputConstraint(unsigned i) const; - + const StringLiteral *getOutputConstraintLiteral(unsigned i) const { return Constraints[i]; } StringLiteral *getOutputConstraintLiteral(unsigned i) { return Constraints[i]; } - - + + Expr *getOutputExpr(unsigned i); - + const Expr *getOutputExpr(unsigned i) const { return const_cast(this)->getOutputExpr(i); } - + /// isOutputPlusConstraint - Return true if the specified output constraint /// is a "+" constraint (which is both an input and an output) or false if it /// is an "=" constraint (just an output). bool isOutputPlusConstraint(unsigned i) const { return getOutputConstraint(i)[0] == '+'; } - + /// getNumPlusOperands - Return the number of output operands that have a "+" /// constraint. unsigned getNumPlusOperands() const; - + //===--- Input operands ---===// - - unsigned getNumInputs() const { return NumInputs; } - + + unsigned getNumInputs() const { return NumInputs; } + const std::string &getInputName(unsigned i) const { return Names[i + NumOutputs]; } - + /// getInputConstraint - Return the specified input constraint. Unlike output /// constraints, these can be empty. std::string getInputConstraint(unsigned i) const; - + const StringLiteral *getInputConstraintLiteral(unsigned i) const { return Constraints[i + NumOutputs]; } StringLiteral *getInputConstraintLiteral(unsigned i) { return Constraints[i + NumOutputs]; } - - + + Expr *getInputExpr(unsigned i); - + const Expr *getInputExpr(unsigned i) const { return const_cast(this)->getInputExpr(i); } void setOutputsAndInputs(unsigned NumOutputs, - unsigned NumInputs, + unsigned NumInputs, const std::string *Names, StringLiteral **Constraints, Stmt **Exprs); //===--- Other ---===// - + /// getNamedOperand - Given a symbolic operand reference like %[foo], /// translate this into a numeric value needed to reference the same operand. /// This returns -1 if the operand name is invalid. int getNamedOperand(const std::string &SymbolicName) const; - + unsigned getNumClobbers() const { return Clobbers.size(); } StringLiteral *getClobber(unsigned i) { return Clobbers[i]; } @@ -1208,62 +1208,62 @@ virtual SourceRange getSourceRange() const { return SourceRange(AsmLoc, RParenLoc); } - + static bool classof(const Stmt *T) {return T->getStmtClass() == AsmStmtClass;} static bool classof(const AsmStmt *) { return true; } - + // Input expr iterators. - + typedef ExprIterator inputs_iterator; typedef ConstExprIterator const_inputs_iterator; - + inputs_iterator begin_inputs() { return Exprs.data() + NumOutputs; } - + inputs_iterator end_inputs() { return Exprs.data() + NumOutputs + NumInputs; } - + const_inputs_iterator begin_inputs() const { return Exprs.data() + NumOutputs; } - + const_inputs_iterator end_inputs() const { return Exprs.data() + NumOutputs + NumInputs; } - + // Output expr iterators. - + typedef ExprIterator outputs_iterator; typedef ConstExprIterator const_outputs_iterator; - + outputs_iterator begin_outputs() { return Exprs.data(); } outputs_iterator end_outputs() { return Exprs.data() + NumOutputs; } - + const_outputs_iterator begin_outputs() const { return Exprs.data(); } const_outputs_iterator end_outputs() const { return Exprs.data() + NumOutputs; } - + // Input name iterator. - + const std::string *begin_output_names() const { return &Names[0]; } - + const std::string *end_output_names() const { return &Names[0] + NumOutputs; } - - // Child iterators - + + // Child iterators + virtual child_iterator child_begin(); virtual child_iterator child_end(); }; Modified: cfe/trunk/include/clang/AST/StmtGraphTraits.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtGraphTraits.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/StmtGraphTraits.h (original) +++ cfe/trunk/include/clang/AST/StmtGraphTraits.h Wed Sep 9 10:08:12 2009 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines a template specialization of llvm::GraphTraits to +// This file defines a template specialization of llvm::GraphTraits to // treat ASTs (Stmt*) as graphs // //===----------------------------------------------------------------------===// @@ -20,7 +20,7 @@ #include "llvm/ADT/DepthFirstIterator.h" namespace llvm { - + //template struct GraphTraits; @@ -28,23 +28,23 @@ typedef clang::Stmt NodeType; typedef clang::Stmt::child_iterator ChildIteratorType; typedef llvm::df_iterator nodes_iterator; - + static NodeType* getEntryNode(clang::Stmt* S) { return S; } - + static inline ChildIteratorType child_begin(NodeType* N) { if (N) return N->child_begin(); else return ChildIteratorType(); } - + static inline ChildIteratorType child_end(NodeType* N) { if (N) return N->child_end(); else return ChildIteratorType(); } - + static nodes_iterator nodes_begin(clang::Stmt* S) { return df_begin(S); } - + static nodes_iterator nodes_end(clang::Stmt* S) { return df_end(S); } @@ -55,29 +55,29 @@ typedef const clang::Stmt NodeType; typedef clang::Stmt::const_child_iterator ChildIteratorType; typedef llvm::df_iterator nodes_iterator; - + static NodeType* getEntryNode(const clang::Stmt* S) { return S; } - + static inline ChildIteratorType child_begin(NodeType* N) { if (N) return N->child_begin(); - else return ChildIteratorType(); + else return ChildIteratorType(); } - + static inline ChildIteratorType child_end(NodeType* N) { if (N) return N->child_end(); else return ChildIteratorType(); } - + static nodes_iterator nodes_begin(const clang::Stmt* S) { return df_begin(S); } - + static nodes_iterator nodes_end(const clang::Stmt* S) { return df_end(S); } }; - + } // end namespace llvm #endif Modified: cfe/trunk/include/clang/AST/StmtIterator.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtIterator.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/StmtIterator.h (original) +++ cfe/trunk/include/clang/AST/StmtIterator.h Wed Sep 9 10:08:12 2009 @@ -23,45 +23,45 @@ class Stmt; class Decl; class VariableArrayType; - + class StmtIteratorBase { protected: enum { DeclMode = 0x1, SizeOfTypeVAMode = 0x2, DeclGroupMode = 0x3, Flags = 0x3 }; - + union { Stmt** stmt; Decl* decl; Decl** DGI; }; - uintptr_t RawVAPtr; + uintptr_t RawVAPtr; Decl** DGE; bool inDecl() const { return (RawVAPtr & Flags) == DeclMode; } - + bool inDeclGroup() const { return (RawVAPtr & Flags) == DeclGroupMode; } - - bool inSizeOfTypeVA() const { + + bool inSizeOfTypeVA() const { return (RawVAPtr & Flags) == SizeOfTypeVAMode; } - + bool inStmt() const { return (RawVAPtr & Flags) == 0; } - + VariableArrayType* getVAPtr() const { return reinterpret_cast(RawVAPtr & ~Flags); } - + void setVAPtr(VariableArrayType* P) { - assert (inDecl() || inDeclGroup() || inSizeOfTypeVA()); + assert (inDecl() || inDeclGroup() || inSizeOfTypeVA()); RawVAPtr = reinterpret_cast(P) | (RawVAPtr & Flags); } - + void NextDecl(bool ImmediateAdvance = true); bool HandleDecl(Decl* D); void NextVA(); - + Stmt*& GetDeclExpr() const; StmtIteratorBase(Stmt** s) : stmt(s), RawVAPtr(0) {} @@ -70,22 +70,22 @@ StmtIteratorBase(Decl** dgi, Decl** dge); StmtIteratorBase() : stmt(NULL), RawVAPtr(0) {} }; - - + + template -class StmtIteratorImpl : public StmtIteratorBase, +class StmtIteratorImpl : public StmtIteratorBase, public std::iterator { + REFERENCE, ptrdiff_t, + REFERENCE, REFERENCE> { protected: StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {} public: - StmtIteratorImpl() {} + StmtIteratorImpl() {} StmtIteratorImpl(Stmt** s) : StmtIteratorBase(s) {} StmtIteratorImpl(Decl** dgi, Decl** dge) : StmtIteratorBase(dgi, dge) {} StmtIteratorImpl(Decl* d) : StmtIteratorBase(d) {} StmtIteratorImpl(VariableArrayType* t) : StmtIteratorBase(t) {} - + DERIVED& operator++() { if (inDecl() || inDeclGroup()) { if (getVAPtr()) NextVA(); @@ -95,36 +95,36 @@ NextVA(); else ++stmt; - + return static_cast(*this); } - + DERIVED operator++(int) { DERIVED tmp = static_cast(*this); operator++(); return tmp; } - + bool operator==(const DERIVED& RHS) const { return stmt == RHS.stmt && RawVAPtr == RHS.RawVAPtr; } - + bool operator!=(const DERIVED& RHS) const { return stmt != RHS.stmt || RawVAPtr != RHS.RawVAPtr; } - - REFERENCE operator*() const { + + REFERENCE operator*() const { return (REFERENCE) (inStmt() ? *stmt : GetDeclExpr()); } - - REFERENCE operator->() const { return operator*(); } + + REFERENCE operator->() const { return operator*(); } }; struct StmtIterator : public StmtIteratorImpl { explicit StmtIterator() : StmtIteratorImpl() {} StmtIterator(Stmt** S) : StmtIteratorImpl(S) {} - StmtIterator(Decl** dgi, Decl** dge) + StmtIterator(Decl** dgi, Decl** dge) : StmtIteratorImpl(dgi, dge) {} StmtIterator(VariableArrayType* t):StmtIteratorImpl(t) {} @@ -133,10 +133,10 @@ struct ConstStmtIterator : public StmtIteratorImpl { - explicit ConstStmtIterator() : + explicit ConstStmtIterator() : StmtIteratorImpl() {} - - ConstStmtIterator(const StmtIterator& RHS) : + + ConstStmtIterator(const StmtIterator& RHS) : StmtIteratorImpl(RHS) {} }; Modified: cfe/trunk/include/clang/AST/StmtObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtObjC.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/StmtObjC.h (original) +++ cfe/trunk/include/clang/AST/StmtObjC.h Wed Sep 9 10:08:12 2009 @@ -27,47 +27,47 @@ SourceLocation ForLoc; SourceLocation RParenLoc; public: - ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, + ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, SourceLocation FCL, SourceLocation RPL); - explicit ObjCForCollectionStmt(EmptyShell Empty) : + explicit ObjCForCollectionStmt(EmptyShell Empty) : Stmt(ObjCForCollectionStmtClass, Empty) { } - + Stmt *getElement() { return SubExprs[ELEM]; } - Expr *getCollection() { - return reinterpret_cast(SubExprs[COLLECTION]); + Expr *getCollection() { + return reinterpret_cast(SubExprs[COLLECTION]); } Stmt *getBody() { return SubExprs[BODY]; } - + const Stmt *getElement() const { return SubExprs[ELEM]; } - const Expr *getCollection() const { + const Expr *getCollection() const { return reinterpret_cast(SubExprs[COLLECTION]); } const Stmt *getBody() const { return SubExprs[BODY]; } - + void setElement(Stmt *S) { SubExprs[ELEM] = S; } - void setCollection(Expr *E) { + void setCollection(Expr *E) { SubExprs[COLLECTION] = reinterpret_cast(E); } void setBody(Stmt *S) { SubExprs[BODY] = S; } - + SourceLocation getForLoc() const { return ForLoc; } void setForLoc(SourceLocation Loc) { ForLoc = Loc; } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } - - virtual SourceRange getSourceRange() const { - return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); + + virtual SourceRange getSourceRange() const { + return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); } - static bool classof(const Stmt *T) { - return T->getStmtClass() == ObjCForCollectionStmtClass; + static bool classof(const Stmt *T) { + return T->getStmtClass() == ObjCForCollectionStmtClass; } static bool classof(const ObjCForCollectionStmt *) { return true; } - + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); -}; - +}; + /// ObjCAtCatchStmt - This represents objective-c's @catch statement. class ObjCAtCatchStmt : public Stmt { private: @@ -78,95 +78,95 @@ public: ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, - ParmVarDecl *catchVarDecl, + ParmVarDecl *catchVarDecl, Stmt *atCatchStmt, Stmt *atCatchList); - explicit ObjCAtCatchStmt(EmptyShell Empty) : + explicit ObjCAtCatchStmt(EmptyShell Empty) : Stmt(ObjCAtCatchStmtClass, Empty) { } - + const Stmt *getCatchBody() const { return SubExprs[BODY]; } Stmt *getCatchBody() { return SubExprs[BODY]; } void setCatchBody(Stmt *S) { SubExprs[BODY] = S; } - + const ObjCAtCatchStmt *getNextCatchStmt() const { return static_cast(SubExprs[NEXT_CATCH]); } - ObjCAtCatchStmt *getNextCatchStmt() { + ObjCAtCatchStmt *getNextCatchStmt() { return static_cast(SubExprs[NEXT_CATCH]); } void setNextCatchStmt(Stmt *S) { SubExprs[NEXT_CATCH] = S; } - - const ParmVarDecl *getCatchParamDecl() const { - return ExceptionDecl; + + const ParmVarDecl *getCatchParamDecl() const { + return ExceptionDecl; } - ParmVarDecl *getCatchParamDecl() { - return ExceptionDecl; + ParmVarDecl *getCatchParamDecl() { + return ExceptionDecl; } void setCatchParamDecl(ParmVarDecl *D) { ExceptionDecl = D; } - + SourceLocation getAtCatchLoc() const { return AtCatchLoc; } void setAtCatchLoc(SourceLocation Loc) { AtCatchLoc = Loc; } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } - - virtual SourceRange getSourceRange() const { - return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd()); + + virtual SourceRange getSourceRange() const { + return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd()); } bool hasEllipsis() const { return getCatchParamDecl() == 0; } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAtCatchStmtClass; } static bool classof(const ObjCAtCatchStmt *) { return true; } - + virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - -/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement + +/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement class ObjCAtFinallyStmt : public Stmt { Stmt *AtFinallyStmt; - SourceLocation AtFinallyLoc; + SourceLocation AtFinallyLoc; public: ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt) - : Stmt(ObjCAtFinallyStmtClass), + : Stmt(ObjCAtFinallyStmtClass), AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {} - explicit ObjCAtFinallyStmt(EmptyShell Empty) : + explicit ObjCAtFinallyStmt(EmptyShell Empty) : Stmt(ObjCAtFinallyStmtClass, Empty) { } - + const Stmt *getFinallyBody() const { return AtFinallyStmt; } Stmt *getFinallyBody() { return AtFinallyStmt; } void setFinallyBody(Stmt *S) { AtFinallyStmt = S; } - - virtual SourceRange getSourceRange() const { - return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); + + virtual SourceRange getSourceRange() const { + return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); } - + SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; } void setAtFinallyLoc(SourceLocation Loc) { AtFinallyLoc = Loc; } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAtFinallyStmtClass; } static bool classof(const ObjCAtFinallyStmt *) { return true; } - + virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - -/// ObjCAtTryStmt - This represent objective-c's over-all + +/// ObjCAtTryStmt - This represent objective-c's over-all /// @try ... @catch ... @finally statement. class ObjCAtTryStmt : public Stmt { private: enum { TRY, CATCH, FINALLY, END_EXPR }; - Stmt* SubStmts[END_EXPR]; - - SourceLocation AtTryLoc; + Stmt* SubStmts[END_EXPR]; + + SourceLocation AtTryLoc; public: - ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, - Stmt *atCatchStmt, + ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, + Stmt *atCatchStmt, Stmt *atFinallyStmt) : Stmt(ObjCAtTryStmtClass) { SubStmts[TRY] = atTryStmt; @@ -174,41 +174,41 @@ SubStmts[FINALLY] = atFinallyStmt; AtTryLoc = atTryLoc; } - explicit ObjCAtTryStmt(EmptyShell Empty) : + explicit ObjCAtTryStmt(EmptyShell Empty) : Stmt(ObjCAtTryStmtClass, Empty) { } - + SourceLocation getAtTryLoc() const { return AtTryLoc; } void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; } - + const Stmt *getTryBody() const { return SubStmts[TRY]; } Stmt *getTryBody() { return SubStmts[TRY]; } void setTryBody(Stmt *S) { SubStmts[TRY] = S; } - - const ObjCAtCatchStmt *getCatchStmts() const { - return dyn_cast_or_null(SubStmts[CATCH]); + + const ObjCAtCatchStmt *getCatchStmts() const { + return dyn_cast_or_null(SubStmts[CATCH]); } - ObjCAtCatchStmt *getCatchStmts() { - return dyn_cast_or_null(SubStmts[CATCH]); + ObjCAtCatchStmt *getCatchStmts() { + return dyn_cast_or_null(SubStmts[CATCH]); } void setCatchStmts(Stmt *S) { SubStmts[CATCH] = S; } - - const ObjCAtFinallyStmt *getFinallyStmt() const { - return dyn_cast_or_null(SubStmts[FINALLY]); + + const ObjCAtFinallyStmt *getFinallyStmt() const { + return dyn_cast_or_null(SubStmts[FINALLY]); } - ObjCAtFinallyStmt *getFinallyStmt() { - return dyn_cast_or_null(SubStmts[FINALLY]); + ObjCAtFinallyStmt *getFinallyStmt() { + return dyn_cast_or_null(SubStmts[FINALLY]); } void setFinallyStmt(Stmt *S) { SubStmts[FINALLY] = S; } - virtual SourceRange getSourceRange() const { - return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd()); + virtual SourceRange getSourceRange() const { + return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd()); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAtTryStmtClass; } static bool classof(const ObjCAtTryStmt *) { return true; } - + virtual child_iterator child_begin(); virtual child_iterator child_end(); }; @@ -223,7 +223,7 @@ enum { SYNC_EXPR, SYNC_BODY, END_EXPR }; Stmt* SubStmts[END_EXPR]; SourceLocation AtSynchronizedLoc; - + public: ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr, Stmt *synchBody) @@ -232,41 +232,41 @@ SubStmts[SYNC_BODY] = synchBody; AtSynchronizedLoc = atSynchronizedLoc; } - explicit ObjCAtSynchronizedStmt(EmptyShell Empty) : + explicit ObjCAtSynchronizedStmt(EmptyShell Empty) : Stmt(ObjCAtSynchronizedStmtClass, Empty) { } - + SourceLocation getAtSynchronizedLoc() const { return AtSynchronizedLoc; } void setAtSynchronizedLoc(SourceLocation Loc) { AtSynchronizedLoc = Loc; } - + const CompoundStmt *getSynchBody() const { return reinterpret_cast(SubStmts[SYNC_BODY]); } - CompoundStmt *getSynchBody() { - return reinterpret_cast(SubStmts[SYNC_BODY]); + CompoundStmt *getSynchBody() { + return reinterpret_cast(SubStmts[SYNC_BODY]); } void setSynchBody(Stmt *S) { SubStmts[SYNC_BODY] = S; } - - const Expr *getSynchExpr() const { - return reinterpret_cast(SubStmts[SYNC_EXPR]); + + const Expr *getSynchExpr() const { + return reinterpret_cast(SubStmts[SYNC_EXPR]); } - Expr *getSynchExpr() { - return reinterpret_cast(SubStmts[SYNC_EXPR]); + Expr *getSynchExpr() { + return reinterpret_cast(SubStmts[SYNC_EXPR]); } void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; } - - virtual SourceRange getSourceRange() const { - return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd()); + + virtual SourceRange getSourceRange() const { + return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd()); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAtSynchronizedStmtClass; } static bool classof(const ObjCAtSynchronizedStmt *) { return true; } - + virtual child_iterator child_begin(); virtual child_iterator child_end(); }; - + /// ObjCAtThrowStmt - This represents objective-c's @throw statement. class ObjCAtThrowStmt : public Stmt { Stmt *Throw; @@ -276,28 +276,28 @@ : Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) { AtThrowLoc = atThrowLoc; } - explicit ObjCAtThrowStmt(EmptyShell Empty) : + explicit ObjCAtThrowStmt(EmptyShell Empty) : Stmt(ObjCAtThrowStmtClass, Empty) { } - + const Expr *getThrowExpr() const { return reinterpret_cast(Throw); } Expr *getThrowExpr() { return reinterpret_cast(Throw); } void setThrowExpr(Stmt *S) { Throw = S; } - + SourceLocation getThrowLoc() { return AtThrowLoc; } void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; } - + virtual SourceRange getSourceRange() const { if (Throw) - return SourceRange(AtThrowLoc, Throw->getLocEnd()); - else + return SourceRange(AtThrowLoc, Throw->getLocEnd()); + else return SourceRange(AtThrowLoc); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAtThrowStmtClass; } static bool classof(const ObjCAtThrowStmt *) { return true; } - + virtual child_iterator child_begin(); virtual child_iterator child_end(); }; Modified: cfe/trunk/include/clang/AST/StmtVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtVisitor.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/StmtVisitor.h (original) +++ cfe/trunk/include/clang/AST/StmtVisitor.h Wed Sep 9 10:08:12 2009 @@ -20,17 +20,17 @@ #include "clang/AST/StmtObjC.h" namespace clang { - + #define DISPATCH(NAME, CLASS) \ return static_cast(this)->Visit ## NAME(static_cast(S)) - + /// StmtVisitor - This class implements a simple visitor for Stmt subclasses. /// Since Expr derives from Stmt, this also includes support for visiting Exprs. template class StmtVisitor { public: RetTy Visit(Stmt *S) { - + // If we have a binary expr, dispatch to the subcode of the binop. A smart // optimizer (e.g. LLVM) will fold this comparison into the switch stmt // below. @@ -53,7 +53,7 @@ case BinaryOperator::GE: DISPATCH(BinGE, BinaryOperator); case BinaryOperator::EQ: DISPATCH(BinEQ, BinaryOperator); case BinaryOperator::NE: DISPATCH(BinNE, BinaryOperator); - + case BinaryOperator::And: DISPATCH(BinAnd, BinaryOperator); case BinaryOperator::Xor: DISPATCH(BinXor, BinaryOperator); case BinaryOperator::Or : DISPATCH(BinOr, BinaryOperator); @@ -101,7 +101,7 @@ case UnaryOperator::OffsetOf: DISPATCH(UnaryOffsetOf, UnaryOperator); } } - + // Top switch stmt: dispatch to VisitFooStmt for each FooStmt. switch (S->getStmtClass()) { default: assert(0 && "Unknown stmt kind!"); @@ -110,7 +110,7 @@ #include "clang/AST/StmtNodes.def" } } - + // If the implementation chooses not to implement a certain visit method, fall // back on VisitExpr or whatever else is the superclass. #define STMT(CLASS, PARENT) \ @@ -127,7 +127,7 @@ BINOP_FALLBACK(Mul) BINOP_FALLBACK(Div) BINOP_FALLBACK(Rem) BINOP_FALLBACK(Add) BINOP_FALLBACK(Sub) BINOP_FALLBACK(Shl) BINOP_FALLBACK(Shr) - + BINOP_FALLBACK(LT) BINOP_FALLBACK(GT) BINOP_FALLBACK(LE) BINOP_FALLBACK(GE) BINOP_FALLBACK(EQ) BINOP_FALLBACK(NE) BINOP_FALLBACK(And) BINOP_FALLBACK(Xor) BINOP_FALLBACK(Or) @@ -148,7 +148,7 @@ CAO_FALLBACK(ShrAssign) CAO_FALLBACK(AndAssign) CAO_FALLBACK(OrAssign) CAO_FALLBACK(XorAssign) #undef CAO_FALLBACK - + // If the implementation doesn't implement unary operator methods, fall back // on VisitUnaryOperator. #define UNARYOP_FALLBACK(NAME) \ @@ -158,13 +158,13 @@ UNARYOP_FALLBACK(PostInc) UNARYOP_FALLBACK(PostDec) UNARYOP_FALLBACK(PreInc) UNARYOP_FALLBACK(PreDec) UNARYOP_FALLBACK(AddrOf) UNARYOP_FALLBACK(Deref) - + UNARYOP_FALLBACK(Plus) UNARYOP_FALLBACK(Minus) UNARYOP_FALLBACK(Not) UNARYOP_FALLBACK(LNot) UNARYOP_FALLBACK(Real) UNARYOP_FALLBACK(Imag) UNARYOP_FALLBACK(Extension) UNARYOP_FALLBACK(OffsetOf) #undef UNARYOP_FALLBACK - + // Base case, ignore it. :) RetTy VisitStmt(Stmt *Node) { return RetTy(); } }; Modified: cfe/trunk/include/clang/AST/TemplateName.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/TemplateName.h (original) +++ cfe/trunk/include/clang/AST/TemplateName.h Wed Sep 9 10:08:12 2009 @@ -61,7 +61,7 @@ /// only be understood in the context of class TemplateName { typedef llvm::PointerUnion4 StorageType; StorageType Storage; @@ -80,25 +80,25 @@ /// \brief Determine whether this template name is NULL. bool isNull() const { return Storage.isNull(); } - + /// \brief Retrieve the the underlying template declaration that /// this template name refers to, if known. /// /// \returns The template declaration that this template name refers /// to, if any. If the template name does not refer to a specific - /// declaration because it is a dependent name, or if it refers to a + /// declaration because it is a dependent name, or if it refers to a /// set of function templates, returns NULL. TemplateDecl *getAsTemplateDecl() const; - /// \brief Retrieve the the underlying, overloaded function template + /// \brief Retrieve the the underlying, overloaded function template // declarations that this template name refers to, if known. /// - /// \returns The set of overloaded function templates that this template - /// name refers to, if known. If the template name does not refer to a + /// \returns The set of overloaded function templates that this template + /// name refers to, if known. If the template name does not refer to a /// specific set of function templates because it is a dependent name or /// refers to a single template, returns NULL. OverloadedFunctionDecl *getAsOverloadedFunctionDecl() const; - + /// \brief Retrieve the underlying qualified template name /// structure, if any. QualifiedTemplateName *getAsQualifiedTemplateName() const { @@ -137,8 +137,8 @@ void *getAsVoidPointer() const { return Storage.getOpaqueValue(); } /// \brief Build a template name from a void pointer. - static TemplateName getFromVoidPointer(void *Ptr) { - return TemplateName(Ptr); + static TemplateName getFromVoidPointer(void *Ptr) { + return TemplateName(Ptr); } }; @@ -171,14 +171,14 @@ QualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) - : Qualifier(NNS, TemplateKeyword? 1 : 0), + : Qualifier(NNS, TemplateKeyword? 1 : 0), Template(reinterpret_cast(Template)) { } QualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, OverloadedFunctionDecl *Template) - : Qualifier(NNS, TemplateKeyword? 1 : 0), + : Qualifier(NNS, TemplateKeyword? 1 : 0), Template(reinterpret_cast(Template)) { } - + public: /// \brief Return the nested name specifier that qualifies this name. NestedNameSpecifier *getQualifier() const { return Qualifier.getPointer(); } @@ -190,22 +190,22 @@ /// \brief The template declaration or set of overloaded functions that /// that qualified name refers to. NamedDecl *getDecl() const { return Template; } - + /// \brief The template declaration to which this qualified name /// refers, or NULL if this qualified name refers to a set of overloaded /// function templates. TemplateDecl *getTemplateDecl() const; /// \brief The set of overloaded function tempaltes to which this qualified - /// name refers, or NULL if this qualified name refers to a single + /// name refers, or NULL if this qualified name refers to a single /// template declaration. OverloadedFunctionDecl *getOverloadedFunctionDecl() const; - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getQualifier(), hasTemplateKeyword(), getDecl()); } - static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS, + static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS, bool TemplateKeyword, NamedDecl *Template) { ID.AddPointer(NNS); ID.AddBoolean(TemplateKeyword); @@ -239,11 +239,11 @@ friend class ASTContext; - DependentTemplateName(NestedNameSpecifier *Qualifier, + DependentTemplateName(NestedNameSpecifier *Qualifier, const IdentifierInfo *Name) : Qualifier(Qualifier), Name(Name), CanonicalTemplateName(this) { } - DependentTemplateName(NestedNameSpecifier *Qualifier, + DependentTemplateName(NestedNameSpecifier *Qualifier, const IdentifierInfo *Name, TemplateName Canon) : Qualifier(Qualifier), Name(Name), CanonicalTemplateName(Canon) { } @@ -260,7 +260,7 @@ Profile(ID, getQualifier(), getName()); } - static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS, + static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS, const IdentifierInfo *Name) { ID.AddPointer(NNS); ID.AddPointer(Name); Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Wed Sep 9 10:08:12 2009 @@ -92,7 +92,7 @@ Volatile = 0x4, CVRFlags = Const|Restrict|Volatile }; - + enum GCAttrTypes { GCNone = 0, Weak, @@ -101,23 +101,23 @@ // 24 bits should be enough for anyone. static const unsigned MaxAddressSpace = 0xffffffu; - + QualType() {} - + QualType(const Type *Ptr, unsigned Quals) : Value(const_cast(Ptr), Quals) {} unsigned getCVRQualifiers() const { return Value.getInt(); } void setCVRQualifiers(unsigned Quals) { Value.setInt(Quals); } Type *getTypePtr() const { return Value.getPointer(); } - + void *getAsOpaquePtr() const { return Value.getOpaqueValue(); } static QualType getFromOpaquePtr(void *Ptr) { QualType T; T.Value.setFromOpaqueValue(Ptr); return T; } - + Type &operator*() const { return *getTypePtr(); } @@ -125,7 +125,7 @@ Type *operator->() const { return getTypePtr(); } - + /// isNull - Return true if this QualType doesn't point to a type yet. bool isNull() const { return getTypePtr() == 0; @@ -142,7 +142,7 @@ } bool isConstant(ASTContext& Ctx) const; - + /// addConst/addVolatile/addRestrict - add the specified type qual to this /// QualType. void addConst() { Value.setInt(Value.getInt() | Const); } @@ -163,12 +163,12 @@ QualType withConst() const { return getWithAdditionalQualifiers(Const); } QualType withVolatile() const { return getWithAdditionalQualifiers(Volatile);} QualType withRestrict() const { return getWithAdditionalQualifiers(Restrict);} - + QualType getUnqualifiedType() const; bool isMoreQualifiedThan(QualType Other) const; bool isAtLeastAsQualifiedAs(QualType Other) const; QualType getNonReferenceType() const; - + /// getDesugaredType - Return the specified type with any "sugar" removed from /// the type. This takes off typedefs, typeof's etc. If the outer level of /// the type is already concrete, it returns it unmodified. This is similar @@ -194,19 +194,19 @@ } void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const; - + void dump(const char *s) const; void dump() const; - + void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddPointer(getAsOpaquePtr()); } public: - + /// getAddressSpace - Return the address space of this type. inline unsigned getAddressSpace() const; - + /// GCAttrTypesAttr - Returns gc attribute of this type. inline QualType::GCAttrTypes getObjCGCAttr() const; @@ -238,7 +238,7 @@ }; template<> struct simplify_type< ::clang::QualType> : public simplify_type {}; - + // Teach SmallPtrSet that QualType is "basically a pointer". template<> class PointerLikeTypeTraits { @@ -252,7 +252,7 @@ // CVR qualifiers go in low bits. enum { NumLowBitsAvailable = 0 }; }; - + } // end namespace llvm namespace clang { @@ -316,15 +316,15 @@ virtual ~Type() {} virtual void Destroy(ASTContext& C); friend class ASTContext; - + public: TypeClass getTypeClass() const { return static_cast(TC); } - + bool isCanonical() const { return CanonicalType.getTypePtr() == this; } - /// Types are partitioned into 3 broad categories (C99 6.2.5p1): + /// Types are partitioned into 3 broad categories (C99 6.2.5p1): /// object types, function types, and incomplete types. - + /// \brief Determines whether the type describes an object in memory. /// /// Note that this definition of object type corresponds to the C++ @@ -336,7 +336,7 @@ /// isIncompleteType - Return true if this is an incomplete type. /// A type that can describe objects, but which lacks information needed to /// determine its size (e.g. void, or a fwd declared struct). Clients of this - /// routine will need to determine if the size is actually required. + /// routine will need to determine if the size is actually required. bool isIncompleteType() const; /// isIncompleteOrObjectType - Return true if this is an incomplete or object @@ -351,13 +351,13 @@ /// isVariablyModifiedType (C99 6.7.5.2p2) - Return true for variable array /// types that have a non-constant expression. This does not include "[]". bool isVariablyModifiedType() const; - + /// Helper methods to distinguish type categories. All type predicates /// operate on the canonical type, ignoring typedefs and qualifiers. /// isSpecificBuiltinType - Test for a particular builtin type. bool isSpecificBuiltinType(unsigned K) const; - + /// isIntegerType() does *not* include complex integers (a GCC extension). /// isComplexIntegerType() can be used to test for complex integers. bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum) @@ -366,7 +366,7 @@ bool isCharType() const; bool isWideCharType() const; bool isIntegralType() const; - + /// Floating point categories. bool isRealFloatingType() const; // C99 6.2.5p10 (float, double, long double) /// isComplexType() does *not* include complex integers (a GCC extension). @@ -380,7 +380,7 @@ bool isDerivedType() const; // C99 6.2.5p20 bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers) bool isAggregateType() const; - + // Type Predicates: Check to see if this type is structurally the specified // type, ignoring typedefs and qualifiers. bool isFunctionType() const; @@ -402,8 +402,8 @@ bool isVariableArrayType() const; bool isDependentSizedArrayType() const; bool isRecordType() const; - bool isClassType() const; - bool isStructureType() const; + bool isClassType() const; + bool isStructureType() const; bool isUnionType() const; bool isComplexIntegerType() const; // GCC _Complex integer type. bool isVectorType() const; // GCC vector type. @@ -422,7 +422,7 @@ bool isNullPtrType() const; // C++0x nullptr_t /// isDependentType - Whether this type is a dependent type, meaning - /// that its definition somehow depends on a template parameter + /// that its definition somehow depends on a template parameter /// (C++ [temp.dep.type]). bool isDependentType() const { return Dependent; } bool isOverloadableType() const; @@ -435,7 +435,7 @@ /// hasObjCPointerRepresentation - Whether this type can represent /// an objective pointer type for the purpose of GC'ability - bool hasObjCPointerRepresentation() const; + bool hasObjCPointerRepresentation() const; // Type Checking Functions: Check to see if this type is structurally the // specified type, ignoring typedefs and qualifiers, and return a pointer to @@ -462,14 +462,14 @@ const ObjCInterfaceType *getAsObjCQualifiedInterfaceType() const; const TemplateTypeParmType *getAsTemplateTypeParmType() const; const CXXRecordDecl *getCXXRecordDeclForPointerType() const; - + // Member-template getAs'. This scheme will eventually // replace the specific getAsXXXX methods above. template const T *getAs() const; - + const TemplateSpecializationType * getAsTemplateSpecializationType() const; - + /// getAsPointerToObjCInterfaceType - If this is a pointer to an ObjC /// interface, return the interface type, otherwise return null. const ObjCInterfaceType *getAsPointerToObjCInterfaceType() const; @@ -478,11 +478,11 @@ /// element type of the array, potentially with type qualifiers missing. /// This method should never be used when type qualifiers are meaningful. const Type *getArrayElementTypeNoTypeQual() const; - + /// getPointeeType - If this is a pointer, ObjC object pointer, or block /// pointer, this returns the respective pointee. QualType getPointeeType() const; - + /// getDesugaredType - Return the specified type with any "sugar" removed from /// the type. This takes off typedefs, typeof's etc. If the outer level of /// the type is already concrete, it returns it unmodified. This is similar @@ -490,7 +490,7 @@ /// example, it returns "T*" as "T*", (not as "int*"), because the pointer is /// concrete. QualType getDesugaredType(bool ForDisplay = false) const; - + /// More type predicates useful for type checking/promotion bool isPromotableIntegerType() const; // C99 6.3.1.1p2 @@ -517,12 +517,12 @@ QualType getCanonicalTypeInternal() const { return CanonicalType; } void dump() const; - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const = 0; static bool classof(const Type *) { return true; } }; -/// ExtQualType - TR18037 (C embedded extensions) 6.2.5p26 +/// ExtQualType - TR18037 (C embedded extensions) 6.2.5p26 /// This supports all kinds of type attributes; including, /// address space qualified types, objective-c's __weak and /// __strong attributes. @@ -537,7 +537,7 @@ unsigned AddressSpace; /// GC __weak/__strong attributes QualType::GCAttrTypes GCAttrType; - + ExtQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace, QualType::GCAttrTypes gcAttr) : Type(ExtQual, CanonicalPtr, Base->isDependentType()), BaseType(Base), @@ -551,19 +551,19 @@ QualType::GCAttrTypes getObjCGCAttr() const { return GCAttrType; } unsigned getAddressSpace() const { return AddressSpace; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getBaseType(), AddressSpace, GCAttrType); } - static void Profile(llvm::FoldingSetNodeID &ID, Type *Base, + static void Profile(llvm::FoldingSetNodeID &ID, Type *Base, unsigned AddrSpace, QualType::GCAttrTypes gcAttr) { ID.AddPointer(Base); ID.AddInteger(AddrSpace); ID.AddInteger(gcAttr); } - + static bool classof(const Type *T) { return T->getTypeClass() == ExtQual; } static bool classof(const ExtQualType *) { return true; } }; @@ -637,7 +637,7 @@ } bool operator==(QualifierSet& Other) { return Mask == Other.Mask; } - + private: void setAddressSpace(unsigned space) { assert(space <= MaxAddressSpace); @@ -668,7 +668,7 @@ public: enum Kind { Void, - + Bool, // This is bool and/or _Bool. Char_U, // This is 'char' for targets where char is unsigned. UChar, // This is explicitly qualified unsigned char. @@ -679,7 +679,7 @@ ULong, ULongLong, UInt128, // __uint128_t - + Char_S, // This is 'char' for targets where char is signed. SChar, // This is explicitly qualified signed char. WChar, // This is 'wchar_t' for C++. @@ -688,14 +688,14 @@ Long, LongLong, Int128, // __int128_t - + Float, Double, LongDouble, NullPtr, // This is the type of C++0x 'nullptr'. Overload, // This represents the type of an overloaded function declaration. Dependent, // This represents the type of a type-dependent expression. - + UndeducedAuto, // In C++0x, this represents the type of an auto variable // that has not been deduced yet. ObjCId, // This represents the ObjC 'id' type. @@ -704,16 +704,16 @@ private: Kind TypeKind; public: - BuiltinType(Kind K) - : Type(Builtin, QualType(), /*Dependent=*/(K == Dependent)), + BuiltinType(Kind K) + : Type(Builtin, QualType(), /*Dependent=*/(K == Dependent)), TypeKind(K) {} - + Kind getKind() const { return TypeKind; } const char *getName(const LangOptions &LO) const; - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + static bool classof(const Type *T) { return T->getTypeClass() == Builtin; } static bool classof(const BuiltinType *) { return true; } }; @@ -728,14 +728,14 @@ public: FixedWidthIntType(unsigned W, bool S) : Type(FixedWidthInt, QualType(), false), Width(W), Signed(S) {} - + unsigned getWidth() const { return Width; } bool isSigned() const { return Signed; } const char *getName() const; - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + static bool classof(const Type *T) { return T->getTypeClass() == FixedWidthInt; } static bool classof(const FixedWidthIntType *) { return true; } }; @@ -746,23 +746,23 @@ class ComplexType : public Type, public llvm::FoldingSetNode { QualType ElementType; ComplexType(QualType Element, QualType CanonicalPtr) : - Type(Complex, CanonicalPtr, Element->isDependentType()), + Type(Complex, CanonicalPtr, Element->isDependentType()), ElementType(Element) { } friend class ASTContext; // ASTContext creates these. public: QualType getElementType() const { return ElementType; } - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getElementType()); } static void Profile(llvm::FoldingSetNodeID &ID, QualType Element) { ID.AddPointer(Element.getAsOpaquePtr()); } - + static bool classof(const Type *T) { return T->getTypeClass() == Complex; } static bool classof(const ComplexType *) { return true; } }; @@ -777,10 +777,10 @@ } friend class ASTContext; // ASTContext creates these. public: - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + QualType getPointeeType() const { return PointeeType; } void Profile(llvm::FoldingSetNodeID &ID) { @@ -789,7 +789,7 @@ static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { ID.AddPointer(Pointee.getAsOpaquePtr()); } - + static bool classof(const Type *T) { return T->getTypeClass() == Pointer; } static bool classof(const PointerType *) { return true; } }; @@ -801,27 +801,27 @@ class BlockPointerType : public Type, public llvm::FoldingSetNode { QualType PointeeType; // Block is some kind of pointer type BlockPointerType(QualType Pointee, QualType CanonicalCls) : - Type(BlockPointer, CanonicalCls, Pointee->isDependentType()), + Type(BlockPointer, CanonicalCls, Pointee->isDependentType()), PointeeType(Pointee) { } friend class ASTContext; // ASTContext creates these. public: - + // Get the pointee type. Pointee is required to always be a function type. QualType getPointeeType() const { return PointeeType; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getPointeeType()); } static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { ID.AddPointer(Pointee.getAsOpaquePtr()); } - - static bool classof(const Type *T) { - return T->getTypeClass() == BlockPointer; + + static bool classof(const Type *T) { + return T->getTypeClass() == BlockPointer; } static bool classof(const BlockPointerType *) { return true; } }; @@ -861,7 +861,7 @@ } friend class ASTContext; // ASTContext creates these public: - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; static bool classof(const Type *T) { @@ -878,7 +878,7 @@ } friend class ASTContext; // ASTContext creates these public: - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; static bool classof(const Type *T) { @@ -907,7 +907,7 @@ const Type *getClass() const { return Class; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; void Profile(llvm::FoldingSetNodeID &ID) { @@ -939,15 +939,15 @@ private: /// ElementType - The element type of the array. QualType ElementType; - + // NOTE: VC++ treats enums as signed, avoid using the ArraySizeModifier enum /// NOTE: These fields are packed into the bitfields space in the Type class. unsigned SizeModifier : 2; - + /// IndexTypeQuals - Capture qualifiers in declarations like: /// 'int X[static restrict 4]'. For function parameters only. unsigned IndexTypeQuals : 3; - + protected: // C++ [temp.dep.type]p1: // A type is dependent if it is... @@ -966,7 +966,7 @@ return ArraySizeModifier(SizeModifier); } unsigned getIndexTypeQualifier() const { return IndexTypeQuals; } - + static bool classof(const Type *T) { return T->getTypeClass() == ConstantArray || T->getTypeClass() == ConstantArrayWithExpr || @@ -984,7 +984,7 @@ /// type is 'int' and the size is 404. class ConstantArrayType : public ArrayType { llvm::APInt Size; // Allows us to unique the type. - + ConstantArrayType(QualType et, QualType can, const llvm::APInt &size, ArraySizeModifier sm, unsigned tq) : ArrayType(ConstantArray, et, can, sm, tq), @@ -996,11 +996,11 @@ friend class ASTContext; // ASTContext creates these. public: const llvm::APInt &getSize() const { return Size; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + void Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, getElementType(), getSize(), + Profile(ID, getElementType(), getSize(), getSizeModifier(), getIndexTypeQualifier()); } static void Profile(llvm::FoldingSetNodeID &ID, QualType ET, @@ -1096,20 +1096,20 @@ : ArrayType(IncompleteArray, et, can, sm, tq) {} friend class ASTContext; // ASTContext creates these. public: - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - static bool classof(const Type *T) { - return T->getTypeClass() == IncompleteArray; + static bool classof(const Type *T) { + return T->getTypeClass() == IncompleteArray; } static bool classof(const IncompleteArrayType *) { return true; } - + friend class StmtIteratorBase; - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getElementType(), getSizeModifier(), getIndexTypeQualifier()); } - + static void Profile(llvm::FoldingSetNodeID &ID, QualType ET, ArraySizeModifier SizeMod, unsigned TypeQuals) { ID.AddPointer(ET.getAsOpaquePtr()); @@ -1134,8 +1134,8 @@ /// } /// class VariableArrayType : public ArrayType { - /// SizeExpr - An assignment expression. VLA's are only permitted within - /// a function block. + /// SizeExpr - An assignment expression. VLA's are only permitted within + /// a function block. Stmt *SizeExpr; /// Brackets - The left and right array brackets. SourceRange Brackets; @@ -1149,7 +1149,7 @@ virtual void Destroy(ASTContext& C); public: - Expr *getSizeExpr() const { + Expr *getSizeExpr() const { // We use C-style casts instead of cast<> here because we do not wish // to have a dependency of Type.h on Stmt.h/Expr.h. return (Expr*) SizeExpr; @@ -1157,17 +1157,17 @@ SourceRange getBracketsRange() const { return Brackets; } SourceLocation getLBracketLoc() const { return Brackets.getBegin(); } SourceLocation getRBracketLoc() const { return Brackets.getEnd(); } - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - - static bool classof(const Type *T) { - return T->getTypeClass() == VariableArray; + + static bool classof(const Type *T) { + return T->getTypeClass() == VariableArray; } static bool classof(const VariableArrayType *) { return true; } - + friend class StmtIteratorBase; - + void Profile(llvm::FoldingSetNodeID &ID) { assert(0 && "Cannnot unique VariableArrayTypes."); } @@ -1176,7 +1176,7 @@ /// DependentSizedArrayType - This type represents an array type in /// C++ whose size is a value-dependent expression. For example: /// @code -/// template +/// template /// class array { /// T data[Size]; /// }; @@ -1186,14 +1186,14 @@ /// become either a ConstantArrayType or a VariableArrayType. class DependentSizedArrayType : public ArrayType { ASTContext &Context; - + /// SizeExpr - An assignment expression that will instantiate to the /// size of the array. Stmt *SizeExpr; /// Brackets - The left and right array brackets. SourceRange Brackets; - - DependentSizedArrayType(ASTContext &Context, QualType et, QualType can, + + DependentSizedArrayType(ASTContext &Context, QualType et, QualType can, Expr *e, ArraySizeModifier sm, unsigned tq, SourceRange brackets) : ArrayType(DependentSizedArray, et, can, sm, tq), @@ -1202,7 +1202,7 @@ virtual void Destroy(ASTContext& C); public: - Expr *getSizeExpr() const { + Expr *getSizeExpr() const { // We use C-style casts instead of cast<> here because we do not wish // to have a dependency of Type.h on Stmt.h/Expr.h. return (Expr*) SizeExpr; @@ -1210,25 +1210,25 @@ SourceRange getBracketsRange() const { return Brackets; } SourceLocation getLBracketLoc() const { return Brackets.getBegin(); } SourceLocation getRBracketLoc() const { return Brackets.getEnd(); } - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - - static bool classof(const Type *T) { - return T->getTypeClass() == DependentSizedArray; + + static bool classof(const Type *T) { + return T->getTypeClass() == DependentSizedArray; } static bool classof(const DependentSizedArrayType *) { return true; } - + friend class StmtIteratorBase; - - + + void Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, Context, getElementType(), + Profile(ID, Context, getElementType(), getSizeModifier(), getIndexTypeQualifier(), getSizeExpr()); } - - static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, - QualType ET, ArraySizeModifier SizeMod, + + static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, + QualType ET, ArraySizeModifier SizeMod, unsigned TypeQuals, Expr *E); }; @@ -1246,11 +1246,11 @@ /// ElementType - The element type of the array. QualType ElementType; SourceLocation loc; - - DependentSizedExtVectorType(ASTContext &Context, QualType ElementType, + + DependentSizedExtVectorType(ASTContext &Context, QualType ElementType, QualType can, Expr *SizeExpr, SourceLocation loc) - : Type (DependentSizedExtVector, can, true), - Context(Context), SizeExpr(SizeExpr), ElementType(ElementType), + : Type (DependentSizedExtVector, can, true), + Context(Context), SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {} friend class ASTContext; virtual void Destroy(ASTContext& C); @@ -1260,62 +1260,62 @@ QualType getElementType() const { return ElementType; } SourceLocation getAttributeLoc() const { return loc; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - - static bool classof(const Type *T) { - return T->getTypeClass() == DependentSizedExtVector; + + static bool classof(const Type *T) { + return T->getTypeClass() == DependentSizedExtVector; } - static bool classof(const DependentSizedExtVectorType *) { return true; } + static bool classof(const DependentSizedExtVectorType *) { return true; } void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Context, getElementType(), getSizeExpr()); } - + static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, QualType ElementType, Expr *SizeExpr); }; - + /// VectorType - GCC generic vector type. This type is created using -/// __attribute__((vector_size(n)), where "n" specifies the vector size in -/// bytes. Since the constructor takes the number of vector elements, the +/// __attribute__((vector_size(n)), where "n" specifies the vector size in +/// bytes. Since the constructor takes the number of vector elements, the /// client is responsible for converting the size into the number of elements. class VectorType : public Type, public llvm::FoldingSetNode { protected: /// ElementType - The element type of the vector. QualType ElementType; - + /// NumElements - The number of elements in the vector. unsigned NumElements; - + VectorType(QualType vecType, unsigned nElements, QualType canonType) : - Type(Vector, canonType, vecType->isDependentType()), - ElementType(vecType), NumElements(nElements) {} - VectorType(TypeClass tc, QualType vecType, unsigned nElements, - QualType canonType) - : Type(tc, canonType, vecType->isDependentType()), ElementType(vecType), - NumElements(nElements) {} + Type(Vector, canonType, vecType->isDependentType()), + ElementType(vecType), NumElements(nElements) {} + VectorType(TypeClass tc, QualType vecType, unsigned nElements, + QualType canonType) + : Type(tc, canonType, vecType->isDependentType()), ElementType(vecType), + NumElements(nElements) {} friend class ASTContext; // ASTContext creates these. public: - + QualType getElementType() const { return ElementType; } - unsigned getNumElements() const { return NumElements; } + unsigned getNumElements() const { return NumElements; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getElementType(), getNumElements(), getTypeClass()); } - static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType, + static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType, unsigned NumElements, TypeClass TypeClass) { ID.AddPointer(ElementType.getAsOpaquePtr()); ID.AddInteger(NumElements); ID.AddInteger(TypeClass); } - static bool classof(const Type *T) { - return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector; + static bool classof(const Type *T) { + return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector; } static bool classof(const VectorType *) { return true; } }; @@ -1327,7 +1327,7 @@ /// points, colors, and textures (modeled after OpenGL Shading Language). class ExtVectorType : public VectorType { ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) : - VectorType(ExtVector, vecType, nElements, canonType) {} + VectorType(ExtVector, vecType, nElements, canonType) {} friend class ASTContext; // ASTContext creates these. public: static int getPointAccessorIdx(char c) { @@ -1366,22 +1366,22 @@ case 'f': return 15; } } - + static int getAccessorIdx(char c) { if (int idx = getPointAccessorIdx(c)+1) return idx-1; return getNumericAccessorIdx(c); } - + bool isAccessorWithinNumElements(char c) const { if (int idx = getAccessorIdx(c)+1) return unsigned(idx-1) < NumElements; return false; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - static bool classof(const Type *T) { - return T->getTypeClass() == ExtVector; + static bool classof(const Type *T) { + return T->getTypeClass() == ExtVector; } static bool classof(const ExtVectorType *) { return true; } }; @@ -1405,7 +1405,7 @@ /// NoReturn - Indicates if the function type is attribute noreturn. unsigned NoReturn : 1; - + // The type returned by the function. QualType ResultType; protected: @@ -1418,11 +1418,11 @@ bool getSubClassData() const { return SubClassData; } unsigned getTypeQuals() const { return TypeQuals; } public: - + QualType getResultType() const { return ResultType; } bool getNoReturnAttr() const { return NoReturn; } - + static bool classof(const Type *T) { return T->getTypeClass() == FunctionNoProto || T->getTypeClass() == FunctionProto; @@ -1435,13 +1435,13 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { FunctionNoProtoType(QualType Result, QualType Canonical, bool NoReturn = false) - : FunctionType(FunctionNoProto, Result, false, 0, Canonical, + : FunctionType(FunctionNoProto, Result, false, 0, Canonical, /*Dependent=*/false, NoReturn) {} friend class ASTContext; // ASTContext creates these. public: // No additional state past what FunctionType provides. - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; void Profile(llvm::FoldingSetNodeID &ID) { @@ -1452,7 +1452,7 @@ ID.AddInteger(NoReturn); ID.AddPointer(ResultType.getAsOpaquePtr()); } - + static bool classof(const Type *T) { return T->getTypeClass() == FunctionNoProto; } @@ -1480,7 +1480,7 @@ bool hasAnyExs, const QualType *ExArray, unsigned numExs, QualType Canonical, bool NoReturn) : FunctionType(FunctionProto, Result, isVariadic, typeQuals, Canonical, - (Result->isDependentType() || + (Result->isDependentType() || hasAnyDependentType(ArgArray, numArgs)), NoReturn), NumArgs(numArgs), NumExceptions(numExs), HasExceptionSpec(hasExs), AnyExceptionSpec(hasAnyExs) { @@ -1528,14 +1528,14 @@ assert(i < NumExceptions && "Invalid exception number!"); return exception_begin()[i]; } - bool hasEmptyExceptionSpec() const { - return hasExceptionSpec() && !hasAnyExceptionSpec() && + bool hasEmptyExceptionSpec() const { + return hasExceptionSpec() && !hasAnyExceptionSpec() && getNumExceptions() == 0; } bool isVariadic() const { return getSubClassData(); } unsigned getTypeQuals() const { return FunctionType::getTypeQuals(); } - + typedef const QualType *arg_type_iterator; arg_type_iterator arg_type_begin() const { return reinterpret_cast(this+1); @@ -1551,7 +1551,7 @@ return exception_begin() + NumExceptions; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; static bool classof(const Type *T) { @@ -1572,15 +1572,15 @@ class TypedefType : public Type { TypedefDecl *Decl; protected: - TypedefType(TypeClass tc, TypedefDecl *D, QualType can) + TypedefType(TypeClass tc, TypedefDecl *D, QualType can) : Type(tc, can, can->isDependentType()), Decl(D) { assert(!isa(can) && "Invalid canonical type"); } friend class ASTContext; // ASTContext creates these. public: - + TypedefDecl *getDecl() const { return Decl; } - + /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to /// potentially looking through *all* consecutive typedefs. This returns the /// sum of the type qualifiers, so if you have: @@ -1588,8 +1588,8 @@ /// typedef volatile A B; /// looking through the typedefs for B will give you "const volatile A". QualType LookThroughTypedefs() const; - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; static bool classof(const Type *T) { return T->getTypeClass() == Typedef; } @@ -1599,50 +1599,50 @@ /// TypeOfExprType (GCC extension). class TypeOfExprType : public Type { Expr *TOExpr; - + protected: TypeOfExprType(Expr *E, QualType can = QualType()); friend class ASTContext; // ASTContext creates these. public: Expr *getUnderlyingExpr() const { return TOExpr; } - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExpr; } static bool classof(const TypeOfExprType *) { return true; } }; -/// Subclass of TypeOfExprType that is used for canonical, dependent -/// typeof(expr) types. -class DependentTypeOfExprType +/// Subclass of TypeOfExprType that is used for canonical, dependent +/// typeof(expr) types. +class DependentTypeOfExprType : public TypeOfExprType, public llvm::FoldingSetNode { ASTContext &Context; - + public: - DependentTypeOfExprType(ASTContext &Context, Expr *E) + DependentTypeOfExprType(ASTContext &Context, Expr *E) : TypeOfExprType(E), Context(Context) { } - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Context, getUnderlyingExpr()); } - + static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, Expr *E); }; - + /// TypeOfType (GCC extension). class TypeOfType : public Type { QualType TOType; - TypeOfType(QualType T, QualType can) + TypeOfType(QualType T, QualType can) : Type(TypeOf, can, T->isDependentType()), TOType(T) { assert(!isa(can) && "Invalid canonical type"); } friend class ASTContext; // ASTContext creates these. public: QualType getUnderlyingType() const { return TOType; } - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; static bool classof(const Type *T) { return T->getTypeClass() == TypeOf; } @@ -1652,12 +1652,12 @@ /// DecltypeType (C++0x) class DecltypeType : public Type { Expr *E; - + // FIXME: We could get rid of UnderlyingType if we wanted to: We would have to // Move getDesugaredType to ASTContext so that it can call getDecltypeForExpr // from it. QualType UnderlyingType; - + protected: DecltypeType(Expr *E, QualType underlyingType, QualType can = QualType()); friend class ASTContext; // ASTContext creates these. @@ -1665,29 +1665,29 @@ Expr *getUnderlyingExpr() const { return E; } QualType getUnderlyingType() const { return UnderlyingType; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + static bool classof(const Type *T) { return T->getTypeClass() == Decltype; } static bool classof(const DecltypeType *) { return true; } }; - -/// Subclass of DecltypeType that is used for canonical, dependent -/// C++0x decltype types. + +/// Subclass of DecltypeType that is used for canonical, dependent +/// C++0x decltype types. class DependentDecltypeType : public DecltypeType, public llvm::FoldingSetNode { ASTContext &Context; - + public: DependentDecltypeType(ASTContext &Context, Expr *E); - + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Context, getUnderlyingExpr()); } - + static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, - Expr *E); + Expr *E); }; - + class TagType : public Type { /// Stores the TagDecl associated with this type. The decl will /// point to the TagDecl that actually defines the entity (or is a @@ -1701,18 +1701,18 @@ protected: TagType(TypeClass TC, TagDecl *D, QualType can); -public: +public: TagDecl *getDecl() const { return decl.getPointer(); } - + /// @brief Determines whether this type is in the process of being - /// defined. + /// defined. bool isBeingDefined() const { return decl.getInt(); } void setBeingDefined(bool Def) { decl.setInt(Def? 1 : 0); } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - static bool classof(const Type *T) { + static bool classof(const Type *T) { return T->getTypeClass() >= TagFirst && T->getTypeClass() <= TagLast; } static bool classof(const TagType *) { return true; } @@ -1730,20 +1730,20 @@ : TagType(TC, reinterpret_cast(D), QualType()) { } friend class ASTContext; // ASTContext creates these. public: - + RecordDecl *getDecl() const { return reinterpret_cast(TagType::getDecl()); } - - // FIXME: This predicate is a helper to QualType/Type. It needs to + + // FIXME: This predicate is a helper to QualType/Type. It needs to // recursively check all fields for const-ness. If any field is declared - // const, it needs to return false. + // const, it needs to return false. bool hasConstFields() const { return false; } // FIXME: RecordType needs to check when it is created that all fields are in // the same address space, and return that. unsigned getAddressSpace() const { return 0; } - + static bool classof(const TagType *T); static bool classof(const Type *T) { return isa(T) && classof(cast(T)); @@ -1758,11 +1758,11 @@ : TagType(Enum, reinterpret_cast(D), QualType()) { } friend class ASTContext; // ASTContext creates these. public: - + EnumDecl *getDecl() const { return reinterpret_cast(TagType::getDecl()); } - + static bool classof(const TagType *T); static bool classof(const Type *T) { return isa(T) && classof(cast(T)); @@ -1814,7 +1814,7 @@ } } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; void Profile(llvm::FoldingSetNodeID &ID) { @@ -1835,12 +1835,12 @@ unsigned ParameterPack : 1; IdentifierInfo *Name; - TemplateTypeParmType(unsigned D, unsigned I, bool PP, IdentifierInfo *N, - QualType Canon) + TemplateTypeParmType(unsigned D, unsigned I, bool PP, IdentifierInfo *N, + QualType Canon) : Type(TemplateTypeParm, Canon, /*Dependent=*/true), Depth(D), Index(I), ParameterPack(PP), Name(N) { } - TemplateTypeParmType(unsigned D, unsigned I, bool PP) + TemplateTypeParmType(unsigned D, unsigned I, bool PP) : Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true), Depth(D), Index(I), ParameterPack(PP), Name(0) { } @@ -1851,16 +1851,16 @@ unsigned getIndex() const { return Index; } bool isParameterPack() const { return ParameterPack; } IdentifierInfo *getName() const { return Name; } - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Depth, Index, ParameterPack, Name); } - static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth, - unsigned Index, bool ParameterPack, + static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth, + unsigned Index, bool ParameterPack, IdentifierInfo *Name) { ID.AddInteger(Depth); ID.AddInteger(Index); @@ -1868,8 +1868,8 @@ ID.AddPointer(Name); } - static bool classof(const Type *T) { - return T->getTypeClass() == TemplateTypeParm; + static bool classof(const Type *T) { + return T->getTypeClass() == TemplateTypeParm; } static bool classof(const TemplateTypeParmType *T) { return true; } }; @@ -1883,18 +1883,18 @@ /// type will point to some other type node that represents the /// instantiation or class template specialization. For example, a /// class template specialization type of @c vector will refer to -/// a tag type for the instantiation +/// a tag type for the instantiation /// @c std::vector>. /// /// Other template specialization types, for which the template name /// is dependent, may be canonical types. These types are always /// dependent. -class TemplateSpecializationType +class TemplateSpecializationType : public Type, public llvm::FoldingSetNode { // FIXME: Currently needed for profiling expressions; can we avoid this? ASTContext &Context; - + /// \brief The name of the template being specialized. TemplateName Template; @@ -1915,7 +1915,7 @@ /// \brief Determine whether any of the given template arguments are /// dependent. static bool anyDependentTemplateArguments(const TemplateArgument *Args, - unsigned NumArgs); + unsigned NumArgs); /// \brief Print a template argument list, including the '<' and '>' /// enclosing the template arguments. @@ -1932,7 +1932,7 @@ TemplateName getTemplateName() const { return Template; } /// \brief Retrieve the template arguments. - const TemplateArgument *getArgs() const { + const TemplateArgument *getArgs() const { return reinterpret_cast(this + 1); } @@ -1943,7 +1943,7 @@ /// \precondition @c isArgType(Arg) const TemplateArgument &getArg(unsigned Idx) const; - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; void Profile(llvm::FoldingSetNodeID &ID) { @@ -1954,8 +1954,8 @@ const TemplateArgument *Args, unsigned NumArgs, ASTContext &Context); - static bool classof(const Type *T) { - return T->getTypeClass() == TemplateSpecialization; + static bool classof(const Type *T) { + return T->getTypeClass() == TemplateSpecialization; } static bool classof(const TemplateSpecializationType *T) { return true; } }; @@ -1988,7 +1988,7 @@ /// \brief Retrieve the type named by the qualified-id. QualType getNamedType() const { return NamedType; } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; void Profile(llvm::FoldingSetNodeID &ID) { @@ -2001,8 +2001,8 @@ NamedType.Profile(ID); } - static bool classof(const Type *T) { - return T->getTypeClass() == QualifiedName; + static bool classof(const Type *T) { + return T->getTypeClass() == QualifiedName; } static bool classof(const QualifiedNameType *T) { return true; } }; @@ -2023,7 +2023,7 @@ /// \brief The nested name specifier containing the qualifier. NestedNameSpecifier *NNS; - typedef llvm::PointerUnion NameType; /// \brief The type that this typename specifier refers to. @@ -2031,15 +2031,15 @@ TypenameType(NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType CanonType) - : Type(Typename, CanonType, true), NNS(NNS), Name(Name) { - assert(NNS->isDependent() && + : Type(Typename, CanonType, true), NNS(NNS), Name(Name) { + assert(NNS->isDependent() && "TypenameType requires a dependent nested-name-specifier"); } TypenameType(NestedNameSpecifier *NNS, const TemplateSpecializationType *Ty, QualType CanonType) - : Type(Typename, CanonType, true), NNS(NNS), Name(Ty) { - assert(NNS->isDependent() && + : Type(Typename, CanonType, true), NNS(NNS), Name(Ty) { + assert(NNS->isDependent() && "TypenameType requires a dependent nested-name-specifier"); } @@ -2055,8 +2055,8 @@ /// This routine will return a non-NULL identifier pointer when the /// form of the original typename was terminated by an identifier, /// e.g., "typename T::type". - const IdentifierInfo *getIdentifier() const { - return Name.dyn_cast(); + const IdentifierInfo *getIdentifier() const { + return Name.dyn_cast(); } /// \brief Retrieve the type named by the typename specifier as a @@ -2065,7 +2065,7 @@ return Name.dyn_cast(); } - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; void Profile(llvm::FoldingSetNodeID &ID) { @@ -2078,8 +2078,8 @@ ID.AddPointer(Name.getOpaqueValue()); } - static bool classof(const Type *T) { - return T->getTypeClass() == Typename; + static bool classof(const Type *T) { + return T->getTypeClass() == Typename; } static bool classof(const TypenameType *T) { return true; } }; @@ -2097,13 +2097,13 @@ llvm::SmallVector Protocols; ObjCInterfaceType(ObjCInterfaceDecl *D, - ObjCProtocolDecl **Protos, unsigned NumP) : - Type(ObjCInterface, QualType(), /*Dependent=*/false), + ObjCProtocolDecl **Protos, unsigned NumP) : + Type(ObjCInterface, QualType(), /*Dependent=*/false), Decl(D), Protocols(Protos, Protos+NumP) { } friend class ASTContext; // ASTContext creates these. public: ObjCInterfaceDecl *getDecl() const { return Decl; } - + /// getNumProtocols - Return the number of qualifying protocols in this /// interface type, or 0 if there are none. unsigned getNumProtocols() const { return Protocols.size(); } @@ -2114,17 +2114,17 @@ qual_iterator qual_begin() const { return Protocols.begin(); } qual_iterator qual_end() const { return Protocols.end(); } bool qual_empty() const { return Protocols.size() == 0; } - - virtual void getAsStringInternal(std::string &InnerString, + + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - + void Profile(llvm::FoldingSetNodeID &ID); - static void Profile(llvm::FoldingSetNodeID &ID, + static void Profile(llvm::FoldingSetNodeID &ID, const ObjCInterfaceDecl *Decl, ObjCProtocolDecl **protocols, unsigned NumProtocols); - - static bool classof(const Type *T) { - return T->getTypeClass() == ObjCInterface; + + static bool classof(const Type *T) { + return T->getTypeClass() == ObjCInterface; } static bool classof(const ObjCInterfaceType *) { return true; } }; @@ -2136,7 +2136,7 @@ /// alphabetical order. class ObjCObjectPointerType : public Type, public llvm::FoldingSetNode { QualType PointeeType; // A builtin or interface type. - + // List of protocols for this protocol conforming object type // List is sorted on protocol name. No protocol is entered more than once. llvm::SmallVector Protocols; @@ -2145,7 +2145,7 @@ Type(ObjCObjectPointer, QualType(), /*Dependent=*/false), PointeeType(T), Protocols(Protos, Protos+NumP) { } friend class ASTContext; // ASTContext creates these. - + public: // Get the pointee type. Pointee will either be: // - a built-in type (for 'id' and 'Class'). @@ -2154,8 +2154,8 @@ // For example: typedef NSObject T; T *var; QualType getPointeeType() const { return PointeeType; } - const ObjCInterfaceType *getInterfaceType() const { - return PointeeType->getAsObjCInterfaceType(); + const ObjCInterfaceType *getInterfaceType() const { + return PointeeType->getAsObjCInterfaceType(); } /// getInterfaceDecl - returns an interface decl for user-defined types. ObjCInterfaceDecl *getInterfaceDecl() const { @@ -2163,22 +2163,22 @@ } /// isObjCIdType - true for "id". bool isObjCIdType() const { - return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) && + return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) && !Protocols.size(); } /// isObjCClassType - true for "Class". bool isObjCClassType() const { - return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) && + return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) && !Protocols.size(); } /// isObjCQualifiedIdType - true for "id

". - bool isObjCQualifiedIdType() const { - return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) && - Protocols.size(); + bool isObjCQualifiedIdType() const { + return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) && + Protocols.size(); } /// isObjCQualifiedClassType - true for "Class

". bool isObjCQualifiedClassType() const { - return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) && + return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) && Protocols.size(); } /// qual_iterator and friends: this provides access to the (potentially empty) @@ -2196,10 +2196,10 @@ void Profile(llvm::FoldingSetNodeID &ID); static void Profile(llvm::FoldingSetNodeID &ID, QualType T, ObjCProtocolDecl **protocols, unsigned NumProtocols); - virtual void getAsStringInternal(std::string &InnerString, + virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const; - static bool classof(const Type *T) { - return T->getTypeClass() == ObjCObjectPointer; + static bool classof(const Type *T) { + return T->getTypeClass() == ObjCObjectPointer; } static bool classof(const ObjCObjectPointerType *) { return true; } }; @@ -2234,10 +2234,10 @@ if (const ExtQualType *EXTQT = dyn_cast(CT)) return EXTQT->getObjCGCAttr(); if (const ObjCObjectPointerType *PT = CT->getAsObjCObjectPointerType()) - return PT->getPointeeType().getObjCGCAttr(); + return PT->getPointeeType().getObjCGCAttr(); // We most look at all pointer types, not just pointer to interface types. if (const PointerType *PT = CT->getAs()) - return PT->getPointeeType().getObjCGCAttr(); + return PT->getPointeeType().getObjCGCAttr(); return GCNone; } @@ -2253,7 +2253,7 @@ return false; } - + /// isMoreQualifiedThan - Determine whether this type is more /// qualified than the Other type. For example, "const volatile int" /// is more qualified than "const int", "volatile int", and @@ -2303,20 +2303,20 @@ return PT->getPointeeType()->getAsObjCInterfaceType(); return 0; } - + // NOTE: All of these methods use "getUnqualifiedType" to strip off address // space qualifiers if present. inline bool Type::isFunctionType() const { return isa(CanonicalType.getUnqualifiedType()); } inline bool Type::isPointerType() const { - return isa(CanonicalType.getUnqualifiedType()); + return isa(CanonicalType.getUnqualifiedType()); } inline bool Type::isAnyPointerType() const { return isPointerType() || isObjCObjectPointerType(); } inline bool Type::isBlockPointerType() const { - return isa(CanonicalType.getUnqualifiedType()); + return isa(CanonicalType.getUnqualifiedType()); } inline bool Type::isReferenceType() const { return isa(CanonicalType.getUnqualifiedType()); @@ -2417,12 +2417,12 @@ inline bool Type::hasPointerRepresentation() const { return (isPointerType() || isReferenceType() || isBlockPointerType() || - isObjCInterfaceType() || isObjCObjectPointerType() || + isObjCInterfaceType() || isObjCObjectPointerType() || isObjCQualifiedInterfaceType() || isNullPtrType()); } inline bool Type::hasObjCPointerRepresentation() const { - return (isObjCInterfaceType() || isObjCObjectPointerType() || + return (isObjCInterfaceType() || isObjCObjectPointerType() || isObjCQualifiedInterfaceType()); } @@ -2434,13 +2434,13 @@ Diagnostic::ak_qualtype); return DB; } - + /// Member-template getAs'. template const T *Type::getAs() const { // If this is directly a T type, return it. if (const T *Ty = dyn_cast(this)) return Ty; - + // If the canonical form of this type isn't the right kind, reject it. if (!isa(CanonicalType)) { // Look through type qualifiers @@ -2448,11 +2448,11 @@ return CanonicalType.getUnqualifiedType()->getAs(); return 0; } - + // If this is a typedef for a pointer type, strip the typedef off without // losing all typedef information. return cast(getDesugaredType()); -} +} } // end namespace clang Modified: cfe/trunk/include/clang/AST/TypeLoc.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/TypeLoc.h (original) +++ cfe/trunk/include/clang/AST/TypeLoc.h Wed Sep 9 10:08:12 2009 @@ -30,7 +30,7 @@ protected: QualType Ty; void *Data; - + TypeLoc(QualType ty, void *data) : Ty(ty), Data(data) { } static TypeLoc Create(QualType ty, void *data) { return TypeLoc(ty,data); } friend class DeclaratorInfo; @@ -86,7 +86,7 @@ class DeclaratorLoc : public TypeLoc { public: /// \brief Find the TypeSpecLoc that is part of this DeclaratorLoc. - TypeSpecLoc getTypeSpecLoc() const; + TypeSpecLoc getTypeSpecLoc() const; static bool classof(const TypeLoc *TL); static bool classof(const DeclaratorLoc *TL) { return true; } @@ -98,7 +98,7 @@ struct Info { SourceLocation StartLoc; }; - + public: SourceLocation getStartLoc() const { return static_cast(Data)->StartLoc; @@ -137,7 +137,7 @@ SourceRange getSourceRange() const { return SourceRange(getNameLoc(), getNameLoc()); } - + /// \brief Returns the size of the type source info data block that is /// specific to this type. unsigned getLocalDataSize() const { return sizeof(Info); } @@ -445,7 +445,7 @@ #define TYPELOC(CLASS, PARENT, TYPE) \ RetTy Visit##TYPE(TYPE *) { \ return Impl->Visit##CLASS(reinterpret_cast(TyLoc)); \ - } + } #include "clang/AST/TypeLocNodes.def" }; Modified: cfe/trunk/include/clang/AST/TypeOrdering.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeOrdering.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/TypeOrdering.h (original) +++ cfe/trunk/include/clang/AST/TypeOrdering.h Wed Sep 9 10:08:12 2009 @@ -37,7 +37,7 @@ template<> struct DenseMapInfo { static inline clang::QualType getEmptyKey() { return clang::QualType(); } - static inline clang::QualType getTombstoneKey() { + static inline clang::QualType getTombstoneKey() { using clang::QualType; return QualType::getFromOpaquePtr(reinterpret_cast(-1)); } @@ -51,11 +51,11 @@ return LHS == RHS; } - static bool isPod() { + static bool isPod() { // QualType isn't *technically* a POD type. However, we can get // away with calling it a POD type since its copy constructor, // copy assignment operator, and destructor are all trivial. - return true; + return true; } }; } Modified: cfe/trunk/include/clang/AST/TypeVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeVisitor.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/TypeVisitor.h (original) +++ cfe/trunk/include/clang/AST/TypeVisitor.h Wed Sep 9 10:08:12 2009 @@ -17,10 +17,10 @@ #include "clang/AST/Type.h" namespace clang { - + #define DISPATCH(CLASS) \ return static_cast(this)->Visit ## CLASS(static_cast(T)) - + template class TypeVisitor { public: @@ -28,12 +28,12 @@ // Top switch stmt: dispatch to VisitFooStmt for each FooStmt. switch (T->getTypeClass()) { default: assert(0 && "Unknown type class!"); -#define ABSTRACT_TYPE(CLASS, PARENT) +#define ABSTRACT_TYPE(CLASS, PARENT) #define TYPE(CLASS, PARENT) case Type::CLASS: DISPATCH(CLASS##Type); #include "clang/AST/TypeNodes.def" } } - + // If the implementation chooses not to implement a certain visit method, fall // back on superclass. #define TYPE(CLASS, PARENT) RetTy Visit##CLASS##Type(CLASS##Type *T) { \ Modified: cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h Wed Sep 9 10:08:12 2009 @@ -23,7 +23,7 @@ class Stmt; class DeclRefExpr; class SourceManager; - + struct LiveVariables_ValueTypes { struct ObserverTy; @@ -35,77 +35,77 @@ // (so that we don't explore such expressions twice). We also want // to compute liveness information for block-level expressions, since these // act as "temporary" values. - + struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy { ObserverTy* Observer; ValTy AlwaysLive; - + AnalysisDataTy() : Observer(NULL) {} }; - + //===-----------------------------------------------------===// // ObserverTy - Observer for uninitialized values queries. //===-----------------------------------------------------===// struct ObserverTy { virtual ~ObserverTy() {} - + /// ObserveStmt - A callback invoked right before invoking the /// liveness transfer function on the given statement. - virtual void ObserveStmt(Stmt* S, const AnalysisDataTy& AD, + virtual void ObserveStmt(Stmt* S, const AnalysisDataTy& AD, const ValTy& V) {} - + virtual void ObserverKill(DeclRefExpr* DR) {} }; }; class LiveVariables : public DataflowValues { - - + + public: typedef LiveVariables_ValueTypes::ObserverTy ObserverTy; - + LiveVariables(ASTContext& Ctx, CFG& cfg); - + /// IsLive - Return true if a variable is live at beginning of a /// specified block. bool isLive(const CFGBlock* B, const VarDecl* D) const; - + /// IsLive - Returns true if a variable is live at the beginning of the /// the statement. This query only works if liveness information /// has been recorded at the statement level (see runOnAllBlocks), and /// only returns liveness information for block-level expressions. bool isLive(const Stmt* S, const VarDecl* D) const; - + /// IsLive - Returns true the block-level expression "value" is live /// before the given block-level expression (see runOnAllBlocks). bool isLive(const Stmt* Loc, const Stmt* StmtVal) const; - + /// IsLive - Return true if a variable is live according to the /// provided livness bitvector. bool isLive(const ValTy& V, const VarDecl* D) const; - + /// dumpLiveness - Print to stderr the liveness information encoded /// by a specified bitvector. void dumpLiveness(const ValTy& V, SourceManager& M) const; - + /// dumpBlockLiveness - Print to stderr the liveness information /// associated with each basic block. void dumpBlockLiveness(SourceManager& M) const; - + /// getNumDecls - Return the number of variables (declarations) that /// whose liveness status is being tracked by the dataflow /// analysis. unsigned getNumDecls() const { return getAnalysisData().getNumDecls(); } - + /// IntializeValues - This routine can perform extra initialization, but /// for LiveVariables this does nothing since all that logic is in - /// the constructor. + /// the constructor. void InitializeValues(const CFG& cfg) {} - + void runOnCFG(CFG& cfg); - + /// runOnAllBlocks - Propagate the dataflow values once for each block, /// starting from the current dataflow values. 'recordStmtValues' indicates /// whether the method should store dataflow values per each individual Modified: cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h Wed Sep 9 10:08:12 2009 @@ -24,7 +24,7 @@ class Expr; class DeclRefExpr; class VarDecl; - + /// UninitializedValues_ValueTypes - Utility class to wrap type declarations /// for dataflow values and dataflow analysis state for the /// Unitialized Values analysis. @@ -32,39 +32,39 @@ public: struct ObserverTy; - - struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy { + + struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy { AnalysisDataTy() : Observer(NULL), FullUninitTaint(true) {} virtual ~AnalysisDataTy() {}; - + ObserverTy* Observer; bool FullUninitTaint; }; - + typedef StmtDeclBitVector_Types::ValTy ValTy; - + //===--------------------------------------------------------------------===// // ObserverTy - Observer for querying DeclRefExprs that use an uninitalized // value. //===--------------------------------------------------------------------===// - + struct ObserverTy { virtual ~ObserverTy(); - virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD, + virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD, DeclRefExpr* DR, VarDecl* VD) = 0; - }; + }; }; /// UninitializedValues - Objects of this class encapsulate dataflow analysis /// information regarding what variable declarations in a function are /// potentially unintialized. -class UninitializedValues : - public DataflowValues { +class UninitializedValues : + public DataflowValues { public: typedef UninitializedValues_ValueTypes::ObserverTy ObserverTy; UninitializedValues(CFG &cfg) { getAnalysisData().setCFG(cfg); } - + /// IntializeValues - Create initial dataflow values and meta data for /// a given CFG. This is intended to be called by the dataflow solver. void InitializeValues(const CFG& cfg); Modified: cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h (original) +++ cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h Wed Sep 9 10:08:12 2009 @@ -13,7 +13,7 @@ #include "clang/Basic/Diagnostic.h" namespace clang { - namespace diag { + namespace diag { enum { #define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define ANALYSISSTART Modified: cfe/trunk/include/clang/Analysis/CFG.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/CFG.h (original) +++ cfe/trunk/include/clang/Analysis/CFG.h Wed Sep 9 10:08:12 2009 @@ -65,27 +65,27 @@ /// statements in the block. When this variable is non-NULL, it is /// either an instance of LabelStmt or SwitchCase. Stmt *Label; - + /// Terminator - The terminator for a basic block that /// indicates the type of control-flow that occurs between a block /// and its successors. Stmt *Terminator; - + /// LoopTarget - Some blocks are used to represent the "loop edge" to /// the start of a loop from within the loop body. This Stmt* will be /// refer to the loop statement for such blocks (and be null otherwise). - const Stmt *LoopTarget; - + const Stmt *LoopTarget; + /// BlockID - A numerical ID assigned to a CFGBlock during construction /// of the CFG. unsigned BlockID; - + /// Predecessors/Successors - Keep track of the predecessor / successor /// CFG blocks. typedef std::vector AdjacentBlocks; AdjacentBlocks Preds; AdjacentBlocks Succs; - + public: explicit CFGBlock(unsigned blockid) : Label(NULL), Terminator(NULL), LoopTarget(NULL), BlockID(blockid) {} @@ -96,25 +96,25 @@ typedef StatementListTy::const_iterator const_iterator; typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; - + Stmt* front() const { return Stmts.front(); } Stmt* back() const { return Stmts.back(); } - + iterator begin() { return Stmts.begin(); } iterator end() { return Stmts.end(); } const_iterator begin() const { return Stmts.begin(); } - const_iterator end() const { return Stmts.end(); } + const_iterator end() const { return Stmts.end(); } reverse_iterator rbegin() { return Stmts.rbegin(); } reverse_iterator rend() { return Stmts.rend(); } const_reverse_iterator rbegin() const { return Stmts.rbegin(); } const_reverse_iterator rend() const { return Stmts.rend(); } - + unsigned size() const { return Stmts.size(); } bool empty() const { return Stmts.empty(); } Stmt* operator[](size_t i) const { assert (i < size()); return Stmts[i]; } - + // CFG iterators typedef AdjacentBlocks::iterator pred_iterator; typedef AdjacentBlocks::const_iterator const_pred_iterator; @@ -125,22 +125,22 @@ typedef AdjacentBlocks::const_iterator const_succ_iterator; typedef AdjacentBlocks::reverse_iterator succ_reverse_iterator; typedef AdjacentBlocks::const_reverse_iterator const_succ_reverse_iterator; - + pred_iterator pred_begin() { return Preds.begin(); } pred_iterator pred_end() { return Preds.end(); } const_pred_iterator pred_begin() const { return Preds.begin(); } const_pred_iterator pred_end() const { return Preds.end(); } - + pred_reverse_iterator pred_rbegin() { return Preds.rbegin(); } - pred_reverse_iterator pred_rend() { return Preds.rend(); } + pred_reverse_iterator pred_rend() { return Preds.rend(); } const_pred_reverse_iterator pred_rbegin() const { return Preds.rbegin(); } const_pred_reverse_iterator pred_rend() const { return Preds.rend(); } - succ_iterator succ_begin() { return Succs.begin(); } + succ_iterator succ_begin() { return Succs.begin(); } succ_iterator succ_end() { return Succs.end(); } const_succ_iterator succ_begin() const { return Succs.begin(); } - const_succ_iterator succ_end() const { return Succs.end(); } - + const_succ_iterator succ_end() const { return Succs.end(); } + succ_reverse_iterator succ_rbegin() { return Succs.rbegin(); } succ_reverse_iterator succ_rend() { return Succs.rend(); } const_succ_reverse_iterator succ_rbegin() const { return Succs.rbegin(); } @@ -151,9 +151,9 @@ unsigned pred_size() const { return Preds.size(); } bool pred_empty() const { return Preds.empty(); } - + // Manipulation of block contents - + void appendStmt(Stmt* Statement) { Stmts.push_back(Statement); } void setTerminator(Stmt* Statement) { Terminator = Statement; } void setLabel(Stmt* Statement) { Label = Statement; } @@ -161,35 +161,35 @@ Stmt* getTerminator() { return Terminator; } const Stmt* getTerminator() const { return Terminator; } - + Stmt* getTerminatorCondition(); - + const Stmt* getTerminatorCondition() const { return const_cast(this)->getTerminatorCondition(); } - + const Stmt *getLoopTarget() const { return LoopTarget; } - + bool hasBinaryBranchTerminator() const; - + Stmt* getLabel() { return Label; } const Stmt* getLabel() const { return Label; } - + void reverseStmts(); - + void addSuccessor(CFGBlock* Block) { if (Block) Block->Preds.push_back(this); Succs.push_back(Block); } - + unsigned getBlockID() const { return BlockID; } - + void dump(const CFG *cfg, const LangOptions &LO) const; void print(llvm::raw_ostream &OS, const CFG* cfg, const LangOptions &LO) const; void printTerminator(llvm::raw_ostream &OS, const LangOptions &LO) const; }; - + /// CFG - Represents a source-level, intra-procedural CFG that represents the /// control-flow of a Stmt. The Stmt can represent an entire function body, @@ -205,28 +205,28 @@ //===--------------------------------------------------------------------===// /// buildCFG - Builds a CFG from an AST. The responsibility to free the - /// constructed CFG belongs to the caller. - static CFG* buildCFG(Stmt* AST, ASTContext *C); - + /// constructed CFG belongs to the caller. + static CFG* buildCFG(Stmt* AST, ASTContext *C); + /// createBlock - Create a new block in the CFG. The CFG owns the block; /// the caller should not directly free it. CFGBlock* createBlock(); - + /// setEntry - Set the entry block of the CFG. This is typically used /// only during CFG construction. Most CFG clients expect that the /// entry block has no predecessors and contains no statements. void setEntry(CFGBlock *B) { Entry = B; } - + /// setIndirectGotoBlock - Set the block used for indirect goto jumps. /// This is typically used only during CFG construction. void setIndirectGotoBlock(CFGBlock* B) { IndirectGotoBlock = B; } - + //===--------------------------------------------------------------------===// // Block Iterators //===--------------------------------------------------------------------===// typedef std::list CFGBlockListTy; - + typedef CFGBlockListTy::iterator iterator; typedef CFGBlockListTy::const_iterator const_iterator; typedef std::reverse_iterator reverse_iterator; @@ -234,17 +234,17 @@ CFGBlock& front() { return Blocks.front(); } CFGBlock& back() { return Blocks.back(); } - + iterator begin() { return Blocks.begin(); } iterator end() { return Blocks.end(); } const_iterator begin() const { return Blocks.begin(); } - const_iterator end() const { return Blocks.end(); } - + const_iterator end() const { return Blocks.end(); } + reverse_iterator rbegin() { return Blocks.rbegin(); } reverse_iterator rend() { return Blocks.rend(); } const_reverse_iterator rbegin() const { return Blocks.rbegin(); } const_reverse_iterator rend() const { return Blocks.rend(); } - + CFGBlock& getEntry() { return *Entry; } const CFGBlock& getEntry() const { return *Entry; } CFGBlock& getExit() { return *Exit; } @@ -252,18 +252,18 @@ CFGBlock* getIndirectGotoBlock() { return IndirectGotoBlock; } const CFGBlock* getIndirectGotoBlock() const { return IndirectGotoBlock; } - + //===--------------------------------------------------------------------===// // Member templates useful for various batch operations over CFGs. //===--------------------------------------------------------------------===// - + template void VisitBlockStmts(CALLBACK& O) const { for (const_iterator I=begin(), E=end(); I != E; ++I) for (CFGBlock::const_iterator BI=I->begin(), BE=I->end(); BI != BE; ++BI) O(*BI); - } - + } + //===--------------------------------------------------------------------===// // CFG Introspection. //===--------------------------------------------------------------------===// @@ -275,11 +275,11 @@ operator bool() const { return Idx >= 0; } operator unsigned() const { assert(Idx >=0); return (unsigned) Idx; } }; - + bool isBlkExpr(const Stmt* S) { return getBlkExprNum(S); } BlkExprNumTy getBlkExprNum(const Stmt* S); unsigned getNumBlkExprs(); - + /// getNumBlockIDs - Returns the total number of BlockIDs allocated (which /// start at 0). unsigned getNumBlockIDs() const { return NumBlockIDs; } @@ -296,15 +296,15 @@ // Internal: constructors and data. //===--------------------------------------------------------------------===// - CFG() : Entry(NULL), Exit(NULL), IndirectGotoBlock(NULL), NumBlockIDs(0), + CFG() : Entry(NULL), Exit(NULL), IndirectGotoBlock(NULL), NumBlockIDs(0), BlkExprMap(NULL) {}; - + ~CFG(); - + llvm::BumpPtrAllocator& getAllocator() { return Alloc; } - + private: CFGBlock* Entry; CFGBlock* Exit; @@ -312,14 +312,14 @@ // for indirect gotos CFGBlockListTy Blocks; unsigned NumBlockIDs; - + // BlkExprMap - An opaque pointer to prevent inclusion of DenseMap.h. - // It represents a map from Expr* to integers to record the set of + // It represents a map from Expr* to integers to record the set of // block-level expressions and their "statement number" in the CFG. void* BlkExprMap; - + /// Alloc - An internal allocator. - llvm::BumpPtrAllocator Alloc; + llvm::BumpPtrAllocator Alloc; }; } // end namespace clang @@ -334,13 +334,13 @@ template <> struct GraphTraits { typedef clang::CFGBlock NodeType; typedef clang::CFGBlock::succ_iterator ChildIteratorType; - + static NodeType* getEntryNode(clang::CFGBlock* BB) { return BB; } static inline ChildIteratorType child_begin(NodeType* N) { return N->succ_begin(); } - + static inline ChildIteratorType child_end(NodeType* N) { return N->succ_end(); } }; @@ -348,13 +348,13 @@ template <> struct GraphTraits { typedef const clang::CFGBlock NodeType; typedef clang::CFGBlock::const_succ_iterator ChildIteratorType; - + static NodeType* getEntryNode(const clang::CFGBlock* BB) { return BB; } - + static inline ChildIteratorType child_begin(NodeType* N) { return N->succ_begin(); } - + static inline ChildIteratorType child_end(NodeType* N) { return N->succ_end(); } }; @@ -368,27 +368,27 @@ static inline ChildIteratorType child_begin(NodeType* N) { return N->pred_begin(); } - + static inline ChildIteratorType child_end(NodeType* N) { return N->pred_end(); } }; // Traits for: CFG -template <> struct GraphTraits +template <> struct GraphTraits : public GraphTraits { typedef clang::CFG::iterator nodes_iterator; - - static NodeType *getEntryNode(clang::CFG* F) { return &F->getEntry(); } + + static NodeType *getEntryNode(clang::CFG* F) { return &F->getEntry(); } static nodes_iterator nodes_begin(clang::CFG* F) { return F->begin(); } static nodes_iterator nodes_end(clang::CFG* F) { return F->end(); } }; -template <> struct GraphTraits< const clang::CFG* > +template <> struct GraphTraits< const clang::CFG* > : public GraphTraits< const clang::CFGBlock* > { - typedef clang::CFG::const_iterator nodes_iterator; + typedef clang::CFG::const_iterator nodes_iterator; static NodeType *getEntryNode( const clang::CFG* F) { return &F->getEntry(); } static nodes_iterator nodes_begin( const clang::CFG* F) { return F->begin(); } @@ -404,7 +404,7 @@ static nodes_iterator nodes_begin(const clang::CFG* F) { return F->begin();} static nodes_iterator nodes_end(const clang::CFG* F) { return F->end(); } }; - + } // end llvm namespace #endif Modified: cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h (original) +++ cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowSolver.h Wed Sep 9 10:08:12 2009 @@ -33,15 +33,15 @@ /// enqueue - Add a block to the worklist. Blocks already on the /// worklist are not added a second time. void enqueue(const CFGBlock* B) { wlist.insert(B); } - + /// dequeue - Remove a block from the worklist. const CFGBlock* dequeue() { assert (!wlist.empty()); const CFGBlock* B = *wlist.begin(); wlist.erase(B); - return B; + return B; } - + /// isEmpty - Return true if the worklist is empty. bool isEmpty() const { return wlist.empty(); } }; @@ -59,20 +59,20 @@ typedef CFGBlock::const_pred_iterator PrevBItr; typedef CFGBlock::const_succ_iterator NextBItr; typedef CFGBlock::const_iterator StmtItr; - + static PrevBItr PrevBegin(const CFGBlock* B) { return B->pred_begin(); } static PrevBItr PrevEnd(const CFGBlock* B) { return B->pred_end(); } - - static NextBItr NextBegin(const CFGBlock* B) { return B->succ_begin(); } + + static NextBItr NextBegin(const CFGBlock* B) { return B->succ_begin(); } static NextBItr NextEnd(const CFGBlock* B) { return B->succ_end(); } - + static StmtItr StmtBegin(const CFGBlock* B) { return B->begin(); } static StmtItr StmtEnd(const CFGBlock* B) { return B->end(); } - + static BlockEdge PrevEdge(const CFGBlock* B, const CFGBlock* Prev) { return BlockEdge(Prev, B, 0); } - + static BlockEdge NextEdge(const CFGBlock* B, const CFGBlock* Next) { return BlockEdge(B, Next, 0); } @@ -82,20 +82,20 @@ typedef CFGBlock::const_succ_iterator PrevBItr; typedef CFGBlock::const_pred_iterator NextBItr; typedef CFGBlock::const_reverse_iterator StmtItr; - - static PrevBItr PrevBegin(const CFGBlock* B) { return B->succ_begin(); } + + static PrevBItr PrevBegin(const CFGBlock* B) { return B->succ_begin(); } static PrevBItr PrevEnd(const CFGBlock* B) { return B->succ_end(); } - - static NextBItr NextBegin(const CFGBlock* B) { return B->pred_begin(); } + + static NextBItr NextBegin(const CFGBlock* B) { return B->pred_begin(); } static NextBItr NextEnd(const CFGBlock* B) { return B->pred_end(); } - + static StmtItr StmtBegin(const CFGBlock* B) { return B->rbegin(); } - static StmtItr StmtEnd(const CFGBlock* B) { return B->rend(); } - + static StmtItr StmtEnd(const CFGBlock* B) { return B->rend(); } + static BlockEdge PrevEdge(const CFGBlock* B, const CFGBlock* Prev) { return BlockEdge(B, Prev, 0); } - + static BlockEdge NextEdge(const CFGBlock* B, const CFGBlock* Next) { return BlockEdge(Next, B, 0); } @@ -105,7 +105,7 @@ //===----------------------------------------------------------------------===// /// DataflowSolverTy - Generic dataflow solver. //===----------------------------------------------------------------------===// - + template second); } } - + // Set the data for the block. D.getBlockDataMap()[B].copyValues(V); - } + } /// ProcessBlock - Process the transfer functions for a given block. void ProcessBlock(const CFGBlock* B, bool recordStmtValues, dataflow::forward_analysis_tag) { - + for (StmtItr I=ItrTraits::StmtBegin(B), E=ItrTraits::StmtEnd(B); I!=E;++I) ProcessStmt(*I, recordStmtValues, AnalysisDirTag()); - - TF.VisitTerminator(const_cast(B)); + + TF.VisitTerminator(const_cast(B)); } - + void ProcessBlock(const CFGBlock* B, bool recordStmtValues, dataflow::backward_analysis_tag) { - + TF.VisitTerminator(const_cast(B)); for (StmtItr I=ItrTraits::StmtBegin(B), E=ItrTraits::StmtEnd(B); I!=E;++I) ProcessStmt(*I, recordStmtValues, AnalysisDirTag()); } - + void ProcessStmt(const Stmt* S, bool record, dataflow::forward_analysis_tag) { if (record) D.getStmtDataMap()[S] = TF.getVal(); - TF.BlockStmt_Visit(const_cast(S)); + TF.BlockStmt_Visit(const_cast(S)); } - + void ProcessStmt(const Stmt* S, bool record, dataflow::backward_analysis_tag){ TF.BlockStmt_Visit(const_cast(S)); if (record) D.getStmtDataMap()[S] = TF.getVal(); @@ -272,12 +272,12 @@ if (CFGBlock *NextBlk = *I) UpdateEdgeValue(ItrTraits::NextEdge(B, NextBlk),V, NextBlk); } - + /// UpdateEdgeValue - Update the value associated with a given edge. void UpdateEdgeValue(BlockEdge E, ValTy& V, const CFGBlock* TargetBlock) { EdgeDataMapTy& M = D.getEdgeDataMap(); typename EdgeDataMapTy::iterator I = M.find(E); - + if (I == M.end()) { // First computed value for this edge? M[E].copyValues(V); WorkList.enqueue(TargetBlock); @@ -287,7 +287,7 @@ WorkList.enqueue(TargetBlock); } } - + private: DFValuesTy& D; DataflowWorkListTy WorkList; Modified: cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowValues.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowValues.h?rev=81346&r1=81345&r2=81346&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowValues.h (original) +++ cfe/trunk/include/clang/Analysis/FlowSensitive/DataflowValues.h Wed Sep 9 10:08:12 2009 @@ -24,7 +24,7 @@ /// Dataflow Directional Tag Classes. These are used for tag dispatching /// within the dataflow solver/transfer functions to determine what direction /// a dataflow analysis flows. -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// namespace clang { namespace dataflow { @@ -34,19 +34,19 @@ //===----------------------------------------------------------------------===// /// DataflowValues. Container class to store dataflow values for a CFG. -//===----------------------------------------------------------------------===// - +//===----------------------------------------------------------------------===// + template class DataflowValues { //===--------------------------------------------------------------------===// // Type declarations. - //===--------------------------------------------------------------------===// + //===--------------------------------------------------------------------===// public: typedef typename ValueTypes::ValTy ValTy; - typedef typename ValueTypes::AnalysisDataTy AnalysisDataTy; + typedef typename ValueTypes::AnalysisDataTy AnalysisDataTy; typedef _AnalysisDirTag AnalysisDirTag; typedef llvm::DenseMap EdgeDataMapTy; typedef llvm::DenseMap BlockDataMapTy; @@ -60,15 +60,15 @@ /// isForwardAnalysis - Returns true if the dataflow values are computed /// from a forward analysis. bool isForwardAnalysis() { return isForwardAnalysis(AnalysisDirTag()); } - + /// isBackwardAnalysis - Returns true if the dataflow values are computed /// from a backward analysis. bool isBackwardAnalysis() { return !isForwardAnalysis(); } - + private: bool isForwardAnalysis(dataflow::forward_analysis_tag) { return true; } - bool isForwardAnalysis(dataflow::backward_analysis_tag) { return false; } - + bool isForwardAnalysis(dataflow::backward_analysis_tag) { return false; } + //===--------------------------------------------------------------------===// // Initialization and accessors methods. //===--------------------------------------------------------------------===// @@ -76,10 +76,10 @@ public: DataflowValues() : StmtDataMap(NULL) {} ~DataflowValues() { delete StmtDataMap; } - + /// InitializeValues - Invoked by the solver to initialize state needed for /// dataflow analysis. This method is usually specialized by subclasses. - void InitializeValues(const CFG& cfg) {}; + void InitializeValues(const CFG& cfg) {}; /// getEdgeData - Retrieves the dataflow values associated with a @@ -89,28 +89,28 @@ assert (I != EdgeDataMap.end() && "No data associated with Edge."); return I->second; } - + const ValTy& getEdgeData(const BlockEdge& E) const { return reinterpret_cast(this)->getEdgeData(E); - } + } - /// getBlockData - Retrieves the dataflow values associated with a + /// getBlockData - Retrieves the dataflow values associated with a /// specified CFGBlock. If the dataflow analysis is a forward analysis, /// this data is associated with the END of the block. If the analysis - /// is a backwards analysis, it is associated with the ENTRY of the block. + /// is a backwards analysis, it is associated with the ENTRY of the block. ValTy& getBlockData(const CFGBlock* B) { typename BlockDataMapTy::iterator I = BlockDataMap.find(B); assert (I != BlockDataMap.end() && "No data associated with block."); return I->second; } - + const ValTy& getBlockData(const CFGBlock* B) const { return const_cast(this)->getBlockData(B); } - - /// getStmtData - Retrieves the dataflow values associated with a + + /// getStmtData - Retrieves the dataflow values associated with a /// specified Stmt.