[PATCH] D94735: CGDebugInfo CreatedLimitedType: Drop file/line for RecordType with invalid location

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 15 16:33:21 PST 2021


dblaikie added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3338-3340
+  const SourceLocation Loc = RD->getLocation();
+  llvm::DIFile *DefUnit = Loc.isValid() ? getOrCreateFile(Loc) : nullptr;
+  const unsigned Line = getLineNumber(Loc);
----------------
MaskRay wrote:
> dblaikie wrote:
> > Might be more readable, even though it provides the same behavior, with something like:
> > ```
> >   llvm::DIFile *DefUnit = nullptr;
> >   unsigned Line = 0;
> >   if (SourceLocation Loc = RD->getLocation(); Loc.isValid()) {
> >     DefUnit = getOrCreateFile(Loc);
> >     Line = getLineNumber(Loc);
> >   }
> > ```
> init-statement in if is C++17, rejected by MSVC and warned by clang -std=c++14... `[-Wc++17-extensions]`
Oh, right right! Well, nearby/similar code:
```
llvm::DIFile *DefUnit = nullptr;
unsigned Line = 0;
SourceLocation Loc = RD->getLocation(); 
if (Loc.isValid()) {
  DefUnit = getOrCreateFile(Loc);
  Line = getLineNumber(Loc);
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94735/new/

https://reviews.llvm.org/D94735



More information about the cfe-commits mailing list