diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-09-20 21:11:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-09-20 21:11:48 +0000 |
commit | b05496dbd63f03bf474dae2c4d1e2142608780cc (patch) | |
tree | e3f6e054547bf217be671a2e081f573000dd38d6 /lib/Sema/SemaCodeComplete.cpp | |
parent | 957b03be80ee712344bc0ff67c5ab7d768e88005 (diff) |
Tweak priorities for some types and macros:
- In Objective-C, we prefer BOOL to bool for historic reasons;
slightly penalize "bool".
- Treat Nil macro as a NULL pointer constant.
- Treat YES, NO, true, and false macros as constants.
- Treat the bool macro as a type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 371921ca11..b02f2dd217 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -1087,7 +1087,8 @@ static void AddTypeSpecifierResults(const LangOptions &LangOpts, if (LangOpts.CPlusPlus) { // C++-specific - Results.AddResult(Result("bool", CCP_Type)); + Results.AddResult(Result("bool", CCP_Type + + (LangOpts.ObjC1? CCD_bool_in_ObjC : 0))); Results.AddResult(Result("class", CCP_Type)); Results.AddResult(Result("wchar_t", CCP_Type)); @@ -2308,15 +2309,25 @@ CodeCompleteConsumer::OverloadCandidate::CreateSignatureString( } unsigned clang::getMacroUsagePriority(llvm::StringRef MacroName, + const LangOptions &LangOpts, bool PreferredTypeIsPointer) { unsigned Priority = CCP_Macro; - // Treat the "nil" and "NULL" macros as null pointer constants. - if (MacroName.equals("nil") || MacroName.equals("NULL")) { + // Treat the "nil", "Nil" and "NULL" macros as null pointer constants. + if (MacroName.equals("nil") || MacroName.equals("NULL") || + MacroName.equals("Nil")) { Priority = CCP_Constant; if (PreferredTypeIsPointer) Priority = Priority / CCF_SimilarTypeMatch; - } + } + // Treat "YES", "NO", "true", and "false" as constants. + else if (MacroName.equals("YES") || MacroName.equals("NO") || + MacroName.equals("true") || MacroName.equals("false")) + Priority = CCP_Constant; + // Treat "bool" as a type. + else if (MacroName.equals("bool")) + Priority = CCP_Type + (LangOpts.ObjC1? CCD_bool_in_ObjC : 0); + return Priority; } @@ -2394,6 +2405,7 @@ static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, M != MEnd; ++M) { Results.AddResult(Result(M->first, getMacroUsagePriority(M->first->getName(), + PP.getLangOptions(), TargetTypeIsPointer))); } Results.ExitScope(); |