[PATCH] D64945: [clang-scan-deps] Dependency directives source minimizer: handle #pragma once

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 13:46:53 PDT 2019


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

LGTM after you add the testcase I mention.



================
Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:623
+    // #pragma once
+    skipLine(First, End);
+    makeToken(pp_pragma_once);
----------------
I wondered if it was wrong to ignore extra token on the line, but `clang` does as well (and emits `-Wextra-tokens`) so this is fine.


================
Comment at: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp:551-555
+  StringRef Source = R"(// comment
+#pragma once
+// another comment
+#include <test.h>
+)";
----------------
Can you also add a test with `#pragma once extra tokens`?  It should get canonicalized to `#pragma once`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64945





More information about the cfe-commits mailing list