[cfe-commits] r140589 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Parse/Parser.cpp lib/Sema/SemaDecl.cpp test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
Bill Wendling
wendling at apple.com
Tue Sep 27 03:13:25 PDT 2011
Hi Kaelyn,
I had to revert this patch. It was causing failures during compilation of LLVM:
llvm[1]: Compiling CommandLine.cpp for Debug+Asserts build
if /Users/void/llvm/llvm-opt.obj/Release+Asserts/bin/clang++ -I/Users/void/llvm/llvm.obj/include -I/Users/void/llvm/llvm.obj/lib/Support -I/Users/void/llvm/llvm.src/include -I/Users/void/llvm/llvm.src/lib/Support -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-common -Woverloaded-virtual -Wcast-qual -m64 -Wall -W -Wno-unused-parameter -Wwrite-strings -c -MMD -MP -MF "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp" -MT "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.o" -MT "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d" /Users/void/llvm/llvm.src/lib/Support/CommandLine.cpp -o /Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.o ; \
then /bin/mv -f "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp" "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d"; else /bin/rm "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp"; exit 1; fi
In file included from /Users/void/llvm/llvm.src/lib/Support/CommandLine.cpp:25:
/Users/void/llvm/llvm.src/include/llvm/Support/system_error.h:690:14: error: unknown type name 'make_error_condition'; did you mean 'error_condition'?
{*this = make_error_condition(_e);}
^~~~~~~~~~~~~~~~~~~~
error_condition
...
-bw
On Sep 26, 2011, at 5:33 PM, Kaelyn Uhrain wrote:
> Author: rikka
> Date: Mon Sep 26 19:33:13 2011
> New Revision: 140589
>
> URL: http://llvm.org/viewvc/llvm-project?rev=140589&view=rev
> Log:
> Add typo correction for the type name in C++ "new" statements
>
> Modified:
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Parse/Parser.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=140589&r1=140588&r2=140589&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Sep 26 19:33:13 2011
> @@ -866,7 +866,8 @@
> bool isClassName = false,
> bool HasTrailingDot = false,
> ParsedType ObjectType = ParsedType(),
> - bool WantNontrivialTypeSourceInfo = false);
> + bool WantNontrivialTypeSourceInfo = false,
> + IdentifierInfo **CorrectedII = 0);
> TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
> bool isMicrosoftMissingTypename(const CXXScopeSpec *SS);
> bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
>
> Modified: cfe/trunk/lib/Parse/Parser.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=140589&r1=140588&r2=140589&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/Parser.cpp (original)
> +++ cfe/trunk/lib/Parse/Parser.cpp Mon Sep 26 19:33:13 2011
> @@ -1278,13 +1278,18 @@
> return true;
>
> if (Tok.is(tok::identifier)) {
> + IdentifierInfo *CorrectedII = 0;
> // Determine whether the identifier is a type name.
> if (ParsedType Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
> Tok.getLocation(), getCurScope(),
> &SS, false,
> NextToken().is(tok::period),
> ParsedType(),
> - /*NonTrivialTypeSourceInfo*/true)) {
> + /*NonTrivialTypeSourceInfo*/true,
> + &CorrectedII)) {
> + // A FixIt was applied as a result of typo correction
> + if (CorrectedII)
> + Tok.setIdentifierInfo(CorrectedII);
> // This is a typename. Replace the current token in-place with an
> // annotation type token.
> Tok.setKind(tok::annot_typename);
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=140589&r1=140588&r2=140589&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Sep 26 19:33:13 2011
> @@ -70,7 +70,8 @@
> Scope *S, CXXScopeSpec *SS,
> bool isClassName, bool HasTrailingDot,
> ParsedType ObjectTypePtr,
> - bool WantNontrivialTypeSourceInfo) {
> + bool WantNontrivialTypeSourceInfo,
> + IdentifierInfo **CorrectedII) {
> // Determine where we will perform name lookup.
> DeclContext *LookupCtx = 0;
> if (ObjectTypePtr) {
> @@ -145,6 +146,51 @@
> switch (Result.getResultKind()) {
> case LookupResult::NotFound:
> case LookupResult::NotFoundInCurrentInstantiation:
> + if (CorrectedII) {
> + TypoCorrection Correction = CorrectTypo(Result.getLookupNameInfo(),
> + Kind, S, SS, 0, false,
> + Sema::CTC_Type);
> + IdentifierInfo *NewII = Correction.getCorrectionAsIdentifierInfo();
> + TemplateTy Template;
> + bool MemberOfUnknownSpecialization;
> + UnqualifiedId TemplateName;
> + TemplateName.setIdentifier(NewII, NameLoc);
> + NestedNameSpecifier *NNS = Correction.getCorrectionSpecifier();
> + CXXScopeSpec NewSS, *NewSSPtr = SS;
> + if (SS && NNS) {
> + NewSS.MakeTrivial(Context, NNS, SourceRange(NameLoc));
> + NewSSPtr = &NewSS;
> + }
> + if (Correction && (NNS || NewII != &II) &&
> + // Ignore a correction to a template type as the to-be-corrected
> + // identifier is not a template (typo correction for template names
> + // is handled elsewhere).
> + !(getLangOptions().CPlusPlus && NewSSPtr &&
> + isTemplateName(S, *NewSSPtr, false, TemplateName, ParsedType(),
> + false, Template, MemberOfUnknownSpecialization))) {
> + ParsedType Ty = getTypeName(*NewII, NameLoc, S, NewSSPtr,
> + isClassName, HasTrailingDot, ObjectTypePtr,
> + WantNontrivialTypeSourceInfo);
> + if (Ty) {
> + std::string CorrectedStr(Correction.getAsString(getLangOptions()));
> + std::string CorrectedQuotedStr(
> + Correction.getQuoted(getLangOptions()));
> + Diag(NameLoc, diag::err_unknown_typename_suggest)
> + << Result.getLookupName() << CorrectedQuotedStr
> + << FixItHint::CreateReplacement(SourceRange(NameLoc),
> + CorrectedStr);
> + if (NamedDecl *FirstDecl = Correction.getCorrectionDecl())
> + Diag(FirstDecl->getLocation(), diag::note_previous_decl)
> + << CorrectedQuotedStr;
> +
> + if (SS && NNS)
> + SS->MakeTrivial(Context, NNS, SourceRange(NameLoc));
> + *CorrectedII = NewII;
> + return Ty;
> + }
> + }
> + }
> + // If typo correction failed or was not performed, fall through
> case LookupResult::FoundOverloaded:
> case LookupResult::FoundUnresolvedValue:
> Result.suppressDiagnostics();
>
> Modified: cfe/trunk/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp?rev=140589&r1=140588&r2=140589&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp (original)
> +++ cfe/trunk/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp Mon Sep 26 19:33:13 2011
> @@ -1,8 +1,10 @@
> // RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++0x-extensions %s
>
> -namespace fizbin { class Foobar; } // expected-note{{'fizbin::Foobar' declared here}}
> +namespace fizbin { class Foobar {}; } // expected-note 2 {{'fizbin::Foobar' declared here}} \
> + // expected-note {{'Foobar' declared here}}
> Foobar *my_bar // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
> - = new Foobar; // expected-error{{expected a type}}
> + = new Foobar; // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
> +fizbin::Foobar *my_foo = new fizbin::FooBar; // expected-error{{unknown type name 'FooBar'; did you mean 'Foobar'?}}
>
> namespace barstool { int toFoobar() { return 1; } } // expected-note 3 {{'barstool::toFoobar' declared here}}
> int Double(int x) { return x + x; }
> @@ -62,11 +64,13 @@
>
> // Test case from http://llvm.org/bugs/show_bug.cgi?id=10318
> namespace llvm {
> - template <typename T> class GraphWriter {}; // expected-note{{'llvm::GraphWriter' declared here}}
> + template <typename T> class GraphWriter {}; // expected-note {{'llvm::GraphWriter' declared here}} \
> + // expected-note {{'GraphWriter' declared here}}
> }
>
> struct S {};
> void bar() {
> GraphWriter<S> x; //expected-error{{no template named 'GraphWriter'; did you mean 'llvm::GraphWriter'?}}
> -
> + (void)new llvm::GraphWriter; // expected-error {{expected a type}}
> + (void)new llvm::Graphwriter<S>; // expected-error {{no template named 'Graphwriter' in namespace 'llvm'; did you mean 'GraphWriter'?}}
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list