rename test
[clang.git] / lib / Sema / Sema.cpp
blob7eb1c57412c85ee2107a94227239c849345d3873
1 //===--- Sema.cpp - AST Builder and Semantic Analysis Implementation ------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the actions class which performs semantic analysis and
11 // builds an AST out of a parse stream.
13 //===----------------------------------------------------------------------===//
15 #include "clang/Sema/SemaInternal.h"
16 #include "clang/Sema/DelayedDiagnostic.h"
17 #include "TargetAttributesSema.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/SmallSet.h"
20 #include "llvm/ADT/APFloat.h"
21 #include "clang/Sema/CXXFieldCollector.h"
22 #include "clang/Sema/TemplateDeduction.h"
23 #include "clang/Sema/ExternalSemaSource.h"
24 #include "clang/Sema/ObjCMethodList.h"
25 #include "clang/Sema/PrettyDeclStackTrace.h"
26 #include "clang/Sema/Scope.h"
27 #include "clang/Sema/ScopeInfo.h"
28 #include "clang/Sema/SemaConsumer.h"
29 #include "clang/AST/ASTContext.h"
30 #include "clang/AST/ASTDiagnostic.h"
31 #include "clang/AST/DeclCXX.h"
32 #include "clang/AST/DeclObjC.h"
33 #include "clang/AST/Expr.h"
34 #include "clang/AST/StmtCXX.h"
35 #include "clang/Lex/Preprocessor.h"
36 #include "clang/Basic/PartialDiagnostic.h"
37 #include "clang/Basic/TargetInfo.h"
38 using namespace clang;
39 using namespace sema;
41 FunctionScopeInfo::~FunctionScopeInfo() { }
43 void FunctionScopeInfo::Clear() {
44 HasBranchProtectedScope = false;
45 HasBranchIntoScope = false;
46 HasIndirectGoto = false;
48 SwitchStack.clear();
49 Returns.clear();
50 ErrorTrap.reset();
53 BlockScopeInfo::~BlockScopeInfo() { }
55 void Sema::ActOnTranslationUnitScope(Scope *S) {
56 TUScope = S;
57 PushDeclContext(S, Context.getTranslationUnitDecl());
59 VAListTagName = PP.getIdentifierInfo("__va_list_tag");
61 if (!Context.isInt128Installed() && // May be set by ASTReader.
62 PP.getTargetInfo().getPointerWidth(0) >= 64) {
63 TypeSourceInfo *TInfo;
65 // Install [u]int128_t for 64-bit targets.
66 TInfo = Context.getTrivialTypeSourceInfo(Context.Int128Ty);
67 PushOnScopeChains(TypedefDecl::Create(Context, CurContext,
68 SourceLocation(),
69 &Context.Idents.get("__int128_t"),
70 TInfo), TUScope);
72 TInfo = Context.getTrivialTypeSourceInfo(Context.UnsignedInt128Ty);
73 PushOnScopeChains(TypedefDecl::Create(Context, CurContext,
74 SourceLocation(),
75 &Context.Idents.get("__uint128_t"),
76 TInfo), TUScope);
77 Context.setInt128Installed();
81 if (!PP.getLangOptions().ObjC1) return;
83 // Built-in ObjC types may already be set by ASTReader (hence isNull checks).
84 if (Context.getObjCSelType().isNull()) {
85 // Create the built-in typedef for 'SEL'.
86 QualType SelT = Context.getPointerType(Context.ObjCBuiltinSelTy);
87 TypeSourceInfo *SelInfo = Context.getTrivialTypeSourceInfo(SelT);
88 TypedefDecl *SelTypedef
89 = TypedefDecl::Create(Context, CurContext, SourceLocation(),
90 &Context.Idents.get("SEL"), SelInfo);
91 PushOnScopeChains(SelTypedef, TUScope);
92 Context.setObjCSelType(Context.getTypeDeclType(SelTypedef));
93 Context.ObjCSelRedefinitionType = Context.getObjCSelType();
96 // Synthesize "@class Protocol;
97 if (Context.getObjCProtoType().isNull()) {
98 ObjCInterfaceDecl *ProtocolDecl =
99 ObjCInterfaceDecl::Create(Context, CurContext, SourceLocation(),
100 &Context.Idents.get("Protocol"),
101 SourceLocation(), true);
102 Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl));
103 PushOnScopeChains(ProtocolDecl, TUScope, false);
105 // Create the built-in typedef for 'id'.
106 if (Context.getObjCIdType().isNull()) {
107 QualType T = Context.getObjCObjectType(Context.ObjCBuiltinIdTy, 0, 0);
108 T = Context.getObjCObjectPointerType(T);
109 TypeSourceInfo *IdInfo = Context.getTrivialTypeSourceInfo(T);
110 TypedefDecl *IdTypedef
111 = TypedefDecl::Create(Context, CurContext, SourceLocation(),
112 &Context.Idents.get("id"), IdInfo);
113 PushOnScopeChains(IdTypedef, TUScope);
114 Context.setObjCIdType(Context.getTypeDeclType(IdTypedef));
115 Context.ObjCIdRedefinitionType = Context.getObjCIdType();
117 // Create the built-in typedef for 'Class'.
118 if (Context.getObjCClassType().isNull()) {
119 QualType T = Context.getObjCObjectType(Context.ObjCBuiltinClassTy, 0, 0);
120 T = Context.getObjCObjectPointerType(T);
121 TypeSourceInfo *ClassInfo = Context.getTrivialTypeSourceInfo(T);
122 TypedefDecl *ClassTypedef
123 = TypedefDecl::Create(Context, CurContext, SourceLocation(),
124 &Context.Idents.get("Class"), ClassInfo);
125 PushOnScopeChains(ClassTypedef, TUScope);
126 Context.setObjCClassType(Context.getTypeDeclType(ClassTypedef));
127 Context.ObjCClassRedefinitionType = Context.getObjCClassType();
131 Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
132 bool CompleteTranslationUnit,
133 CodeCompleteConsumer *CodeCompleter)
134 : TheTargetAttributesSema(0), FPFeatures(pp.getLangOptions()),
135 LangOpts(pp.getLangOptions()), PP(pp), Context(ctxt), Consumer(consumer),
136 Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
137 ExternalSource(0), CodeCompleter(CodeCompleter), CurContext(0),
138 PackContext(0), VisContext(0),
139 IdResolver(pp.getLangOptions()), CXXTypeInfoDecl(0), MSVCGuidDecl(0),
140 GlobalNewDeleteDeclared(false),
141 CompleteTranslationUnit(CompleteTranslationUnit),
142 NumSFINAEErrors(0), SuppressAccessChecking(false),
143 AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false),
144 NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1),
145 CurrentInstantiationScope(0), TyposCorrected(0),
146 AnalysisWarnings(*this)
148 TUScope = 0;
149 if (getLangOptions().CPlusPlus)
150 FieldCollector.reset(new CXXFieldCollector());
152 // Tell diagnostics how to render things from the AST library.
153 PP.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument,
154 &Context);
156 ExprEvalContexts.push_back(
157 ExpressionEvaluationContextRecord(PotentiallyEvaluated, 0));
159 FunctionScopes.push_back(new FunctionScopeInfo(Diags));
162 void Sema::Initialize() {
163 // Tell the AST consumer about this Sema object.
164 Consumer.Initialize(Context);
166 // FIXME: Isn't this redundant with the initialization above?
167 if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
168 SC->InitializeSema(*this);
170 // Tell the external Sema source about this Sema object.
171 if (ExternalSemaSource *ExternalSema
172 = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
173 ExternalSema->InitializeSema(*this);
176 Sema::~Sema() {
177 if (PackContext) FreePackedContext();
178 if (VisContext) FreeVisContext();
179 delete TheTargetAttributesSema;
181 // Kill all the active scopes.
182 for (unsigned I = 1, E = FunctionScopes.size(); I != E; ++I)
183 delete FunctionScopes[I];
184 if (FunctionScopes.size() == 1)
185 delete FunctionScopes[0];
187 // Tell the SemaConsumer to forget about us; we're going out of scope.
188 if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
189 SC->ForgetSema();
191 // Detach from the external Sema source.
192 if (ExternalSemaSource *ExternalSema
193 = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
194 ExternalSema->ForgetSema();
197 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
198 /// If there is already an implicit cast, merge into the existing one.
199 /// The result is of the given category.
200 void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty,
201 CastKind Kind, ExprValueKind VK,
202 const CXXCastPath *BasePath) {
203 QualType ExprTy = Context.getCanonicalType(Expr->getType());
204 QualType TypeTy = Context.getCanonicalType(Ty);
206 if (ExprTy == TypeTy)
207 return;
209 // If this is a derived-to-base cast to a through a virtual base, we
210 // need a vtable.
211 if (Kind == CK_DerivedToBase &&
212 BasePathInvolvesVirtualBase(*BasePath)) {
213 QualType T = Expr->getType();
214 if (const PointerType *Pointer = T->getAs<PointerType>())
215 T = Pointer->getPointeeType();
216 if (const RecordType *RecordTy = T->getAs<RecordType>())
217 MarkVTableUsed(Expr->getLocStart(),
218 cast<CXXRecordDecl>(RecordTy->getDecl()));
221 if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr)) {
222 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
223 ImpCast->setType(Ty);
224 ImpCast->setValueKind(VK);
225 return;
229 Expr = ImplicitCastExpr::Create(Context, Ty, Kind, Expr, BasePath, VK);
232 ExprValueKind Sema::CastCategory(Expr *E) {
233 Expr::Classification Classification = E->Classify(Context);
234 return Classification.isRValue() ? VK_RValue :
235 (Classification.isLValue() ? VK_LValue : VK_XValue);
238 /// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector.
239 static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) {
240 if (D->isUsed())
241 return true;
243 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
244 // UnusedFileScopedDecls stores the first declaration.
245 // The declaration may have become definition so check again.
246 const FunctionDecl *DeclToCheck;
247 if (FD->hasBody(DeclToCheck))
248 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
250 // Later redecls may add new information resulting in not having to warn,
251 // so check again.
252 DeclToCheck = FD->getMostRecentDeclaration();
253 if (DeclToCheck != FD)
254 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
257 if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
258 // UnusedFileScopedDecls stores the first declaration.
259 // The declaration may have become definition so check again.
260 const VarDecl *DeclToCheck = VD->getDefinition();
261 if (DeclToCheck)
262 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
264 // Later redecls may add new information resulting in not having to warn,
265 // so check again.
266 DeclToCheck = VD->getMostRecentDeclaration();
267 if (DeclToCheck != VD)
268 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
271 return false;
274 /// ActOnEndOfTranslationUnit - This is called at the very end of the
275 /// translation unit when EOF is reached and all but the top-level scope is
276 /// popped.
277 void Sema::ActOnEndOfTranslationUnit() {
278 // At PCH writing, implicit instantiations and VTable handling info are
279 // stored and performed when the PCH is included.
280 if (CompleteTranslationUnit) {
281 // If any dynamic classes have their key function defined within
282 // this translation unit, then those vtables are considered "used" and must
283 // be emitted.
284 for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I) {
285 assert(!DynamicClasses[I]->isDependentType() &&
286 "Should not see dependent types here!");
287 if (const CXXMethodDecl *KeyFunction
288 = Context.getKeyFunction(DynamicClasses[I])) {
289 const FunctionDecl *Definition = 0;
290 if (KeyFunction->hasBody(Definition))
291 MarkVTableUsed(Definition->getLocation(), DynamicClasses[I], true);
295 // If DefinedUsedVTables ends up marking any virtual member functions it
296 // might lead to more pending template instantiations, which we then need
297 // to instantiate.
298 DefineUsedVTables();
300 // C++: Perform implicit template instantiations.
302 // FIXME: When we perform these implicit instantiations, we do not
303 // carefully keep track of the point of instantiation (C++ [temp.point]).
304 // This means that name lookup that occurs within the template
305 // instantiation will always happen at the end of the translation unit,
306 // so it will find some names that should not be found. Although this is
307 // common behavior for C++ compilers, it is technically wrong. In the
308 // future, we either need to be able to filter the results of name lookup
309 // or we need to perform template instantiations earlier.
310 PerformPendingInstantiations();
313 // Remove file scoped decls that turned out to be used.
314 UnusedFileScopedDecls.erase(std::remove_if(UnusedFileScopedDecls.begin(),
315 UnusedFileScopedDecls.end(),
316 std::bind1st(std::ptr_fun(ShouldRemoveFromUnused),
317 this)),
318 UnusedFileScopedDecls.end());
320 if (!CompleteTranslationUnit) {
321 TUScope = 0;
322 return;
325 // Check for #pragma weak identifiers that were never declared
326 // FIXME: This will cause diagnostics to be emitted in a non-determinstic
327 // order! Iterating over a densemap like this is bad.
328 for (llvm::DenseMap<IdentifierInfo*,WeakInfo>::iterator
329 I = WeakUndeclaredIdentifiers.begin(),
330 E = WeakUndeclaredIdentifiers.end(); I != E; ++I) {
331 if (I->second.getUsed()) continue;
333 Diag(I->second.getLocation(), diag::warn_weak_identifier_undeclared)
334 << I->first;
337 // C99 6.9.2p2:
338 // A declaration of an identifier for an object that has file
339 // scope without an initializer, and without a storage-class
340 // specifier or with the storage-class specifier static,
341 // constitutes a tentative definition. If a translation unit
342 // contains one or more tentative definitions for an identifier,
343 // and the translation unit contains no external definition for
344 // that identifier, then the behavior is exactly as if the
345 // translation unit contains a file scope declaration of that
346 // identifier, with the composite type as of the end of the
347 // translation unit, with an initializer equal to 0.
348 llvm::SmallSet<VarDecl *, 32> Seen;
349 for (unsigned i = 0, e = TentativeDefinitions.size(); i != e; ++i) {
350 VarDecl *VD = TentativeDefinitions[i]->getActingDefinition();
352 // If the tentative definition was completed, getActingDefinition() returns
353 // null. If we've already seen this variable before, insert()'s second
354 // return value is false.
355 if (VD == 0 || VD->isInvalidDecl() || !Seen.insert(VD))
356 continue;
358 if (const IncompleteArrayType *ArrayT
359 = Context.getAsIncompleteArrayType(VD->getType())) {
360 if (RequireCompleteType(VD->getLocation(),
361 ArrayT->getElementType(),
362 diag::err_tentative_def_incomplete_type_arr)) {
363 VD->setInvalidDecl();
364 continue;
367 // Set the length of the array to 1 (C99 6.9.2p5).
368 Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
369 llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
370 QualType T = Context.getConstantArrayType(ArrayT->getElementType(),
371 One, ArrayType::Normal, 0);
372 VD->setType(T);
373 } else if (RequireCompleteType(VD->getLocation(), VD->getType(),
374 diag::err_tentative_def_incomplete_type))
375 VD->setInvalidDecl();
377 // Notify the consumer that we've completed a tentative definition.
378 if (!VD->isInvalidDecl())
379 Consumer.CompleteTentativeDefinition(VD);
383 // If there were errors, disable 'unused' warnings since they will mostly be
384 // noise.
385 if (!Diags.hasErrorOccurred()) {
386 // Output warning for unused file scoped decls.
387 for (llvm::SmallVectorImpl<const DeclaratorDecl*>::iterator
388 I = UnusedFileScopedDecls.begin(),
389 E = UnusedFileScopedDecls.end(); I != E; ++I) {
390 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
391 const FunctionDecl *DiagD;
392 if (!FD->hasBody(DiagD))
393 DiagD = FD;
394 Diag(DiagD->getLocation(),
395 isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function
396 : diag::warn_unused_function)
397 << DiagD->getDeclName();
398 } else {
399 const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition();
400 if (!DiagD)
401 DiagD = cast<VarDecl>(*I);
402 Diag(DiagD->getLocation(), diag::warn_unused_variable)
403 << DiagD->getDeclName();
408 TUScope = 0;
412 //===----------------------------------------------------------------------===//
413 // Helper functions.
414 //===----------------------------------------------------------------------===//
416 DeclContext *Sema::getFunctionLevelDeclContext() {
417 DeclContext *DC = CurContext;
419 while (isa<BlockDecl>(DC) || isa<EnumDecl>(DC))
420 DC = DC->getParent();
422 return DC;
425 /// getCurFunctionDecl - If inside of a function body, this returns a pointer
426 /// to the function decl for the function being parsed. If we're currently
427 /// in a 'block', this returns the containing context.
428 FunctionDecl *Sema::getCurFunctionDecl() {
429 DeclContext *DC = getFunctionLevelDeclContext();
430 return dyn_cast<FunctionDecl>(DC);
433 ObjCMethodDecl *Sema::getCurMethodDecl() {
434 DeclContext *DC = getFunctionLevelDeclContext();
435 return dyn_cast<ObjCMethodDecl>(DC);
438 NamedDecl *Sema::getCurFunctionOrMethodDecl() {
439 DeclContext *DC = getFunctionLevelDeclContext();
440 if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
441 return cast<NamedDecl>(DC);
442 return 0;
445 Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() {
446 if (!isActive())
447 return;
449 if (llvm::Optional<TemplateDeductionInfo*> Info = SemaRef.isSFINAEContext()) {
450 switch (DiagnosticIDs::getDiagnosticSFINAEResponse(getDiagID())) {
451 case DiagnosticIDs::SFINAE_Report:
452 // Fall through; we'll report the diagnostic below.
453 break;
455 case DiagnosticIDs::SFINAE_AccessControl:
456 // Unless access checking is specifically called out as a SFINAE
457 // error, report this diagnostic.
458 if (!SemaRef.AccessCheckingSFINAE)
459 break;
461 case DiagnosticIDs::SFINAE_SubstitutionFailure:
462 // Count this failure so that we know that template argument deduction
463 // has failed.
464 ++SemaRef.NumSFINAEErrors;
465 SemaRef.Diags.setLastDiagnosticIgnored();
466 SemaRef.Diags.Clear();
467 Clear();
468 return;
470 case DiagnosticIDs::SFINAE_Suppress:
471 // Make a copy of this suppressed diagnostic and store it with the
472 // template-deduction information;
473 FlushCounts();
474 DiagnosticInfo DiagInfo(&SemaRef.Diags);
476 if (*Info)
477 (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
478 PartialDiagnostic(DiagInfo,
479 SemaRef.Context.getDiagAllocator()));
481 // Suppress this diagnostic.
482 SemaRef.Diags.setLastDiagnosticIgnored();
483 SemaRef.Diags.Clear();
484 Clear();
485 return;
489 // Emit the diagnostic.
490 if (!this->Emit())
491 return;
493 // If this is not a note, and we're in a template instantiation
494 // that is different from the last template instantiation where
495 // we emitted an error, print a template instantiation
496 // backtrace.
497 if (!DiagnosticIDs::isBuiltinNote(DiagID) &&
498 !SemaRef.ActiveTemplateInstantiations.empty() &&
499 SemaRef.ActiveTemplateInstantiations.back()
500 != SemaRef.LastTemplateInstantiationErrorContext) {
501 SemaRef.PrintInstantiationStack();
502 SemaRef.LastTemplateInstantiationErrorContext
503 = SemaRef.ActiveTemplateInstantiations.back();
507 Sema::SemaDiagnosticBuilder Sema::Diag(SourceLocation Loc, unsigned DiagID) {
508 DiagnosticBuilder DB = Diags.Report(Loc, DiagID);
509 return SemaDiagnosticBuilder(DB, *this, DiagID);
512 Sema::SemaDiagnosticBuilder
513 Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) {
514 SemaDiagnosticBuilder Builder(Diag(Loc, PD.getDiagID()));
515 PD.Emit(Builder);
517 return Builder;
520 /// \brief Determines the active Scope associated with the given declaration
521 /// context.
523 /// This routine maps a declaration context to the active Scope object that
524 /// represents that declaration context in the parser. It is typically used
525 /// from "scope-less" code (e.g., template instantiation, lazy creation of
526 /// declarations) that injects a name for name-lookup purposes and, therefore,
527 /// must update the Scope.
529 /// \returns The scope corresponding to the given declaraion context, or NULL
530 /// if no such scope is open.
531 Scope *Sema::getScopeForContext(DeclContext *Ctx) {
533 if (!Ctx)
534 return 0;
536 Ctx = Ctx->getPrimaryContext();
537 for (Scope *S = getCurScope(); S; S = S->getParent()) {
538 // Ignore scopes that cannot have declarations. This is important for
539 // out-of-line definitions of static class members.
540 if (S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope))
541 if (DeclContext *Entity = static_cast<DeclContext *> (S->getEntity()))
542 if (Ctx == Entity->getPrimaryContext())
543 return S;
546 return 0;
549 /// \brief Enter a new function scope
550 void Sema::PushFunctionScope() {
551 if (FunctionScopes.size() == 1) {
552 // Use the "top" function scope rather than having to allocate
553 // memory for a new scope.
554 FunctionScopes.back()->Clear();
555 FunctionScopes.push_back(FunctionScopes.back());
556 return;
559 FunctionScopes.push_back(new FunctionScopeInfo(getDiagnostics()));
562 void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
563 FunctionScopes.push_back(new BlockScopeInfo(getDiagnostics(),
564 BlockScope, Block));
567 void Sema::PopFunctionOrBlockScope() {
568 FunctionScopeInfo *Scope = FunctionScopes.pop_back_val();
569 assert(!FunctionScopes.empty() && "mismatched push/pop!");
570 if (FunctionScopes.back() != Scope)
571 delete Scope;
574 /// \brief Determine whether any errors occurred within this function/method/
575 /// block.
576 bool Sema::hasAnyErrorsInThisFunction() const {
577 return getCurFunction()->ErrorTrap.hasErrorOccurred();
580 BlockScopeInfo *Sema::getCurBlock() {
581 if (FunctionScopes.empty())
582 return 0;
584 return dyn_cast<BlockScopeInfo>(FunctionScopes.back());
587 // Pin this vtable to this file.
588 ExternalSemaSource::~ExternalSemaSource() {}
590 std::pair<ObjCMethodList, ObjCMethodList>
591 ExternalSemaSource::ReadMethodPool(Selector Sel) {
592 return std::pair<ObjCMethodList, ObjCMethodList>();
595 void PrettyDeclStackTraceEntry::print(llvm::raw_ostream &OS) const {
596 SourceLocation Loc = this->Loc;
597 if (!Loc.isValid() && TheDecl) Loc = TheDecl->getLocation();
598 if (Loc.isValid()) {
599 Loc.print(OS, S.getSourceManager());
600 OS << ": ";
602 OS << Message;
604 if (TheDecl && isa<NamedDecl>(TheDecl)) {
605 std::string Name = cast<NamedDecl>(TheDecl)->getNameAsString();
606 if (!Name.empty())
607 OS << " '" << Name << '\'';
610 OS << '\n';