[PATCH] Transform all files in a compilation database if no source files are provided.

Edwin Vane edwin.vane at intel.com
Thu Sep 5 08:01:03 PDT 2013


  The logic is too complex. I think the best way to clean this up is to refactor it. What is is this code really trying to do? Two things:
  # Initialize `Compilations`, the compilation database.
  # Figure out the list of sources to transform.

  I think you should split up the code to follow this division. Here's a pseudo algorithm for the compilation database:

    Load fixed compilation database
    if !successful:
      if -p option present:
        Load compilation database from file.
        if !success:
          ERROR
      else:
        if !SourcePaths.empty():
          Try to autodetect compilation database from SourcePaths[0]
          if !success:
            special case: create compilation database with -std=c++11.

  Now for the list of sources:
    if !SourcePaths.empty()
      for each path in SourcePaths:
        is it explicitly exlucded:
          warning
        else:
          add to list
    else:
      for each file in Compilations.getAllFiles():
        is file included:
          add to list

  Please proof this before implementing. I may not have got all cases. But you can see at least this division makes it very obvious what's going on.


================
Comment at: cpp11-migrate/Core/IncludeExcludeInfo.h:51
@@ -50,1 +50,3 @@
 
+  bool isFileExplicitlyExcluded(llvm::StringRef FilePath) const;
+
----------------
Don't forget doxygen docs for new member functions.

================
Comment at: cpp11-migrate/Core/IncludeExcludeInfo.cpp:160
@@ -159,3 +159,3 @@
 
   for (std::vector<std::string>::const_iterator I = ExcludeList.begin(),
                                                 E = ExcludeList.end();
----------------
You should replace this for loop with a call to `isFileExplicitlyExcluded()`.


http://llvm-reviews.chandlerc.com/D1517



More information about the cfe-commits mailing list