[cfe-commits] r95049 - in /cfe/trunk/lib/Sema: Sema.cpp Sema.h SemaLookup.cpp
Douglas Gregor
dgregor at apple.com
Mon Feb 1 20:06:15 PST 2010
This looks good. Thanks!
Sent from my iPhone
On Feb 1, 2010, at 6:07 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Mon Feb 1 20:07:01 2010
> New Revision: 95049
>
> URL: http://llvm.org/viewvc/llvm-project?rev=95049&view=rev
> Log:
> Add a stop gap to Sema::CorrectTypo() to correct only up to 20 typos.
> This is to address a serious performance problem observed when running
> 'clang -fsyntax-only' on really broken source files. In one case,
> repeatedly calling CorrectTypo() caused one source file to be rejected
> after 2 minutes instead of 1 second.
>
> This patch causes typo correction to take neglible time on that file
> while still providing correction results for the first 20 cases. I
> felt this was a reasonable number for moderately broken source files.
>
> I don't claim this is the best solution. Comments welcome. It is
> necessary for us to address this issue because it is a serious
> performance problem.
>
> Modified:
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaLookup.cpp
>
> Modified: cfe/trunk/lib/Sema/Sema.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=95049&r1=95048&r2=95049&view=diff
>
> ===
> ===
> ===
> =====================================================================
> --- cfe/trunk/lib/Sema/Sema.cpp (original)
> +++ cfe/trunk/lib/Sema/Sema.cpp Mon Feb 1 20:07:01 2010
> @@ -364,7 +364,7 @@
> GlobalNewDeleteDeclared(false),
> CompleteTranslationUnit(CompleteTranslationUnit),
> NumSFINAEErrors(0), NonInstantiationEntries(0),
> - CurrentInstantiationScope(0)
> + CurrentInstantiationScope(0), TyposCorrected(0)
> {
> TUScope = 0;
> if (getLangOptions().CPlusPlus)
>
> Modified: cfe/trunk/lib/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=95049&r1=95048&r2=95049&view=diff
>
> ===
> ===
> ===
> =====================================================================
> --- cfe/trunk/lib/Sema/Sema.h (original)
> +++ cfe/trunk/lib/Sema/Sema.h Mon Feb 1 20:07:01 2010
> @@ -3305,6 +3305,9 @@
> /// variables.
> LocalInstantiationScope *CurrentInstantiationScope;
>
> + /// \brief The number of typos corrected by CorrectTypo.
> + unsigned TyposCorrected;
> +
> /// \brief An entity for which implicit template instantiation is
> required.
> ///
> /// The source location associated with the declaration is the
> first place in
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=95049&r1=95048&r2=95049&view=diff
>
> ===
> ===
> ===
> =====================================================================
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Feb 1 20:07:01 2010
> @@ -2348,9 +2348,16 @@
> bool Sema::CorrectTypo(LookupResult &Res, Scope *S, const
> CXXScopeSpec *SS,
> DeclContext *MemberContext, bool
> EnteringContext,
> const ObjCObjectPointerType *OPT) {
> -
> if (Diags.hasFatalErrorOccurred())
> return false;
> +
> + // Provide a stop gap for files that are just seriously broken.
> Trying
> + // to correct all typos can turn into a HUGE performance penalty,
> causing
> + // some files to take minutes to get rejected by the parser.
> + // FIXME: Is this the right solution?
> + if (TyposCorrected == 20)
> + return false;
> + ++TyposCorrected;
>
> // We only attempt to correct typos for identifiers.
> IdentifierInfo *Typo = Res.getLookupName().getAsIdentifierInfo();
>
>
> _______________________________________________
> 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