[modules] Make sure enabled diagnostic pragmas inside the module don't affect the translation unit that

imports the module.

Getting diagnostic sections from modules properly working is a fixme.

rdar://13516663

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178151 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Argyrios Kyrtzidis 2013-03-27 17:17:23 +00:00
Родитель 94b748ff16
Коммит ea744ab5f3
5 изменённых файлов: 31 добавлений и 4 удалений

Просмотреть файл

@ -432,7 +432,8 @@ private:
void WritePreprocessorDetail(PreprocessingRecord &PPRec);
void WriteSubmodules(Module *WritingModule);
void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag);
void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
bool isModule);
void WriteCXXBaseSpecifiersOffsets();
void WriteType(QualType T);
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);

Просмотреть файл

@ -2444,8 +2444,14 @@ ASTWriter::inferSubmoduleIDFromLocation(SourceLocation Loc) {
return getSubmoduleID(OwningMod);
}
void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag) {
// FIXME: Make it work properly with modules.
void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
bool isModule) {
// Make sure set diagnostic pragmas don't affect the translation unit that
// imports the module.
// FIXME: Make diagnostic pragma sections work properly with modules.
if (isModule)
return;
llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned, 64>
DiagStateIDMap;
unsigned CurrID = 0;
@ -4048,7 +4054,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
WriteOpenCLExtensions(SemaRef);
WriteTypeDeclOffsets();
WritePragmaDiagnosticMappings(Context.getDiagnostics());
WritePragmaDiagnosticMappings(Context.getDiagnostics(), isModule);
WriteCXXBaseSpecifiersOffsets();

Просмотреть файл

@ -0,0 +1,3 @@
#define DIAG_PRAGMA_MACRO 1
#pragma clang diagnostic ignored "-Wparentheses"

Просмотреть файл

@ -188,3 +188,7 @@ module config {
header "config.h"
config_macros [exhaustive] WANT_FOO, WANT_BAR
}
module diag_pragma {
header "diag_pragma.h"
}

Просмотреть файл

@ -0,0 +1,13 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma %S/Inputs/module.map
// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t %s
// FIXME: When we have a syntax for modules in C, use that.
@import diag_pragma;
int foo(int x) {
if (x = DIAG_PRAGMA_MACRO) // expected-warning {{using the result of an assignment as a condition without parentheses}} \
// expected-note {{place parentheses}} expected-note {{use '=='}}
return 0;
return 1;
}