[PATCH] D153914: [clang-cl] Enable concatenation of predefined identifiers
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 8 15:28:36 PDT 2023
aaron.ballman added inline comments.
================
Comment at: clang/lib/Sema/Sema.cpp:1494-1505
+Decl *Sema::getCurLocalScopeDecl() {
+ if (const BlockScopeInfo *BSI = getCurBlock())
+ return BSI->TheDecl;
+ else if (const LambdaScopeInfo *LSI = getCurLambda())
+ return LSI->CallOperator;
+ else if (const CapturedRegionScopeInfo *CSI = getCurCapturedRegion())
+ return CSI->TheCapturedDecl;
----------------
RIscRIpt wrote:
> aaron.ballman wrote:
> > Made the function `const` because it's not writing to any fields, removed `else` because of preceding `return`.
> I would love to, and I tried. But unfortunately it's not possible without introducing more changes: all the member functions (except `getCurFunctionOrMethodDecl()`) are non-const.
> Removed `else`.
Ah, thanks!
================
Comment at: clang/lib/Sema/SemaExpr.cpp:2034-2035
+ // StringToks is read-only, we need backstorage for expanded macros
+ std::vector<Token> ExpandedToks;
+ if (getLangOpts().MicrosoftExt)
----------------
================
Comment at: clang/lib/Sema/SemaExpr.cpp:1998-2000
+ if (isa<TranslationUnitDecl>(currentDecl)) {
+ Diag(Tok.getLocation(), diag::ext_predef_outside_function);
+ }
----------------
RIscRIpt wrote:
> aaron.ballman wrote:
> > This will miss the diagnostic if the current declaration is a namespace instead of at file scope, right?
> Right. But `getCurLocalScopeDecl()` returns function scope at most. See Note in a code comment above.
Ah, exactly right, thank you!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153914/new/
https://reviews.llvm.org/D153914
More information about the cfe-commits
mailing list