[PATCH] D14329: Show inclusions from a preamble in clang_getInclusions.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 6 05:41:51 PST 2016


bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the fix!


================
Comment at: tools/libclang/CIndexInclusionStack.cpp:32
@@ -36,13 +31,3 @@
   SmallVector<CXSourceLocation, 10> InclusionStack;
-  unsigned n =  SM.local_sloc_entry_size();
-
-  // In the case where all the SLocEntries are in an external source, traverse
-  // those SLocEntries as well.  This is the case where we are looking
-  // at the inclusion stack of an AST/PCH file.
-  const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const;
-  if (n == 1) {
-    Getter = &SourceManager::getLoadedSLocEntry;
-    n = SM.loaded_sloc_entry_size();
-  } else
-    Getter = &SourceManager::getLocalSLocEntry;
+  const bool hasPreamble = SM.getPreambleFileID().isValid();
 
----------------
There's already a wild mix of coding styles in this file, let's not add more of them. `bool HasPreamble` is the preferred style.


http://reviews.llvm.org/D14329





More information about the cfe-commits mailing list