r186649 - Remove unnecessary IsFirst variable from debug codde in GetDiagInfo.

Benjamin Kramer benny.kra at gmail.com
Sun Jul 21 09:22:22 PDT 2013


On 19.07.2013, at 05:59, Craig Topper <craig.topper at gmail.com> wrote:

> Author: ctopper
> Date: Thu Jul 18 22:59:51 2013
> New Revision: 186649
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=186649&view=rev
> Log:
> Remove unnecessary IsFirst variable from debug codde in GetDiagInfo.

Was it really unnecessary? I think this was done to avoid a large hit in compile time in +Asserts builds. Now we verify the table on every lookup. Optimizing assertions may be not beneficial in general but in this case it doesn't add much code and doesn't affect the quality of the checks in any kind. Can you put it back?

- Ben

> 
> Modified:
>    cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> 
> Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=186649&r1=186648&r2=186649&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
> +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu Jul 18 22:59:51 2013
> @@ -94,17 +94,13 @@ static const unsigned StaticDiagInfoSize
> static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
>   // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
> #ifndef NDEBUG
> -  static bool IsFirst = true;
> -  if (IsFirst) {
> -    for (unsigned i = 1; i != StaticDiagInfoSize; ++i) {
> -      assert(StaticDiagInfo[i-1].DiagID != StaticDiagInfo[i].DiagID &&
> -             "Diag ID conflict, the enums at the start of clang::diag (in "
> -             "DiagnosticIDs.h) probably need to be increased");
> +  for (unsigned i = 1; i != StaticDiagInfoSize; ++i) {
> +    assert(StaticDiagInfo[i-1].DiagID != StaticDiagInfo[i].DiagID &&
> +           "Diag ID conflict, the enums at the start of clang::diag (in "
> +           "DiagnosticIDs.h) probably need to be increased");
> 
> -      assert(StaticDiagInfo[i-1] < StaticDiagInfo[i] &&
> -             "Improperly sorted diag info");
> -    }
> -    IsFirst = false;
> +    assert(StaticDiagInfo[i-1] < StaticDiagInfo[i] &&
> +           "Improperly sorted diag info");
>   }
> #endif
> 
> 
> 
> _______________________________________________
> 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