Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/lib/Lex/PPDirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ SourceLocation
Preprocessor::CheckEndOfDirective(StringRef DirType, bool EnableMacros,
SmallVectorImpl<Token> *ExtraToks) {
Token Tmp;
// Avoid use-of-uninitialized-memory for edge case(s) where there is no extra
// token to be parsed.
Tmp.startToken();
auto ReadNextTok = [this, ExtraToks, &Tmp](auto &&LexFn) {
std::invoke(LexFn, this, Tmp);
if (ExtraToks && Tmp.isNot(tok::eod))
Expand Down
25 changes: 25 additions & 0 deletions clang/test/ClangScanDeps/p1689-suppress-warnings-no-eol.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Test that there is no use-of-uninitialized memory when parsing '#include' in
// the last line, without a newline.
//
// Forked from p1689-suppress-warnings.cppm.

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t

// Test P1689 format - should NOT emit warnings
// RUN: clang-scan-deps -format=p1689 -- %clang++ -std=c++20 -I%t -c %t/mylib.cppm -o %t/mylib.o 2>&1 | FileCheck %s

// CHECK-NOT: warning:
// CHECK: {
// CHECK: "revision"

//--- header.h
// Empty header for testing

//--- mylib.cppm
module;

export module mylib;

#include <header.h>