[PATCH] D32646: Fix a bug that -Wmissing-braces fires on system headers

Rui Ueyama via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 30 06:37:52 PDT 2017


ruiu added inline comments.


================
Comment at: lib/Sema/SemaInit.cpp:875
 
   if (!VerifyOnly) {
     StructuredSubobjectInitList->setType(T);
----------------
Is it intentional that you run the new code only when !VerifyOnly?


================
Comment at: lib/Sema/SemaInit.cpp:890-891
     if (T->isArrayType() || T->isRecordType()) {
+      SourceLocation SpellingLoc = StructuredSubobjectInitList->getLocStart();
+      SpellingLoc = SemaRef.getSourceManager().getSpellingLoc(SpellingLoc);
+      if (SpellingLoc.isValid() && 
----------------
This piece of code seems a bit puzzling as you initialize a variable to some value and immediately re-assign to some other value. It's better to initialize it only once.

  SourceLocation SpellingLoc = SemaRef.getSourceManager().getSpellingLoc(
    StructuredSubobjectInitList->getLocStart());



https://reviews.llvm.org/D32646





More information about the cfe-commits mailing list