<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Add a warning for using the same include guard in 2 different files"
   href="https://llvm.org/bugs/show_bug.cgi?id=28851">28851</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Add a warning for using the same include guard in 2 different files
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>rtrieu@google.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zturner@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Imagine the following scenario:

// foo.cpp
#include "foo.h"

// foo.h
#ifndef FOO_H
#define FOO_H

#include "bar.h"

#endif

// bar.h
#ifndef FOO_H
#define FOO_H

#endif


This happens occasionally as a result of copy-pasting one header file to
another header file to get the basic layout (header file premable, include
guards, namespace layout, etc) in place and then fixing up.  But occasionally
one forgets to fix the header guard, leading to mysterious compiler errors.

It would be nice if this warned, by keeping for each translation unit a mapping
of hashed include guard to include file name, and if an entry is found that
exists in the hash table under a different filename, generating a warning.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>