llvm-project/clang/test/PCH/macro-cmdline.c
John Brawn 524ed4b1ba [Serialization] Place command line defines in the correct file
Fix several problems related to serialization causing command line
defines to be reported as being built-in defines:
 * When serializing the <built-in> and <command line> files don't
   convert them into absolute paths.
 * When deserializing SM_SLOC_BUFFER_ENTRY we need to call
   setHasLineDirectives in the same way as we do for
   SM_SLOC_FILE_ENTRY.
 * When created suggested predefines based on the current command line
   options we need to add line markers in the same way that
   InitializePreprocessor does.
 * Adjust a place in clangd where it was implicitly relying on command
   line defines being treated as builtin.

Differential Revision: https://reviews.llvm.org/D144651
2023-04-24 14:07:41 +01:00

14 lines
448 B
C

// RUN: %clang_cc1 %s -emit-pch -o %t1.pch -DMACRO1=1
// RUN: %clang_cc1 -fsyntax-only %s -include-pch %t1.pch -DMACRO2=1 2>&1 | FileCheck %s
#ifndef HEADER
#define HEADER
#else
#define MACRO1 2
// CHECK: macro-cmdline.c{{.*}}'MACRO1' macro redefined
// CHECK: <command line>{{.*}}previous definition is here
#define MACRO2 2
// CHECK: macro-cmdline.c{{.*}}'MACRO2' macro redefined
// CHECK: <command line>{{.*}}previous definition is here
#endif