blob: 253c10e7d5e98164db08acaa095b3636724fc0e6 [file] [log] [blame]
Douglas Gregor3545ff42009-09-21 16:56:56 +00001//===--- CodeCompleteConsumer.cpp - Code Completion Interface ---*- C++ -*-===//
Douglas Gregor2436e712009-09-17 21:32:03 +00002//
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 CodeCompleteConsumer class.
11//
12//===----------------------------------------------------------------------===//
13#include "clang/Sema/CodeCompleteConsumer.h"
John McCall8b0666c2010-08-20 18:27:03 +000014#include "clang/Sema/Scope.h"
Douglas Gregorc3a6ade2010-08-12 20:07:10 +000015#include "clang/Sema/Sema.h"
Douglas Gregor56c2dbc2009-09-18 17:54:00 +000016#include "clang/AST/DeclCXX.h"
John McCallde6836a2010-08-24 07:21:54 +000017#include "clang/AST/DeclObjC.h"
John McCall19c1bfd2010-08-25 05:32:35 +000018#include "clang/AST/DeclTemplate.h"
Douglas Gregor2436e712009-09-17 21:32:03 +000019#include "clang/Lex/Preprocessor.h"
Douglas Gregorf09935f2009-12-01 05:55:20 +000020#include "clang-c/Index.h"
Douglas Gregor2436e712009-09-17 21:32:03 +000021#include "llvm/ADT/STLExtras.h"
Douglas Gregor669a25a2011-02-17 00:22:45 +000022#include "llvm/ADT/Twine.h"
Douglas Gregor2436e712009-09-17 21:32:03 +000023#include "llvm/Support/raw_ostream.h"
24#include <algorithm>
Douglas Gregorfedc3282009-09-18 22:15:54 +000025#include <cstring>
26#include <functional>
Douglas Gregorab6ccb52009-11-17 16:43:05 +000027
Douglas Gregor2436e712009-09-17 21:32:03 +000028using namespace clang;
Douglas Gregorab6ccb52009-11-17 16:43:05 +000029using llvm::StringRef;
Douglas Gregor2436e712009-09-17 21:32:03 +000030
Douglas Gregorfedc3282009-09-18 22:15:54 +000031//===----------------------------------------------------------------------===//
Douglas Gregor0212fd72010-09-21 16:06:22 +000032// Code completion context implementation
33//===----------------------------------------------------------------------===//
34
35bool CodeCompletionContext::wantConstructorResults() const {
36 switch (Kind) {
Douglas Gregor0ac41382010-09-23 23:01:17 +000037 case CCC_Recovery:
Douglas Gregor0212fd72010-09-21 16:06:22 +000038 case CCC_Statement:
39 case CCC_Expression:
40 case CCC_ObjCMessageReceiver:
41 case CCC_ParenthesizedExpression:
42 return true;
43
44 case CCC_TopLevel:
45 case CCC_ObjCInterface:
46 case CCC_ObjCImplementation:
47 case CCC_ObjCIvarList:
48 case CCC_ClassStructUnion:
49 case CCC_MemberAccess:
50 case CCC_EnumTag:
51 case CCC_UnionTag:
52 case CCC_ClassOrStructTag:
53 case CCC_ObjCProtocolName:
54 case CCC_Namespace:
55 case CCC_Type:
56 case CCC_Name:
57 case CCC_PotentiallyQualifiedName:
58 case CCC_MacroName:
59 case CCC_MacroNameUse:
60 case CCC_PreprocessorExpression:
61 case CCC_PreprocessorDirective:
62 case CCC_NaturalLanguage:
63 case CCC_SelectorName:
64 case CCC_TypeQualifiers:
Douglas Gregor0ac41382010-09-23 23:01:17 +000065 case CCC_Other:
Douglas Gregor0212fd72010-09-21 16:06:22 +000066 return false;
67 }
68
69 return false;
70}
71
72//===----------------------------------------------------------------------===//
Douglas Gregorfedc3282009-09-18 22:15:54 +000073// Code completion string implementation
74//===----------------------------------------------------------------------===//
Douglas Gregorb278aaf2011-02-01 19:23:04 +000075CodeCompletionString::Chunk::Chunk(ChunkKind Kind, const char *Text)
Daniel Dunbarb0a19422009-11-12 18:40:12 +000076 : Kind(Kind), Text("")
Douglas Gregor5bf52692009-09-22 23:15:58 +000077{
Douglas Gregor9eb77012009-11-07 00:00:49 +000078 switch (Kind) {
79 case CK_TypedText:
80 case CK_Text:
81 case CK_Placeholder:
82 case CK_Informative:
Douglas Gregorb3fa9192009-12-18 18:53:37 +000083 case CK_ResultType:
Douglas Gregorb278aaf2011-02-01 19:23:04 +000084 case CK_CurrentParameter:
85 this->Text = Text;
Douglas Gregor9eb77012009-11-07 00:00:49 +000086 break;
Douglas Gregor9eb77012009-11-07 00:00:49 +000087
88 case CK_Optional:
Jeffrey Yasskin1615d452009-12-12 05:05:38 +000089 llvm_unreachable("Optional strings cannot be created from text");
Douglas Gregor9eb77012009-11-07 00:00:49 +000090 break;
91
92 case CK_LeftParen:
93 this->Text = "(";
94 break;
95
96 case CK_RightParen:
97 this->Text = ")";
98 break;
99
100 case CK_LeftBracket:
101 this->Text = "[";
102 break;
103
104 case CK_RightBracket:
105 this->Text = "]";
106 break;
107
108 case CK_LeftBrace:
109 this->Text = "{";
110 break;
111
112 case CK_RightBrace:
113 this->Text = "}";
114 break;
115
116 case CK_LeftAngle:
117 this->Text = "<";
118 break;
119
120 case CK_RightAngle:
121 this->Text = ">";
122 break;
123
124 case CK_Comma:
125 this->Text = ", ";
126 break;
Douglas Gregor504a6ae2010-01-10 23:08:15 +0000127
128 case CK_Colon:
Douglas Gregor636a61e2010-04-07 00:21:17 +0000129 this->Text = ":";
Douglas Gregor504a6ae2010-01-10 23:08:15 +0000130 break;
131
132 case CK_SemiColon:
133 this->Text = ";";
134 break;
135
136 case CK_Equal:
137 this->Text = " = ";
138 break;
139
140 case CK_HorizontalSpace:
141 this->Text = " ";
142 break;
143
144 case CK_VerticalSpace:
145 this->Text = "\n";
146 break;
Douglas Gregor9eb77012009-11-07 00:00:49 +0000147 }
Douglas Gregor5bf52692009-09-22 23:15:58 +0000148}
149
150CodeCompletionString::Chunk
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000151CodeCompletionString::Chunk::CreateText(const char *Text) {
Douglas Gregor5bf52692009-09-22 23:15:58 +0000152 return Chunk(CK_Text, Text);
Douglas Gregorfedc3282009-09-18 22:15:54 +0000153}
154
155CodeCompletionString::Chunk
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000156CodeCompletionString::Chunk::CreateOptional(CodeCompletionString *Optional) {
Douglas Gregorfedc3282009-09-18 22:15:54 +0000157 Chunk Result;
158 Result.Kind = CK_Optional;
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000159 Result.Optional = Optional;
Douglas Gregorfedc3282009-09-18 22:15:54 +0000160 return Result;
161}
162
163CodeCompletionString::Chunk
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000164CodeCompletionString::Chunk::CreatePlaceholder(const char *Placeholder) {
Douglas Gregor5bf52692009-09-22 23:15:58 +0000165 return Chunk(CK_Placeholder, Placeholder);
166}
167
168CodeCompletionString::Chunk
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000169CodeCompletionString::Chunk::CreateInformative(const char *Informative) {
Douglas Gregor5bf52692009-09-22 23:15:58 +0000170 return Chunk(CK_Informative, Informative);
Douglas Gregorfedc3282009-09-18 22:15:54 +0000171}
172
Douglas Gregor9eb77012009-11-07 00:00:49 +0000173CodeCompletionString::Chunk
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000174CodeCompletionString::Chunk::CreateResultType(const char *ResultType) {
Douglas Gregorb3fa9192009-12-18 18:53:37 +0000175 return Chunk(CK_ResultType, ResultType);
176}
177
178CodeCompletionString::Chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +0000179CodeCompletionString::Chunk::CreateCurrentParameter(
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000180 const char *CurrentParameter) {
Douglas Gregor9eb77012009-11-07 00:00:49 +0000181 return Chunk(CK_CurrentParameter, CurrentParameter);
182}
183
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000184CodeCompletionString::CodeCompletionString(const Chunk *Chunks,
185 unsigned NumChunks,
186 unsigned Priority,
187 CXAvailabilityKind Availability)
188 : NumChunks(NumChunks), Priority(Priority), Availability(Availability)
189{
190 Chunk *StoredChunks = reinterpret_cast<Chunk *>(this + 1);
191 for (unsigned I = 0; I != NumChunks; ++I)
192 StoredChunks[I] = Chunks[I];
Douglas Gregorfedc3282009-09-18 22:15:54 +0000193}
194
195std::string CodeCompletionString::getAsString() const {
196 std::string Result;
197 llvm::raw_string_ostream OS(Result);
198
199 for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) {
200 switch (C->Kind) {
Douglas Gregorfedc3282009-09-18 22:15:54 +0000201 case CK_Optional: OS << "{#" << C->Optional->getAsString() << "#}"; break;
Douglas Gregor5bf52692009-09-22 23:15:58 +0000202 case CK_Placeholder: OS << "<#" << C->Text << "#>"; break;
Douglas Gregorb3fa9192009-12-18 18:53:37 +0000203
204 case CK_Informative:
205 case CK_ResultType:
206 OS << "[#" << C->Text << "#]";
207 break;
208
Douglas Gregor9eb77012009-11-07 00:00:49 +0000209 case CK_CurrentParameter: OS << "<#" << C->Text << "#>"; break;
210 default: OS << C->Text; break;
Douglas Gregorfedc3282009-09-18 22:15:54 +0000211 }
212 }
Dan Gohman4888f1a2010-07-26 21:33:22 +0000213 return OS.str();
Douglas Gregorfedc3282009-09-18 22:15:54 +0000214}
215
Douglas Gregor45f83ee2009-11-19 00:01:57 +0000216const char *CodeCompletionString::getTypedText() const {
217 for (iterator C = begin(), CEnd = end(); C != CEnd; ++C)
218 if (C->Kind == CK_TypedText)
219 return C->Text;
220
221 return 0;
222}
223
Douglas Gregorbcbf46c2011-02-01 22:57:45 +0000224const char *CodeCompletionAllocator::CopyString(llvm::StringRef String) {
225 char *Mem = (char *)Allocate(String.size() + 1, 1);
226 std::copy(String.begin(), String.end(), Mem);
227 Mem[String.size()] = 0;
228 return Mem;
229}
230
Douglas Gregor669a25a2011-02-17 00:22:45 +0000231const char *CodeCompletionAllocator::CopyString(llvm::Twine String) {
232 // FIXME: It would be more efficient to teach Twine to tell us its size and
233 // then add a routine there to fill in an allocated char* with the contents
234 // of the string.
235 llvm::SmallString<128> Data;
236 return CopyString(String.toStringRef(Data));
237}
238
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000239CodeCompletionString *CodeCompletionBuilder::TakeString() {
240 void *Mem = Allocator.Allocate(
241 sizeof(CodeCompletionString) + sizeof(Chunk) * Chunks.size(),
242 llvm::alignOf<CodeCompletionString>());
243 CodeCompletionString *Result
244 = new (Mem) CodeCompletionString(Chunks.data(), Chunks.size(),
245 Priority, Availability);
246 Chunks.clear();
Douglas Gregor45f83ee2009-11-19 00:01:57 +0000247 return Result;
248}
Douglas Gregor9eb77012009-11-07 00:00:49 +0000249
John McCall276321a2010-08-25 06:19:51 +0000250unsigned CodeCompletionResult::getPriorityFromDecl(NamedDecl *ND) {
Douglas Gregora2db7932010-05-26 22:00:08 +0000251 if (!ND)
252 return CCP_Unlikely;
253
254 // Context-based decisions.
Sebastian Redl50c68252010-08-31 00:36:30 +0000255 DeclContext *DC = ND->getDeclContext()->getRedeclContext();
Douglas Gregor521db402010-09-18 15:16:27 +0000256 if (DC->isFunctionOrMethod() || isa<BlockDecl>(DC)) {
257 // _cmd is relatively rare
258 if (ImplicitParamDecl *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
259 if (ImplicitParam->getIdentifier() &&
260 ImplicitParam->getIdentifier()->isStr("_cmd"))
261 return CCP_ObjC_cmd;
262
Douglas Gregora2db7932010-05-26 22:00:08 +0000263 return CCP_LocalDeclaration;
Douglas Gregor521db402010-09-18 15:16:27 +0000264 }
Douglas Gregora2db7932010-05-26 22:00:08 +0000265 if (DC->isRecord() || isa<ObjCContainerDecl>(DC))
266 return CCP_MemberDeclaration;
267
268 // Content-based decisions.
269 if (isa<EnumConstantDecl>(ND))
270 return CCP_Constant;
271 if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))
272 return CCP_Type;
Douglas Gregor521db402010-09-18 15:16:27 +0000273
Douglas Gregora2db7932010-05-26 22:00:08 +0000274 return CCP_Declaration;
275}
276
Douglas Gregorfedc3282009-09-18 22:15:54 +0000277//===----------------------------------------------------------------------===//
Douglas Gregor05f477c2009-09-23 00:16:58 +0000278// Code completion overload candidate implementation
279//===----------------------------------------------------------------------===//
280FunctionDecl *
281CodeCompleteConsumer::OverloadCandidate::getFunction() const {
282 if (getKind() == CK_Function)
283 return Function;
284 else if (getKind() == CK_FunctionTemplate)
285 return FunctionTemplate->getTemplatedDecl();
286 else
287 return 0;
288}
289
290const FunctionType *
291CodeCompleteConsumer::OverloadCandidate::getFunctionType() const {
292 switch (Kind) {
293 case CK_Function:
294 return Function->getType()->getAs<FunctionType>();
295
296 case CK_FunctionTemplate:
297 return FunctionTemplate->getTemplatedDecl()->getType()
298 ->getAs<FunctionType>();
299
300 case CK_FunctionType:
301 return Type;
302 }
303
304 return 0;
305}
306
307//===----------------------------------------------------------------------===//
Douglas Gregorfedc3282009-09-18 22:15:54 +0000308// Code completion consumer implementation
309//===----------------------------------------------------------------------===//
310
Douglas Gregor3545ff42009-09-21 16:56:56 +0000311CodeCompleteConsumer::~CodeCompleteConsumer() { }
Douglas Gregorfedc3282009-09-18 22:15:54 +0000312
Douglas Gregor2436e712009-09-17 21:32:03 +0000313void
Daniel Dunbar242ea9a2009-11-13 08:58:20 +0000314PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef,
Douglas Gregor00c37ef2010-08-11 21:23:17 +0000315 CodeCompletionContext Context,
John McCall276321a2010-08-25 06:19:51 +0000316 CodeCompletionResult *Results,
Douglas Gregor2436e712009-09-17 21:32:03 +0000317 unsigned NumResults) {
Douglas Gregor49f67ce2010-08-26 13:48:20 +0000318 std::stable_sort(Results, Results + NumResults);
319
Douglas Gregor2436e712009-09-17 21:32:03 +0000320 // Print the results.
321 for (unsigned I = 0; I != NumResults; ++I) {
Douglas Gregor58acf322009-10-09 22:16:47 +0000322 OS << "COMPLETION: ";
Douglas Gregor2436e712009-09-17 21:32:03 +0000323 switch (Results[I].Kind) {
John McCall276321a2010-08-25 06:19:51 +0000324 case CodeCompletionResult::RK_Declaration:
Benjamin Kramerb11416d2010-04-17 09:33:03 +0000325 OS << Results[I].Declaration;
Douglas Gregor2436e712009-09-17 21:32:03 +0000326 if (Results[I].Hidden)
327 OS << " (Hidden)";
Douglas Gregor3545ff42009-09-21 16:56:56 +0000328 if (CodeCompletionString *CCS
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000329 = Results[I].CreateCodeCompletionString(SemaRef, Allocator)) {
Douglas Gregorfedc3282009-09-18 22:15:54 +0000330 OS << " : " << CCS->getAsString();
Douglas Gregorfedc3282009-09-18 22:15:54 +0000331 }
332
Douglas Gregor2436e712009-09-17 21:32:03 +0000333 OS << '\n';
334 break;
335
John McCall276321a2010-08-25 06:19:51 +0000336 case CodeCompletionResult::RK_Keyword:
Douglas Gregor52ce62f2010-01-13 23:24:38 +0000337 OS << Results[I].Keyword << '\n';
Douglas Gregor2436e712009-09-17 21:32:03 +0000338 break;
Douglas Gregorf329c7c2009-10-30 16:50:04 +0000339
John McCall276321a2010-08-25 06:19:51 +0000340 case CodeCompletionResult::RK_Macro: {
Douglas Gregor52ce62f2010-01-13 23:24:38 +0000341 OS << Results[I].Macro->getName();
Douglas Gregorf329c7c2009-10-30 16:50:04 +0000342 if (CodeCompletionString *CCS
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000343 = Results[I].CreateCodeCompletionString(SemaRef, Allocator)) {
Douglas Gregorf329c7c2009-10-30 16:50:04 +0000344 OS << " : " << CCS->getAsString();
Douglas Gregorf329c7c2009-10-30 16:50:04 +0000345 }
346 OS << '\n';
347 break;
348 }
Douglas Gregor45f83ee2009-11-19 00:01:57 +0000349
John McCall276321a2010-08-25 06:19:51 +0000350 case CodeCompletionResult::RK_Pattern: {
Douglas Gregor52ce62f2010-01-13 23:24:38 +0000351 OS << "Pattern : "
Douglas Gregor45f83ee2009-11-19 00:01:57 +0000352 << Results[I].Pattern->getAsString() << '\n';
353 break;
354 }
Douglas Gregor2436e712009-09-17 21:32:03 +0000355 }
356 }
Douglas Gregor2436e712009-09-17 21:32:03 +0000357}
Douglas Gregor05f477c2009-09-23 00:16:58 +0000358
359void
Daniel Dunbar242ea9a2009-11-13 08:58:20 +0000360PrintingCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef,
361 unsigned CurrentArg,
Douglas Gregor05f477c2009-09-23 00:16:58 +0000362 OverloadCandidate *Candidates,
363 unsigned NumCandidates) {
364 for (unsigned I = 0; I != NumCandidates; ++I) {
Douglas Gregorf0f51982009-09-23 00:34:09 +0000365 if (CodeCompletionString *CCS
Douglas Gregorb278aaf2011-02-01 19:23:04 +0000366 = Candidates[I].CreateSignatureString(CurrentArg, SemaRef,
367 Allocator)) {
Douglas Gregor58acf322009-10-09 22:16:47 +0000368 OS << "OVERLOAD: " << CCS->getAsString() << "\n";
Douglas Gregor05f477c2009-09-23 00:16:58 +0000369 }
370 }
Douglas Gregor05f477c2009-09-23 00:16:58 +0000371}
Douglas Gregor9eb77012009-11-07 00:00:49 +0000372
John McCall276321a2010-08-25 06:19:51 +0000373void CodeCompletionResult::computeCursorKindAndAvailability() {
Douglas Gregorb14904c2010-08-13 22:48:40 +0000374 switch (Kind) {
375 case RK_Declaration:
Douglas Gregorf757a122010-08-23 23:00:57 +0000376 // Set the availability based on attributes.
377 Availability = CXAvailability_Available;
378 if (Declaration->getAttr<UnavailableAttr>())
379 Availability = CXAvailability_NotAvailable;
380 else if (Declaration->getAttr<DeprecatedAttr>())
381 Availability = CXAvailability_Deprecated;
382
Douglas Gregor09c0eb12010-09-03 23:30:36 +0000383 if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Declaration))
384 if (Function->isDeleted())
Douglas Gregorf757a122010-08-23 23:00:57 +0000385 Availability = CXAvailability_NotAvailable;
Douglas Gregor09c0eb12010-09-03 23:30:36 +0000386
387 CursorKind = getCursorKindForDecl(Declaration);
388 if (CursorKind == CXCursor_UnexposedDecl)
Douglas Gregorb14904c2010-08-13 22:48:40 +0000389 CursorKind = CXCursor_NotImplemented;
Douglas Gregorb14904c2010-08-13 22:48:40 +0000390 break;
391
John McCall276321a2010-08-25 06:19:51 +0000392 case RK_Macro:
Douglas Gregorf757a122010-08-23 23:00:57 +0000393 Availability = CXAvailability_Available;
Douglas Gregorb14904c2010-08-13 22:48:40 +0000394 CursorKind = CXCursor_MacroDefinition;
395 break;
396
John McCall276321a2010-08-25 06:19:51 +0000397 case RK_Keyword:
Douglas Gregorf757a122010-08-23 23:00:57 +0000398 Availability = CXAvailability_Available;
Douglas Gregorb14904c2010-08-13 22:48:40 +0000399 CursorKind = CXCursor_NotImplemented;
400 break;
401
John McCall276321a2010-08-25 06:19:51 +0000402 case RK_Pattern:
Douglas Gregorb14904c2010-08-13 22:48:40 +0000403 // Do nothing: Patterns can come with cursor kinds!
404 break;
Douglas Gregor8e984da2010-08-04 16:47:14 +0000405 }
406}
Douglas Gregorf09935f2009-12-01 05:55:20 +0000407
Douglas Gregor0de55ce2010-08-25 18:41:16 +0000408/// \brief Retrieve the name that should be used to order a result.
409///
410/// If the name needs to be constructed as a string, that string will be
411/// saved into Saved and the returned StringRef will refer to it.
412static llvm::StringRef getOrderedName(const CodeCompletionResult &R,
413 std::string &Saved) {
414 switch (R.Kind) {
415 case CodeCompletionResult::RK_Keyword:
416 return R.Keyword;
417
418 case CodeCompletionResult::RK_Pattern:
419 return R.Pattern->getTypedText();
420
421 case CodeCompletionResult::RK_Macro:
422 return R.Macro->getName();
423
424 case CodeCompletionResult::RK_Declaration:
425 // Handle declarations below.
426 break;
427 }
428
429 DeclarationName Name = R.Declaration->getDeclName();
430
431 // If the name is a simple identifier (by far the common case), or a
432 // zero-argument selector, just return a reference to that identifier.
433 if (IdentifierInfo *Id = Name.getAsIdentifierInfo())
434 return Id->getName();
435 if (Name.isObjCZeroArgSelector())
436 if (IdentifierInfo *Id
437 = Name.getObjCSelector().getIdentifierInfoForSlot(0))
438 return Id->getName();
439
440 Saved = Name.getAsString();
441 return Saved;
442}
443
444bool clang::operator<(const CodeCompletionResult &X,
445 const CodeCompletionResult &Y) {
446 std::string XSaved, YSaved;
447 llvm::StringRef XStr = getOrderedName(X, XSaved);
448 llvm::StringRef YStr = getOrderedName(Y, YSaved);
449 int cmp = XStr.compare_lower(YStr);
450 if (cmp)
451 return cmp < 0;
452
Douglas Gregor49f67ce2010-08-26 13:48:20 +0000453 // If case-insensitive comparison fails, try case-sensitive comparison.
454 cmp = XStr.compare(YStr);
455 if (cmp)
456 return cmp < 0;
Douglas Gregor0de55ce2010-08-25 18:41:16 +0000457
458 return false;
459}