diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-04-12 02:47:21 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-04-12 02:47:21 +0000 |
commit | ec3310a1e371cc3bfc0f2c355767d1b6653357f2 (patch) | |
tree | b3598e1777f8b904a30b3a9f6d10c4bfb041919e /lib/Sema/SemaCodeComplete.cpp | |
parent | 99ace16bc6962f1fc3dc45bbbdf2eb74e555a8ad (diff) |
Don't suggest dynamic_cast or typeid as code completion results when
RTTI is disabled. Similarly, don't suggest throw or try as code
completion results when C++ exceptions are disabled. Fixes
<rdar://problem/9193560>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 72074ae820..75253b5b30 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -1482,7 +1482,8 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, case Sema::PCC_Statement: { AddTypedefResult(Results); - if (SemaRef.getLangOptions().CPlusPlus && Results.includeCodePatterns()) { + if (SemaRef.getLangOptions().CPlusPlus && Results.includeCodePatterns() && + SemaRef.getLangOptions().CXXExceptions) { Builder.AddTypedTextChunk("try"); Builder.AddChunk(CodeCompletionString::CK_LeftBrace); Builder.AddPlaceholderChunk("statements"); @@ -1655,15 +1656,17 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Results.AddResult(Result("true")); Results.AddResult(Result("false")); - // dynamic_cast < type-id > ( expression ) - Builder.AddTypedTextChunk("dynamic_cast"); - Builder.AddChunk(CodeCompletionString::CK_LeftAngle); - Builder.AddPlaceholderChunk("type"); - Builder.AddChunk(CodeCompletionString::CK_RightAngle); - Builder.AddChunk(CodeCompletionString::CK_LeftParen); - Builder.AddPlaceholderChunk("expression"); - Builder.AddChunk(CodeCompletionString::CK_RightParen); - Results.AddResult(Result(Builder.TakeString())); + if (SemaRef.getLangOptions().RTTI) { + // dynamic_cast < type-id > ( expression ) + Builder.AddTypedTextChunk("dynamic_cast"); + Builder.AddChunk(CodeCompletionString::CK_LeftAngle); + Builder.AddPlaceholderChunk("type"); + Builder.AddChunk(CodeCompletionString::CK_RightAngle); + Builder.AddChunk(CodeCompletionString::CK_LeftParen); + Builder.AddPlaceholderChunk("expression"); + Builder.AddChunk(CodeCompletionString::CK_RightParen); + Results.AddResult(Result(Builder.TakeString())); + } // static_cast < type-id > ( expression ) Builder.AddTypedTextChunk("static_cast"); @@ -1695,13 +1698,15 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Builder.AddChunk(CodeCompletionString::CK_RightParen); Results.AddResult(Result(Builder.TakeString())); - // typeid ( expression-or-type ) - Builder.AddTypedTextChunk("typeid"); - Builder.AddChunk(CodeCompletionString::CK_LeftParen); - Builder.AddPlaceholderChunk("expression-or-type"); - Builder.AddChunk(CodeCompletionString::CK_RightParen); - Results.AddResult(Result(Builder.TakeString())); - + if (SemaRef.getLangOptions().RTTI) { + // typeid ( expression-or-type ) + Builder.AddTypedTextChunk("typeid"); + Builder.AddChunk(CodeCompletionString::CK_LeftParen); + Builder.AddPlaceholderChunk("expression-or-type"); + Builder.AddChunk(CodeCompletionString::CK_RightParen); + Results.AddResult(Result(Builder.TakeString())); + } + // new T ( ... ) Builder.AddTypedTextChunk("new"); Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); @@ -1738,11 +1743,13 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Builder.AddPlaceholderChunk("expression"); Results.AddResult(Result(Builder.TakeString())); - // throw expression - Builder.AddTypedTextChunk("throw"); - Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); - Builder.AddPlaceholderChunk("expression"); - Results.AddResult(Result(Builder.TakeString())); + if (SemaRef.getLangOptions().CXXExceptions) { + // throw expression + Builder.AddTypedTextChunk("throw"); + Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); + Builder.AddPlaceholderChunk("expression"); + Results.AddResult(Result(Builder.TakeString())); + } // FIXME: Rethrow? } |